﻿

/*
	事件绑定
	如:window.onload=fn; -> bind(window,'load',fn);
*/
function bind(o,ev,fn){
	if (document.all){
		o.attachEvent('on'+ev,fn);////////////IE绑定上但是fn里this指向window
	}
	else{
		o.addEventListener(ev,fn,false);
	}
	return o;
}

(function(){
	function initQuery(){
		var query=document.getElementById('query');
		if(query){
			query.onfocus=function(){
				if(this.value=='产品型号'){
					this.value='';
				}
			}
			query.onblur=function(){
				if(this.value==''){
					this.value='产品型号';
				}
			}
		}
		var btnsearch=document.getElementById('btnsearch');
		if(btnsearch){
	        btnsearch.onclick=function(){
	            var qval=query.value;
	            if(qval=="产品型号" || qval.length<2)
	            {
	                //alert("产品型号 至少为2位！");
	                return;
	            }
	            self.location.href="../product/search.aspx?tag="+qval;
		    }
		}
	}
	bind(window,'load',initQuery);
})();