function checkspace(checkstr2) {
   var str = '';
   for(i = 0; i < checkstr2.length; i++) {
       str = str + ' ';
   }
   return (str == checkstr2);
}
function CheckAll(form) {  
	for (var i=0;i<form.elements.length;i++)  
	{  
		var e = form.elements[i];  
		if (e.name != 'chkall')  
		e.checked = true 
	}  
} 
function ContraSel(form) {
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
		if (e.name != 'chkall')
		e.checked=!e.checked;
	}
}

function checkstr2(str1,str2,j){
	if(j==1){
	    if(checkspace(str1.value)){
	        alert("Sorry，Did you forget your "+ str2 + "？");
		    str1.focus();
		    return true;
	    }
	    else return false;
	}
	if(j==2){
	    if(isNaN(str1.value)){
	        alert("Sorry， "+ str2 + " Must be a number of");
		    str1.focus();
		    return true;
	    }
	    else return false;		
	}
	if(j==3){
	    var pattern = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+/;
	    var r = (str1.value).match(pattern);
	    if(r==null){
	        alert("Sorry, my system does not understand your "+ str2 + " ，Please try again");
		    str1.focus();
		    return true;
	    }
		else 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;
            }
        }
    }
}