﻿var UserAgent = navigator.userAgent.toLowerCase();
var ie4=document.all&&UserAgent.indexOf("opera")==-1
var ns6=document.getElementById&&!document.all

function CheckLogin(){
	Ajax_CallBack(false,'UserInfoArea','/module/passport/chklogin.asp',false);
}

/*IE下控件虚线框清除*/

function flash(url,width,height,var1) {
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0" width="'+width+'" height="'+height+'">');
    document.write('<param name="movie" value="'+url+'" />');
    document.write('<param name="quality" value="high" />');
    document.write('<param name="flashVars" value="'+var1+'" />');
    document.write('<param name="wmode" value="transparent" />');
    document.write('<param name="menu" value="false" />');
    document.write('<embed flashvars="'+var1+'" src="'+url+'" wmode="transparent" quality="high" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed>');
    document.write('</object>');
}
/*FF下连续长字段自动换行 */
function toBreakWord(intLen){
var obj=document.getElementById("ff");
var strContent=obj.innerHTML;
var strTemp="";
while(strContent.length>intLen){
strTemp+=strContent.substr(0,intLen)+"&#10;";
strContent=strContent.substr(intLen,strContent.length);
}
strTemp+="&#10;"+strContent;
obj.innerHTML=strTemp;
}
if(document.getElementById  &&  !document.all)  toBreakWord(37)

/*通用加入收藏夹代码 <a href="javascript:favorites()">加入收藏</a> */
function favorites(){
var title=document.title
var url=document.location.href
if (window.sidebar) window.sidebar.addPanel(title, url,"");
else if( window.opera && window.print ){
var mbm = document.createElement('a');
mbm.setAttribute('rel','sidebar');
mbm.setAttribute('href',url);
mbm.setAttribute('title',title);
mbm.click();}
else if( document.all ) window.external.AddFavorite( url, title);
}

/*anti_spam 防范垃圾邮件 anti_spam("domain","liam"); */
function anti_spam(domain,in_email) {
  var out_email = "", i;

  for (i = 0; i < in_email.length; i++) {
    out_email += in_email.charAt(in_email.length - i - 1);
  };
  document.write("<a href=\"mailto:" + out_email +"@"+ domain + "\">" + out_email +"@"+ domain + "</a>");
}
function anti_mail(domain,in_email) {
  document.write("<a href=\"mailto:" + in_email +"@"+ domain + "\">" + in_email +"@"+ domain + "</a>");
}

/*Div层隐藏 */
function selecthide(ucode){
	if (ucode=='page')
	{
		document.getElementById("showContent").style.display='none';
	}
	else {
		document.getElementById("showContent").style.display='';
		document.frames.in_iframe.location.reload();
	}
}
/*显示隐藏图层 */
function showLayer(objid)
{
	if(document.getElementById(objid).style.display == "none"){
		document.getElementById(objid).style.display = "block";
    } else {
	    document.getElementById(objid).style.display = "none";
	}
}



function SetCookie(sName, sValue){
	var expdate = new Date();
	expdate.setFullYear(expdate.getFullYear() + 30);
	document.cookie = sName + "=" + escape(sValue) + "; path=/; expires="+expdate.toGMTString()+"";
}

function getCookie(name){
	var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	if(arr != null) return unescape(arr[2]); return null;
}

function orderForm(val,ck){
	var expdate = new Date();
	expdate.setFullYear(expdate.getFullYear() + 30);
	if (getCookie('PID')==null){
		var PID=''
	}else{
		var PID=getCookie('PID');
	}
	var now=new Date();
	if (ck){
		if (PID==''){
			document.cookie = "PID=" + val + "; path=/; expires="+expdate.toGMTString()+"";
		}else{
			document.cookie = "PID=" + PID + "," + val + "; path=/; expires="+expdate.toGMTString()+"";
		}
	}else{
		PIDS=PID.split(",");
		for (i=0;i<PIDS.length;i++){
			if (PIDS[i]==val){
				PIDS.splice(i,1);
				break;
			}
		}
		PID='';
		for(i=0;i<PIDS.length;i++){
			if(i==0){
				PID=PIDS[i];
			}else{
				PID=PID+','+PIDS[i];}
		}
		document.cookie = "PID=" + PID + "; path=/; expires="+expdate.toGMTString()+"";
	}
}
function chkPid(val){
	if (getCookie('PID')==null){
		var PID=''
	}else{
		var PID=getCookie('PID');
	}
	var	PIDS=PID.split(",");
	for(i=0;i<PIDS.length;i++){
		if(PIDS[i]==val){
			return true;
			break;
		}
	}
	return false;
}






var menuOffX=0		//菜单距连接文字最左端距离
var menuOffY=15		//菜单距连接文字顶端距离

