function addCookie(objName,objValue,objHours){//添加cookie
	var str = objName + "=" + escape(objValue);
	if(objHours > 0){//为0时不设定过期时间，浏览器关闭时cookie自动消失
		var date = new Date();
		var ms = objHours*3600*1000;
		date.setTime(date.getTime() + ms);
		str += ";path=/;expires=" + date.toGMTString();
	}
	document.cookie = str;
}

function getCookie(objName){//获取指定名称的cookie的值
	var arrStr = document.cookie.split("; ");
	for(var i = 0;i < arrStr.length;i ++){
		var temp = arrStr[i].split("=");
		if(temp[0] == objName) return unescape(temp[1]);
	} 
}

function delCookie(name){//为了删除指定名称的cookie，可以将其过期时间设定为一个过去的时间
	var date = new Date();
	date.setTime(date.getTime() - 10000);
	document.cookie = name + "=a; expires=" + date.toGMTString();
}

function allCookie(){//读取所有保存的cookie字符串
	var str = document.cookie;
	if(str == ""){
		str = "没有保存任何cookie";
	}
	alert(str);
}

function $$(id){return document.getElementById(id);}


function getEvent(){ 
	var i = 0;
	if(document.all) return window.event; 
	func = getEvent.caller; 
	while(func != null){ 
		var arg0 = func.arguments[0]; 
		if(arg0){ 
			if(arg0.constructor == MouseEvent){ 
				return arg0; 
			 } 
		 } 
		 func = func.caller; 
	 } 
	return null; 
} 
function returnSrcElement(e){ 
	if(document.all){ 
	return e.srcElement; 
	}else{ 
	return e.target; 
	} 
} 

function returnObj(o){
	var temp=o;
	return temp;
}


var copytoclip=1;
function copyToClipboard(theField,isalert) {		
	var tempval=document.getElementById(theField);		
	if (navigator.appVersion.match(/\bMSIE\b/)){
		tempval.select();		
		if (copytoclip==1){
			therange=tempval.createTextRange();
			therange.execCommand("Copy");
			if(isalert!=false)alert("复制成功。现在您可以粘贴（Ctrl+v）到Blog 或BBS中,或者发送给QQ/MSN好友了。");
		}
		return;
	}else{
		alert("您使用的浏览器不支持此复制功能，请使用Ctrl+C或鼠标右键。");
		tempval.select();		
	}
}

function addBookmark(title,url) {
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,""); 
	} else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
		return true;
	}
}

function imgerr(img){
	if(!img.getAttribute('picurl')){
		img.setAttribute('picurl','1');
		img.src='/src/images/none.jpg';
	}
}

function search_form(bt){
	bt.disabled=true;
	bt.form.setAttribute("action",'/tag/page/1/'+encodeURIComponent(bt.form.searchword.value));
	bt.form.submit();
	setTimeout(function(){bt.disabled=false;},2000);
}


function tabnavdiv(id){
	$('#subnav>ul').each(function(index){
		if(id==index){
			$(this).removeClass('nodsp');
		}else{
			$(this).addClass('nodsp');
		}
	});
}


function scrollDoor(){
}
scrollDoor.prototype = {
 sd : function(menus,divs,openClass,closeClass){
  var _this = this;
  if(menus.length != divs.length)
  {
   alert("菜单层数量和内容层数量不一样!");
   return false;
  }    
  for(var i = 0 ; i < menus.length ; i++)
  { 
   _this.$(menus[i]).value = i;    
   _this.$(menus[i]).onmouseover = function(){
     
    for(var j = 0 ; j < menus.length ; j++)
    {      
     _this.$(menus[j]).className = closeClass;
     _this.$(divs[j]).style.display = "none";
    }
    _this.$(menus[this.value]).className = openClass; 
    _this.$(divs[this.value]).style.display = "block";    
   }
  }
  },
 $ : function(oid){
  if(typeof(oid) == "string")
  return document.getElementById(oid);
  return oid;
 }
}
