﻿function strlen(str)
{
	var i;
	var len = 0;
	for (i=0;i<str.length;i++) if (str.charCodeAt(i)>255) len+=2; else len++;
	return len;
}
function checksearch(obj) {
	if (obj.k.value=="" || obj.k.value=="请输入关键字"){
		alert("请输入搜索关键字.");
		obj.k.focus();
		return false;
	}
	if (strlen(obj.k.value)<3){
		alert("关键字不能少于3个字节.");
		obj.k.focus();
		return false;
	}
}
function CheckAll(control)
		   {
		    var CheckBoxList = eval("document.getElementsByName('"+control+"')");
		    for(var i =0; i<CheckBoxList.length;i++)
		    {
		      var e = CheckBoxList[i];
		       e.checked = true;
		    }
		   }
function CheckNo(form)
		   {
		     for (var i=0;i<form.elements.length;i++)
	        {
		     var e = form.elements[i];
		      if (e.name == 'CheckBox1')
		       e.checked=!e.checked;
	          }
		   }
function $(o){return document.getElementById(o);}
function $s(i,a){$(i).style.display=a?'':'none';}
function lnet(a){$(a).innerHTML=$(a+'_code').innerHTML;$(a+'_code').innerHTML="";$(a+'_code').removeNode(true);}
function getreq(url){
		if (window.XMLHttpRequest) { // Non-IE browsers
			req = new XMLHttpRequest();
			try {
				req.open("GET", url, false);
			} catch (e) {
				alert(e);
			}
			req.send(null);
		} else if (window.ActiveXObject) { // IE
			req = new ActiveXObject("Microsoft.XMLHTTP");
			if (req) {
				req.open("GET", url, false);
				req.send(null);
			}
		}
		return req;
}
function hit(){
	document.write("<script src=\"/hits.aspx?id="+id+"\"></script>");
}

function getCookie(name){
	var strCookies = document.cookie;
	var cookieName = name + "=";
	var valueBegin, valueEnd, value;
	valueBegin = strCookies.indexOf(cookieName);
	if (valueBegin == -1) return null;
	valueEnd = strCookies.indexOf(";", valueBegin);
	if (valueEnd == -1)
	valueEnd = strCookies.length;
	value = strCookies.substring(valueBegin+cookieName.length,valueEnd);
	return value;
}
function checkCookieExist(name){ if (getCookie(name))return true;else return false;}
function deleteCookie (name) 
{  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);  
	var cval = getCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function setCookie (name, value) 
{
	var argv = setCookie.arguments;  
	var argc = setCookie.arguments.length;  
	var path = (argc > 2) ? argv[2] : "/";  
	var hours = (argc > 3) ? argv[3] : 24*365;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	deleteCookie (name);
	var expires = new Date((new Date()).getTime() + hours * 60 * 60 * 1000);
	document.cookie = name + "=" + value + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");

}
function oSearch(obj)
{
   var oLocation = location.href.toString();
   var oKeyWords = document.getElementById("k");
   if (oKeyWords.value=="" || oKeyWords.value=="请输入关键字"){
		alert("请输入关键字.");
		oKeyWords.focus();
		return false;
	}
	if (strlen(oKeyWords.value)<3){
		alert("关键字不能少于3个字节.");
		oKeyWords.focus();
		return false;
	}
   if(oKeyWords != null)
   {
     if(oLocation.toLowerCase().indexOf('so.aspx') == -1)
      {
          window.open("/so.aspx?k="+escape(oKeyWords.value));
      }
      else
      {
         location.href = "so.aspx?k="+escape(oKeyWords.value);
      }
   }
   return false;
}

function oSearch1(obj)
{
   var oLocation = location.href.toString();
   var oKeyWords = document.getElementById("pkk");
   if (oKeyWords.value=="" || oKeyWords.value=="请输入关键字"){
		alert("请输入关键字.");
		oKeyWords.focus();
		return false;
	}
	if (strlen(oKeyWords.value)<3){
		alert("关键字不能少于3个字节.");
		oKeyWords.focus();
		return false;
	}
   if(oKeyWords != null)
   {
     if(oLocation.toLowerCase().indexOf('so1.aspx') == -1)
      {
          window.open("/so1.aspx?k="+escape(oKeyWords.value));
      }
      else
      {
         location.href = "so1.aspx?k="+escape(oKeyWords.value);
      }
   }
   return false;
}

