﻿function CurrnetUrlFileName()
 {
  	var s=top.location.href;
    s=s.replace(/(.*\/){0,}([^\.]+).*/ig,"$2");
    return s;
 }
 function returnLang()
 {
  	var s=top.location.href;
    if(s.indexOf("tai")>-1)
	  return "tai";
   else
      return "en";
 }
 function ScsgUrlFileName()
 {
  	var s=location.href;
    s=s.replace(/(.*\/){0,}([^\.]+).*/ig,"$2");
    return s;
 }
 /*给让球盘路设置赛季下拉链接*/
function goNewMatchPageA(thises)
{
	var MatchValue = thises.options[thises.options.selectedIndex].value;
	if(MatchValue.length<=4)
	{
	   var theNextSeason=parseInt(MatchValue)+1;
	   MatchValue=MatchValue+'-'+theNextSeason;
	}	
	var currentPage = location;
	var url ='/football/'+returnLang()+'/league_data/'+MatchValue+'/'+CurrnetUrlFileName()+'.htm';
	location = url;
}

 /*给大小盘路设置赛季下拉链接*/
function goNewMatchPageB(thises)
{
	var MatchValue = thises.options[thises.options.selectedIndex].value;
	if(MatchValue.length<=4)
	{
	   var theNextSeason=parseInt(MatchValue)+1;
	   MatchValue=MatchValue+'-'+theNextSeason;
	}	
	var currentPage = location;
	var url = '/football/'+returnLang()+'/bigsmallleague/'+MatchValue+'/'+CurrnetUrlFileName()+'.htm';
	location = url;
}

 /*给积分榜设置赛季下拉链接*/
function goNewMatchPageC(thises)
{
	var MatchValue = thises.options[thises.options.selectedIndex].value;
	if(MatchValue.length<=4)
	{
	   var theNextSeason=parseInt(MatchValue)+1;
	   MatchValue=MatchValue+'-'+theNextSeason;
	}	
	var currentPage = location;
	var url = '/football/'+returnLang()+'/score/'+MatchValue+'/'+CurrnetUrlFileName()+'.htm';
	location = url;
}

 /*给最常见赛果设置赛季下拉链接*/
function goNewMatchPageD(thises)
{
	var MatchValue = thises.options[thises.options.selectedIndex].value;
	if(MatchValue.length<=4)
	{
	   var theNextSeason=parseInt(MatchValue)+1;
	   MatchValue=MatchValue+'-'+theNextSeason;
	}	
	var currentPage = location;
	var url = '/football/'+returnLang()+'/league_match/'+MatchValue+'/nor_result/'+CurrnetUrlFileName()+'.htm';
	location = url;
}
function searchTeamOrPlayer(lang)
{
var str2=textfield.value;
if(document.getElementById("Radio2").checked==true)
{
   //str1=document.getElementById("Radio1").value;
   if(lang=="tai")
      window.open ("/football/tai/Search_Team.aspx?str1="+"&str2="+str2);
   else
      window.open ("/football/aspx/Search_Team.aspx?str1="+"&str2="+str2);
}
 if(document.getElementById("Radio1").checked==true)
   {
   //str1=document.getElementById("Radio2").value;
   if(lang=="tai")
      window.open ("/football/tai/Search_Player.aspx?str1="+str2+"&str2=");
   else
       window.open ("/football/aspx/Search_Player.aspx?str1="+str2+"&str2=");
  }
   
}

function goNewStatisticPage(thises,folder)
{
	var MatchValue = thises.options[thises.options.selectedIndex].value;
	var currentPage = location;
	 MatchValue=MatchValue.replace(/^\s+/,"").replace(/\s+$/,"")
	 if((MatchValue.length>4 && MatchValue.indexOf('-')>-1) || MatchValue.length<=4)
	 {
	   if(MatchValue.length<=4)
	    {
	       var theNextSeason=parseInt(MatchValue)+1;
	       MatchValue=MatchValue+'-'+theNextSeason;
	    }	
	
	  var url = '/'+folder+'/'+MatchValue+'/'+ScsgUrlFileName()+'.htm';
	  location = url;
	}
}



function Location(url,MatchSeason,FileName)
{     
	if(MatchSeason.length<=4)
	{
	   var theNextSeason=parseInt(MatchSeason)+1;
	   MatchSeason=MatchSeason+'-'+theNextSeason;
	}
	if(MatchSeason.indexOf("\/")>0)
	{
		MatchSeason2="";
		for(var i=0;i<MatchSeason.split('/').length;i++)
		{
			if(i==0)
			{
				MatchSeason2=MatchSeason.split('/')[i];
				if(MatchSeason.split('/')[i].length<=4)
				{
					var theNextSeason=parseInt(MatchSeason)+1;
					MatchSeason2=MatchSeason2+'-'+theNextSeason;
				}
			}
			else
				MatchSeason2+="/"+MatchSeason.split('/')[i];
		}
		MatchSeason=MatchSeason2;
	}
	url=url.replace(/^\s+/,"").replace(/\s+$/,"")
	MatchSeason=MatchSeason.replace(/^\s+/,"").replace(/\s+$/,"")
	FileName=FileName.replace(/^\s+/,"").replace(/\s+$/,"")
	url="/football/en"+url+MatchSeason+FileName
	return url;
}

