function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");

		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_off."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
				}
			}
		}
	}
}

if(window.addEventListener) {
	window.addEventListener("load", smartRollover, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", smartRollover);
}

function sendMailChk(){
	if(confirm("送信しますがよろしいですか？")){
		var bool = true;
		var msg = "";
		var bgcolor = "#FFA07A";
		document.getElementById("email").style.backgroundColor = "";
		document.getElementById("name").style.backgroundColor = "";
		document.getElementById("tel").style.backgroundColor = "";
		document.getElementById("address").style.backgroundColor = "";
		document.getElementById("detail").style.backgroundColor = "";
		
		// メールアドレスチェック
		var email = trim(document.getElementById("email").value);
		if(email == ""){
			bool = false;
			document.getElementById("email").style.backgroundColor = bgcolor;
			msg += "メールアドレスは必須項目です.\n";
		}else if(!isEmail(email)){
			bool = false;
			document.getElementById("email").style.backgroundColor = bgcolor;
			msg += "メールアドレスは形式が不正です.\n";
		}
		
		// 名前チェック
		var name = trim(document.getElementById("name").value);
		if(name == ""){
			bool = false;
			document.getElementById("name").style.backgroundColor = bgcolor;
			msg += "お名前は必須項目です.\n";
		}
		
		// 電話番号チェック
		var tell = trim(document.getElementById("tel").value);
		if(tell == ""){
			bool = false;
			document.getElementById("tel").style.backgroundColor = bgcolor;
			msg += "電話番号は必須項目です.\n";
		}else if(!isTell(tell)){
			bool = false;
			document.getElementById("tel").style.backgroundColor = bgcolor;
			msg += "電話番号の形式が不正です.\n";
		}
		
		// 住所チェック
		var name = trim(document.getElementById("address").value);
		if(name == ""){
			bool = false;
			document.getElementById("address").style.backgroundColor = bgcolor;
			msg += "住所は必須項目です.\n";
		}
		
		
		if(bool){
			//sendMailEx();
			
			return true;
		}else{
			alert(msg);
			
			return false;
		}
	}
}

function isEmail(param){
    if(param.match(/^[A-Za-z0-9\.-]+[\w-]+@[\w\.-]+\.\w{2,}$/)){
        return true;
    }else{
        return false;
    }
}

function isTell(param){
	if(param == "") return true;
	
    if(param.match(/^[0-9]{1,4}-[0-9]{4}$|^[0-9]{2,5}-[0-9]{1,4}-[0-9]{4}$/)){
        return true;
    }else{
        return false;
    }
}

function trim(value){
	return value.replace(/(^\s*)|(\s*$)/g, "");
}


