//检查论坛登录函数
function checklogin(form){
    if(JTrim(form.UserName.value).length<=0){
	    alert("请输入论坛登录名！");
		form.UserName.focus();
		return false;
	}
    if(JTrim(form.Passer.value).length<=0){
	    alert("请输入您的私人密码！");
		form.Passer.focus();
		return false;
	}
}

//检查搜索表单函数
function checksearch(form){
    if(JTrim(form.keyword.value.length) <= 0){
	    alert("请输入搜索关键字！");
		form.keyword.focus();
		return false;
	}
}

//检测投票函数
function dc(form){
    var i;
    var count = 0;
	for(i=0;i<form.elements.length;i++){
	    if(form.elements[i].type=="radio"&&form.elements[i].checked){
		    count++;
		}
	}
	
	if(count==0){
	    alert("至少要选择一个投票对象！");
		return false;
	}
}

//检测留言信息
function checkgb(form){
   if(JTrim(form.content.value).length<=0){
      alert("请输入留言内容！");
	  form.content.focus();
	  return false;
   }else if(JTrim(form.content.value).length<=25||JTrim(form.content.value).length>150){
      alert("留言内容不能少于25个字或多于150个字符（不包含空格！）");
      form.content.focus();
      return false;
   }
   
   if(JTrim(form.oicq.value).length>0){
      if(!isNumber(JTrim(form.oicq.value))){
	     alert("OICQ应输入数字，你若没空的话？可不填的！~o~");
		 return false;
	  }
   }
   
   if(JTrim(form.email.value).length>0){
      if(!isemail(form.email.value)){
	     return false;
	  }
   }
}

//验证管理员登录
function chkadmin(form){
   if(JTrim(form.adminid.value).length<=0){
      alert("请输入登录名！\n\n警告！非管理员切勿尝试登录本页……");
	  form.adminid.focus();
	  return false;
   }
   if(JTrim(form.adminpwd.value).length<=0){
      alert("请输入登录密码！\n\n警告！非管理员切勿尝试登录本页……");
	  form.adminpwd.focus();
	  return false;
   }
}

//投票系统函数
function dc(f){
   var dcvalue;
   var j = 0;
   for(var i=0;i<f.elements.length;i++){
   var e = f.elements[i]
   if(e.name == "voteid"&&e.checked){
   j++;
   dcvalue = e.value;
   window.open("vote.asp?id="+dcvalue,"lvote","width=400,height=240,status=yes,scrollbars=no,menubar=no");
   e.checked = false;
   return false;
   }
   }
}

//验证E-MAIL格式函数
function isemail(s)
{
                
                if(s.length > 100)
                {
                                window.alert("email地址长度不能超过100位!");
                                return false;
                }

                  var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT)$"
                  var re = new RegExp(regu);
                  if(s.search(re) != -1){
                              return true;
                  }else{
                              window.alert("请输入有效合法的E-mail地址！");
                              return false;
                  }
}

//判断值是否为数字的函数
function isNumber(s)
                {
                                var digits = "0123456789";
                                var i = 0;
                                var sLength = s.length;

                                while ((i <  sLength))
                                {
                                                var c = s.charAt(i);
                                                if(digits.indexOf(c) == -1) return false;
                                                i++;
                                }

                                return  true;
                }


//去空格函数
function  JTrim(str)
{

                var i = 0;
                var len = str.length;
                if(str == ""){
				   return(str);
				}
                j = len - 1;
                flagbegin = true;
                flagend = true;
                while(flagbegin == true&&i < len)
                {
                      if(str.charAt(i) == " ")
                                {
                                    i=i+1;
                                    flagbegin=true;
                                }
                                else
                                {
                                                flagbegin=false;
                                }
                }

                while(flagend == true&&j >= 0)
                {
                        if(str.charAt(j)==" ")
                                {
                                                j=j-1;
                                                flagend=true;
                                }
                                else
                                {
                                                flagend=false;
                                }
                }

                if(i > j){
				   return("")
				}

                trimstr = str.substring(i,j+1);
                return trimstr;
}

//鼠标提示文本
tPopWait=50;//停留tWait豪秒后显示提示。
tPopShow=15000;//显示tShow豪秒后关闭提示
showPopStep=20;
popOpacity=99;

//***************内部变量定义*****************
sPop=null;
curShow=null;
tFadeOut=null;
tFadeIn=null;
tFadeWaiting=null;

document.write("<style type='text/css'id='defaultPopStyle'>");
document.write(".cPopText {  background-color: #F2F2F2; color:#000000; border: solid 1px #666666; font-color: font-size: 12px; padding: 2px 6px 1px 6px; filter: Alpha(Opacity=0)}");
document.write("</style>");
document.write("<div id='dypopLayer' style='font-family: 宋体; line-height: 16px; font-size: 12px; position:absolute;z-index:1000;' class='cPopText'></div>");


