// JavaScript Document
if(!$)var $=function(a){return document.getElementById(a)};
function getCookie(a){
	var b=a+"=";
	a=document.cookie.indexOf(b);
	if(a!=-1){
		a+=b.length;
		b=document.cookie.indexOf(";",a);
		if(b==-1)b=document.cookie.length;
		return unescape(document.cookie.substring(a,b))
	}else return""
}
function _getCookie(a){
	return document.cookie.match(RegExp("(^"+a+"| "+a+")=([^;]*)"))==null?"":decodeURIComponent(RegExp.$2);
}
String.prototype.len=function(){
	return this.replace(/[^\x00-\xff]/g,"rr").length;
};
String.prototype.sub=function(a){
	var b=/[^\x00-\xff]/g;
	if(this.replace(b,"mm").length<=a)return this;
	for(var c=Math.floor(a/2);c<this.length;c++)if(this.substr(0,c).replace(b,"mm").length>=a)return this.substr(0,c)+"...";
	return this
};
function setCookie(a,b,c){
	c=new Date((new Date).getTime()+c*36E5);
	document.cookie=a+"="+escape(b)+"; path=/; domain=xunlei.com; expires="+c.toGMTString();
}
function delCookie(a){
	var b=new Date((new Date).getTime());
	document.cookie=a+"= ; path=/; domain=xunlei.com; expires="+b.toGMTString()
}
var EventUtil={};
EventUtil.addEventHandler=function(a,b,c){
	if(a.addEventListener)
		a.addEventListener(b,c,false);
	else if(a.attachEvent)
		a.attachEvent("on"+b,c);
	else a["on"+b]=c
};
ScrollCrossTOP={interval:0,count:0,duration:0,step:0,srcObj:null,callback:null};
ScrollCrossTOP.doit=function(a,b,c,f){
		BigNews.OnScrolling=true;
		var d=ScrollCrossTOP;
		d.callback();
		a.style.marginTop=function(g,e,h,j){
			return h*((g=g/j-1)*g*g+1)+e;
		}(d.count,b,c,f)+"px";
		d.count++;
		if(d.count==f){
			clearInterval(d.interval);
			d.count=0;
			a.style.marginTop=b+c+"px";
			BigNews.currentBegin=b+c;			
			BigNews.OnScrolling=false;
		}
};

var B=BigNews={current:0,next:0,scrollInterval:0,autoScroller:0,s:{},OnScrolling:false,currentBegin:0};
BigNews.turn=function(a,b){
		clearInterval(BigNews.autoScroller);
		BigNews.scroll(a,b);
};
BigNews.scroll=function(a,b){
		var c=b.step,f=BigNews;
		f.next=a;
		try{
			clearInterval(BigNews.s.interval)
		}catch(d){}
		if(b.pictxt!=null&&b.pictxt!="")
			$(b.pictxt+"_"+a).style.display="block";
		var g=-a+f.current;
		$(b.bigpic);
		BigNews.s.duration=16;
		BigNews.s.callback=function(){
			BigNews.current=a;
			for(i=0;i<b.totalcount;i++)
				if(i==a)
					$("big_pic_nav_"+i).className="on";
				else 
					$("big_pic_nav_"+i).className=""
		};
		var beign = parseInt(BigNews.currentBegin);
		var span=-(a*c+beign);
		var e=parseInt($(b.bigpic).style.marginTop)||0;
			
		BigNews.s.interval=setInterval(
									   function(){
										   BigNews.s.doit($(b.bigpic),beign,span,16)
									   },10)
};
BigNews.auto=function(a){
		clearInterval(BigNews.autoScroller);
		BigNews.autoScroller=setInterval(function(){
												  	BigNews.scroll(BigNews.current==a.totalcount-1?0:BigNews.current+1,a)
													},
										 a.autotimeintval)
};
BigNews.pauseSwitch=function(){clearTimeout(BigNews.autoScroller)};
BigNews.showNext=function(a,b){
		if(a>=MovieRecom.totalcount-1){
				document.body.focus();
				return false
		}else{
				BigNews.pauseSwitch();
				BigNews.turn(a+1,b);
				BigNews.auto(b);
				document.body.focus()
		}
};
BigNews.showPre=function(a,b){
		if(a<=0){
				document.body.focus();
				return false
		}else{
				BigNews.pauseSwitch();
				BigNews.turn(a-1,b);
				BigNews.auto(b);
				document.body.focus()
		}
};
BigNews.init=function(a){
		BigNews.s=ScrollCrossTOP;
		EventUtil.addEventHandler($(a.bigpic),"mouseover",new Function("BigNews.pauseSwitch();"));
		EventUtil.addEventHandler($(a.bigpic),"mouseout",new Function("BigNews.auto("+a.objname+");"));
		for(i=0;i<a.totalcount;i++){
			a.smallpic!=null&&a.smallpic!=""&&EventUtil.addEventHandler($(a.smallpic+"_"+i),
																		"mouseover",
																		new Function("BigNews.turn("+i+","+a.objname+");BigNews.pauseSwitch();return false;"));
            a.smallpic!=null&&a.smallpic!=""&&EventUtil.addEventHandler($(a.smallpic+"_"+i),
																		"mouseout",
																		new Function("BigNews.auto("+a.objname+");return false;"));       	
		}
        BigNews.auto(a);
};
var MiniSite={};
MiniSite.Browser={ie:/msie/.test(window.navigator.userAgent.toLowerCase()),
				  moz:/gecko/.test(window.navigator.userAgent.toLowerCase()),
				  opera:/opera/.test(window.navigator.userAgent.toLowerCase()),
				  safari:/safari/.test(window.navigator.userAgent.toLowerCase())
				  };
