// JavaScript Document

function login_auth(){
	if(document.Login.username.value==""){
	document.getElementById("u_name").innerHTML="<font color=red> * 请输入用户名!</font>";
	return false
	}
	if(document.Login.username.value.length<=4){
	document.getElementById("u_name").innerHTML="<font color=red> * 用户名至少5位!</font>";
	return false
	}
	if(document.Login.password.value==""){
	document.getElementById("u_pwd").innerHTML="<font color=red> * 请输入密码!</font>";
	return false
	}
	if(document.Login.password.value.length<=4){
	document.getElementById("u_pwd").innerHTML="<font color=red> * 密码至少6位!</font>";
	return false
	}
	if(document.Login.Admin_Auth.value=="" | document.Login.Admin_Auth.value.length<4 | !checkrz(document.Login.Admin_Auth.value)){
	document.getElementById("u_rz").innerHTML="<font color=red> * 验证码不正确!</font>";
	return false
	}
	return true
}



function showsubmenu(sid)
{
whichEl = eval("submenu" + sid);
if (whichEl.style.display == "none")
{
eval("submenu" + sid + ".style.display=\"\";");
}
else
{
eval("submenu" + sid + ".style.display=\"none\";");
}
}

function checkrz(rz){  
var re1 = new RegExp("^([0-9])*$");
if (!re1.test(rz)){
     return false;
}
     return true;
}

//图片按比例缩放
var flag=false;

function DrawImage(ImgD,w,h){
var image=new Image();
var iwidth = w; //定义允许图片宽度
var iheight = h; //定义允许图片高度
image.src=ImgD.src;
if(image.width>0 && image.height>0){
	flag=true;
		if(image.width/image.height>= iwidth/iheight){
			if(image.width>iwidth){ 
			ImgD.width=iwidth;
			ImgD.height=(image.height*iwidth)/image.width;
			}else{
			ImgD.width=image.width; 
			ImgD.height=image.height;
			}
		
		}
	else{
		if(image.height>iheight){ 
		ImgD.height=iheight;
		ImgD.width=(image.width*iheight)/image.height; 
		}else{
		ImgD.width=image.width; 
		ImgD.height=image.height;
		}
	}
}
} 


//用户名 数字汉字字母
function checkusername(username){  
var re1 = new RegExp("^([a-zA-Z0-9]|[_])*$");
if (!re1.test(username)){
     return false;
}
     return true;
	 
}

function isnumeric(id){  
var re1 = new RegExp("^([0-9]|[-])*$");
if (!re1.test(id)){
     return false;
}
     return true;
	 
}

function AddFavorite(sTitle, sURL){ 
if(document.all)
{
window.external.AddFavorite(sURL, sTitle); 
}
else
{
window.sidebar.addPanel(sTitle, sURL, "");
}
}

function SetHome(obj,vrl)
    {
        try
        {
                obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
        }
        catch(e){
                if(window.netscape) {
                        try {
                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
                        } 
                        catch (e) { 
                                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); 
                        }
                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                        prefs.setCharPref('browser.startup.homepage',vrl);
                 }
        }
    }
