function ImgAuto(i){//你必须给图片提前设定初始宽度和高度，建议直接就是最大宽度和高度
var MaxW=450; //定义图片显示的最大宽度
var MaxH=1000; //定义图片显示的最大高度
var o=new Image();o.src=i.src;var w=o.width;var h=o.height;var t;if (w>MaxW){t=MaxW;}else
{t=w;}
if ((h*t/w)>MaxH){i.height=MaxH;i.width=MaxH/h*w;}else{i.width=t;i.height=t/w*h;}
}
/*****导航函数*******/
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
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_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function playerWindow(webname,bk,URLStr, left, top, width, height)
{
window.open(URLStr, webname, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+bk+',resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}
/*****用户注册****/
function checkpostform()
{
var fn=document.postform;
/*if(!fn.firstname.value){alert('Please Input Your First Name.');fn.firstname.focus();return false;}
if(!fn.lastname.value){alert('Please Input Your Last Name.');fn.lastname.focus();return false;}
*/
if(!fn.useremail.value){alert('Please Input Your E-Mail Address.');fn.useremail.focus();return false;}
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i ;
var returnval=emailfilter.test(fn.useremail.value);
if (returnval==false){alert('Please Check Your E-Mail Address.');fn.useremail.focus();return false;} 
if(!fn.password.value){alert('Please Input Your Password.');fn.password.focus();return false;}
if(fn.password.value!=fn.password2.value){alert('Please verify your password again');fn.password2.focus();return false;}
/*if(!fn.etcphone.value){
if(!fn.usaphone1.value||!fn.usaphone2.value||!fn.usaphone3.value)
{alert('Please Input Your Phone.');return false;}
}
if(!fn.a_code.value||!fn.phone.value){
alert('Please Input Your telephone.');return false;
}
if(!fn.telephone.value){
if(!fn.usa1.value||!fn.usa2.value||!fn.usa3.value)
{alert('Please Input Your Phone.');return false;}
}
*/
if(fn.question.value=='0'){alert('Please  Select a Question.');return false;}
if(!fn.answer.value){alert('Please Input Your Answer.');fn.answer.focus();return false;}
if(!fn.telephone.value){alert('Please Input Your Phone .');fn.telephone.focus();return false;}
if(!fn.fullname.value){alert('Please Input Your full name.');fn.fullname.focus();return false;}
if(!fn.address1.value){alert('Please Input Your Address.');fn.address1.focus();return false;}
if(!fn.zipcode.value){alert('Please Input Your Post code .');fn.zipcode.focus();return false;}
if(!fn.city.value){alert('Please Input Your City.');fn.city.focus();return false;}
if(!fn.province.value){alert('Please Input Your Province.');fn.province.focus();return false;}
if(fn.country.value=='0'){alert('Please  Select a Country.');return false;}
fn.action='index.php?main_page=reg&action=add';
}
/*****修改用户资料****/
function checkpostform2()
{
var fn=document.postform;
/*if(!fn.firstname.value){alert('Please Input Your First Name.');fn.firstname.focus();return false;}
if(!fn.lastname.value){alert('Please Input Your Last Name.');fn.lastname.focus();return false;}
if(!fn.telephone.value){
if(!fn.usa1.value||!fn.usa2.value||!fn.usa3.value)
{alert('Please Input Your Phone.');return false;}
}
if(!fn.a_code.value||!fn.phone.value){
alert('Please Input Your telephone.');return false;
}
if(!fn.etcphone.value){
if(!fn.usaphone1.value||!fn.usaphone2.value||!fn.usaphone3.value)
{alert('Please Input Your Phone.');return false;}
if(!fn.address1.value){alert('Please Input Your Address.');fn.address1.focus();return false;}
if(!fn.city.value){alert('Please Input Your City.');fn.city.focus();return false;}
if(!fn.province.value){alert('Please Input Your Province.');fn.province.focus();return false;}
}*/fn.action='index.php?main_page=user_information&action=edit';
}
/*****用户登录*****/
function checkLogo(){
if(logoform.email.value==""){
alert('E-mail should not be empty!');
logoform.email.focus();
return false;
}
tChk = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
if(!tChk.exec(document.logoform.email.value)){
alert('E-mail is not legitimate!');
logoform.email.focus();
return false;
}
if(logoform.password.value==""){
alert('Password should not be empty!');
logoform.password.focus();
return false;
}
}
/*****选择下拉列表******/
function CheckSel(Voption,Value)
{
var obj = document.getElementById(Voption);
for (i=0;i<obj.length;i++){
if (obj.options[i].value==Value){
obj.options[i].selected=true;
break;
}
}
}
function checkKey(){
if(document.sou.keyword.value==""){
alert('Can not be empty!');
document.sou.keyword.focus();
return false;
}	
}
function checkKey2(){
if(document.sou2.keyword.value==""){
alert('Can not be empty!');
document.sou2.keyword.focus();
return false;
}	
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
function checkPassword(){
var fn=document.myform;
if(fn.password.value==""){
alert('Please Input Your Password!');	
fn.password.focus();
return false;
}
if(fn.password2.value!=fn.password.value){
alert('Please verify your password again!');
fn.password.focus();
return false;
}
fn.action="index.php?main_page=user_password&action=edit"
}
/*****金币订单*****/
function ckjborder()
{
var fn=document.add;
/*if(fn.buytype[0].checked){
if (!fn.goods.value){alert('Please Input the name of auction goods');fn.goods.focus();return false;}
}*/
if(!fn.fullname.value){alert('Please Input Your Full Name.');fn.fullname.focus();return false;}
//if(!fn.lname.value){alert('Please Input Your Last Name.');fn.lname.focus();return false;}
if(!fn.email.value){alert('Please Input Your E-Mail Address.');fn.email.focus();return false;}
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i ;
var returnval=emailfilter.test(fn.email.value);
if (returnval==false){alert('Please Check Your E-Mail Address.');fn.email.focus();return false;} 
if(!fn.telephone.value){alert('Please Input Your telephone.');return false;}
/*if(!fn.telephone.value){
if(!fn.usa1.value||!fn.usa2.value||!fn.usa3.value)
{alert('Please Input Your Phone.');return false;}
}
*/
if(!fn.country.value){alert('Please Input Your Country.');fn.country.focus();return false;}
if(!fn.charactername.value){alert('Please Input Your character Name.');fn.charactername.focus();return false;}
/*if(!fn.nustel.value){
if(!fn.usaphone1.value||!fn.usaphone2.value||!fn.usaphone3.value)
{alert('Please Input Your Phone.');return false;}
}
*/
if(!fn.chk.checked){alert('Acceptable terms and conditions'); fn.chk.focus();return false;}
fn.action='index.php?main_page=buygold_order&action=add';
}
/****找回密码***/
function check1(){
if(getpwd.email.value==""){
alert('Please Input Your E-mail Address!')
getpwd.email.focus();
return false;
}	
}
function check2(){
if(afrom.answer.value==""){
alert('Answer of Password ID Can not be empty!');
afrom.answer.focus();
return false;
}
}
/****搜索订单****/
function checkOrder(){
var that=document.orderfrm;
if(that.order_id.value==""){
alert('No. of orders can not be empty!');
that.order_id.focus();
return false;
}
if(that.email.value==""){
alert('E-mail can not be empty!');
that.email.focus();
return false;
}
tChk = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
if(!tChk.exec(that.email.value)){
alert('E-mail is not legitimate!');
that.email.focus();
return false;
}
that.action="index.php?main_page=searchOrder&action=search"
}
function ckdlorder()
{
var fn=document.add;
if(!fn.fullname.value){alert('Please Input Your Full Name.');fn.fullname.focus();return false;}
if(!fn.email.value){alert('Please Input Your E-Mail Address.');fn.email.focus();return false;}
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i ;
var returnval=emailfilter.test(fn.email.value);
if (returnval==false){alert('Please Check Your E-Mail Address.');fn.email.focus();return false;} 
/*if(!fn.nustel.value){
if(!fn.usaphone1.value||!fn.usaphone2.value||!fn.usaphone3.value)
{alert('Please Input Your Phone.');return false;}
}
if(!fn.a_code.value||!fn.phone.value){
alert('Please Input Your telephone.');return false;
}*/
if(!fn.telephone.value){
fn.telephone.focus();
alert('Please Input Your Phone.');return false;
}
if(!fn.country.value){alert('Please Input Your Country.');fn.country.focus();return false;}
if(!fn.cname.value){alert('Please Input Your Character Name.');fn.cname.focus();return false;}
if(fn.servername.value==0){alert('Please Select a Server Name.');return false;}
if(!fn.cclass.value){alert('Please Input Your Character Class.');fn.cclass.focus();return false;}
if(!fn.gameaccount.value){alert('Please Input Your Account.');fn.gameaccount.focus();return false;}
if(!fn.gamepwd.value){alert('Please Input Your Password.');fn.gamepwd.focus();return false;}
if(fn.gamepwd.value!=fn.regamepwd.value){alert('Please verify your password again.');fn.gamepwd.focus();return false;}
fn.product_content.value=document.getElementById("p_content").innerHTML;
fn.action='index.php?main_page=powerleveling_order&action=add';
}
