// 本日の日付
var today = new Date();


// CSS書き出し
if(isMember()){
		document.write('<style type="text/css"><!-- #memberPrice th, #memberPrice td { background-color: #CCC; color: #333; } --><\/style>');
}


// メンバーチェック
function checkMember(num) {
	if(isMember()){
	   document.cartForm.kakaku.value = mprice;
	}
	else{
	   document.cartForm.kakaku.value = price;
	   count = Math.ceil( (xday.getTime() - today.getTime()) / (60*60*1000) );
	 	if(count > 0) {
		var f=document.getElementById("cartForm");
			for (var i =0; i<=f.length -1 ;i++){
				f.elements[i].disabled=num;
			}
		}
	}
  }


function isMember(){
return document.cookie.substring(0, 11) == "MEMBER=1"
}


  
//  在庫チェック

function stockStatus (num){

	   document.cartForm.shouhinnumber.value = inumber;
	   document.cartForm.shouhinmei.value = iname;

	 	if(stock == 0) {
		var f=document.getElementById("cartForm");
			for (var i =0; i<=f.length -1 ;i++){
				f.elements[i].disabled=num;
			}
		 document.getElementById('addcart').style.background='transparent url(/img/bkd_addcart_soldout.gif)';
		}
	 	else if(count > 0 && document.cookie.substring(0, 11) != "MEMBER=1") { 
		 document.getElementById('addcart').style.background='transparent url(/img/bkd_addcart_disable.gif)';
		}

}

//  Lotus会員ログインを表示
function writeLogin() {
	   document.write('<a href="/lotus/index.php" id="login">' +
					  'Lotus会員ログイン</a>');
}  
function writeLogout() {
	   document.write('<a href="#" id="login" onClick="eatCookie(\'MEMBER\',\'0\',-1);location.reload()">' + 
					  'Lotus会員ログアウト</a>');
}   


//  価格表を表示
function writePrice() {
	document.write('<table border="0" cellspacing="0" cellpadding="0" id="priceTable"><caption>ITEM: '+inumber+'<\/caption>');
	document.write('<tr class="firstrow"><th scope="row">PRICE:<\/th><td>'+price+'yen<\/td><\/tr><tr class="firstcol" id="memberPrice">');
	document.write('<th scope="row"><a href="/guide/lotus/">Lotus会員<\/a>:<\/th><td>'+mprice+'yen<\/td><\/tr><\/table>');
}   

//  残り時間を表示
function writeTime() {
	count = Math.ceil( (xday.getTime() - today.getTime()) / (60*60*1000) );
	if(document.cookie.substring(0, 11) != "MEMBER=1" && count > 0 && stock != 0){
		document.write('<p style="margin-top: 0.5em">発売開始は'+count+'時間後です。<br />Lotus会員は通常より1日早くご購入いただけます。<\/p>');
	}
	else if(document.cookie.substring(0, 11) == "MEMBER=1" && count > 0 && stock != 0){
		document.write('<p style="margin-top: 0.5em">LOTUS会員のみ先行販売中。'+count+'時間後に一般販売開始します。<\/p>');
	}

}

//  イメージを表示
function writeImage() {
	document.write('<p><a href="javascript:;"><img src="/category/img/'+inumber+'.jpg" alt="" onclick="winOpen(this,iphoto)" id="iimage" /></a><br />');
	document.write('<a href="javascript:;" onclick="return winOpen(\'/category/img/'+inumber+'.jpg\',iphoto)" id="btn_moreimages">more images</a></p>');
}   

// アラートウインドウ
function check(cartForm) {
	if (stock == 0) { 
		alert('申し訳ありません。SOLD OUTしました。'); 
		return false; 
	}

	else if (count > 0 && document.cookie.substring(0, 11) != "MEMBER=1") { 
		alert('発売開始は'+count+'時間後です');
		return false; 
	}

	else if (cartForm.op2.options[cartForm.op2.selectedIndex].text == 'サイズを選択' && cartForm.op1.options[cartForm.op1.selectedIndex].text == 'カラーを選択') { 
		alert('サイズとカラーを選択してください！'); 
		return false; 
	}
	else if (cartForm.op1.options[cartForm.op1.selectedIndex].text == 'カラーを選択') { 
		alert('カラーを選択してください！'); 
		return false; 
	}
	else if (cartForm.op2.options[cartForm.op2.selectedIndex].text == 'サイズを選択') { 
		alert('サイズを選択してください！'); 
		return false; 
	}
	else if (cartForm.op1.options[cartForm.op1.selectedIndex].text == '--') { 
		alert('申し訳ありません。このカラーはSOLD OUTしました'); 
		return false; 
	}
	else if (cartForm.op2.options[cartForm.op2.selectedIndex].text == '--') { 
		alert('申し訳ありません。このサイズはSOLD OUTしました'); 
		return false; 
	}
}
