// JavaScript Document

	$(document).ready(function()
	{
			
		
		var root1='mypost';
		$("#"+root1+"").find('span').addClass('nav1');
		$(".sortby").click(function()
		{
			 $('.sortby').find('span').removeClass('nav1');	
			 $('.sortby').find('span').css({'text-decoration' : 'underline'});
			 $(this).find('span').addClass('nav1');	
			 $(this).find('span').css({'text-decoration' : 'none'});
			 var gen1 = $(this).find('span').attr('id');
			 $("#"+root1+"1").hide();
			 $("#"+gen1+"1").show();
			 root1 = gen1;
		});	
		
		var root='mysubrs';
		$("#"+root+"").find('span').addClass('nav1');
		$(".sortby").click(function()
		{
			// alert(root);
			 $('.sortby').find('span').removeClass('nav1');	
			 $('.sortby').find('span').css({'text-decoration' : 'underline'});
			 $(this).find('span').addClass('nav1');	
			 $(this).find('span').css({'text-decoration' : 'none'});
			 var gen = $(this).find('span').attr('id');
			 //alert(gen);
			 $("#"+root+"1").hide();
			 $("#"+gen+"1").show();
			 root = gen;
		});
		
	});

function PageRate(mid,mdat,type)
	{
		window.location.href = "/"+mid+"/"+mdat+"/"+type+".html";
	}

	function PageD(tourid,teamid)
	{
		window.location.href = "/tour/"+tourid+"/"+teamid+"/Tour_Player.html";
	}
	function PageComm(mid,mdat,teamname,inngsset)
	{
		window.location.href = "/"+mid+"/"+mdat+"/c/0/all/"+teamname+"/"+inngsset+"/overs/Commentry.html";
	}
	function PagePlayer(tid,teamname1,type)
	{
		if(type == "Retired")
		{
			window.location.href = "/"+tid+"/0/"+teamname1+"/0/16/team_player";
		}
		else
		{
			window.location.href = "/"+tid+"/0/"+teamname1+"/1/16/team_player";
		}
	}
	
	function getresults(gettype,type,val)
	{
		window.location.href = "/"+gettype+"/"+type+"/"+val+"/livescores.html";
		
	}
	
function expand_Div(root,id)
{
	//alert(id);
	 var z = id;
	 var currentSetting = $("#"+z).css("display");
	 if (currentSetting=="none")
	 {
		$(root).parent().parent().parent().find("div[class='battingComms']").css("display","none");
		$(root).parent().parent().parent().find("img[class='inningsIcon']").attr('src','/cricket/images/expand.gif');
		$("#"+z).css("display","block");
		$(root).parent().parent().removeClass("height20");
		$(root).parent().parent().addClass("height_auto");
		$(root).attr('src','/cricket/images/collapse.gif');
	 }
	 else
	 {
		$("#"+z).css("display","none");
		$(root).parent().parent().removeClass("height_auto");
		$(root).parent().parent().addClass("height20");
		$(root).attr('src','/cricket/images/expand.gif');
	 }
}

function getlive(mid,mdat,refreshs)
{
	sskey = $("input#scorecardrefreshs").attr("value");
	$.ajax({
			type: "GET",
			url: "/cricket/"+mid+"/"+mdat+"/"+refreshs+"/GetScorecard?sskey="+sskey,
			dataType: "json",
			timeout:5000, 
			success: function(data)
				{
					if (data.value != "")
					{
						$("#ciHomeContentlhs").html(data.value);
						$("input#scorecardrefreshs").attr("value",data.sskey);
					}
					/*if (data != "")
					{
						$("#ciHomeContentlhs").html(data);
					}*/
				}
		  });
	getScore(mid);
}
function getScore(mid)
{
		$.ajax({
			type: "GET",
			url: "/"+mid+"/GetScore?fortitle=true",
			dataType: "html",
			timeout:5000, 
			success: function(data)
			{
				data =  jQuery.trim(data.replace("\u00a0","").replace("<br/>"," ").replace("  "," ") +" | "+ title);						
				document.title = data
			}
		  });
}
