function checkSub(type,keywordss,swhere)
{
    var aa=document.getElementById('goto').value;
	if(aa!=""&&aa<1000000)
	{
	    var str=swhere.split('_');
	    var strLink;
	    var key="";
	    if(keywordss!="")
	    {
	         key = "?Key=" + keywordss;
	    }
	    if(str.length>2)
	    {
            strLink = "t" + str[2] + "_" + type + "_" + str[0] + "_" + str[1] + "_" + aa + ".html" + key;
          
            if (str[0] == "0" && str[1] == "0" && str[2] != "0")
            {
                if (type == 1)
                {
                    strLink = "t" + str[2] +  "_" + aa + ".html";
                }
                else 
                { 
                    strLink = "t" + str[2] + "_" + type + "_" + aa + ".html"; 
                }
               
            }                  
	    }	   
	   window.location=strLink;
	}
}


function checkSubRank(yearID,Filmtype,region,flag,orders)
{
    var aa=document.getElementById('goto').value;
	if(aa!=""&&aa<1000000) 
	{
	    var link='Rank' + Filmtype + '_' + yearID + '_' + region + '_' + flag + '_' + orders + '_' + aa + '.html';
	    if (yearID != 0 && region == 0 && Filmtype == 0)
        {
            link = "TimeRank" + yearID+"_" + orders+"_"+ aa + ".html";
        }
        if (yearID == 0 && region == 0 && Filmtype != 0)
        {
            link = "CategoryRank" + Filmtype + "_" + aa + ".html";
        }
        if (yearID == 0 && region != 0 && Filmtype == 0)
        {
            link = "RegionRank" + region + "_" + aa + ".html";
        }   
        window.location=link;
     }	    	
}

function SearchKey()
{
    var a=document.getElementById('keyword').value;
    if(a!='')
    {
        window.location='t0_1.html?key='+a;
    }
}
function Selected(sid,mid)
{
    for(var i=0;i<document.getElementById("year").options.length;i++)
        {if(document.getElementById("year").options[i].innerHTML==sid)
            document.getElementById("year").options[i].selected = true;}
    
    for(var i=0;i<document.getElementById("smonth").options.length;i++)
        {if(document.getElementById("smonth").options[i].innerHTML==mid)
            document.getElementById("smonth").options[i].selected = true;}

}
function onClickSubmit(flag)
{
    var YearMonth=0;
    if(document.getElementById("year").options[document.getElementById("year").selectedIndex].value!=-1)
    {
        if(document.getElementById("smonth").options[document.getElementById("smonth").selectedIndex].value==-1)
        {
            YearMonth=document.getElementById("year").options[document.getElementById("year").selectedIndex].innerHTML+"00";
        }
        else
        {
            YearMonth=document.getElementById("year").options[document.getElementById("year").selectedIndex].innerHTML+document.getElementById("smonth").options[document.getElementById("smonth").selectedIndex].innerHTML;
        }
    }   
    if(flag==0)
    {
        window.location='Rank' + document.getElementById("filmtype").options[document.getElementById("filmtype").selectedIndex].value + '_' + YearMonth + '_' + document.getElementById("region").options[document.getElementById("region").selectedIndex].value + '_0_0_1.html';   	    	
    }
   if(flag==1)
   {
        if(document.getElementById("txt_keyword").value!='')
        {
            window.location='t'+document.getElementById("filmtype").options[document.getElementById("filmtype").selectedIndex].value+'_1_'+YearMonth+'_'+document.getElementById("region").options[document.getElementById("region").selectedIndex].value+'_1.html?key='+document.getElementById("txt_keyword").value;
        }
        else
        {
            window.location='t'+document.getElementById("filmtype").options[document.getElementById("filmtype").selectedIndex].value+'_1_'+YearMonth+'_'+document.getElementById("region").options[document.getElementById("region").selectedIndex].value+'_1.html';
        }
   }
}

//获取指定名称的cookie值：getCookie(name)

function getCookie(name){
             var strCookie=document.cookie;
             var arrCookie=strCookie.split("; ");
             for(var i=0;i<arrCookie.length;i++){
                   var arr=arrCookie[i].split("=");
                   if(arr[0]==name)return arr[1];
             }
             return "";
}


//创建cookie的函数
  function writeCookie (FilmID)
   {   
        if(document.cookie=="")
        {
            //创建一个时间对象，用于确定cookie保留时间
            var destoryTime = new Date();
            //cookie在7天后失效
            destoryTime.setTime(destoryTime.getTime() + 24 * 3600 * 1000 * 7);
            //转为GMT时间
            var expireTime = destoryTime.toGMTString();           
              //写入cookie  
            var strCookie=document.cookie = "user="+FilmID+"|"+expireTime+";expires=" + expireTime+";";
          
            //alert(strCookie);
        }
        else
        { 
                var a=true;     
                var arr=getCookie("user").split('|');
                var two=  arr[0].split(',');                               
                
                for(var i=0; i< two.length;i++)
                {  
                    if(FilmID==two[i])
                        a=false;
                }
                if(a)
                {
                    var strCookie=document.cookie = "user="+arr[0]+","+FilmID+"|"+arr[1]+";expires=" + arr[1]+";";
                         //alert(strCookie);
                }
                
                if(two.length==4)
                {
                    var CallBack = function callback(obj)
                   {      
                      
                   }
                   Request.SendToPage('AjaxDataOperate/AjaxCookie.aspx?Insert='+getCookie("user"),'',CallBack,false,null);  
                }
        }
   

   }
