// JavaScript Document
/* <script language="javascript" type="text/javascript" src="../function/fun_java.js"></script> */


//前往某頁
function gourl() { 
  var checkname=document.form1.cName.value;
  window.location.href('company_cnamecheck.php?checkvalue='+encodeURI(checkname));
  //document.form1.submit();  	
}




function chkpic(pname,fixw,fixh,fsid){
/*
var img=null;
	if(img)img.removeNode(true);
	img=document.createElement("img");
	img.attachEvent("onreadystatechange",op_s);
	img.attachEvent("onerror",op_f);
	img.src=pname.value;
	function op_f(){ alert("Please try again.");	}
	function op_s(){	
		if(img.readyState!="complete"){return false;}
		else if ((img.width != fixw) && (img.height != fixh)){
			alert("Image > 285x180px\nPlease try again!");
			switch(fsid){
				case 1:
				document.getElementById('fs1').outerHTML = document.getElementById('fs1').outerHTML;
				document.getElementById('fs1').focus();
				break;
				
				case 2:
				document.getElementById('fs2').outerHTML = document.getElementById('fs2').outerHTML;
				document.getElementById('fs2').focus();
				break;
				
				case 3:
				document.getElementById('fs3').outerHTML = document.getElementById('fs3').outerHTML;
				document.getElementById('fs3').focus();
				break;
			}
			
		}
		
	}
	*/
}





/*
圖片縮放
//html----------------------------------------------
原大圖片：<br />
<img src="attachments/month_0710/22007101744156.jpg" alt="這是原大" /><br />
縮放後的圖片：<br />
<img src="attachments/month_0710/22007101744156.jpg" alt="自動縮放後的效果" onload="javascript:DrawImage(this,200,200);" />
*/
function DrawImage(ImgD,FitWidth,FitHeight){
	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		if(image.width/image.height>= FitWidth/FitHeight){
			if(image.width>FitWidth){
				ImgD.width=FitWidth;
				ImgD.height=(image.height*FitWidth)/image.width;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
		} else{
			if(image.height>FitHeight){
				ImgD.height=FitHeight;
				ImgD.width=(image.width*FitHeight)/image.height;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
		}
	}
}

