function callAjax(elemid, url, options )
{
  var params = options.params || "";
  var meth = options.meth || "post";
  var async = options.mode || true;
  var startfunc = options.startfunc || "";
  var endfunc = options.endfunc || "";
  var errorfunc = options.errorfunc || "";

  if( startfunc != "" )
    eval( startfunc );

 var url_with_param = url+( params != "" ? "?"+params : "" );
//alert(elemid);
// alert(url_with_param);

  loadXMLDoc();
//----------------------------------------------------------------
	var xmlhttp
	function loadXMLDoc()
	{ 
		// code for Mozilla, etc.
		if (window.XMLHttpRequest)
		  {
			  xmlhttp=new XMLHttpRequest()
			  xmlhttp.onreadystatechange=xmlhttpChange
			  xmlhttp.open(meth,url_with_param,async)
			  xmlhttp.send('')
		  }
	
		// code for IE
		else if (window.ActiveXObject)
		  {
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
			if (xmlhttp)
			{
				xmlhttp.onreadystatechange=xmlhttpChange
				xmlhttp.open(meth,url_with_param,async)
				xmlhttp.send('')
					return false;
			  }
			  else
			  {
					alert( "Your browser cannot perform the requested action. "+
						 "Either your security settings are too high or your "+
						 "browser is outdated. Try the newest version of "+
						 "Internet Explorer or Mozilla Firefox." );
					return false;
			  }
		  }
	}

	function xmlhttpChange()
	{
	// if xmlhttp shows "loaded"
	if (xmlhttp.readyState==4)
	  {

		  if (xmlhttp.status==200)
			{
				var objXML = xmlhttp.responseXML;
				var objXML1 = xmlhttp.responseText;
				//alert(objXML1);
				if(elemid!='')
				{ 
					document.getElementById(elemid).innerHTML = objXML1;
				}
			   if( endfunc != "" )
				{
					eval( endfunc );
				}
		  }
		  else
			{
			
				//alert("Problem retrieving XML data")
				if( endfunc != "" )
					eval( endfunc );
			  if( errorfunc != "" )
					//eval( errorfunc );
				  return false;
			}
		}
	}
}
//END OF AJAX FUNCTIONS.

function show_cricket_news(div,type)
{
	callAjax( div, "hot_cricket_news.php", {
		params:"type="+type,
		meth:"post",
		async:true,
		startfunc:crk_show_data_loading(div),
		//endfunc:document.getElementById('offset').value=(document.getElementById('offset').value*1)+4,
		errorfunc:""});		
}

function crk_show_data_loading(container_id)
{
	var div_data=document.getElementById(''+container_id+'');
	if(div_data)
	{
		div_data.innerHTML='<div class="loading"></div>';
	}
}

function show_cricket_images(div)
{
	$("#center_image_container").hide();
	callAjax( div, "hot_cricket_images.php", {
		params:"",
		meth:"post",
		async:true,
		startfunc:"crk_show_data_loading('"+div+"');crk_show_data_loading('center_image_container')",
		endfunc:"endBigImage();",
		errorfunc:"" });
}

function showImage(image,text)
{
	//$("#center_image_container").slideUp("fast");
	if(typeof(image)=='undefined') image= '';
	if(typeof(text)=='undefined') text= '';
	if(text=='')
	{
		text='';
	}
	$("#center_image_container").hide();
	$("body")[0].scrollIntoView(true);
	if(image=='')
	{
		$("#center_image_container").html('<div class="noRecordFound">No Image Found</div><div id="div_crk_video" class="lightbox" style="background:#000000; border:1px solid #666;display:none; text-align:center; padding:2px;"></div>');
	}
	else
	{
		$("#center_image_container").html('<div id="tableid_crk_image" class="center_IMGholder"><img src="'+image+'" border="0"/><div class="center_IMGtile">'+text+'</div></div><div id="div_crk_video" class="lightbox" style="background:#000000; border:1px solid #666;display:none; text-align:center; padding:2px;"></div>');
	}
	$("#div_crk_video").hide();
	$("#center_image_container").slideDown("slow");
	//$("#center_image_container").html("this is Test");
}
function endBigImage()
{
	//showImage($("#crk_small_img0").attr("bigurl"),$("#crk_small_img0").attr("title"))
	$("#crk_small_img_link0").click();
}
//Function To Fecth video
function show_cricket_video(div)
{
	callAjax( div, "hot_cricket_video.php", {
		params:"",
		meth:"post",
		async:true,
		startfunc:"crk_show_data_loading('"+div+"')",
		endfunc:"",
		errorfunc:"" });
}

function playCricketVideoBlinkx(embed_tag)
{
	//$("#fade_help").show();
	//$("#div_crk_video").fadeIn();
	//getPageSize();
	$("#fade_help").show();
	$("#tableid_crk_image").hide();
	$("#div_crk_video").show();
	$("body")[0].scrollIntoView(true);
	$("#div_crk_video").html("<a href='javascript:;' onclick=\"closeVideoDiv();\"><div class='close_button' style='text-align:right;'></div></a><br>"+embed_tag+"");
}
function closeVideoDiv()
{
	//getPageSize();
	$("#fade_help").hide();
	$("#div_crk_video").html("");
	$("#div_crk_video").hide();
	$("#tableid_crk_image").show();
}

function upcoming_matches(div)
{
	callAjax( div, "upcoming_matches.php", {
		params:"",
		meth:"post",
		async:true,
		startfunc:"crk_show_data_loading('"+div+"')",
		endfunc:"",
		errorfunc:"" });
}

function upcoming_schedule(div,type)
{
	//Type for upcomming macthes=match and for series= series 
	if(typeof(type)=='undefined') type= 'match';
	callAjax( div, "upcoming_schedule.php", {
		params:"type="+type,
		meth:"post",
		async:true,
		startfunc:"crk_show_data_loading('"+div+"')",
		endfunc:"",
		errorfunc:"" });
}
//Cricket Saggon Live Score

function show_cricket_live_score(div)
{
	callAjax( div, "live_score.php", {
		params:"",
		meth:"post",
		async:true,
		startfunc:"crk_show_data_loading('"+div+"')",
		endfunc:"",
		errorfunc:"" });
}

function show_most_view_topic(div,type)
{
	if(typeof(type)=='undefined') type= '';
	callAjax( div, "show_most_view_topic.php", {
		params:"type="+type,
		meth:"post",
		async:true,
		startfunc:"crk_show_data_loading('"+div+"');",
		errorfunc:"" });
}

function playCricketVideoPage(embed_tag)
{
	//$("#fade_help").show();
	//$("#div_crk_video").fadeIn();
	//getPageSize();
	$("#player_Area").html(""+embed_tag+"");
}

function closeVideoDivPage()
{
	//getPageSize();
	//$("#fade_help").hide();
	$("#player_Area").html("");
}

function select_time_zone(div,file_name)
{
	if(typeof(file_name)=='undefined' || file_name=='') file_name= '';
	callAjax(div, "timezone.php", {
	params:"file_name="+file_name+"",
	meth:"post",
	async:true,
	startfunc:"",
	endfunc:"",
	errorfunc:"ajaxError()" });
}
/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/
var iframeids=["full_scorecard_frame","scorecard_frame"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller


