// JavaScript Document

function mOvr(src,clrOver){
if (!src.contains(event.fromElement)) {
		//src.style.cursor = 'hand';
		src.bgColor = clrOver;
	}
}

function mOut(src,clrIn)  {
	if (!src.contains(event.toElement)) {
		src.style.cursor = 'default';
		src.bgColor = clrIn;
	}
}

function mClk1(src,id) {
		window.location .href =src;
 }

//search form
function searchkey() {
validity=true;

 if (!check_empty(document.form_search.keyword.value))
{ validity=false;
 alert('请输入要搜索的关键字');
document.form_search.keyword.focus();
 return validity; } 
}

//发表FORM
function validata_form() {
validity=true;
clipboardData.setData('Text',editor.HtmlEdit.document.body.innerHTML);
document.formpub.content.value=editor.HtmlEdit.document.body.innerHTML; 

 if (!check_empty(document.formpub.title.value))
{ validity=false;
 alert('请填上标题吧!');
document.formpub.title.focus();
 return validity; } 
 
 if (!check_empty(document.formpub.content.value))
{ validity=false;
 alert('请填上你要写的内容吧');
document.formpub.content.focus();
 return validity; }

}

//回复FORM
function validata_formrep()
{
validity=true;
clipboardData.setData('Text',editor.HtmlEdit.document.body.innerHTML); //复制
document.formrep.content.value=editor.HtmlEdit.document.body.innerHTML; 

if (!check_empty(document.formrep.username.value))
{ validity=false;
 alert('请填写你的大名!');
document.formrep.username.focus();
 return validity; }

if (!check_empty(document.formrep.content.value))
{ validity=false;
 alert('请填写回复内容!');
document.formrep.content.focus();
 return validity; }
}

//浮动登录
function fdlogin()
{
validity=true;

 if (!check_empty(document.fdform.username.value))
{ validity=false;
 alert('请输入用户名!');
document.fdform.username.focus();
 return validity; }

 if (!check_empty(document.fdform.password.value))
{ validity=false;
 alert('请输入密码!');
document.fdform.password.focus();
 return validity; }
}

function check_email(address)
{
if ((address == "") || (address.indexOf ('@') == -1) || (address.indexOf ('.') == -1))
{
return false;
}
else
{
return true;
}
}


function check_empty(text)
{
return (text.length > 0); // returns false if empty
}

function cfdel(){
 if(!confirm("注意：删除后不能恢复，您确认删除吗? "))
 return false;
}


/*调整图片尺寸*/ 
function ResizePic()
{
	if (document.all("imgList"))
	{
		if (document.all("imgList").length)
		{
			for (var i=0;i<document.all("imgList").length;i++)
			{
			    if (document.all("imgList").item(i).width>500) document.all("imgList").item(i).width=500;		    
			}
		}
		else
		{			
			if (document.all("imgList").width>500) document.all("imgList").width=500;
		}	
	}
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//浮标登录
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


function openwin(url,w,h)
{
  top.window.open(url,"","top=100,left=100,width="+w+",height="+h+",toolbar=0,location=0,directories=0,menubar=0,scrollbars=1,resizable=1,status=0");
  return false;
}

function Favorite(id)
{
openwin('user_function.asp?action=Favorite&indexid='+id,1,1);
}

//复选表单全选事件 form：表单名
function CheckAll(form)  {
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
		if (e.name != 'chkall'&&e.type=="checkbox")
		{
			e.checked = form.chkall.checked;
		}
	}
}

function CheckAllbox(form) {
for (var i=0;i<form.elements.length;i++) {
var e = form.elements[i];
if (e.name != 'chkall') e.checked = form.chkall.checked; 
}
}


//////////////检查是否数字和字母
function isLegal(ch)
{
	if(ch >= '0' && ch <= '9')return true;
	if(ch >= 'a' && ch <= 'z')return true;
	if(ch >= 'A' && ch <= 'Z')return true;
	return false;
}
function isAllLegal(str)
{
	for (i=0; i<str.length; i++) {
		if (!isLegal(str.charAt(i)))//发现非数字和字母
		{
			return false;
		}
	}
	return true;
}
/////////////////if(!isAllLegal(str)){alert("名字含有非法字符（只能含有字母和数字）");return false;}

function chkregname(arr)
{
var reg = /^(\w|[\u4E00-\u9FA5])*$/;
if(arr=username.match(reg))
{
ti=1;
return ture;
}
else
{
alert("用户名只允许为英文，数字和汉字的混合,\n请检查是否前后有空格或者其他符号");
ti=0;
return false;
} 
}