//清除网页错误
window.onerror = killErrors;
function killErrors(){
return true;
}

//搜索引擎
var frmact = new Array();
frmact[1]="http://www.baidu.com/baidu";
frmact[2]="http://news.baidu.com/ns"
frmact[3]="http://post.baidu.com/f";
frmact[4]="http://mp3.baidu.com/m";
frmact[6]="http://image.baidu.com/i";
var frmtn = new Array();
frmtn[1]="88311515_pg";
frmtn[2]="news";
frmtn[3]="baiduPostSearch";
frmtn[4]="baidump3";
frmtn[6]="baiduimage";
var frmct = new Array();
frmct[1] = "";
frmct[2] = "";
frmct[3] = "352321536";
frmct[4] = "134217728";
frmct[6] = "201326592";
var frmlm = new Array();
frmlm[1] = "";
frmlm[2] = "";
frmlm[3] = "65536";
frmlm[4] = "-1";
frmlm[6] = "-1";
var frmz = new Array();
frmz[1] = "";
frmz[2] = "";
frmz[3] = "";
frmz[4] = "";
frmz[6] = "0";
var frmrn = new Array();
frmrn[1] = "";
frmrn[2] = "";
frmrn[3] = "10";
frmrn[4] = "";
frmrn[6] = "";
var bd_idx="1";

function bd_chg_idx(idx){
bd_idx=idx;
}

function gowhere(formname){
var url;
var idx = bd_idx;
if (frmact[idx] == null || frmact[idx] == "") idx = "1";
url = frmact[idx];
if (frmtn[idx] != "") document.search_form.tn.value = frmtn[idx];
if (frmct[idx] != "") document.search_form.ct.value = frmct[idx];
if (frmlm[idx] != "") document.search_form.lm.value = frmlm[idx];
if (frmz[idx] != "") document.search_form.z.value = frmz[idx];
if (frmrn[idx] != "") document.search_form.rn.value = frmrn[idx];
formname.method = "get";
formname.action = url;
return true;
}

//I Don't Know
newDate=new Date()
newDate=""+newDate.getYear()+"-"+[newDate.getMonth()+1]+"-"+newDate.getDate()+""

//清除网页错误
window.onerror = killErrors;
function killErrors(){
return true;
}
//读取COOKIE
function getCookie(CookieName) { 
return SkinsDir;
return value;
}

function GetCookieData() {
return SkinsDir;
}

function ShowCookie(name) {
var mycookie = document.cookie;
var start1 = mycookie.indexOf(name + "=");
if (start1 != -1){
start=mycookie.indexOf("=",start1)+1;
var end = mycookie.indexOf(";",start);
if (end == -1){end=mycookie.length;}
value=unescape(mycookie.substring(start,end));
if (value != null){document.write(value);}
}
}


//签名档显示
function ShowSign(id,heig,sign){
if(heig>120){
document.write("<div style='OVERFLOW:hidden' id=div"+id+">"+sign+"</div>");
}else{
document.write("<div style='OVERFLOW-X:hidden;OVERFLOW-Y:auto' id=div"+id+">"+sign+"</div>");
}
}
function CtrlSign(id,heig){
if(eval("div"+id+".scrollHeight")>heig){eval("div"+id+".style.height=heig");}
}

