	document.domain = "xunlei.com";

	function setCookie(name,value,hours)
	{
		var expireDate=new Date(new Date().getTime()+hours*3600000);
		document.cookie = name + "=" + escape(value) + "; path=/; domain=xunlei.com ; expires=" + expireDate.toGMTString() ;
	}
	var advid = "";
	var url = window.location.href;
	getPara(url);
	if(advid != "")
	{
		setCookie("shengxiao_statadvid",advid,1);
		setCookie("location",url,1);
	}
	function getPara(url) {
		var para = "";
		var paraindex = url.indexOf("?");
		if(paraindex != -1){
			var advidindex = url.indexOf("advid=");
			if(advidindex != -1){
				advid = url.substring(advidindex + 6);
			}
		}

	}
	function register() {
		var registerUrl = "http://shengxiao.xunlei.com/reg/";
		var advid = getCookie("shengxiao_statadvid");
		if( advid !=""){
		     window.open(registerUrl + "?advid=" +advid ,"reg");
	  }else{
	  	   window.open(registerUrl ,"reg");
	  }	
	}
	function download(downloadUrl) {
		var advid = getCookie("shengxiao_statadvid");
		if( advid !=""){
		    window.open(downloadUrl  + "?advid=" +advid  ,"download");
	  }else{
	  	  window.open(downloadUrl ,"download");
	  }	
		
	}
	function getCookie(name)
	{
		var search;
		search = name + "=";
		offset = document.cookie.indexOf(search);
		if (offset != -1) 
		{
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1)
				end = document.cookie.length;
			return unescape(document.cookie.substring(offset, end));
		}
		else
		{
			return "";
		}
	}