//window open
function showDetail(loc,brand,id){
	//var rootURL = " ";
	var rootURL = "";
	var link=rootURL+loc+"?brandid="+brand+"&id="+id;
	var wndw="cart";
	var myWindow=window.open(link,wndw,'resizable=no,scrollbars=yes,status=yes,location=no,menubar=no,toolbar=no,width=700,height=450');
	if(myWindow.focus!=null){myWindow.focus();}
 }
 
 function mapDetail(loc){
	var link=loc;
	var wndw="map";
	var myWindow=window.open(link,wndw,'resizable=no,scrollbars=yes,status=yes,location=no,menubar=no,toolbar=yes,width=700,height=450');
	if(myWindow.focus!=null){myWindow.focus();}
 }
 
 //元のウインドウのリンク
 function winOpener(url){
 	window.opener.location.href = url; 
 }

//ロールオーバー
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//ジャンプメニュー
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
/*
//テーブル背景色変更
function cellOver(obj){
  document.getElementById(obj).style.backgroundColor="#FBFBFB"
}

function cellOut(obj){
  document.getElementById(obj).style.backgroundColor="#EFEFEF"
}
*/

//商品削除確認
function checkDelete(){
	flag = confirm("この商品を本当に削除してもよろしいですか？");
if (flag) return true; 
else return false;
}

//お届け先等の入力チェック
function checkInput(){
	if(document.form1.customerName.value==""){
		window.alert("お名前を入力してください。");
		document.form1.customerName.focus();
		return false;
//	}else if(document.form1.customerNameKana.value==""){
//		window.alert("ふりがなを入力してください。");
//		document.form1.customerNameKana.focus();
//		return false;
	}else if(document.form1.deliverTime.value=="配達希望時間を選択してください" || document.form1.deliverTime.value==""){
		window.alert("配達希望時間を選択してください。");
		document.form1.deliverTime.focus();
		return false;
	}else if(document.form1.deliverDate.value=="配達希望日を選択してください" || document.form1.deliverDate.value==""){
		window.alert("配達希望日を選択してください。");
		document.form1.deliverDate.focus();
		return false;
	}else if((document.form1.customerZip1.value=="")||(document.form1.customerZip1.value.length!=3)){
		window.alert("郵便番号を入力してください。");
		document.form1.customerZip1.focus();
		return false;
	}else if((document.form1.customerZip2.value=="")||(document.form1.customerZip2.value.length!=4)){
		window.alert("郵便番号を入力してください。");
		document.form1.customerZip2.focus();
		return false;
	}else if(document.form1.customerAddress.value==""){
		window.alert("住所（市区町村）を入力してください。");
		document.form1.customerAddress.focus();
		return false;
		}else if(document.form1.customerAddress2.value==""){
		window.alert("住所（番地）を入力してください。");
		document.form1.customerAddress2.focus();
		return false;
	}else if(document.form1.customerTel1.value==""){
		window.alert("市外局番を入力してください。");
		document.form1.customerTel1.focus();
		return false;
	}else if(document.form1.customerTel2.value==""){
		window.alert("電話番号を入力してください。");
		document.form1.customerTel2.focus();
		return false;
	}else if(document.form1.customerTel3.value==""){
		window.alert("電話番号を入力してください。");
		document.form1.customerTel3.focus();
		return false;
	}else if((document.form1.customerMail.value!="")||(document.form1.customerMail.value=="")){
	
		if(document.form1.customerMail.value==""){
			window.alert("メールアドレスを入力してください。");
			document.form1.customerMail.focus();
			return false;
		}
		//アドレスの形のチェック
		var emailStr = document.form1.customerMail.value
		var emailPat=/^(.+)@(.+)$/
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		var validChars="\[^\\s" + specialChars + "\]"
		var quotedUser="(\"[^\"]*\")"
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		var atom=validChars + '+'
		var word="(" + atom + "|" + quotedUser + ")"
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		var matchArray=emailStr.match(emailPat)

			if (matchArray == null) {
			alert("メールアドレスが正しくありません。")
			document.form1.customerMail.focus();
			return false;
		}

		 var user=matchArray[1]
		 var domain=matchArray[2]

		if (user.match(userPat)==null) {
			alert("メールアドレスが正しくありません。")
			document.form1.customerMail.focus();
			return false;
		}

		var IPArray=domain.match(ipDomainPat)

		if (IPArray!=null) {
			for (var i=1;i<=4;i++) {
				if (IPArray[i]>255) {
					alert("メールアドレスが正しくありません")
					document.form1.customerMail.focus();
					return false;
				}
			}
		}

		var domainArray=domain.match(domainPat)

		if (domainArray==null) {
			alert("ドメイン名がありません。")
			document.form1.customerMail.focus();
			return false;
		}

		var atomPat=new RegExp(atom,"g")
		var domArr=domain.match(atomPat)
		var len=domArr.length

		if (domArr[domArr.length-1].length<2 ||
			domArr[domArr.length-1].length>3) {
				alert("メールアドレスが正しくありません。")
				document.form1.customerMail.focus();
				return false;
			}

		if (len<2) {
			var errStr="メールアドレスにドメイン名がありません。"
			alert(errStr)
			document.form1.customerMail.focus();
			return false;
		}
		
	}
	
	//お届け先が異なる場合のチェック
	if(document.form1.reciever.checked==false){
		if(document.form1.receiverName.value==""){
			window.alert("お届け先のお名前を入力してください。");
			document.form1.receiverName.focus();
			return false;
		}else if((document.form1.destinationZip1.value=="")||(document.form1.destinationZip1.value.length!=3)){
			window.alert("お届け先の郵便番号を入力してください。");
			document.form1.destinationZip1.focus();
			return false;
		}else if((document.form1.destinationZip2.value=="")||(document.form1.destinationZip2.value.length!=4)){
			window.alert("お届け先の郵便番号を入力してください。");
			document.form1.destinationZip2.focus();
			return false;
		}else if(document.form1.destinationAddress.value==""){
			window.alert("お届け先の住所（市区町村）を入力してください。");
			document.form1.destinationAddress.focus();
			return false;
		}else if(document.form1.destinationAddress2.value==""){
			window.alert("お届け先の住所（番地）を入力してください。");
			document.form1.destinationAddress2.focus();
			return false;
		}else if(document.form1.destinationTel1.value==""){
			window.alert("お届け先の市外局番を入力してください。");
			document.form1.destinationTel1.focus();
			return false;
		}else if(document.form1.destinationTel2.value==""){
			window.alert("お届け先の電話番号を入力してください。");
			document.form1.destinationTel2.focus();
			return false;
		}else if(document.form1.destinationTel3.value==""){
			window.alert("お届け先の電話番号を入力してください。");
			document.form1.destinationTel3.focus();
			return false;
		}
	}
	return true;
}