function showPopupText(){
var o=event.srcElement;
	MouseX=event.x;
	MouseY=event.y;
	if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
        if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
	if(o.dypop!=sPop) {
			sPop=o.dypop;
			clearTimeout(curShow);
			clearTimeout(tFadeOut);
			clearTimeout(tFadeIn);
			clearTimeout(tFadeWaiting);	
			if(sPop==null || sPop=="") {
				dypopLayer.innerHTML="";
				dypopLayer.style.filter="Alpha()";
				dypopLayer.filters.Alpha.opacity=0;	
				}
			else {
				if(o.dyclass!=null) popStyle=o.dyclass 
					else popStyle="cPopText";
				curShow=setTimeout("showIt()",tPopWait);
			}
			
	}
}

function showIt(){
		dypopLayer.className=popStyle;
		dypopLayer.innerHTML=sPop;
		popWidth=dypopLayer.clientWidth;
		popHeight=dypopLayer.clientHeight;
		if(MouseX+12+popWidth>document.body.clientWidth) popLeftAdjust=-popWidth-24
			else popLeftAdjust=0;
		if(MouseY+12+popHeight>document.body.clientHeight) popTopAdjust=-popHeight-24
			else popTopAdjust=0;
		dypopLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust;
		dypopLayer.style.top=MouseY+12+document.body.scrollTop+popTopAdjust;
		dypopLayer.style.filter="Alpha(Opacity=0)";
		fadeOut();
}

function fadeOut(){
	if(dypopLayer.filters.Alpha.opacity<popOpacity) {
		dypopLayer.filters.Alpha.opacity+=showPopStep;
		tFadeOut=setTimeout("fadeOut()",1);
		}
		else {
			dypopLayer.filters.Alpha.opacity=popOpacity;
			tFadeWaiting=setTimeout("fadeIn()",tPopShow);
			}
}

function fadeIn(){
	if(dypopLayer.filters.Alpha.opacity>0) {
		dypopLayer.filters.Alpha.opacity-=1;
		tFadeIn=setTimeout("fadeIn()",1);
		}
}
document.onmouseover=showPopupText;

//下拉菜单代码
 var h;
 var w;
 var l;
 var t;
 var topMar = 1;
 var leftMar = -2;
 var space = 1;
 var isvisible;
 var MENU_SHADOW_COLOR='#FFFFFF';//定义下拉菜单阴影色
 var global = window.document
 global.fo_currentMenu = null
 global.fo_shadows = new Array

function HideMenu() 
{
 var mX;
 var mY;
 var vDiv;
 var mDiv;
	if (isvisible == true)
{
		vDiv = document.all("menuDiv");
		mX = window.event.clientX + document.body.scrollLeft;
		mY = window.event.clientY + document.body.scrollTop;
		if ((mX < parseInt(vDiv.style.left)) || (mX > parseInt(vDiv.style.left)+vDiv.offsetWidth) || (mY < parseInt(vDiv.style.top)-h) || (mY > parseInt(vDiv.style.top)+vDiv.offsetHeight)){
			vDiv.style.visibility = "hidden";
			isvisible = false;
		}
}
}

function ShowMenu(vCode) {
	vSrc = window.event.srcElement;
	vMnuCode = vCode;

	h = vSrc.offsetHeight;
	w = vSrc.offsetWidth;
	l = vSrc.offsetLeft + leftMar+4;
	t = vSrc.offsetTop + topMar + h + space-2;
	vParent = vSrc.offsetParent;
	while (vParent.tagName.toUpperCase() != "BODY")
	{
		l += vParent.offsetLeft;
		t += vParent.offsetTop;
		vParent = vParent.offsetParent;
	}

	menuDiv.innerHTML = vMnuCode;
	menuDiv.style.top = t;
	menuDiv.style.left = l;
	menuDiv.style.visibility = "visible";
	isvisible = true;
    //makeRectangularDropShadow(submenu, MENU_SHADOW_COLOR, 4)
}

function makeRectangularDropShadow(el, color, size)
{
	var i;
	for (i=size; i>0; i--)
	{
		var rect = document.createElement('div');
		var rs = rect.style
		rs.position = 'absolute';
		rs.left = (el.style.posLeft + i) + 'px';
		rs.top = (el.style.posTop + i) + 'px';
		rs.width = el.offsetWidth + 'px';
		rs.height = el.offsetHeight + 'px';
		rs.zIndex = el.style.zIndex - i;
		rs.backgroundColor = color;
		var opacity = 1 - i / (i + 1);
		rs.filter = 'alpha(opacity=' + (100 * opacity) + ')';
		el.insertAdjacentElement('afterEnd', rect);
		global.fo_shadows[global.fo_shadows.length] = rect;
	}
}