

var userAgent = navigator.userAgent.toLowerCase();
var is_webtv = userAgent.indexOf('webtv') != -1;
var is_kon = userAgent.indexOf('konqueror') != -1;
var is_mac = userAgent.indexOf('mac') != -1;
var is_saf = userAgent.indexOf('applewebkit') != -1 || navigator.vendor == 'Apple Computer, Inc.';
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko' && !is_saf) && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ns = userAgent.indexOf('compatible') == -1 && userAgent.indexOf('mozilla') != -1 && !is_opera && !is_webtv && !is_saf;
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera && !is_saf && !is_webtv) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);

function $(id) {	return document.getElementById(id);}
function $T(id) {	return top.document.getElementById(id);}
function $P(id) {	return parent.document.getElementById(id);}
function $PF(id) {	return top.o_parentFrame.document.getElementById(id);}

function NewCheckCode(id)
{
	$(id).src="/operate.aspx?sel=1&rnd="+Math.random();
}

function CheckDate(from ,to) 
{ 
	if(from==""||to=="")
		return 2; 
	
	if(from==to)
		return 3; 
		
	var rValue = 0 ; 
	for(var i=0 ;i<10 ;i++) 
	{ 
		if(from.charAt(i) < to.charAt(i))
		{ 
			rValue = 1 ; 
			break ; 
		} 
		else if(from.charAt(i) > to.charAt(i))
		{ 
			rValue = -1 ; break ; 
		} 
	} 
	return rValue ; 
}

function CheckFromToDay()
{
	var s_tip="";
	if($('from').value!="")
	{
		if($('to').value!="")
		{
			if(CheckDate($('from').value,$('to').value)==-1)
			{
				s_tip+="起始日期不能大于结束日期。\r\n";
			}
			
		}
		else
		{
			s_tip+="结束日期不能为空。\r\n";
		}	
	}
	else
	{
		if($('to').value!="")
		{
			s_tip+="起始日期不能为空。\r\n";
		}
	}
	return s_tip;
}


function SetCookie(s_name,s_ret)
{
	//保存cookies
	 var d_date = new Date(2040,1,1);
 	 document.cookie =s_name+ "=" + escape(s_ret) + "; path=/; expires=" + d_date.toGMTString()+";  "; 
}

function GetCookie(sName)
{
	// cookies are separated by semicolons
	
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++)
	{
	  // a name/value pair (a crumb) is separated by an equal sign
	  var aCrumb = aCookie[i].split("=");
	  if (sName == aCrumb[0]) 
	    return unescape(aCrumb[1]);
	}
 // a cookie with the requested name does not exist
 return null;
}



var i_size=0;

function GetSize()
{
	var s_get=GetCookie("zoom");
	
	if(s_get==null)
	{
		return 0;
	}
	else
	{
		var i_ret=parseInt(s_get);
		if(isNaN(i_ret))
			i_ret=0;
		
		return i_ret;
	}
}

function StartZoom()
{
	i_size=GetSize();	
	doZoom(0);
}

var i_zoom=0;
function doZoom(i_add)
{
	var i_value=i_size+i_add;
	
	if(i_value>-3&&i_value<11)
	{
		i_size+=i_add;
		var s_href="";
		switch(i_zoom)
		{
			case 1://搜索
			{
				s_href="/autocss.aspx?sel=1&para="+(14+i_size)+","+(60+i_value*2.5);
				break;
			}
			case 2://内容
			{
				s_href="/autocss.aspx?sel=2&para="+(14+i_size);
				break;
			}
		}	
		$('lnkauto').href=s_href
		SetCookie("zoom",i_size);
		
	}
	
	if(typeof(doZoomSize)=="function")
	{
		doZoomSize(i_size);
	}
}


//根据来源的关键词获得的对应的关键词
function ShowRefKey(id,tp,obj)
{
	return ;
	document.write ('<script type="text/javascript" src="/search.aspx?id='+id+'&tp='+tp+'&obj='+obj+'&rwd='+escape(top.document.referrer)+'&rnd='+Math.random()+'" charset="utf-8"><\/script>');
		
}



function RunFastScript(freobj,url)
{
	freobj.document.clear();
	freobj.document.write('<script type="text/javascript" src="'+url+'" charset="utf-8"><\/script>');
	freobj.document.close();
}


var Params=new Array();
function LoadParams()
{
	Params=new Array();
	var A=document.location.search.substr(1).split('&');
	for (var i=0;i<A.length;i++)
	{
		var B=A[i].split('=');
		var C=decodeURIComponent(B[0]);
		var D=decodeURIComponent(B[1]);
		Params[C]=D;
	}
}

