
var pos,str,para,parastr,tempstr1;
tempstr="";
str = window.location.href;
pos = str.indexOf("?")
parastr = str.substring(pos+1);
//document.write("<br>文件路径："+str);
//if (pos>0){
// document.write("<br>所有参数："+parastr);
// }
//else 
// {
// document.write ("<br>无参数");
// }


if (str.indexOf("&")>0)
{
 	para = parastr.split("&");
 	for(i=0;i<para.length;i++)
 	{
 		tempstr1 = para[i];
 
 		pos = tempstr1.indexOf("=");
		if(tempstr1.substring(0,pos)=="ad")
 		{
			//document.write ("等于:"+tempstr1.substring(pos+1)); 
			setCookie("getadSource",tempstr1.substring(pos+1));
			//var aabb=getCookie("getadSource");
			//document.write (aabb); 	
		}
 		//document.write (tempstr1.substring(0,pos));
 		//document.write ("<br>参数"+i+":"+tempstr1.substring(0,pos));
 		//document.write ("等于:"+tempstr1.substring(pos+1));
 	}
 }
 else
 {
 	pos=parastr.indexOf("=");
 	if(parastr.substring(0,pos)=="ad")
 	{
		//document.write ("<br>参数"+":"+parastr.substring(0,pos));
 		//document.write ("等于:"+parastr.substring(pos+1)); 
		setCookie("getadSource",parastr.substring(pos+1));
		//var aabb=getCookie("getadSource");
		//document.write (aabb); 		
 	}
 }
 //--- 设置cookie
  function setCookie(name,value) 
  {  
  	document.cookie = name+"="+value;
  }
 //--- 获取cookie
function getCookie(name)
{
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