function showmenu(e,vmenu,mod){
	if (!vmenu){return false;} //如果空则不显示
	var which=vmenu
	menuobj=document.getElementById("popmenu")
	menuobj.innerHTML=which
	menuobj.contentwidth=menuobj.offsetWidth
	eventX=e.clientX
	eventY=e.clientY
	var rightedge=document.body.clientWidth-eventX
	var bottomedge=document.body.clientHeight-eventY
	var getlength
	if (rightedge<menuobj.contentwidth){
		getlength=ie4? document.body.scrollLeft+eventX-menuobj.contentwidth+menuOffX : ns6? window.pageXOffset+eventX-menuobj.contentwidth : eventX-menuobj.contentwidth
	}else{
		getlength=ie4? ie_x(event.srcElement)+menuOffX : ns6? window.pageXOffset+eventX : eventX
	}
	menuobj.style.left=getlength+'px'
	
	if (bottomedge<menuobj.contentheight&&mod!=0){
		getlength=ie4? document.body.scrollTop+eventY-menuobj.contentheight-event.offsetY+menuOffY-23 : ns6? window.pageYOffset+eventY-menuobj.contentheight-10 : eventY-menuobj.contentheight
	}
	else{
		getlength=ie4? ie_y(event.srcElement)+menuOffY : ns6? window.pageYOffset+eventY+10 : eventY
	}
	menuobj.style.top=getlength+'px'
	
	menuobj.style.visibility="visible"
}

function ie_y(e){  
	var t=e.offsetTop;  
	while(e=e.offsetParent){  
		t+=e.offsetTop;  
	}  
	return t;  
}  
function ie_x(e){  
	var l=e.offsetLeft;  
	while(e=e.offsetParent){  
		l+=e.offsetLeft;  
	}  
	return l;  
} 
function highlightmenu(e,state){
	if (document.all)
		source_el=event.srcElement
	else if (document.getElementById)
		source_el=e.target
	if (source_el.className!="menuskin" && source_el.className!=""){
		source_el.className=(state=="on")? "mouseoverstyle" : "menuitems";
	}
	else{
		while(source_el.id!="popmenu"){
			source_el=document.getElementById? source_el.parentNode : source_el.parentElement
			if (source_el.className!="menuskin" && source_el.className!=""){
				source_el.className = (state=="on")? "mouseoverstyle" : "menuitems"
			}
		}
	}
}

function hidemenu(){if (window.menuobj)menuobj.style.visibility="hidden"}

function contains_ns6(a, b) {
        while (b.parentNode)
                if ((b = b.parentNode) == a)
                        return true;
        return false;
}
function dynamichide(e){
        if (ie4&&!menuobj.contains(e.toElement))
                hidemenu()
        else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
                hidemenu()
}

document.onclick=hidemenu
document.write("<div class=menuskin id=popmenu onmouseover=highlightmenu(event,'on') onmouseout=highlightmenu(event,'off');dynamichide(event)></div>")




//Ajax Start
function Ajax_GetXMLHttpRequest() {
	if (window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} 
	else if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	}
}
function Ajax_CallBack(FormName,ID,URL,IsAlert){
	var x = Ajax_GetXMLHttpRequest();
	var ID = document.getElementById(ID);
	x.open("POST",URL+'?t='+Math.random()+'');
	x.setRequestHeader("REFERER", location.href);
	x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	x.onreadystatechange = function(){if(x.readyState == 4 && x.status == 200){if(IsAlert){x.responseText?alert(x.responseText):alert('添加成功');}else if(ID&&x.responseText){ID.innerHTML=x.responseText;}}}
	var encodedData=""
	if (document.forms.length > 0 && FormName) {
		var form = document.forms[FormName];
		for (var i = 0; i < form.length; ++i) {
			var element = form.elements[i];
			if (element.name) {
				var elementValue = null;
				if (element.nodeName == "INPUT") {
					var inputType = element.getAttribute("TYPE").toUpperCase();
					if (inputType == "TEXT" || inputType == "PASSWORD" || inputType == "HIDDEN") {
						elementValue = escape(element.value);
					} else if (inputType == "CHECKBOX" || inputType == "RADIO") {
						if (element.checked) {
							elementValue = escape(element.value);
						}
					}
				} else if (element.nodeName == "SELECT" || element.nodeName == "TEXTAREA") {
					elementValue = escape(element.value);
				}
				if (elementValue) {
					if(encodedData==""){
						encodedData = element.name + "=" + encodeURIComponent(elementValue);
					}
					else{
						encodedData += "&" + element.name + "=" + encodeURIComponent(elementValue);
					}
				}
			}
		}

	}
	x.send(encodedData);
}

//Ajax End

function isMatch(str1,str2) 
{  
var index = str1.indexOf(str2); 
if(index==-1) return false; 
return true; 
} 

function ResumeError() { 
return true; 
} 
window.onerror = ResumeError; 

