// JavaScript Document
// JavaScript Document

function jtrim(str)
{     while ((str.charAt(0)==" ")||(str.charAt(0)=="　"))
          {str=str.substr(1);}      
     while (str.charAt(str.length-1)==" ")
         {str=str.substr(0,str.length-1);}
     return(str);
}

function chkLength(strTemp)
{
	var i,sum;
	sum=0;
	for(i=0;i<strTemp.length;i++)
	{
		if ((strTemp.charCodeAt(i)>=0) && (strTemp.charCodeAt(i)<=255))
			sum=sum+1;
		else
			sum=sum+2;
	}
	return sum;
}

function $(e)
{
	return document.getElementById(e);
}
function $v(e)
{
	return document.getElementById(e).value;		
}

	

//函数名：fucCheckTel
//功能介绍：检查是否为电话号码
//参数说明：要检查的电话号码

function fucCheckTel(Tel)
{
	var i,j,strTemp;
	strTemp="0123456789-#() ";
	if (Tel.length < 7 )
	{
	 return false;
	 }
	for (i=0;i<Tel.length;i++)
	{
		j=strTemp.indexOf(Tel.charAt(i));	
		if (j==-1)
		{
		//说明不是电话号码
			return false;
		}
	}
	//说明是电话号码
	return true;
}

function email(str)
{
    var email = str;
    if (email.length < 8)
    {
        return false;
    }
    else
    {
        if (email.indexOf(".") <=1 || email.indexOf("@") == -1)
        {
            return false;
        }    
    }
	return true;
}

var flag=false;
function DrawImage(ImgD,x,y){
   var image=new Image();
   image.src=ImgD.src;
   if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= x/y){
     if(image.width>x){  
     ImgD.width=x;
     ImgD.height=(image.height*x)/image.width;
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }
     //ImgD.alt=image.width+"×"+image.height;
     }
    else{
     if(image.height>y){  
     ImgD.height=y;
     ImgD.width=(image.width*y)/image.height;     
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }
     //ImgD.alt=image.width+"×"+image.height;
     }
    }
} 