//农历显示
function ShowLC(sysyear,sysmonth,sysday){
var LunarDaysOfMonth=new Array(0xd4a8,0xd4a0,0xda50,0x5aa8,0x56a0,0xaad8,0x25d0,0x92d0,0xc958,0xa950);
var LunarLeapYear=new Array(0x40,0x02,0x07,0x00,0x50);
var str=GetLunarDateString(new Date(sysyear,sysmonth-1,sysday));
document.write("<font color=AA9900>农历"+str+"</font>");

function GetLeapMonth(iLunarYear){
var Leap=LunarLeapYear[(iLunarYear-2001)>>1];
return (((iLunarYear-2001)&1)==0)?(Leap>>4):(Leap&0x0f);} 
function LunarMonthDays(iLunarYear,iLunarMonth){ 
var High=0;
var Low=29;
var Bit=16-iLunarMonth;
if ((iLunarMonth>GetLeapMonth(iLunarYear))&&(GetLeapMonth(iLunarYear)>0)) Bit--;
if ((LunarDaysOfMonth[iLunarYear-2001]&(1<<Bit))>0) Low++;
if (iLunarMonth==GetLeapMonth(iLunarYear)){
High=((LunarDaysOfMonth[iLunarYear-2001]&(1<<(Bit-1)))>0)?30:29;}
return Low+(High<<16);
}
function LunarYearDays(iLunarYear){ 
var tmp;
var Days=0;
for (var i=1;i<=12;i++){
tmp=LunarMonthDays(iLunarYear,i);
Days=Days+((tmp>>16) & 0xffff);
Days=Days+(tmp & 0xffff);}
return Days;
}
function FormatLunarMonth(iLunarMonth){ 
var szText=new String("正二三四五六七八九十");
var strMonth;
if (iLunarMonth<=10)
{strMonth=szText.substr(iLunarMonth-1,1);}
else if (iLunarMonth==11) strMonth="十一";
else strMonth="腊";
return strMonth+"月";} 
function FormatLunarDay(iLunarDay){ 
var szText1=new String("初十廿三");
var szText2=new String("一二三四五六七八九十");
var strDay;
if ((iLunarDay!=20)&&(iLunarDay !=30))
{strDay=szText1.substr((iLunarDay-1)/10,1)+szText2.substr((iLunarDay-1)%10,1);}
else if (iLunarDay!=20)
{strDay=szText1.substr(iLunarDay/10,1)+"十";}
else
{strDay="二十";}
return strDay;
}
function GetLunarDateString(SolarDate){
var tmp;
var iLunarYear;
var iLunarMonth;
var iLunarDay;
var Leap=false;
var iSpanDays=Math.round(SolarDate.getTime()/86400000)-11323;
{iSpanDays=iSpanDays-23;
iLunarYear=2001;
iLunarMonth=1;
iLunarDay=1;
tmp=LunarYearDays(iLunarYear);
while(iSpanDays>=tmp){
iSpanDays-=tmp;
iLunarYear++;
tmp=LunarYearDays(iLunarYear);}
tmp=LunarMonthDays(iLunarYear,iLunarMonth)&0xffff;
while(iSpanDays>=tmp){
iSpanDays-=tmp;
if (iLunarMonth==GetLeapMonth(iLunarYear)){
tmp=LunarMonthDays(iLunarYear,iLunarMonth)>>16;
if (iSpanDays<tmp)
{Leap=(tmp>0)?true:false;
break;}
iSpanDays=iSpanDays-tmp;}
iLunarMonth++;
tmp=LunarMonthDays(iLunarYear,iLunarMonth)&0xffff;}
iLunarDay+=iSpanDays;}
return (Leap?"闰":"")+FormatLunarMonth(iLunarMonth)+FormatLunarDay(iLunarDay);
}
}

//跳转页面显示
function ShowPage(TotalPage,PageIndex,url){
document.write("<table cellspacing=1 class=a2><tr class=a3><td class=a1><b>"+PageIndex+"/"+TotalPage+"</b></td>");
if (PageIndex<6){PageLong=11-PageIndex;}
else
if (TotalPage-PageIndex<6){PageLong=10-(TotalPage-PageIndex)}
else{PageLong=5;}
for (var i=1; i <= TotalPage; i++) {
if (i < PageIndex+PageLong && i > PageIndex-PageLong || i==1 || i==TotalPage){
if (PageIndex==i){document.write("<td>&nbsp;<font color=red>"+ i +"</font>&nbsp;</td>");}else{document.write("<td><a href=?PageIndex="+i+"&"+url+">&nbsp;"+ i +"&nbsp;</a></td>");}
}
}
document.write("<td class=a4><input onkeydown=if((event.keyCode==13)&&(this.value!=''))window.location='?PageIndex='+this.value+'&"+url+"'; onkeyup=if(isNaN(this.value))this.value='' style='border:1px solid #698cc3;' size=2></td></tr></table>");
}

//全选复选框
function CheckAll(form){for (var i=0;i<form.elements.length;i++){var e = form.elements[i];if (e.name != 'chkall')e.checked = form.chkall.checked;}}

//全选主题ID复选框
function ThreadIDCheckAll(form){
for (var i=0;i<form.elements.length;i++){
var e = form.elements[i];
if (e.name == 'ThreadID')e.checked = form.chkall.checked;
}
}

//菜单
var menuOffX=0	//菜单距连接文字最左端距离
var menuOffY=15	//菜单距连接文字顶端距离