MiniSite.JsLoader={
				   load:function(a,b,c){
					   	var f=document.createElement("script");
						f.setAttribute("charset",b);
						f.setAttribute("type","text/javascript");
						f.setAttribute("src",a);
						document.getElementsByTagName("head")[0].appendChild(f);
						if(MiniSite.Browser.ie)
							f.onreadystatechange=function(){
								if(this.readyState=="loaded"||this.readyState=="complete")
									setTimeout(function(){try{c()}catch(d){}},50)
							};
						else if(MiniSite.Browser.moz)
							f.onload=function(){
									setTimeout(function(){try{c()}catch(d){}},50)};
						else setTimeout(function(){try{c()}catch(d){}},50)
					}
				   };
var ShowMoreLinks="",MoreLinksShowHandles=null;
function showMoreLinks(a,b){
		clearTimeout(MoreLinksShowHandles);
		document.getElementById(a).style.display="block";
		if(b)document.getElementById(a+"Handle").className=b;
		if(a!=ShowMoreLinks&&ShowMoreLinks!=""){
				document.getElementById(ShowMoreLinks).style.display="none";
				if(b)
					document.getElementById(a+"Handle").className=b
		}
		ShowMoreLinks=a
}
function hideMoreLinks(a,b){
		MoreLinksShowHandles=setTimeout(function(){document.getElementById(a).style.display="none"},100);
		if(b){
			document.getElementById(a+"Handle").className=b;
		}
}
String.prototype.LTrim=function(){
		return LTrim(this)};
		function LTrim(a){
			var b;
			for(b=0;b<a.length;b++)
				if(a.charAt(b)!=" "&&a.charAt(b)!=" ")
				break;
		return a=a.substring(b,a.length)
}
function doGougouSearch(){
		var a=document.getElementById("gougou_keywords").value;
		a=a.LTrim();
		if(a==""||a=="\u8f93\u5165\u5f71\u7247\u540d\u6216\u4e3b\u6f14\u540d"){
			alert("\u8bf7\u8f93\u5165\u641c\u7d22\u5173\u952e\u5b57!");
			document.getElementById("gougou_keywords").value="";
			document.getElementById("gougou_keywords").focus();
			return false
		}
		a=encodeURIComponent(a);
		a="http://search.xunlei.com/search.php?keyword="+a+"";
		var b=new Date;
		b=parseInt(b.getHours().toString()+b.getMinutes().toString()+b.getSeconds().toString()/3);
		window.open(a,"so_"+b);
		return false
};

