﻿function mysearch(src,e){
try{
	var v;
	if(src.type=="text"){
		e=window.event||e;
		var code=e.keyCode||e.which;
		if(code!=13) return;
		v=src.value.trim();
	}
	else v=$$(Dom.top(src,"TABLE"),"INPUT")[0].value.trim();
	var loc=src.getAttribute("loc"),tail=v?"?key="+escape(v):"";
	location="http://list.soncool.com/"+(loc?loc:"index")+".aspx"+tail;
	return false;
}catch(e){return false;}
}
function myarea(){
	var k=$("keyword"),o=$("keylink"),a=[],area=$("areafilter").value;
	if(!k||!o) return;
	var v=k.value.trim();
	var tail=v?"?key="+escape(v):"",loc=o.getAttribute("loc");
	location="http://list.soncool.com/"+(loc?loc:"index")+(area?"-a"+area:"")+".htm"+tail;
}
function myfilter(o){
	var l=$$$("xml"),btn=$("keylink"),a=[];
	if(!btn) return;
	if(l.length>0){
		var x;
		for(var i=0;i<l.length;i++){
			if(l[i].style.display=="none")continue;
			x=l[i]; break;
		}
		if(x){
			var l=$$(x,"SELECT");
			for(var i=0;i<l.length;i++) if(l[i].selectedIndex>0) a.push(escape(l[i].options[l[i].selectedIndex].text));
		}
	}
	var tail=o.getAttribute("tail");
	if(a.length>0) tail+=(tail.indexOf('?')>-1?"&":"?")+"sub="+a.join(',');
	location="http://search.soncool.com/"+btn.getAttribute("loc")+tail;
}
function myreset(){
	var x=$$$("xml");
	for(var i=0;i<x.length;i++){
		var l=$$(x[i],"SELECT");
		for(var j=0;j<l.length;j++) l[j].selectedIndex=0;
	}
}
function mytran(o){
	o.blur();
	var l=$$(Dom.top(o,"UL"),"A"),p=parseInt(o.getAttribute("pos"));
	for(var i=0;i<l.length;i++){
		var v=parseInt(l[i].getAttribute("pos"));
		l[i].className=v==p?"focus":"";
	}
	var x=$$$("xml");
	for(var i=0;i<x.length;i++) x[i].style.display=i==p?"":"none";
	return false;
}
function searchit(btn){
	var o=$("key");
	if(!o) return;
	var s = o.value;
	location=btn.getAttribute("url")+(!s?"":"?key="+escape(s));
}
function compareit(o){
	var l=document.getElementsByName("chkdiff"),a=[];
	for(var i=0;i<l.length;i++){if(l[i].checked)a.push(l[i].value);}
	if(a.length<=1) {
		alert("对不起，您至少要选择两种以上的产品！");
		return false;
	}
	o.href="http://www.soncool.com/compare.htm?key="+a.join();
	return true;
}
var MoveV={
	start:function(o,h,t){
		clearTimeout(this.timer);
		this.ref=o;
		this.height=(h?h:document.body.clientHeight)-o.offsetHeight;
		this.offset=Dom.scroll().t-(t?t:0);
		this.top = parseInt(o.style.marginTop.replace("px",""));
		if(this.offset<0) this.offset=0;
		if(isNaN(this.top)) this.top=0;
		this.timer=setTimeout("MoveV.run()",20);
	},
	run:function(){
		var v=(this.offset-this.top);
		if(Math.abs(v)>1) v=v*0.2;
		this.top+=v;
		if(this.top<=0){this.ref.style.marginTop="0px"; return;}
		else if(this.top>=this.height){this.ref.style.marginTop=this.height+"px"; return;}
		this.ref.style.marginTop=this.top+10+"px";
		this.timer=setTimeout("MoveV.run()",20);
	}
};


