﻿function runCode(cod1){cod=document.getElementById(cod1);var code=cod.value;if(code!=""){var newwin=window.open('','','');newwin.opener=null;newwin.document.write(code);newwin.document.close();}}
function copycode(obj){var temp=document.getElementById(obj);if(document.all){var rng=document.body.createTextRange();rng.moveToElementText(temp);rng.scrollIntoView();rng.select();rng.execCommand("Copy");rng.collapse(false);}else
{window.alert("此功能仅在IE上有效");}}
function saveCode(obj){var winname=window.open('','_blank','top=10000');winname.document.open('text/html','replace');winname.document.write(obj.value);winname.document.execCommand('saveas','','code.htm');winname.close();}
function doCopy(obj){var rng=document.body.createTextRange();rng.moveToElementText(obj);rng.scrollIntoView();rng.select();rng.execCommand("Copy");rng.collapse(false);}
function vote(obj1,obj2){var option1=document.getElementById("option1");var option2=document.getElementById("option2");var toupiao4=document.getElementById("toupiao4");var url="/article/vote.asp?id="+obj1+"&option="+obj2+"&"+Math.random();var xmlhttp;try{xmlhttp=new ActiveXObject('Msxm12.XMLHTTP');}catch(e){try{xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');}catch(e){try{xmlhttp=new XMLHttpRequest();}catch(e){}}}
xmlhttp.open("get",url,true);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState<4){toupiao4.style.display="block";}
if(xmlhttp.readyState==4){toupiao4.style.display="none";newwidth=xmlhttp.responseText;if(obj2==1){option1.style.width=xmlhttp.responseText+"px";option2.style.width=100-xmlhttp.responseText+"px";}
else{option2.style.width=xmlhttp.responseText+"px";option1.style.width=100-xmlhttp.responseText+"px";}}}
xmlhttp.send(null);}
function check()
{var book=document.forms["book"];if(book.elements["nname"].value=="")
{alert("名字不为空");return false;}
if(book.elements["nword"].value=="")
{alert("内容不为空");return false;}}
function $(id){return document.getElementById(id);}
function copyIdText(id)
{copy($(id).innerText,$(id));}
function copy(txt,obj)
{if(window.clipboardData)
{window.clipboardData.clearData();window.clipboardData.setData("Text",txt);alert("复制成功！")
if(obj.style.display!='none'){var rng=document.body.createTextRange();rng.moveToElementText(obj);rng.scrollIntoView();rng.select();rng.collapse(false);}}
else{alert("请选中文本，使用 Ctrl+C 复制!");}}
function $code(){for(var i=0;i<arguments.length;i++){$(arguments[i]).style.display=="none"?$(arguments[i]).style.display="":$(arguments[i]).style.display="none";}}