// JavaScript Document

//提交留言表单验证
function isMessage(){
	var Email = document.getElementById("EMail").value; 
	var OrderNum = document.getElementById("OrderNum").value; 
	if (Email.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
		{alert('email error');document.getElementById("EMail").focus();return false;}
	if(OrderNum == '')
		{alert('Order Num error');document.getElementById("OrderNum").focus();return false;}
}
//提交订单表单验证
function isOrder(){
	if(document.getElementById("ORFullName").value == '')
		{alert('Name error');document.getElementById("ORFullName").focus();return false;}
	if(document.getElementById("ORTel").value == '')
		{alert('Tel error');document.getElementById("ORTel").focus();return false;}	
	var OREMail = document.getElementById("OREMail").value; 
	if (OREMail == '')
		{alert('email error');document.getElementById("OREMail").focus();return false;}
	if (OREMail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
		{alert('email error');document.getElementById("OREMail").focus();return false;}
	if(document.getElementById("ORState").value == '')
		{alert('State error');document.getElementById("ORState").focus();return false;}
	if(document.getElementById("ORCity").value == '')
		{alert('City error');document.getElementById("ORCity").focus();return false;}
	if(document.getElementById("ORZip").value == '')
		{alert('Zip error');document.getElementById("ORZip").focus();return false;}
	if(document.getElementById("ORAddress").value == '')
		{alert('Address error');document.getElementById("ORAddress").focus();return false;}
}


function DrawImage(ImgD,iwidth,iheight){    
    //参数(图片,允许的宽度,允许的高度)    
    var image=new Image();    
    image.src=ImgD.src;    
    if(image.width>0 && image.height>0){    
      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;    
          }    
      }    
    }    
}  