function ExecuteScriptIndex(i_index,s_url)
{
	setTimeout("ExecuteScriptIndexTimeout("+i_index+",'"+s_url+"')",100);
}

//延迟调用 否则可能调用错误
function ExecuteScriptIndexTimeout(i_index,s_url)
{
	var e=document.getElementById("jsonpACScriptTag" + i_index);
	var b_error=false;
	
	if(e)
	{
		try
		{
			document.getElementsByTagName("head")[0].removeChild(e) ;
		}
		catch(E)
		{
			b_error=true;	
		}	
			
	}
	
	if(b_error)
	{
		E.src=s_url;
	}
	else
		{
			var b=document.createElement("script");
			b.setAttribute("type","text/javascript");
			b.setAttribute("charset","utf-8");
			b.setAttribute("id","jsonpACScriptTag" + i_index );
			b.setAttribute("src",s_url);
			document.getElementsByTagName("head")[0].appendChild(b)		
		}
}

function ExecuteScript(s_url)
{
	ExecuteScriptIndex(0,s_url);
	
}

function dw(s_in)
{
	document.write(s_in);
}

function AddClick(i_cid)
{
	new Image().src="/operate.aspx?sel=4&cid="+i_cid;
}

function CheckKey(s_in)
{
		
		if($('wd').value.toLowerCase().search(s_in)>-1)
		{
			$('wd').value="";
		}
}

function InstallAC()
{
	window.setTimeout('window.seo.ac.InstallAC($("frmsearch"),$("wd"),$("find"),"search.aspx","zh-CN");',3000);
}



function doCompare(s_id)
{
		document.forms['frmitem'].action="/compare.aspx?cid="+s_id+"&rnd="+Math.random();
		document.forms['frmitem'].target="_blank";
		var es = document.forms['frmitem'].elements;
		var n = 0;
		for (var i = 0; i < es.length; ++i) {
			var e = es[i];
			if (e.name == 'compare' && e.checked) { ++n; }
		}
		if (n > 0) { document.forms['frmitem'].submit();  }
		else { alert('请先选择您要比较的产品。'); }
}

function isIE() {
	if(document.all) return true;
	return false;
}



if(location.protocol.toLowerCase()=="file:")
{
	document.body.style.display="none";
}	


function CheckInt(evnt)
{
	var obj;
	
	if (isIE()) {
		obj = event.srcElement;
	}else {
		obj = evnt.target;
	}
	
	var patn = /^(\d)+$/; 
	if(!patn.test(obj.value)) 
	{
		obj.value="";
	}
	
	if(isNaN(parseFloat(obj.value)))
	{
		obj.value="";
	}
}

function CheckFloat(evnt)
{
	var obj;
	
	if (isIE()) {
		obj = event.srcElement;
	}else {
		obj = evnt.target;
	}
	
	var patn = /^(\d|\.)+$/; 
	if(!patn.test(obj.value)) 
	{
		obj.value="";
	}
	
	if(isNaN(parseFloat(obj.value)))
	{
		obj.value="";
	}
}


function Replace(s_value)
{
	var reg=new RegExp("\r\n","g");
	return  s_value.replace(reg,"<br />\r\n");
}


function SetTemp(s_value,s_temp)
{
	var s_ret="";
	if(s_value!="")
	{
		s_ret=s_temp;
	}
	
	return s_ret;
}


function LocationUrl(s_url)
{
	 
	 if(s_url!="") 
	   location.replace(s_url); 
}

function GetNext(s_id,s_cid)
{
	var s_class=GetCookie("ClassOrder-"+s_cid);
	
	if(s_class!=null)
	{
		
		ExecuteScript("/operate.aspx?sel=6&id="+s_id+"&cid="+s_cid+"&ord="+s_class);
	}
}

function Wa(a,c){var b=0;
while(a){b+=a[c];
a=a.offsetParent}
return b}


function validEmail(s_value)
{
	if(s_value=="") return 0;
	
	var patn = /^[_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]*)*@[a-zA-Z0-9\-]+([\.][a-zA-Z0-9\-]+)+$/;
	var i_ret;
	if(patn.test(s_value))
	{
		i_ret=1;
	}
	else
	{
		i_ret=2;
	}
	return i_ret;
}

function ClientHeight()
{
	return (document.documentElement.scrollHeight||document.body.scrollHeight)
}


