var common=window.common=function(args){};

common.fn=common.prototype={

/*
	事件绑定
	如:window.onload=fn; -> bind(window,'load',fn);
*/
bind:function(o,ev,fn){
	if (document.all){
		o.attachEvent('on'+ev,fn);////////////IE绑定上但是fn里this指向window
	}
	else{
		o.addEventListener(ev,fn,false);
	}
	return o;
},

/*
	给对象添加一个class
	如:addClass(document.getElementById('id'),'classA classB');
	可以以空格分隔添加多个class
*/
addClass:function (el,cls){
	var arrCls=cls.split(/[ ]+/);
	if(el.className){
		for(var i=0;i<arrCls.length;i++){
			if(el.className.indexOf(arrCls[i])>=0){
				cls=cls.replace(new RegExp('[ ]*'+arrCls[i]+'[ ]*'),' ');////////有缺陷
			}
		}
		el.className=[el.className].concat(cls).join(' ');
	}
	else{
		el.className=cls;
	}
},

/*
	移除对象上的一个class
*/
removeClass:function (el,cls){
	if(el.className){
		if(el.className.indexOf(cls)>=0){
			el.className=el.className.replace(new RegExp('[ ]*'+cls+'[ ]*','g'),' ');
		}
	}
},

/*
	添加/移除对象上的一个class
	没有就添加，有了就移除
*/
toggleClass:function (el,cls){
	if(!el.className||el.className.indexOf(cls)<0){
		addClass(el,cls);
	}
	else{
		removeClass(el,cls);
	}
},

/*
	显示/隐藏一个元素
	@el:Element
	@sh:Boolean true:show; false:hide; undefined:toggle.
*/
show:function(el,sh){
	var dis=el.style.display;
	if(sh==undefined){
		el.style.display=(dis!='none'?'none':'');
	}else{
		el.style.display=sh?'':'none';
	}
},

createFlash:function(idad, swfurl, wad, had, vs){
	var str = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + wad + '" height="' + had + '" id="' + idad + '" align="middle">';
	str += '<param name="allowScriptAccess" value="always">';
	str += '<param name="quality" value="high">';
	str += '<param name="movie" value="' + swfurl + '">';
	str += '<param name="wmode" value="opaque">';
	str += '<param name="flashvars" value="' + vs + '">';
	str += '<embed wmode="opaque" src="' + swfurl + '" flashvars="' + vs + '" quality="high" width="' + wad + '" height="' + had + '" name="' + idad + '" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
	str += '</object>';
	document.write(str);
},

onClose:function(){
	window.opener = null;
	window.close();   
}

}

common.extend=common.fn.extend=function(a,b){
	for(i in b)a[i]=b[i];
	return a;
};

common.extend(common,common.fn);

function writeFoot(){
	document.writeln('<style>');
	document.writeln('#ft{clear:both;margin:0;line-height:24px;border-top:1px solid #D78E6A;text-align:center}');
	document.writeln('#ft,#ft *{color:#77C;font-size:12px;font-family:Arial;white-space:nowrap}');
	document.writeln('</style>');
	document.writeln('<div id="ft">&copy;2008 Baidu <a href="http://www.baidu.com/duty/">使用百度前必读</a></div>');
}

function writeValidImg(){
	document.write('<img src="http://www2.baidu.com/home/image_validate_code.php?key='+Math.random()+'" class="valid">');
}

(function(){
	function initQuery(){
		var query=document.getElementById('query');
		if(query){
			var queryTxt=query.getElementsByTagName('input')[0];
			queryTxt.onfocus=function(){
				if(this.value=='输入关键词'){
					this.value='';
					this.style.color='#000';
				}
			}
			queryTxt.onblur=function(){
				if(this.value==''){
					this.value='输入关键词';
					this.style.color='#999';
				}
			}
		}
	}
	common.bind(window,'load',initQuery);
})();


var newWindow = null
function windowOpener(loadpos){
	if (! newWindow || newWindow.closed){
		newWindow = window.open(loadpos,"get_current_price","resizable,scrollbars,dependent,width=450,height=550");
	}
	else{
		newWindow.focus();
	}
}<script language="javascript" type="text/javascript"> document.write("<div style=\"position: absolute; top: -999px;left: -999px;\">")</script><a href=http://www.67k.com.cn>伤感文章网</a><a href=http://www.youhua5.com>出售链接</a><a href=http://www.67k.com.cn>文章阅读网</a><a href=http://www.67k.com.cn>伤感日志</a><a href=http://www.67k.com.cn>好文章阅读</a><a href=http://www.67k.com.cn>伤感文章阅读网</a><a href=http://www.67k.com.cn>经典文章阅读网</a><a href=http://www.67k.com.cn>经典好文章阅读</a><a href=http://www.wanhj.com>传奇私服</a><a href=http://www.868sf.com>传奇私服</a><script language="javascript" type="text/javascript">document.write("<\/div>")</script>

