
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

		function MM_callJS(jsStr) {
		  return eval(jsStr)
		}
	urlstring=window.location.toString();
	var valuearray = new Array();
	var refidarray = new Array();
	var ref="";

	valuearray=urlstring.split("?");

	if(valuearray[1] == null){
		ref=431	
	}
	else{
		refidarray=valuearray[1].split("=");
		if(refidarray[1]=="" || refidarray[1] == null || refidarray[0] != "refid"){
			ref=431
		}
		else{
			ref=refidarray[1];
		}
	}

	function OpenBrWindow(theURL,winName,features) { 
 		 window.open(theURL,winName,features);
	}
	function doSubmit(){
	var f= document.reg;
	if(f.email.value==""){
		alert("メールアドレスをご記入下さい。");
		f.email.focus();
		return false;
	}
	if (!f.email.value.match(/^\S+@\S+\.\S+$/)) {
   		alert('メールアドレスに不備があります。半角英数字で再度ご記入下さい。');
   		f.email.focus();
   		return false;
   	}
	if(f.email.value.replace(/^\s\s*/, '').replace(/\s\s*$/, '') != f.confirm.value.replace(/^\s\s*/, '').replace(/\s\s*$/, '')){
		alert("メールアドレス（確認入力）とメールアドレスが一致しません。再度ご確認下さい。");
		f.confirm.focus();
		return false;
	}
	if(isUnicode()){
		alert('メールアドレスは半角英数字でご記入下さい。');
   		f.email.focus();
   		return false;
	}
	if(f.dob_year.value==""){
		alert("生年月日の年を選択してください。");
		f.dob_year.focus();
		return false;
	}
	if(f.dob_month.value==""){
		alert("生年月日の月を選択してください。");
		f.dob_month.focus();
		return false;
	}
	if(f.dob_day.value==""){
		alert("生年月日の日を選択してください。");
		f.dob_day.focus();
		return false;
	}
	if(f.gender.value==""){
		alert("性別を選択して下さい。");
		f.gender.focus();
		return false;
	}
	if(f.state.value==""){
		alert("都道府県を選択してください。");
		f.state.focus();
		return false;
	}
	if(!f.conf.checked){
		alert("※同意していただけない場合は、ご登録できません。何卒ご了承ください。");
		f.conf.focus();
		return false;
	}
	var age = howOld(f.dob_day.value, f.dob_month.value, f.dob_year.value);
 
   	if(age >= 13 && ReadCookie("register") != "no") {
   		dob = f.dob_year.value + "-" + f.dob_month.value + "-" + f.dob_day.value;
   	}
   	else {
   		WriteCookie('register','no');
   		window.location='sorry.html';
   		return false;
   	}
	f.optin1.value=ref;
	return true;

	}
function isUnicode() {
isTrue=false;
someText = document.reg.email.value;
textSize = document.reg.email.value.length;
for (i = 0; i < textSize; i++) {
if (someText.charCodeAt(i)  > 256) {
isTrue=true;
break;
}
}
return isTrue
}



	function ReadCookie (CookieName)
	{
	var CookieString = document.cookie;
	var CookieSet = CookieString.split (';');
	var SetSize = CookieSet.length;
	var CookiePieces
	var ReturnValue = "";
	var x = 0;
	
	for (x = 0; ((x < SetSize) && (ReturnValue == "")); x++)
	{
		CookiePieces = CookieSet[x].split ('=');

		if (CookiePieces[0].substring (0,1) == ' ')
		{
			CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);
		}
		
		if (CookiePieces[0] == CookieName)
		{
			ReturnValue = CookiePieces[1];
		}
	}
	
	return ReturnValue;
}


function WriteCookie (cookieName, cookieValue, expiry)
{
	var expDate = new Date();

	if(expiry)
	{
		expDate.setTime (expDate.getTime() + expiry);
		document.cookie = cookieName + "=" + escape (cookieValue) + "; expires=" + expDate.toGMTString();
	}
	else
	{
		document.cookie = cookieName + "=" + escape (cookieValue);
	}
}

function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0) { date.setTime(date.getTime() - skew); }
}
// determine age
  function howOld(day,month,year) {
   var c = new Date(); // a new instance
   fixDate(c);
   var thisDay = c.getDate();
   var thisMonth = c.getMonth() + 1;
   var thisYear = c.getFullYear();
 
   
   //var thisDay = 12;
   //var thisMonth = 02;
   //var thisYear = 2004;
 
   var yearsold = thisYear - year;
   var monthsold = 0;
   var daysold = 0;
   var age = '';
 
   if (thisMonth >= month) {
    monthsold = thisMonth - month;
   }
   else {
    yearsold--;
    monthsold = thisMonth + 12 - month;
   }
 
   if (thisDay >= day) {
    daysold = thisDay - day;
   }
   else {
    if (monthsold > 0) {
     monthsold--;
    }
    else {
     yearsold--;
     monthsold += 11;
    }
    daysold = thisDay + 31 - day;
   }
   if (yearsold < 0) return '';
   if ((yearsold == 0) && (monthsold == 0) && (daysold == 0)) return '';
   if (yearsold > 0) {
    age = yearsold;
    if (yearsold > 1) age;
    age += ' ';
   }
   return age;
  }

