﻿
function $(id){return document.getElementById(id)}
function AddFavorite(){var url=window.location.href;try{window.external.addFavorite(url,'中华漆包线网');}catch(e){try{window.sidebar.addPanel('中华漆包线网',url,"");}catch(e){alert("加入收藏失败，请使用Ctrl+D进行添加");}}}
function setHomepage() { if (document.all) { document.body.style.behavior = 'url(#default#homepage)'; document.body.setHomePage(location.href); } else if (window.sidebar) { if (window.netscape) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } catch (e) { alert("该操作被浏览器拒绝，假如想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true"); } } var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); prefs.setCharPref('browser.startup.homepage', 'http://www.cnqbx.com'); } }
function getsina(){var _w=106,_h=24;var param={url:location.href,type:'5',count:'',appkey:'2165851164',title:document.title,pic:'',ralateUid:'',rnd:new Date().valueOf()}
var temp=[];for(var p in param){temp.push(p+'='+encodeURIComponent(param[p]||''))}
document.write('<iframe allowTransparency="true" frameborder="0" scrolling="no" src="http://hits.sinajs.cn/A1/weiboshare.html?'+temp.join('&')+'" width="'+_w+'" height="'+_h+'"></iframe>');}
function getQQ(){document.write('<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=651767130&site=qq&menu=yes"><img border="0" src="http://wpa.qq.com/pa?p=2:651767130:41" alt="点击这里给我发消息" title="点击这里给我发消息"></a>');}
function getQQWeibo(){document.write(' <a href="javascript:void(0)" onclick="postToWb();return false;" class="tmblog"><img src="http://v.t.qq.com/share/images/s/b24.png" border="0" alt="转播到腾讯微博" ></a>');}
function postToWb(){var _url=encodeURIComponent(document.location);var _assname=encodeURI("");var _appkey=encodeURI("");var _pic=encodeURI('');var _t='';_t=document.title+_t;if(_t.length>120){_t=_t.substr(0,117)+'...';}
_t=encodeURI(_t);var _u='http://share.v.t.qq.com/index.php?c=share&a=index&url='+_url+'&appkey='+_appkey+'&pic='+_pic+'&assname='+_assname+'&title='+_t;window.open(_u,'','width=700, height=680, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no');}
function AjaxSearch(obj,Name)
{var ajax=new list("","<book>"+Name+"</book>","10");ajax.onSuccess=function(){document.getElementById("search_result").innerHTML=xmlHttp.responseText;}
ajax.Init();}
function checkCookieExist() { if (cookie("LoginName") != "" && cookie("LoginName") != null) { document.getElementById("loginName").innerHTML = "您好" + cookie("LoginName") + "，&nbsp;&nbsp;<a href=\"#\" onclick='delCookie(\"LoginName\");delCookie(\"UserID\");delCookie(\"GradeID\");location.reload()'>[退出]</a>&nbsp;&nbsp;" + document.getElementById("loginName").innerHTML; } else { document.getElementById("loginName").innerHTML = "您好，欢迎来到中华漆包线网&nbsp;&nbsp;<a href=\"/login.aspx\" target=\"_blank\">[请登录]</a>&nbsp;&nbsp;<a href=\"/register.aspx\" target=\"_blank\">[免费注册]</a>&nbsp;&nbsp;" + document.getElementById("loginName").innerHTML; } }
function tabit(id,cid){biz_tit1.className="tagsbutton2";biz_tit2.className="tagsbutton2";id.className="tagsbutton lanktitle";biz_1.style.display="none";biz_2.style.display="none";cid.style.display="block";}
function cookie(name){var cookieArray=document.cookie.split("; ");for(var i=0;i<cookieArray.length;i++){var arr=cookieArray[i].split("=");if(arr[0]==name)return unescape(arr[1]);}
return"";}
function delCookie(name)
{var date=new Date();date.setTime(date.getTime()-10000);document.cookie=name+"=a; expires="+date.toGMTString();}
function AjaxDigg(strType,strID){if(getCookie("WebDigg")==strID)
{alert("您已经评论过")
return false;}
var str="<book>";str+="<mode>"+strType+"</mode>";str+="<id>"+strID+"</id>";str+="</book>"
var ajax=new list("",str,"6");ajax.onSuccess=function(){if(strType=="up"){document.getElementById("up").innerHTML="已顶过";addCookie("WebDigg",strID,"1")
document.getElementById("CountUp").innerHTML=++document.getElementById("CountUp").innerHTML;}else{document.getElementById("down").innerHTML="已踩过";addCookie("WebDigg",strID,"1")
document.getElementById("CountDown").innerHTML=++document.getElementById("CountDown").innerHTML;}}
ajax.Init();}
function save(){if(getCookie("wbrefer")==document.getElementById("newsid").value){window.alert("您不是已经提交过了嘛！");document.getElementById("userName").focus();return;}
if(document.getElementById("userName").value==""&&document.getElementById("hasName").checked==false){window.alert("请输入用户名!");document.getElementById("userName").focus();return;}
if(document.getElementById("fcontent").value==""){window.alert("请输入内容!");$("fcontent").focus();return;}
var str="<book>";str+="<typeid>"+document.getElementById("newsid").value+"</typeid>";str+="<name>"+document.getElementById("userName").value+"</name>";str+="<info>"+document.getElementById("fcontent").value+"</info>";str+="</book>";var ajax=new list("",str,"8");ajax.onSuccess=function(){if(xmlHttp.responseText=="ok"){alert("评论成功");addCookie("wbrefer",document.getElementById("newsid").value,"1")}
else{alert("评论");}}
ajax.Init();}
function getCookie(objName){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 addCookie(objName,objValue,objHours){var str=objName+"="+escape(objValue);if(objHours>0){var date=new Date();var ms=objHours*3600*1000;date.setTime(date.getTime()+ms);str+="; expires="+date.toGMTString();}
document.cookie=str;}
function checkclick(){if(document.getElementById("hasName").checked==true){document.getElementById("userName").value="匿名用户"}
else{document.getElementById("userName").value=""}}
function checkSMSMessage(){var content=document.getElementById("fcontent").value;document.getElementById("leaveCount").innerText=120-content.length;if(content.length>=120){document.getElementById("fcontent").value=content.substring(0,120);}}
function setLeaveCount(){window.setTimeout('checkSMSMessage()',100);}
function list(parame,xmldom,ID){if(document.implementation&&document.implementation.createDocument)
{try
{var oParser=new DOMParser();var xmlDoc=oParser.parseFromString(xmldom,"text/xml");}
catch(e)
{alert("error:001");}}
else if(typeof window.ActiveXObject!='undefined')
{xmlDoc=new ActiveXObject('Microsoft.XMLDOM');xmlDoc.async=false;xmlDoc.loadXML(xmldom);}
else
{alert("Browser unknown!");}
var thisTHost=top.location.host;var obj=this;this.Init=function(){xmlHttp=false;if(window.XMLHttpRequest){xmlHttp=new XMLHttpRequest();if(!xmlHttp){alert("创建 XMLHttpRequest 对象失败!");}}
else if(window.ActiveXObject){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e){try{xmlHttp=new ActiveXOBject("Microsoft.XMLHTTP");}
catch(e){}}}
else{window.alert("不能创建　XMLHttpRequest对象，无法应用Ajax");return false;}
var url="http://"+thisTHost+"/Control/Ajax.ashx?"
url+=parame+"&ID="+ID;xmlHttp.open("POST",url,false);xmlHttp.onreadystatechange=function()
{if(xmlHttp.readyState==4){if(xmlHttp.status==200){obj.onSuccess();}}}
xmlHttp.send(xmlDoc);}}
function insert_page(tag,id){var myField;myField=document.getElementById(id);if(document.selection){myField.focus();sel=document.selection.createRange();sel.text=tag;myField.focus();}else if(myField.selectionStart||myField.selectionStart=='0'){var startPos=myField.selectionStart;var endPos=myField.selectionEnd;var cursorPos=endPos;myField.value=myField.value.substring(0,startPos)+tag+myField.value.substring(endPos,myField.value.length);cursorPos+=tag.length;myField.focus();myField.selectionStart=cursorPos;myField.selectionEnd=cursorPos;}else{myField.value+=tag;myField.focus();}}
function DrawImage(ImgD,iwidth,iheight){var flag=false;var image=new Image();image.src=ImgD.src;if(image.width>0&&image.height>0){flag=true;if(image.width/image.height>=iwidth/iheight){if(image.width>iwidth){ImgD.width=iwidth;ImgD.height=(image.height*iwidth)/image.width;}else{ImgD.width=image.width;ImgD.height=image.height}}
else{if(image.height>iheight){ImgD.height=iheight;ImgD.width=(image.width*iheight)/image.height;}else{ImgD.width=image.width;ImgD.height=image.height}}}}