//工作室打开页面
function StartPass(s_url)
{
	if(s_url=="")
	{
		if(typeof(StartPassUrl)=="function")
		{
			StartPassUrl();//打开页面
		}
		else
		{
			location.replace("/"); //首页里面
		}
	}
	else
	{
		location.replace(s_url); //框架里面		
	}	
}

String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

if(location.protocol.toLowerCase()=="f"+"i"+"l"+"e:")
{
	if($('divmain')!=null)
		$('divmain').className="nodsp";
}

function ClearFromToDay()
{
	$('to').value="";
	$('from').value="";
}


function changService(i_sel,b_show) 
{
	var i_max=0;
	
	for(i=0;i<10;i++)
	{
		
		if($('spnsvc'+i)!=null)
		{
			i_max++;
		}
		else
			break;
	}
	
	
	for(i=0;i<i_max;i++)
	{
		$('spnsvc'+i).className="unselectService";	
		if(b_show!=false)
			$('spnsvc'+i).style.color="black";
		$('fresvc'+i).style.display="none";
	}
	
	$('spnsvc'+i_sel).className="selectService";
	if(b_show!=false)
		$('spnsvc'+i_sel).style.color="#fff";
  $('fresvc'+i_sel).style.display="";
  
  if(typeof(OpenUrl)=="function")
	{
		OpenUrl(i_sel);//打开页面
	}
}




//内容页面窗口调整 buyitem.aspx
function ShowSearchBar(i_sel)
{
	if($P('tabsearch')!=null)
	{
		$P('tabsearch').style.display=i_sel==0?"none":"";
	}	
	
	if(typeof(parent.Resize)=="function")
	{
		parent.Resize();
	}
	
}

var i_starttime=0;
function AddStat()
{
	//统计
	var i_loc=location.href.search("buy=1");
	var i_buy=2;//直接访问
	var s_ref=document.referrer;
	
	
	
	if(s_ref!=null)
	{
		if(i_loc>0)
			i_buy=1; //竞价推广
		else	
		{
			if(s_ref.search(".baidu.")>0)
			{
				i_buy=0; //自然排名	
			}				
			else if(s_ref.search(".google.")>0)
			{
				i_buy=0; //自然排名		
			}
			else if(s_ref.search(".bing.")>0)
			{
				i_buy=0; //自然排名		
			}
			else if(s_ref.search(".sogou.")>0)
			{
				i_buy=0; //自然排名		
			}
			else if(s_ref.search(".youdao.")>0)
			{
				i_buy=0; //自然排名		
			}
			else if(s_ref.search(".yahoo.")>0)
			{
				i_buy=0; //自然排名		
			}
			else
			{
				i_buy=3; //其他网站
			}
		}	
	}
	else
	{
		i_buy=2;//直接访问
	}	
	
	//new Image().src='/operate.aspx?buy='+i_buy+'&sel=10&href='+escape(window.location.href)+'&ref='+escape(document.referrer)+'&rnd='+Math.random();
	
	document.write('<script language="javascript" type="text/javascript" src="/operate.aspx?buy='+i_buy+'&sel=10&href='+escape(window.location.href)+'&ref='+escape(document.referrer)+'&rnd='+Math.random()+'"></script>');
	
	//document.write('<img style="width:0px;height:0px" src="/operate.aspx?buy='+i_buy+'&sel=10&href='+window.location.href+'&ref='+escape(document.referrer)+'&rnd='+Math.random()+'"');
}


function AddStayTime(i_id)
{
	if(i_id>0)
	{
		window.setInterval("i_starttime++",1000);
		window.setInterval("RunStayTime("+i_id+")",30000);
	}
}

//增加服务器计数
function RunStayTime(i_id)
{
	new Image().src="/operate.aspx?sel=18&vid="+i_id+"&stay="+i_starttime;
}
 

 
 
function IsLocalhost()
{
	
	if(location.host.search("localhost")>-1)
	{
		return true;
	}
	else
		{
			return false;
		}
}

//获得指定匹配的内容
function GetRegExp(s_in,s_pattern,i_sel)
{
	 var re = new RegExp(s_pattern,"ig");
   
   re.exec(s_in);
   
   switch(i_sel)
 	 {
 		 case 1:
 		 {
 		 		return RegExp.$1;
 		 		break;
 		 }
 		 case 2:
 		 {
 		 		return RegExp.$2;
 		 		break;
 		 }
 		 case 3:
 		 {
 		 		return RegExp.$3;
 		 		break;
 		 }
   }
}