function ShowTag(strTargetId){
	var tag = document.getElementById("itags").getElementsByTagName("span");
	for(i=3; i<5; i++){
		if(strTargetId=='tagContent'+i){
				tag[i-3].className = "Selected";
				document.getElementById('tagContent'+i).style.display = "block";
		}else{
				tag[i-3].className = "UnSelected";
				document.getElementById('tagContent'+i).style.display = "none";
		}
	}
}
function ShowTag1(strTargetId){
	var tag = document.getElementById("itags").getElementsByTagName("span");
	for(i=5; i<7; i++){
		if(strTargetId=='tagContent'+i){
				tag[i-5].className = "Selected";
				document.getElementById('tagContent'+i).style.display = "block";
		}else{
				tag[i-5].className = "UnSelected";
				document.getElementById('tagContent'+i).style.display = "none";
		}
	}
}
function ctb(){document.write('<button onclick="copyToClipBoard();" class="copybutton" title="点此复制标题和地址,直接粘贴即可^0^"></button><a id="qzonelink" href="#" onclick="gotoqzone();" target="_blank"><span></span></a>');}
function searchdiv(){
	document.write('<form action=\"\" method=\"get\"><span class=\"font_bold\">站内搜索：</span><input name=\"k\" type=\"text\" class=\"search_text\" /><input type=\"button\" value=\"搜索\"  class=\"search_btn\" onclick=\"oSearch(this);\" /></form>');
}
function searchpicdiv(){
	document.write('<div class=\"jsc\">检索词：<input name=\"pkk\" type=\"text\" /></div><input name=\"\" type=\"image\" src=\"/images/cx.jpg\" onclick=\"oSearch1(this);\"  class=\"cx_btn\"/>');
}
function bbslogindiv()
{
   document.writeln("<form action=\"\/bbs\/login.aspx?agree=yes\" method=\"post\">");
   document.writeln("<div id=\"forum_left\">");
   document.writeln("<div class=\"username\"><span>用&nbsp;户：</span>");
   document.writeln("<input name=\"username\" type=\"text\" />");
   document.writeln("</div>");
   document.writeln("<div class=\"password\"><span>密&nbsp;码：</span>");
   document.writeln("<input name=\"password\" type=\"password\" />");
   document.writeln("</div>");
   document.writeln("</div>");
   document.writeln("<div id=\"forum_right\">");
   document.writeln("<input name=\"\" type=\"submit\" value=\"登录\" />");
   document.writeln("</div>");
   document.writeln("<div class=\"clear\"></div>");
   document.writeln("</form>");
}
//转换字号
function doZoom(size){
	if(size==12){
		$("ccontent").style.fontSize = size + "px";
	}
	if(size==16){
		$("ccontent").style.fontSize = size + "px";
	}
	if(size==24){
		$("ccontent").style.fontSize = size + "px";
	}
}
today=new Date(); 
function initArray(){ 
this.length=initArray.arguments.length 
for(var i=0;i<this.length;i++) 
this[i+1]=initArray.arguments[i] } 
var d=new initArray( 
"星期日", 
"星期一", 
"星期二", 
"星期三", 
"星期四", 
"星期五", 
"星期六"); 

function datediv(){
document.write( 
today.getYear(),"年", 
today.getMonth()+1,"月", 
today.getDate(),"日 ", 
d[today.getDay()+1], 
"</font>" );
document.write('&nbsp;&nbsp;&nbsp;<iframe src=\"http://m.weather.com.cn/m/p2/weather1.htm\" style=\"padding-top:5px;\" allowtransparency=\"true\" width=\"200\" height=\"14\" marginwidth=\"0\" marginheight=\"0\" hspace=\"0\" vspace=\"0\" frameborder=\"0\" scrolling=\"no\"></iframe>');
}

var dlfav=document.location.href.toLowerCase();
if(dlfav.indexOf("fav")>0 || dlfav.indexOf("hnlgb")>0) setCookie('addfav', 'addlgbcookies', '/');
function bookmark(){
	if(document.cookie=="") return;
	if(getCookie("addfav")=="addlgbcookies") return;
	var dr= document.referrer;
	if(dr && !/(hnlgb)/i.test(dr.toLowerCase())){
		if(confirm('收藏河南老干部网')){
			window.external.addFavorite('http://www.hnlgb.com/?fav', '河南老干部网');
		}else{
		
		}
	}
	setCookie('addfav', 'addwingcookies', '/');
}
//window.setTimeout(bookmark,2000);

function killErrors() {return true;} 
window.onerror = killErrors;
document.onmouseover=o;

