// JavaScript Document
//分类打开编辑窗口
function DivOpenClose(Url,OpenClose,width,height){
	var w=width
	var h=height
	var t=(document.body.clientHeight-h)/2;
	var l=(document.body.clientWidth-w)/2;
	var i=Url
	var j=OpenClose
	if(j==1){
		document.getElementById("DivMenu").style.visibility="visible";
		document.getElementById("DivIframe").style.visibility="visible";
		document.getElementById("DivIframe").style.width=w+"px";
		document.getElementById("DivIframe").style.height=h+"px";
		document.getElementById("DivIframe").style.top=t+"px";
		document.getElementById("DivIframe").style.left=l+"px";
		document.getElementById("OpenIframe").src=i;
	}
	if(j==2){
		parent.document.getElementById("DivIframe").style.width=0;
		parent.document.getElementById("DivIframe").style.height=0;
		parent.document.getElementById("DivMenu").style.visibility='hidden';
		parent.document.getElementById("DivIframe").style.visibility='hidden';
		parent.document.getElementById("OpenIframe").src="londing.html";
	}
}
//网站信息表单
function ConFigCheck()
{
    var form = document.ConFigFrom;
	if (form.Site_Name.value == "")
	{
		alert("网站名称不能为空!");
		form.Site_Name.focus();
		return false;
	}
	if (form.Site_Name.value.length > 50)
	{
		alert("网站最多为50个字节!");
		form.Site_Name.focus();
		return false;
	}
	if (form.Site_Url.value == "")
	{
		alert("网站地址不能为空!");
		form.Site_Url.focus();
		return false;
	}
	if (form.Site_Url.value.length > 100)
	{
		alert("网站地址为100个字节!");
		form.Site_Url.focus();
		return false;
	}
	if (form.Site_Memo.value.length>100)
	{
		alert("网站描术最多100字节!");
		form.Site_Memo.focus();
		return false;
	}
	if (form.Site_Db.value == "")
	{
		alert("数据库地址不能为空");
		form.Site_Db.focus();
		return false;
	}
	if (form.Site_Div.value == "")
	{
		alert("网站目录不能为空");
		form.Site_Div.focus();
		return false;
	}
	if (form.Site_AdminDiv.value == "")
	{
		alert("后台目录不能为空");
		form.Site_AdminDiv.focus();
		return false;
	}
	if (form.Site_ClassSkinId.value == "")
	{
		alert("默认样式不能为空");
		form.Site_ClassSkinId.focus();
		return false;
	}
	if(checkerrnum(form.Site_ClassSkinId.value)==1)
    {
        alert("样式请用0-9的数字ID号，不允许怪字符($!@#%^等)！");
        form.Site_ClassSkinId.focus();
        return false;
    }
	return true;
}
//验证主分类表单
function ClassCheck()
{
    var form = document.ClassFrom;
	if (form.Class_Name.value == "")
	{
		alert("分类名称不能为空!");
		form.Class_Name.focus();
		return false;
	}
	if (form.Class_Name.value.length > 20)
	{
		alert("分类名称最多为20个字节!");
		form.Class_Name.focus();
		return false;
	}
	if (form.Class_Memo.value.length>100)
	{
		alert("描术最多100字节!");
		form.Class_Memo.focus();
		return false;
	}
	if (form.Class_Html.value=="")
	{
		alert("后缀名称不能为空!");
		form.Class_Html.focus();
		return false;
	}
    if(checkerr(form.Class_Html.value)==1)
    {
        alert("后缀名称请用0-9的数字和a-z的字母，不允许怪字符($!@#%^等)！");
        form.Class_Html.focus();
        return false;
    }
	if(checkerrnum(form.Class_SkinId.value)==1)
    {
        alert("样式请用0-9的数字ID号，不允许怪字符($!@#%^等)！");
        form.Class_SkinId.focus();
        return false;
    }
	return true;
}
//验证子分类表单
function UrlClassCheck()
{
    var form = document.UrlClassFrom;
	if (form.UrlClass_Name.value == "")
	{
		alert("分类名称不能为空!");
		form.UrlClass_Name.focus();
		return false;
	}
	if (form.UrlClass_Name.value.length > 20)
	{
		alert("子分类名称最多为20个字节!");
		form.Class_Name.focus();
		return false;
	}
	if (form.UrlClass_Memo.value.length>100)
	{
		alert("描术最多100字节!");
		form.UrlClass_Memo.focus();
		return false;
	}
	if (form.UrlClass_Search.value.length>255)
	{
		alert("相关搜索最多255字节!");
		form.UrlClass_Search.focus();
		return false;
	}
	if(checkerrnum(form.UrlClass_SkinId.value)==1)
    {
        alert("样式请用0-9的数字ID号，不允许怪字符($!@#%^等)！");
        form.UrlClass_SkinId.focus();
        return false;
    }
	return true;
}
//验证是不是0-9的数字和a-z的字母
function checkerr(string)
{
   var i=0;
   for (i=0;i<string.length;i++)
   {
       if((string.charAt(i) < '0' || string.charAt(i) > '9') && (string.charAt(i) < 'a' || string.charAt(i) > 'z') && (string.charAt(i) < 'A' || string.charAt(i) > 'Z') && (string.charAt(i) != '_') && (string.charAt(i) != '/'))
	   {
	      return 1;
		}
	}
	return 0;
}
//验证是不是0-9的数字
function checkerrnum(string)
{
   var i=0;
   for (i=0;i<string.length;i++)
   {
       if((string.charAt(i) < '0' || string.charAt(i) > '9'))
	   {
	      return 1;
		}
	}
	return 0;
}
//验证网址表单
function UrlCheck()
{
    var form = document.UrlFrom;
	if (form.Url_Name.value == "")
	{
		alert("网站名称不能为空!");
		form.Url_Name.focus();
		return false;
	}
	if (form.Url_Name.value.length > 50)
	{
		alert("网站名称最多为50个字节!");
		form.Url_Name.focus();
		return false;
	}
	if (form.Url_Url.value.length>200 || form.Url_Url.value.length=="")
	{
		alert("网址长度为1-200字节!");
		form.Url_Url.focus();
		return false;
	}
	if (form.Url_Memo.value.length>100)
	{
		alert("描术最多100字节!");
		form.Url_Memo.focus();
		return false;
	}
	if(checkerrnum(form.Url_TopId.value)==1)
    {
        alert("级别请用0-9的数字，不允许怪字符($!@#%^等)！");
        form.Url_TopId.focus();
        return false;
    }
	if (form.Url_UrlClassId.value == "")
	{
		alert("子分类不能为空!");
		form.Url_UrlClassId.focus();
		return false;
	}
	return true;
}
//验证批量添加表单
function UrlAllCheck(All)
{
    var form = document.UrlFrom;
	j=All
	for(var i=0;i<=j;i++)
	if (form.Url_Name[i].value == "")
	{
		alert("网站名称不能为空!");
		form.Url_Name[i].focus();
		return false;
	}
	if (form.Url_Name[i].value.length > 20)
	{
		alert("网站名称最多为20个字节!");
		form.Url_Name.focus();
		return false;
	}
	if (form.Url_Url[i].value.length>200 || form.Url_Url[i].value.length=="")
	{
		alert("网址长度为1-200字节!");
		form.Url_Url.focus();
		return false;
	}
	return true;
}
//验证跳到表单
function GoCheck()
{
    var form = document.GoFrom;
	if (form.pn.value == "")
	{
		alert("页码不能为空!");
		form.pn.focus();
		return false;
	}
	if (form.pn.value == 10000)
	{
		alert("最多为10000页!");
		form.pn.focus();
		return false;
	}
	if(checkerrnum(form.pn.value)==1)
    {
        alert("请用0-9的数字，不允许怪字符($!@#%^等)！");
        form.pn.focus();
        return false;
    }
	return true;
}
//验证管理员表单
function ManageCheck()
{
    var form = document.ManageFrom;
	if (form.Admin_UserName.value == "")
	{
		alert("用户名不能为空!");
		form.Admin_UserName.focus();
		return false;
	}
	if(checkerr(form.Admin_UserName.value)==1)
    {
        alert("管理员名称请用0-9的数字和a-z的字母，不允许怪字符($!@#%^等)！");
        form.Admin_UserName.focus();
        return false;
    }
	if (form.Admin_UserName.value.length > 20)
	{
		alert("用户名最多为20个字节!");
		form.Admin_UserName.focus();
		return false;
	}
	if (form.Admin_NewUserPass.value == "")
	{
		alert("新密码不能为空!");
		form.Admin_NewUserPass.focus();
		return false;
	}
	if (form.Admin_NewUserPass.value.length > 20)
	{
		alert("密码最多为20个字节!");
		form.Admin_NewUserPass.focus();
		return false;
	}
	if (form.Admin_NewUserPass.value != form.Admin_NewUserPass2.value)
	{
		alert("两次密码输入不一致,请检查!");
		form.Admin_NewUserPass2.focus();
		return false;
	}
	return true;
}
//验证模板分类表单
function SkinClassCheck()
{
    var form = document.SkinClassFrom;
	if (form.SkinClass_Name.value == "")
	{
		alert("分类名称不能为空!");
		form.SkinClass_Name.focus();
		return false;
	}
	if (form.SkinClass_Name.value.length > 20)
	{
		alert("分类名称最多为20个字节!");
		form.SkinClass_Name.focus();
		return false;
	}
	if (form.SkinClass_Memo.value.length > 50)
	{
		alert("描术最多为50个字节!");
		form.SkinClass_Memo.focus();
		return false;
	}
	return true;
}
//验证模板表单
function SkinCheck()
{
    var form = document.SkinFrom;
	if (form.Skin_Name.value == "")
	{
		alert("模板名称不能为空!");
		form.Skin_Name.focus();
		return false;
	}
	if (form.Skin_Name.value.length > 20)
	{
		alert("模板名称最多为20个字节!");
		form.Skin_Name.focus();
		return false;
	}
	if (form.Skin_Memo.value.length > 50)
	{
		alert("描术最多为50个字节!");
		form.Skin_Memo.focus();
		return false;
	}
	if (form.Skin_Html.disabled == false)
	{
		if(form.Skin_Html.value == "")
		{
			alert("后缀名不能为空!");
		    form.Skin_Html.focus();
			return false;
		}
	}
	if (form.Skin_SkinClassId.value < 0)
	{
		alert("模板分类不能为空!");
		form.Skin_SkinClassId.focus();
		return false;
	}
	if (form.Skin_Skin.value == "")
	{
		alert("模板内容不能为空!");
		form.Skin_Skin.focus();
		return false;
	}
	return true;
}
//模板是否生成HTML
function SkinHtmlCheck()
{
	if ( document.getElementsByName("Skin_HtmlYn")[0].checked == true)
	{
		document.getElementsByName("Skin_Html")[0].value = "";
		document.getElementsByName("Skin_Html")[0].disabled= false;
	}
	if ( document.getElementsByName("Skin_HtmlYn")[1].checked == true)
	{
		document.getElementsByName("Skin_Html")[0].value = "";
		document.getElementsByName("Skin_Html")[0].disabled= true;
	}
}
//生成分类HTML窗口
function HtmlOpenClose(AllYn){
	var w="200";
	var h="200";
	var t=(document.body.clientHeight-h)/2;
	var l=(document.body.clientWidth-w)/2;
	var k=AllYn
	if(k==1){
		var i="Admin_HtmLClassSkinGO.asp?Class_Id="+document.getElementById("Class_Id").value;
		document.getElementById("DivMenu").style.visibility="visible";
		document.getElementById("DivIframe").style.visibility="visible";
		document.getElementById("DivIframe").style.width=w+"px";
		document.getElementById("DivIframe").style.height=h+"px";
		document.getElementById("DivIframe").style.top=t+"px";
		document.getElementById("DivIframe").style.left=l+"px";
		document.getElementById("OpenIframe").src=i;
	}
	if(k==0){
		document.getElementById("DivMenu").style.visibility="visible";
		document.getElementById("DivIframe").style.visibility="visible";
		document.getElementById("DivIframe").style.width=w+"px";
		document.getElementById("DivIframe").style.height=h+"px";
		document.getElementById("DivIframe").style.top=t+"px";
		document.getElementById("DivIframe").style.left=l+"px";
		document.getElementById("OpenIframe").src="Admin_HtmLClassSkinGO.asp";
	}
}