function $(id) {
    return document.getElementById(id);
}
// 相对尺寸
function GetOffsetTop (el, p) {
    var _t = el.offsetTop;
    var _p = el.offsetParent;

    while (_p) {
        if (_p == p) break;
        _t += _p.offsetTop;
        _p = _p.offsetParent;
    }

    return _t;
};
function GetOffsetLeft (el, p) {
    var _l = el.offsetLeft;
    var _p = el.offsetParent;

    while (_p) {
        if (_p == p) break;
        _l += _p.offsetLeft;
        _p = _p.offsetParent;
    }

    return _l;
};
function showMenu (baseID, divID) {
    baseID = $(baseID);
    divID  = $(divID);

    //var l = GetOffsetLeft(baseID);
    //var t = GetOffsetTop(baseID);

    //divID.style.left = l + 'px';
//    divID.style.top = t + baseID.offsetHeight + 'px';
    if (showMenu.timer) clearTimeout(showMenu.timer);
	hideCur();
    divID.style.display = 'block';
	showMenu.cur = divID;

    if (! divID.isCreate) {
        divID.isCreate = true;
        //divID.timer = 0;
        divID.onmouseover = function () {
            if (showMenu.timer) clearTimeout(showMenu.timer);
			hideCur();
            divID.style.display = 'block';
        };

        function hide () {
            showMenu.timer = setTimeout(function () {divID.style.display = 'none';}, 1000);
        }

        divID.onmouseout = hide;
        baseID.onmouseout = hide;
    }
	function hideCur () {
		showMenu.cur && (showMenu.cur.style.display = 'none');
	}
}

function doClick_down(o){
	 o.className="current";
	 var j;
	 var id;
	 var e;
	 for(var i=1;i<=4;i++){
	   id ="down"+i;
	   j = document.getElementById(id);
	   e = document.getElementById("d_con"+i);
	   if(id != o.id){
	   	 j.className="";
	   	 e.style.display = "none";
	   }else{
		e.style.display = "block";
	   }
	 }
	 }
	 
function doClick_jy(o){
	 o.className="current";
	 var j;
	 var id;
	 var e;
	 for(var i=1;i<=8;i++){
	   id ="jy"+i;
	   j = document.getElementById(id);
	   e = document.getElementById("jy_con"+i);
	   if(id != o.id){
	   	 j.className="";
	   	 e.style.display = "none";
	   }else{
		e.style.display = "block";
	   }
	 }
	 }


function doZoom(size){
	document.getElementById('textbody').style.fontSize=size+'px'
}

/// 修改及新增
function doClick_menu (o) {
	o.className = 'menu_gg';
	var j, id, e;
	for (var i = 1; i <= 11; i++) {
	    id = 'menu' + i;
	    j = document.getElementById(id);
	    e = document.getElementById('menu_con' + i);
	    if (id != o.id) {
	   	   j.className = '';
	   	   e.style.display = 'none';
	    }
        else {
		    e.style.display = 'block';
	    }
	 }
     var url = '';
     switch (o.innerHTML) {
        case '资讯':
            url = '/plus/search.php?searchtype=titlekeyword&keyword=';
            break;
        case '源码':
            url = 'http://down.chinaz.com/query.asp?q=';
            break;
        case '软件':
            url = 'http://www.chinaz.cn/query.asp?q=';
            break;
        case '论坛':
            url = 'http://bbs.chinaz.com/Search.html?mode=1&searchText=';
            break;
        case '博客':
            url = 'http://my.chinaz.com/list.asp?selecttype=topic&keyword=';
            break;
        case '交易':
            url = 'http://1m.chinaz.com/Search.asp?keyword=';
            break;
        case 'GOOGLE':
            url = 'http://google.chinaz.com/custom?hl=zh-CN&inlang=zh-CN&ie=GB2312&newwindow=1&cof=AWFID%3A0b9847e42caf283e%3BL%3Ahttp%3A%2F%2Fwww.chinaz.com%2FIMAGES%2Flogo.gif%3BLH%3A60%3BLW%3A165%3BBGC%3Awhite%3BT%3A%23000000%3BLC%3A%230000cc%3BVLC%3A%23551A8B%3BALC%3A%23ff3300%3BGALT%3A%23008000%3BGFNT%3A%237777CC%3BGIMP%3A%23FF0000%3BDIV%3A%23000099%3BLBGC%3Awhite%3BAH%3Aleft%3B&domains=chinaz.com&sitesearch=chinaz.com&q=';
            break;
        case 'ALEXA':
            url = 'http://alexa.chinaz.com/index.asp?domain=';
            break;
        case 'IP归属':
            url = 'http://tool.chinaz.com/Ip/Default.aspx?ip=';
            break;
        case 'Whois':
            url = 'http://whois.chinaz.com/';
            break;
		case '素材':
            url = 'http://sc.chinaz.com/Search.aspx?page=1&SearchWord=';
            break;
     }
     doClick_submit.url = url;
}
doClick_submit.url = '/plus/search.php?searchtype=titlekeyword&keyword=';
function doClick_submit () {
    var keyword = document.getElementsByName('keyword')[0].value;
	var nwin = window.open('');
    nwin.location.href = doClick_submit.url + keyword;
}
window.onload = function (){
	var keyword = document.getElementsByName('keyword')[0];
	keyword.onkeydown = function (e) {
		e = e || window.event;
		if (e.keyCode == 13) {
			doClick_submit();
		}
	};
}





document.write('<!--[if lt IE 7]><style type="text/css">*{ behavior: url(images/scripts/iepngfix.htc) }</style><![endif]-->');