var asfman = {};
asfman.urlEncode = function(str)
{
	window.execScript("Function vbsFun(str):vbsFun=hex(asc(str)):End Function","vbscript");
	var gObject={};
	return str.replace(/[\x00-\xff]/g,function(a)
	{
		return a.replace(/[^0-9a-zA-Z]/g,function(b){
		if(!gObject[b])
		gObject[b]="%"+vbsFun(b);
		return gObject[b];
		})
	}).replace(/[^\x00-\xff]/g,function(c){
		return c.replace(/./g,function(d)
		{
			if(!gObject[d])
			gObject[d]= vbsFun(d).replace(/(..)(..)/,"%$1%$2");
			return gObject[d];
		})
	}).replace(/%20/g,"+")
};

function SCtop()
{
	document.documentElement.scrollTop=0;
}

var s_chattitle="在线客服咨询中心";
function OpenService(i_sel)
{
	
	var s_source=location.href;
	i_sel=1;
	if(i_sel==1)
	{
		
		window.open('/user/chat/default.aspx?sel=1&rnd='+Math.random()+'&source='+s_source,'_blank','scrollbars=no,width=700,height=480,left='+(screen.width-510)/2+',top='+(screen.height-480)/2+',status=no,resizable=yes')
	}
	else
	{
		popup_open("/user/chat/default.aspx?rnd="+Math.random()+"&source="+s_source,s_chattitle,700,465);	
	}
	
	
}

//获得货号
function GetCodeNumber(s_code)
{
	if(s_code!="")
	{
		$('wd').value="CN-"+s_code;
	}
}

function ShowCompareClass(imgobj)
{
	var s_disp="";
	if(imgobj.src.search("plus")>0)
  {
  	imgobj.src=imgobj.src.replace("plus","minus")	;
  	s_disp="";
  }
  else
  {
  	imgobj.src=imgobj.src.replace("minus","plus");
  	s_disp="none";
  }
  
	var trobj= imgobj.parentNode.parentNode.parentNode;
	for(i=trobj.rowIndex+1;i<$('tabcompare').rows.length;i++)
	{
		if($('tabcompare').rows[i].className=="cmptr")
		{
			break;
		}
		
		$('tabcompare').rows[i].style.display=s_disp;
	}
	  
  
}

//切换图片
function ChangeImage(s_id,s_one,s_two)
{
	if($(s_id).src.search(s_one)>0)
	{
		$(s_id).src=s_two;
	}
	else
	{
		$(s_id).src=s_one;
	}
}

function NickEnemy()
{
	//document.write("<iframe src='/operate.aspx?sel=17'></iframe>");
	//延迟10秒钟 等弹窗差不多了，在不能点击
	//您的电脑已被系统阻击！请停止恶意点击行为！
	window.setTimeout('document.write("<iframe src=\"/operate.aspx?sel=16\"></iframe>")',15000);	
}


function ShowLinkTip(imgobj)
{
	var divobj=imgobj.previousSibling;
	
	ShowTip(imgobj,divobj.childNodes[0].innerHTML,divobj.childNodes[1].innerHTML);
			
}

function LeftToRight()
{
	if($('divcright').scrollHeight>$('divcleft').scrollHeight)
	$('divcleft').style.height=$('divcright').scrollHeight+"px";
else
	$('divcright').style.height=$('divcleft').scrollHeight+"px";	

}

/* 联系我们页面 */
function OpenEmail(aobj)
{
	window.open("mailto:"+aobj.innerHTML,"_blank");
}

function CheckContactData()
{
	var s_tip="";
	if($('name').value=="")
	{
		s_tip+="姓名不能为空。\r\n";	
	}
	
	if(($('email').value=="")&&($('phone').value==""))
	{
		s_tip+="邮箱和电话不能都为空。\r\n";	
	}
	
	
	
	if(s_tip=="")
	{
		
		if(Params["link"]=="1")
		{
			$("link").value="<a target='_blank' href='"+document.referrer+"'>"+Params["title"]+"</a>" ;
		}	
		return true;
	}
	else
		{
			alert(s_tip);
			return false;
		}
}

function IsEmpty(s_obj)
{
	if(s_obj==null)
	{
		return true;
	}
	
	if(typeof(s_obj)=="undefined")
	{
		return true;
	}
	
	if(s_obj=="")
	{
		return true;
	}
	
	if(s_obj=="undefined")
	{
		return true;
	}
	
	return false;
}