function LocationTai(url,MatchSeason,FileName)
{     
	if(MatchSeason.length<=4)
	{
	   var theNextSeason=parseInt(MatchSeason)+1;
	   MatchSeason=MatchSeason+'-'+theNextSeason;
	}
	if(MatchSeason.indexOf("\/")>0)
	{
		MatchSeason2="";
		for(var i=0;i<MatchSeason.split('/').length;i++)
		{
			if(i==0)
			{
				MatchSeason2=MatchSeason.split('/')[i];
				if(MatchSeason.split('/')[i].length<=4)
				{
					var theNextSeason=parseInt(MatchSeason)+1;
					MatchSeason2=MatchSeason2+'-'+theNextSeason;
				}
			}
			else
				MatchSeason2+="/"+MatchSeason.split('/')[i];
		}
		MatchSeason=MatchSeason2;
	}
	url=url.replace(/^\s+/,"").replace(/\s+$/,"")
	MatchSeason=MatchSeason.replace(/^\s+/,"").replace(/\s+$/,"")
	FileName=FileName.replace(/^\s+/,"").replace(/\s+$/,"")
	url="/football/tai"+url+MatchSeason+FileName
	return url;
}
function goNewMatchPage(thises,folder)
{
	var MatchValue = thises.options[thises.options.selectedIndex].value;
	var currentPage = location;
	var url = '/'+folder+'/'+MatchValue+'/'+CurrnetUrlFileName()+'.htm';
	location = url;
}

function goCupCountPage(thises,folder,num)
{
	var MatchValue = thises.options[thises.options.selectedIndex].value;
	var currentPage = location;
	var m=MatchValue.split(",");
	var url,fram;
	if(num==1)
	{
	   url= '/'+folder+'/CupCount.aspx?sclassID='+m[0]+'&matchSeason='+m[1]+'&teamID='+m[2];
	    fram=document.getElementById('CupIntroduce');
	 }
	else
	{
	   url= '/'+folder+'/CountPlayerData.aspx?sclassID='+m[0]+'&matchSeason='+m[1]+'&teamID='+m[2];
	    fram=document.getElementById('CountData');
	 }	
	fram.src=url;
}

function goNewCupMatchPage(thises,folder,sclassid,cMatchSeason,cGroupid,cGroupNum)
{
	var MatchValue = thises.options[thises.options.selectedIndex].value;
	var currentPage = location;
	MatchValue=MatchValue.replace(/^\s+/,"").replace(/\s+$/,"");
	cMatchSeason=cMatchSeason.replace(/^\s+/,"").replace(/\s+$/,"");
	cGroupid=cGroupid.replace(/^\s+/,"").replace(/\s+$/,"");
	cGroupNum=cGroupNum.replace(/^\s+/,"").replace(/\s+$/,"");
	var MatchSeason = MatchValue;
	if(MatchSeason.length<=4)
	  {
	    var theNextSeason=parseInt(MatchSeason)+1;
	    MatchSeason=MatchSeason+'-'+theNextSeason;
	 }
	m  = cMatchSeason.split(",");
	gid = cGroupid.split(",");
	gnum = cGroupNum.split(",");
	for(var i=0;i<cGroupid.length;i++)
	 {
		if(MatchValue == m[i])
		 {
		 if(gnum[i]!='0')
			 {
				var url = '/'+folder+'/'+MatchSeason+'/cupmatch_vs/cupmatch_'+sclassid+'_'+gid[i]+'_all.htm';
			 }
			 else
			  {
				 var url = '/'+folder+'/'+MatchSeason+'/cupmatch_vs/cupmatch_'+sclassid+'_'+gid[i]+'.htm';
			  }
		 }
	 }
	location = url;
}

/*给让球盘路设置球队下拉链接*/
function goNewTeamPageA(SclassID)
{
	var thisSeason = document.getElementById('dropMatchSeason');
	var thisTeam = document.getElementById('dropTeam');
	var Season = thisSeason.options[thisSeason.options.selectedIndex].value;
	var Team = thisTeam.options[thisTeam.options.selectedIndex].value;
	//var url = "http://61.143.225.110:1222/aspx/scsg.aspx?SclassID="+SclassID+"&MatchSeason="+Season+"&TeamID="+Team+"";
	var url = "/football/aspx/BallPanluTeam.aspx?SclassID="+SclassID+"&MatchSeason="+Season+"&TeamID="+Team+"";
	window.open(url);
}

