﻿//＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝图片按比例缩放
var flag=false;
function DrawImage(ImgD,iwidth,iheight){
    //参数(图片,允许的宽度,允许的高度)
    var image=new Image();
    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;
        }
        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.alt=image.width+"×"+image.height;
        }
    }
} 



//＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝留言板表单验证
function chk(obj){	
	if(obj.gname.value.length==0){
			alert("请输入姓名!");
			obj.gname.focus();
			return false;
			}
		
if(obj.gcomp.value.length==0){
		alert("请输入公司名称!");
		obj.gcomp.focus();
		return false;
		}
		
//-------------------------------------------------------电话号码		
var  tel=obj.gtel.value;   	
if(tel.length<=6){
		alert("请输入正确的电话号码!");
		obj.gtel.focus();
		return false;
		}	
if(tel.length>=16){
		alert("请输入正确的电话号码!");
		obj.gtel.focus();
		return false;
		}	
var i,j,strTemp;    
      strTemp="0123456789-()# ";    
      for (i=0;i<tel.length;i++)    
      {    
          j=strTemp.indexOf(tel.charAt(i));    
         if (j==-1)    
         { //说明有字符不合法    
			alert("请输入正确的电话号码!");
			obj.gtel.focus();
			return false;
         }    
      } //说明合法    
     // alert("填写电话号码正确！");

if(obj.gcontent.value.length==0){
		alert("Please content!");
		obj.gcontent.focus();
		return false;
		}	

if(obj.e_mail.value.length!=0){
var  email=obj.e_mail.value;   
var  pattern=/^([a-zA-Z0-9])+@([a-zA-Z0-9])+\.([a-zA-Z0-9])+/;   
if(!pattern.test(email)) {  
		alert("Please e_mail!");   
		return   false;   
		} 
}		
//---------------------------------------------------------		
 }