var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1
var ns6=document.getElementById&&!document.all
function showmenu(e,vmenu,mod){
	which=vmenu
	menuobj=document.getElementById("popmenu")
	menuobj.thestyle=menuobj.style
	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

		if (rightedge<menuobj.contentwidth)
			menuobj.thestyle.left=document.body.scrollLeft+eventX-menuobj.contentwidth+menuOffX
		else
			menuobj.thestyle.left=ie4? ie_x(event.srcElement)+menuOffX : ns6? window.pageXOffset+eventX : eventX
		
		if (bottomedge<menuobj.contentheight&&mod!=0)
			menuobj.thestyle.top=document.body.scrollTop+eventY-menuobj.contentheight-event.offsetY+menuOffY-23
		else
			menuobj.thestyle.top=ie4? ie_y(event.srcElement)+menuOffY : ns6? window.pageYOffset+eventY+10 : eventY

	menuobj.thestyle.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
		while(source_el.id!="popmenu"){
			source_el=document.getElementById? source_el.parentNode : source_el.parentElement
			if (source_el.className=="menuitems"){
				source_el.id=(state=="on")? "mouseoverstyle" : ""
		}
	}
}


function hidemenu(){if (window.menuobj)menuobj.thestyle.visibility="hidden"}
function dynamichide(e){if ((ie4||ns6)&&!menuobj.contains(e.toElement))hidemenu()}
document.onclick=hidemenu
document.write("<div class=menuskin id=popmenu onmouseover=highlightmenu(event,'on') onmouseout=highlightmenu(event,'off');dynamichide(event)></div>")


function copyProcess(Action){	
	if(navigator.userAgent.indexOf('MSIE 7.0')!=-1){
		return true;
	}
	window.event.returnValue=false;
	if(Action=='copy'){
		Data = document.selection.createRange().duplicate().text;
		Data += "\n\n(来源:给力英语网 | "+location.href+" | WWW.171ENGLISH.CN)";
		window.clipboardData.setData('Text',Data);
		//alert(Data);
	}
	else if(Action=='beforepaste'){
		Data = window.clipboardData.getData('Text');
		Data = Data.replace(/\n\nPasteFrom \|.+?\| CatArchives/gm,'');
		window.clipboardData.setData('Text',Data);
		//alert(Data);
	}
}

// 菜单END

// add area script
function focusEdit(editBox)
{
 if ( editBox.value == editBox.Helptext )
 {
 editBox.value = '';
 editBox.className = 'editbox';
 }
 return true;
}
function blurEdit(editBox)
{
 if ( editBox.value.length == 0 )
 {
 editBox.className = 'editbox Graytitle';
 editBox.value = editBox.Helptext;
 }
}
function ValidateTextboxAdd(box, button)
{
 var buttonCtrl = document.getElementById( button );
 if ( buttonCtrl != null )
 {
 if (box.value == "" || box.value == box.Helptext)
 {
 buttonCtrl.disabled = true;
 }
 else
 {
 buttonCtrl.disabled = false;
 }
 }
}
// add area script end


function loadtree(ino){
document.frames["hiddenframe"].location.replace("ForumTree.asp?id="+ino+"")
}


function loadThreadFollow(ino,Online){
var targetImg =document.getElementById("followImg" + ino);
var targetDiv =document.getElementById("follow" + ino);
if (targetDiv.style.display!='block'){
if(targetImg.loaded=="no"){document.frames["hiddenframe"].location.replace("loading.asp?id="+ino+"&ForumID="+Online+"");}
targetDiv.style.display="block";
targetImg.src="images/minus.gif";
}else{
targetDiv.style.display="none";
targetImg.src="images/plus.gif";
}
}


function ToggleMenuOnOff (menuName) {
    var menu = document.getElementById(menuName);

    if (menu.style.display == 'none') {
      menu.style.display = 'block';
    } else {
      menu.style.display = 'none';
    }
}

//自定义类别
function ChangeCategory()
{
	CategoryName=prompt("请输入类别名称(最多20个字符):","");
	if(!CategoryName) return;
	if(CategoryName.length > 20){alert("类别名称不能大于20个字符！");return false;}
	this.focus();
	i=document.form.Category.length;
	document.form.Category.options[i]=new Option(CategoryName,CategoryName);
	document.form.Category.options[i].selected=true;
}