/*给大小盘路设置球队下拉链接*/
function goNewTeamPageB(SclassID)
{
	var thisSeason = document.getElementById('dropMatchSeason');
	var thisTeam = document.getElementById('dropTeam');
	var Season = thisSeason.options[thisSeason.options.selectedIndex].value;
	var Team = thisTeam.options[thisTeam.options.selectedIndex].value;
	var url = "/football/aspx/SamallPanluTeam.aspx?SclassID="+SclassID+"&MatchSeason="+Season+"&TeamID="+Team+"";
	window.open(url);	
}

/*设置当前赛季值默认值*/
function SettingdropSeason(folder)
{
	var url = location.href;
	var s = url.split(folder);
	var a = s[1].split('/');
	
	var b = a[1].split('-');
	
	var MatchSeasonA = a[1];
	var MatchseasonB = b[0];
	
	var dropMatchSeason = document.getElementById("dropMatchSeason");

	for(i=0;i<dropMatchSeason.length;i++)
	{ 
		if(dropMatchSeason.options[i].value==MatchSeasonA || dropMatchSeason.options[i].value==MatchseasonB) dropMatchSeason.options[i].selected = true;
	}
}

/*给让球盘路设置当前赛季值*/
function SettingdropSeasonA()
{
	var url = location.href;
	var s = url.split('/league_data/');
	var a = s[1].split('/');
	var MatchSeason = a[0];
	var dropMatchSeason = document.getElementById("dropMatchSeason");

	for(i=0;i<dropMatchSeason.length;i++)
	{ 
		if(dropMatchSeason.options[i].value==MatchSeason) dropMatchSeason.options[i].selected = true;
	}
}

/*给大小盘路设置当前赛季值*/
function SettingdropSeasonB()
{
	var url = location.href;
	var s = url.split('/bigsmallleague/');
	var a = s[1].split('/');
	var MatchSeason = a[0];
	var dropMatchSeason = document.getElementById("dropMatchSeason");

	for(i=0;i<dropMatchSeason.length;i++)
	{ 
		if(dropMatchSeason.options[i].value==MatchSeason) dropMatchSeason.options[i].selected = true;
	}
}

/*给赛程赛果设置球队跳转链接*/
function goNewTeamPage(SclassID)
{
    var s=top.location.href;
	var thisSeason = document.getElementById('dropMatchSeason');
	var thisTeam = document.getElementById('dropTeam');
	var Team = thisTeam.options[thisTeam.options.selectedIndex].value;
	var Season = thisSeason.options[thisSeason.options.selectedIndex].value;
	if(s.indexOf("tai")>-1)
	  location.href="/football/tai/tcsg.aspx?SclassID="+SclassID+"&MatchSeason="+Season+"&TeamID="+Team;
	else
	  location.href="/football/aspx/tcsg.aspx?SclassID="+SclassID+"&MatchSeason="+Season+"&TeamID="+Team;
}
function Odds(ID) {
var s=top.location.href;
var head=s.split('/')[4];
var theURL='';
if(head=="tai")
   theURL='http://thai.nowgoal.com/OddsComp.aspx?id='+ID;
else
   theURL='http://www.nowgoal.com/OddsComp.aspx?id='+ID;
window.open(theURL,'','');}

function analysis(ID){
var s=top.location.href;
var head=s.split('/')[4];;
var theURL='';
if(head=="tai")
  theURL='http://thai.nowgoal.com/analysis/'+ID+'.html';
else
  theURL='http://www.nowgoal.com/analysis/'+ID+'.html';
window.open(theURL,'','');
}
function scoreDetail(ID){
var s=top.location.href;
var head=s.split('/')[4];
var theURL='';
if(head=="tai")
   theURL='http://thai.nowgoal.com/detail/'+ID+'.html';
else
   theURL='http://www.nowgoal.com/detail/'+ID+'.html';
window.open(theURL,'','');
}
function showtime(t1,t2,t3,t4,t5,t6,type)
{
	var t = new Date(t1,t2,t3,t4,t5,t6);
	t = new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds())); 
	var Y=t.getFullYear();
	var S=Y.toString().substring(2);
    var M=t.getMonth()+1;    
    var d=t.getDate();
    var h=t.getHours();
    var m=t.getMinutes();
    if(M<10) M="0" + M;
    if(d<10) d="0" + d;
    if(h<10) h="0" + h;
    if(m<10) m="0" + m;
    if(type==1)
        document.write(M+"/" + d +" " +h+":"+m);
    else if(type==2)
        document.write(M+"/" + d +"/"+S+" " +h+":"+m);
    else if(type==3)
        document.write(M+"/" + d +"/"+Y);
    else if(type==4)
       document.write(M+"/" + d +"/"+Y+" " +h+":"+m);
    else
       document.write(M+"/" + d +"<br/>" +h+":"+m);
}