function ResumeError() { 
return true; 
} 
window.onerror = ResumeError; 

function $(id) {
    return document.getElementById(id);
}

function menuFix() {
 var sfEls = document.getElementById("nav").getElementsByTagName("li");
 for (var i=0; i<sfEls.length; i++) {
  sfEls[i].onmouseover=function() {
  this.className+=(this.className.length>0? " ": "") + "sfhover";
  }
  sfEls[i].onMouseDown=function() {
  this.className+=(this.className.length>0? " ": "") + "sfhover";
  }
  sfEls[i].onMouseUp=function() {
  this.className+=(this.className.length>0? " ": "") + "sfhover";
  }
  sfEls[i].onmouseout=function() {
  this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), 

"");
  }
 }
}
//window.onload=menuFix;


function changeimg(imgID,imgSrc)
{
	document.getElementById(imgID).src=""+imgSrc+"";
}

function checkMessage()
{
	if($("username").value=="")
	{
		alert('聯絡人不能為空！');
		$("username").focus();
		return false
	}
	if($("email").value=="")
	{
		alert("E-mail不能為空！");
		$("email").focus();
		return false;
	}else{
		var email=$("email").value;
		if(!/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(email)){ 
			alert("E-Mail格式不對,請重新輸入"); 
			$("email").focus(); 
			return false; 
		}
	}
 
	if($("tel").value=="")
	{
		alert('聯絡電話不能為空！');
		$("tel").focus();
		return false
	}
	if($("content").value=="")
	{
		alert('留言內容不能為空！');
		$("content").focus();
		return false
	}
	if($("code").value=="")
	{
		alert('驗證碼不能為空！');
		$("code").focus();
		return false
	}
	return true;
}


function DrawImage(ImgD,widths,heights){ 
	var image=new Image(); 
	image.src=ImgD.src; 
	if(image.width>0 && image.height>0){ 
		flag=true; 
		if(image.width/image.height>= widths/heights){ 
			if(image.width>widths){ 
				ImgD.width=widths; 
				ImgD.height=(image.height*widths)/image.width; 
			}else{ 
				ImgD.width=image.width; 
				ImgD.height=image.height; 
			} 
			//ImgD.alt=image.width+"x"+image.height; 
		} 
		else{ 
			if(image.height>heights){ 
				ImgD.height=heights; 
				ImgD.width=(image.width*heights)/image.height; 
			}else{ 
				ImgD.width=image.width; 
				ImgD.height=image.height; 
			} 
			//ImgD.alt=image.width+"x"+image.height; 
		} 
	} 
} 

