﻿// JavaScript Document

//导航js
navHover = function() { 
var lis = document.getElementById("navmenu").getElementsByTagName("LI"); 
for (var i=0; i<lis.length; i++) { 
lis[i].onmouseover=function() { 
this.className+=" iehover"; 
} 
lis[i].onmouseout=function() { 
this.className=this.className.replace(new RegExp(" iehover\\b"), ""); 
} 
} 
} 
if (window.attachEvent) window.attachEvent("onload", navHover); 

//imgroll

//图片按比例缩放
//调用：<img src="图片" onload="javascript:DrawImage(this,100,100)">
var imgflag=false;
function DrawImage(ImgD,iwidth,iheight){
    //参数(图片,允许的宽度,允许的高度)
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
    imgflag=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;
		ImgD.style.width=image.width; 
		ImgD.style.height=image.height; 
		//ImgD.style.padding=""+(200-image.height)/2+"px "+(300-image.width)/2+"px "+(200-image.height)/2+"px "+(300-image.width)/2+"px"; 
		//ImgD.style.margin-top=(200-image.height)/2; 
        }
        //ImgD.alt=image.width+"×"+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;
		ImgD.style.width=image.width;
		ImgD.style.height=image.height;
		//ImgD.style.padding=""+(200-image.height)/2+"px "+(300-image.width)/2+"px "+(200-image.height)/2+"px "+(300-image.width)/2+"px"; 
		//alert(""+(200-image.height)/2+"px "+(300-image.width)/2+"px "+(200-image.height)/2+"px "+(300-image.width)/2+"px"); 
        }
        //ImgD.alt=image.width+"×"+image.height;
        }
    }
} 

function checkkey(){
	 var keyword=document.getElementById("keyword");
	 if (keyword.value == undefined || keyword.value.replace(/[\s]/g,'') == "" ){
		 alert("请输入关键词！")
		 keyword.focus();
		 return false;
		 }
     return true;
	}
	
function chklogin(){
	var Me_Username=document.getElementById("account")
	var Me_Password=document.getElementById("password")

if (Me_Username.value == undefined || Me_Username.value == "") {
	alert("请输入帐号！");
	Me_Username.focus();
	return false;
}
if (Me_Password.value == undefined || Me_Password.value == "") {
	alert("请输入密码！");
	Me_Password.focus();
	return false;
}

return true;
}

	
function chkreg(){
	var Me_Username=document.getElementById("Me_Username")
	var Me_Password=document.getElementById("Me_Password")
	var email=document.getElementById("Me_Email")	
	var Fjm=document.getElementById("Fjm")	
	var myReg = /^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig;

if (Me_Username.value == undefined || Me_Username.value == "") {
	alert("请输入您的帐号！");
	Me_Username.focus();
	return false;
}
if (Me_Password.value == undefined || Me_Password.value == "") {
	alert("请输入密码！");
	Me_Password.focus();
	return false;
}

if (!myReg.test(email.value) || email.value == undefined || email.value == "") {
	alert("请填写正确的邮箱");
	email.focus();
	return false;
}

if (Fjm.value == undefined || Fjm.value == "") {
	alert("请输入验证码！");
	Fjm.focus();
	return false;
}

return true;
}


function chkfeedback(){
	var userName=document.getElementById("Me_Name")
	var phone=document.getElementById("Me_Tel")
	var email=document.getElementById("Me_You")	
	var subject=document.getElementById("Me_Title")

	var telreg = /^0?1[35]\d{9}|(0{1,2}\d{2,3}-?)?\d{7}\d?(-\d+)?$/;
	var myReg = /^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig;
	
	
if (userName.value == undefined || userName.value == "") {
	alert("Please fill in Your Name!");
	userName.focus();
	return false;
}	
if (!telreg.test(phone.value) || phone.value == undefined || phone.value == "") {
	alert("Please fill in the correct Tel!");
	phone.focus();
	return false;
}

if (!myReg.test(email.value) || email.value == undefined || email.value == "") {
	alert("Please fill in the correct E-mail!");
	email.focus();
	return false;
}	

if (subject.value == undefined || subject.value == "") {
	alert("Please fill in the Subject!");
	subject.focus();
	return false;
}

return true;
}
