//固定データの宣言
var main_m_images = {
			'price_pt': 'PT',
			'price_ne': 'NEO',
			'price_nwg': 'NWG',
			'price_wg': 'WG',
			'price_yg': 'YG',
			'price_pg': 'PG',
			'price_rg': 'RG',
			'price_gg': 'GG',
			'price_si': 'SV',
			'price_ibushi': 'IBUSHI',
			'price_blk': 'BLK',
			'price_shirakaba': 'SHIRAKABA',
			'price_sakura': 'SAKURA',
			'price_psv': 'PSV',
			'price_ptxyg': 'PTxYG',
			'price_ptxpg': 'PTxPG',
			'nothing': '',
			'1': ''
					}


//金属がすでに選択されているかチェックする
function KindSelectCheck( selects )
{
	var errorflg = 0;

	if( selects == 'product1' ){
		if( document.getElementById('Product1KindSelect').selectedIndex == 0 ){ errorflg = 1; }
	}

	if( selects == 'product2' ){
		if( document.getElementById('Product2KindSelect').selectedIndex == 0 ){ errorflg = 1; }
	}

	if( selects == 'product3' ){
		if( document.getElementById('Product3KindSelect').selectedIndex == 0 ){ errorflg = 1; }
	}

	return errorflg;
}


//サイズがすでに選択されているかチェックする
function SizeSelectCheck( selects )
{
	var errorflg = 0;


	if( selects == 'product1' ){
		if( document.getElementById('Product1SizeSelect').selectedIndex == 0 ){ errorflg = 1; }
	}

	if( selects == 'product2' ){
		if( document.getElementById('Product2SizeSelect').selectedIndex == 0 ){ errorflg = 1; }
	}

	if( selects == 'product3' ){
		if( document.getElementById('Product3SizeSelect').selectedIndex == 0 ){ errorflg = 1; }
	}

	return errorflg;
}


function ArrangeWindowOpen( selects, kokuin, urabori, uraishi, product_id, priceidname, priceidnameArrange, disney, product_width )
{
			/* 
				サイズを選択しないと先に進めないようにする。
				これは刻印入力がある場合に、サイズが無いと上限文字数が設定出来ないため。
			*/
	if( KindSelectCheck(selects) )
	{
		if( SizeSelectCheck(selects) )
		{
			alert('金属とサイズをお選びください。'); return;
		}
		else
		{
			alert('金属をお選びください。'); return;
		}
	}
	else if( SizeSelectCheck(selects) )
	{
		alert('サイズをお選びください。'); return;
	}


			//選ばれているサイズを取得する
	var size = "";
	var oldsize = "";
	if( selects == 'product1' )
	{
		kind = document.ProductDetailForm.Product1KindSelect[document.getElementById('Product1KindSelect').selectedIndex].value;
		size = document.ProductDetailForm.Product1SizeSelect[document.getElementById('Product1SizeSelect').selectedIndex].value;
		oldsize = document.ProductDetailForm.Product1Size.value;
	}
	else if( selects == 'product2' )
	{
		kind = document.ProductDetailForm.Product2KindSelect[document.getElementById('Product2KindSelect').selectedIndex].value;
		size = document.ProductDetailForm.Product2SizeSelect[document.getElementById('Product2SizeSelect').selectedIndex].value;
		oldsize = document.ProductDetailForm.Product2Size.value;
	}
	else if( selects == 'product3' )
	{
		kind = document.ProductDetailForm.Product3KindSelect[document.getElementById('Product3KindSelect').selectedIndex].value;
		size = document.ProductDetailForm.Product3SizeSelect[document.getElementById('Product3SizeSelect').selectedIndex].value;
		oldsize = document.ProductDetailForm.Product3Size.value;
	}

	var classcategory_id1 = get_classcategory_id1( kind, size );

//	var url = "/Index/arrangewindow/selects/" + selects + "/kokuin/" + kokuin + "/urabori/" + urabori + "/uraishi/" + uraishi + "/product_id/" + product_id + "/priceidname/" + priceidname + "/priceidnameArrange/" + priceidnameArrange + "/size/" + size + "/oldsize/" + oldsize + "/classcategory_id1/" + classcategory_id1;
	var url = "/shopping/Index/arrangewindow/selects/" + selects + "/kokuin/" + kokuin + "/urabori/" + urabori + "/uraishi/" + uraishi + "/product_id/" + product_id + "/priceidname/" + priceidname + "/priceidnameArrange/" + priceidnameArrange + "/size/" + size + "/oldsize/" + oldsize + "/classcategory_id1/" + classcategory_id1 + "/disney/" + disney + "/product_width/" + product_width;


/* ここはまずい
submitされない場合も消えてしまうので。
				//oldsizeの取得は完了したので空白に戻す。
				//そうしないと-1が一生残る。
	if( selects == 'product1' )
	{
		document.ProductDetailForm.Product1Size.value = "";
	}
	else if( selects == 'product2' )
	{
		document.ProductDetailForm.Product2Size.value = "";
	}
	else if( selects == 'product3' )
	{
		document.ProductDetailForm.Product3Size.value = "";
	}
*/


//	window.open(url, 'ArrangeWindow', 'width=400, height=300, menubar=no, toolbar=no, scrollbars=yes');
	window.open(url, 'ArrangeWindow', 'width=800, menubar=no, toolbar=no, scrollbars=no');
}


function ArrangeWindowOpenOnlyZigane( selects, kokuin, urabori, uraishi, product_id, priceidname, priceidnameArrange, disney, product_width )
{
			/* 
				サイズを選択しないと先に進めないようにする。
				これは刻印入力がある場合に、サイズが無いと上限文字数が設定出来ないため。
			*/
	if( KindSelectCheck(selects) )
	{
		alert('金属をお選びください。'); return;
	}


			//選ばれているサイズを取得する
	if( selects == 'product1' )
	{
		kind = document.ProductDetailForm.Product1KindSelect[document.getElementById('Product1KindSelect').selectedIndex].value;
	}

	var classcategory_id1 = get_classcategory_id1OnlyZigane( kind );
	var size = 99;
	var oldsize = 99;
	var url = "/shopping/Index/arrangewindow/selects/" + selects + "/kokuin/" + kokuin + "/urabori/" + urabori + "/uraishi/" + uraishi + "/product_id/" + product_id + "/priceidname/" + priceidname + "/priceidnameArrange/" + priceidnameArrange + "/size/" + size + "/oldsize/" + oldsize + "/classcategory_id1/" + classcategory_id1 + "/disney/" + disney + "/product_width/" + product_width;

//	window.open(url, 'ArrangeWindow', 'menubar=no, toolbar=no, scrollbars=yes');
	window.open(url, 'ArrangeWindow', 'width=800, menubar=no, toolbar=no, scrollbars=no');
}


//商品詳細ページの『カゴに入れる』をクリックした後の送信プログラム
function ProductDetailSubmit()
{
	var thisForm = document.ProductDetailForm;
	var kind = 0;
	var size = 0;
	var Product1product_id = "";
	var Product2product_id = "";
	var Product3product_id = "";
	var Product1classcategory_id1 = 0;
	var Product2classcategory_id1 = 0;
	var Product3classcategory_id1 = 0;
	var Product1classcategory_id2 = 0;
	var Product2classcategory_id2 = 0;
	var Product3classcategory_id2 = 0;


	if( document.getElementById('Product1KindSelect') )
	{
		kind=document.getElementById('Product1KindSelect').options[document.getElementById('Product1KindSelect').selectedIndex].value;
		size=document.getElementById('Product1SizeSelect').options[document.getElementById('Product1SizeSelect').selectedIndex].value;
		Product1classcategory_id1 = get_classcategory_id1(kind,size);
		thisForm.classcategory_id1.value = Product1classcategory_id1;
	}

	if( document.getElementById('Product2KindSelect') )
	{
		kind=document.getElementById('Product2KindSelect').options[document.getElementById('Product2KindSelect').selectedIndex].value;
		size=document.getElementById('Product2SizeSelect').options[document.getElementById('Product2SizeSelect').selectedIndex].value;
		Product2classcategory_id1 = get_classcategory_id1(kind,size);
		thisForm.Product2classcategory_id1.value = Product2classcategory_id1;
	}

	if( document.getElementById('Product3KindSelect') )
	{
		kind=document.getElementById('Product3KindSelect').options[document.getElementById('Product3KindSelect').selectedIndex].value;
		size=document.getElementById('Product3SizeSelect').options[document.getElementById('Product3SizeSelect').selectedIndex].value;
		Product3classcategory_id1 = get_classcategory_id1(kind,size);
		thisForm.Product3classcategory_id1.value = Product3classcategory_id1;
	}


	if( thisForm.classcategory_id2 ){
//オプション反映までコメントアウト
//		Product1classcategory_id2 = thisForm.classcategory_id2.value;
	}

	if( thisForm.Product2classcategory_id2 ){
//オプション反映までコメントアウト
//		Product2classcategory_id2 = thisForm.Product2classcategory_id2.value;
	}

	if( thisForm.Product3classcategory_id2 ){
//オプション反映までコメントアウト
//		Product3classcategory_id2 = thisForm.Product3classcategory_id2.value;
	}

/*
					//ここで、商品がある数だけカートに登録
					//裏石関係も登録
	Product1product_id = document.getElementById('Product1product_id').value;
	if( document.getElementById('Product2product_id') ){
		Product2product_id = document.getElementById('Product2product_id').value;
	}
	if( document.getElementById('Product3product_id') ){
		Product3product_id = document.getElementById('Product3product_id').value;
	}

	PostData(
		Product1product_id,
		Product1classcategory_id1,
		Product1classcategory_id2,
		Product2product_id,
		Product2classcategory_id1,
		Product2classcategory_id2,
		Product3product_id,
		Product3classcategory_id1,
		Product3classcategory_id2
				);
*/

				//最後にショッピングカートページにジャンプさせる。
				//ただし、ジャンプは、上のAjax送信が全て完了したら。
//	location.href = '/cart/index.php';

	thisForm.submit();
}


//商品詳細ページの『カゴに入れる』をクリックした後の送信プログラム
//金属のみ　版
function ProductDetailSubmitOnlyZigane()
{
	var thisForm = document.ProductDetailForm;
	var kind = 0;
	var size = 0;
	var Product1product_id = "";
	var Product1classcategory_id1 = 0;
	var Product1classcategory_id2 = 0;

	if( document.getElementById('Product1KindSelect') )
	{
		kind = document.getElementById('Product1KindSelect').options[document.getElementById('Product1KindSelect').selectedIndex].value;

		Product1classcategory_id1 = get_classcategory_id1OnlyZigane( kind );
		thisForm.classcategory_id1.value = Product1classcategory_id1;
	}

	if( thisForm.classcategory_id2 ){
//オプション反映までコメントアウト
//		Product1classcategory_id2 = thisForm.classcategory_id2.value;
	}

	thisForm.submit();
}


//規格１の正式な値を決定する。
//これはdtb_classcategoryの数値を参考に決め打ちで決定してしまっているハードコーディング！
function get_classcategory_id1( kind, size )
{
	var classcategory_id1 = 0;
	size = Number(size);

	if( kind == 'price_pt' ){ classcategory_id1 = 303 + size; }
	else if( kind == 'price_ne' ){ classcategory_id1 = 333 + size; }
	else if( kind == 'price_nwg' ){ classcategory_id1 = 363 + size; }
	else if( kind == 'price_wg' ){ classcategory_id1 = 393 + size; }
	else if( kind == 'price_yg' ){ classcategory_id1 = 423 + size; }
	else if( kind == 'price_pg' ){ classcategory_id1 = 453 + size; }
	else if( kind == 'price_rg' ){ classcategory_id1 = 483 + size; }
	else if( kind == 'price_gg' ){ classcategory_id1 = 513 + size; }
	else if( kind == 'price_si' ){ classcategory_id1 = 543 + size; }
	else if( kind == 'price_ibushi' ){ classcategory_id1 = 573 + size; }
	else if( kind == 'price_blk' ){ classcategory_id1 = 603 + size; }
	else if( kind == 'price_shirakaba' ){ classcategory_id1 = 633 + size; }
	else if( kind == 'price_sakura' ){ classcategory_id1 = 663 + size; }
	else if( kind == 'price_psv' ){ classcategory_id1 = 705 + size; }
	else if( kind == 'price_ptxyg' ){ classcategory_id1 = 735 + size; }
	else if( kind == 'price_ptxpg' ){ classcategory_id1 = 765 + size; }

	return(classcategory_id1);
}

function get_classcategory_id1OnlyZigane( kind )
{
/*
	if( kind == 'price_pt' ){ classcategory_id1 = 295; }
	else if( kind == 'price_wg' ){ classcategory_id1 = 296; }
	else if( kind == 'price_yg' ){ classcategory_id1 = 297; }
	else if( kind == 'price_gg' ){ classcategory_id1 = 298; }
	else if( kind == 'price_pg' ){ classcategory_id1 = 299; }
	else if( kind == 'price_rg' ){ classcategory_id1 = 300; }
	else if( kind == 'price_si' ){ classcategory_id1 = 301; }
	else if( kind == 'price_co' ){ classcategory_id1 = 302; }
	else if( kind == 'price_ne' ){ classcategory_id1 = 303; }
	else{ classcategory_id1 = 0; }
*/

	if( kind == 'price_pt' ){ classcategory_id1 = 796; }
	else if( kind == 'price_ne' ){ classcategory_id1 = 797; }
	else if( kind == 'price_nwg' ){ classcategory_id1 = 798; }
	else if( kind == 'price_wg' ){ classcategory_id1 = 799; }
	else if( kind == 'price_yg' ){ classcategory_id1 = 800; }
	else if( kind == 'price_pg' ){ classcategory_id1 = 801; }
	else if( kind == 'price_rg' ){ classcategory_id1 = 802; }
	else if( kind == 'price_gg' ){ classcategory_id1 = 803; }
	else if( kind == 'price_si' ){ classcategory_id1 = 804; }
	else if( kind == 'price_ibushi' ){ classcategory_id1 = 805; }
	else if( kind == 'price_blk' ){ classcategory_id1 = 806; }
	else if( kind == 'price_shirakaba' ){ classcategory_id1 = 807; }
	else if( kind == 'price_sakura' ){ classcategory_id1 = 808; }
	else if( kind == 'price_psv' ){ classcategory_id1 = 809; }
	else if( kind == 'price_ptxyg' ){ classcategory_id1 = 810; }
	else if( kind == 'price_ptxpg' ){ classcategory_id1 = 811; }
	else{ classcategory_id1 = 0; }

	return(classcategory_id1);
}


//選択された情報に応じてallpriceの値を変更する
//（価格の情報）
function ChangeAllPrice()
{
	var thisForm = document.ProductDetailForm;
	var Product1classcategory_id1 = 0;
	var Product2classcategory_id1 = 0;
	var Product3classcategory_id1 = 0;
	var Product1classcategory_id2 = 0;
	var Product2classcategory_id2 = 0;
	var Product3classcategory_id2 = 0;
	var varname = "";
	var tmpprice1 = 0;
	var tmpprice2 = 0;
	var tmpprice3 = 0;
	var tmpprice1arrange = 0;
	var tmpprice2arrange = 0;
	var tmpprice3arrange = 0;
	var surfaceprice1 = 0;
	var surfaceprice2 = 0;
	var surfaceprice3 = 0;


	if( document.getElementById('Product1SurfacePrice') ){
		surfaceprice1 = document.getElementById('Product1SurfacePrice').value;
	}

	if( document.getElementById('Product2SurfacePrice') ){
		surfaceprice2 = document.getElementById('Product2SurfacePrice').value;
	}

	if( document.getElementById('Product3SurfacePrice') ){
		surfaceprice3 = document.getElementById('Product3SurfacePrice').value;
	}



					//最初に必ず初期化
	document.getElementById('AllPrice').innerHTML = "";


	if( document.getElementById('Product1KindSelect') )
	{
		kind = document.getElementById('Product1KindSelect').options[document.getElementById('Product1KindSelect').selectedIndex].value;

		size = document.getElementById('Product1SizeSelect').options[document.getElementById('Product1SizeSelect').selectedIndex].value;


				//サイズが未選択だったら無視
		if( (size>=1 && size<=30) || size==99 )
		{
			Product1classcategory_id1 = get_classcategory_id1(kind,size);

			varname = "Product1" + kind;

			if( document.getElementById(varname) )
			{
				tmpprice1 = document.getElementById(varname).value;

				if( size != 99 )
				{

				if( size >=1 && size <= 5 ){ tmpprice1 = Number(tmpprice1) + 10500; }
				else if( size >= 20 ){ tmpprice1 = Number(tmpprice1) + 21000; }

				}

//				tmpprice1 = Number(tmpprice1) + Number(surfaceprice1);


					//2011-01-20add
					//ディズニーオプション料を加算するのであればここだと思う
					//tmpprice1
					//に対して、ディズニーオプション料を計算して、
					//加算！
					//ここから
				DisneyOption = GetDisneyOption( 'Product1disneyflg', tmpprice1 );
				tmpprice1 = Number( tmpprice1 ) + Number( DisneyOption );

				document.getElementById('Product1Price').value = tmpprice1;

				if( DisneyOption != 0 )
				{
					document.getElementById('DisneyOptionExplain1').style.display = "block";
				}
				else
				{
					document.getElementById('DisneyOptionExplain1').style.display = "none";
					//商品価格
					//ディズニー刻印の関係でかなりの端数が出るので、
					//10桁以下は0にしてしまうよう修正
					//2011-03-04
					//畠山さんよりディズニーオプションが入らない場合に限ると指示あり
					tmpprice1 = Erase10( tmpprice1 );
				}
			}
		}
	}



	if( document.getElementById('Product2KindSelect') )
	{
		kind = document.getElementById('Product2KindSelect').options[document.getElementById('Product2KindSelect').selectedIndex].value;

		size = document.getElementById('Product2SizeSelect').options[document.getElementById('Product2SizeSelect').selectedIndex].value;


				//サイズが未選択だったら無視
		if( size>=1 && size<=30 )
		{
			Product2classcategory_id1 = get_classcategory_id1(kind,size);

			varname = "Product2" + kind;

			if( document.getElementById(varname) )
			{
				tmpprice2 = document.getElementById(varname).value;

				if( size >=1 && size <= 5 ){ tmpprice2 = Number(tmpprice2) + 10500; }
				else if( size >= 20 ){ tmpprice2 = Number(tmpprice2) + 21000; }


					//2011-01-20add
					//ディズニーオプション料を加算するのであればここだと思う
					//tmpprice1
					//に対して、ディズニーオプション料を計算して、
					//加算！
				DisneyOption = GetDisneyOption( 'Product2disneyflg', tmpprice2 );
				tmpprice2 = Number( tmpprice2 ) + Number( DisneyOption );

//				tmpprice2 = Number(tmpprice2) + Number(surfaceprice2);

				document.getElementById('Product2Price').value = tmpprice2;

				if( DisneyOption != 0 )
				{
					document.getElementById('DisneyOptionExplain2').style.display = "block";
				}
				else
				{
					document.getElementById('DisneyOptionExplain2').style.display = "none";

					//商品価格
					//ディズニー刻印の関係でかなりの端数が出るので、
					//10桁以下は0にしてしまうよう修正
					//2011-03-04
					//畠山さんよりディズニーオプションが入らない場合に限ると指示あり
					tmpprice2 = Erase10( tmpprice2 );
				}
			}
		}
	}



	if( document.getElementById('Product3KindSelect') )
	{
		kind = document.getElementById('Product3KindSelect').options[document.getElementById('Product3KindSelect').selectedIndex].value;
		size = document.getElementById('Product3SizeSelect').options[document.getElementById('Product3SizeSelect').selectedIndex].value;


				//サイズが未選択だったら無視
		if( size>=1 && size<=30 )
		{
			Product3classcategory_id1 = get_classcategory_id1(kind,size);

			varname = "Product3" + kind;

			if( document.getElementById(varname) )
			{
				tmpprice3 = document.getElementById(varname).value;

				if( size >=1 && size <= 5 ){ tmpprice3 = Number(tmpprice3) + 10500; }
				else if( size >= 20 ){ tmpprice3 = Number(tmpprice3) + 21000; }


					//2011-01-20add
					//ディズニーオプション料を加算するのであればここだと思う
					//tmpprice1
					//に対して、ディズニーオプション料を計算して、
					//加算！
				DisneyOption = GetDisneyOption( 'Product3disneyflg', tmpprice3 );
				tmpprice3 = Number( tmpprice3 ) + Number( DisneyOption );


//				tmpprice3 = Number(tmpprice3) + Number(surfaceprice3);
				document.getElementById('Product3Price').value = tmpprice3;


				if( DisneyOption != 0 )
				{
					document.getElementById('DisneyOptionExplain3').style.display = "block";
				}
				else
				{
					document.getElementById('DisneyOptionExplain3').style.display = "none";

					//商品価格
					//ディズニー刻印の関係でかなりの端数が出るので、
					//10桁以下は0にしてしまうよう修正
					//2011-03-04
					//畠山さんよりディズニーオプションが入らない場合に限ると指示あり
					tmpprice3 = Erase10( tmpprice3 );
				}
			}
		}
	}


				//アレンジの価格についても変数化
	if( document.getElementById('Product1ArrangePrice') ){

		tmpprice1arrange = document.getElementById('Product1ArrangePrice').value;
		tmpprice1arrange = Number(tmpprice1arrange) + Number(surfaceprice1);


					//ディズニーオプション料も発生するならば足す
		DisneyOption = GetDisneyOption( 'Product1disneyflg', tmpprice1arrange );
		tmpprice1arrange = Number( tmpprice1arrange ) + Number( DisneyOption );
	}

	if( document.getElementById('Product2ArrangePrice') ){

		tmpprice2arrange = document.getElementById('Product2ArrangePrice').value;
		tmpprice2arrange = Number(tmpprice2arrange) + Number(surfaceprice2);



					//ディズニーオプション料も発生するならば足す
		DisneyOption = GetDisneyOption( 'Product2disneyflg', tmpprice2arrange );
		tmpprice2arrange = Number( tmpprice2arrange ) + Number( DisneyOption );
	}

	if( document.getElementById('Product3ArrangePrice') ){

		tmpprice3arrange = document.getElementById('Product3ArrangePrice').value;

		tmpprice3arrange = Number(tmpprice3arrange) + Number(surfaceprice3);



					//ディズニーオプション料も発生するならば足す
		DisneyOption = GetDisneyOption( 'Product3disneyflg', tmpprice3arrange );
		tmpprice3arrange = Number( tmpprice3arrange ) + Number( DisneyOption );
	}


				//商品価格
				//ディズニー刻印の関係でかなりの端数が出るので、
				//10桁以下は0にしてしまうよう修正
//	tmpprice1 = Erase10( tmpprice1 );
//	tmpprice2 = Erase10( tmpprice2 );
//	tmpprice3 = Erase10( tmpprice3 );

	var tmpPrice1 = addFigure( Number(tmpprice1) );
	var tmpPrice2 = addFigure( Number(tmpprice2) );
	var tmpPrice3 = addFigure( Number(tmpprice3) );



	if( tmpPrice1 == '0' ){ tmpPrice1 = ""; }
	if( tmpPrice2 == '0' ){ tmpPrice2 = ""; }
	if( tmpPrice3 == '0' ){ tmpPrice3 = ""; }



	if( document.getElementById('tmpPrice1') ){ document.getElementById('tmpPrice1').innerHTML = tmpPrice1; }
	if( document.getElementById('tmpPrice2') ){ document.getElementById('tmpPrice2').innerHTML = tmpPrice2; }
	if( document.getElementById('tmpPrice3') ){ document.getElementById('tmpPrice3').innerHTML = tmpPrice3; }





				//オプション価格

				//端数を丸める処理を最初に入れる
//	tmpprice1arrange = Erase10( tmpprice1arrange );
//	var tmpprice1arrange_count = String(tmpprice1arrange).length;
//	var tmpprice1arrange_tmp = String(tmpprice1arrange).substring( 0,tmpprice1arrange_count-2);
//	var tmpprice1arrange_formal = String(tmpprice1arrange_tmp) + '00';
//	tmpprice1arrange = tmpprice1arrange_formal;

//	tmpprice2arrange = Erase10( tmpprice2arrange );
//	var tmpprice2arrange_count = String(tmpprice2arrange).length;
//	var tmpprice2arrange_tmp = String(tmpprice2arrange).substring( 0,tmpprice2arrange_count-2);
//	var tmpprice2arrange_formal = String(tmpprice2arrange_tmp) + '00';
//	tmpprice2arrange = tmpprice2arrange_formal;

//	tmpprice3arrange = Erase10( tmpprice3arrange );
//	var tmpprice3arrange_count = String(tmpprice3arrange).length;
//	var tmpprice3arrange_tmp = String(tmpprice3arrange).substring( 0,tmpprice3arrange_count-2);
//	var tmpprice3arrange_formal = String(tmpprice3arrange_tmp) + '00';
//	tmpprice3arrange = tmpprice3arrange_formal;



	var tmpArrangePrice1 = addFigure( Number(tmpprice1arrange) );
	var tmpArrangePrice2 = addFigure( Number(tmpprice2arrange) );
	var tmpArrangePrice3 = addFigure( Number(tmpprice3arrange) );



	if( tmpArrangePrice1 == '0' ){ tmpArrangePrice1 = ""; }
	if( tmpArrangePrice2 == '0' ){ tmpArrangePrice2 = ""; }
	if( tmpArrangePrice3 == '0' ){ tmpArrangePrice3 = ""; }


	if( document.getElementById('tmpArrangePrice1') ){ document.getElementById('tmpArrangePrice1').innerHTML = tmpArrangePrice1; }
	if( document.getElementById('tmpArrangePrice2') ){ document.getElementById('tmpArrangePrice2').innerHTML = tmpArrangePrice2; }
	if( document.getElementById('tmpArrangePrice3') ){ document.getElementById('tmpArrangePrice3').innerHTML = tmpArrangePrice3; }



	var AllPrice = addFigure( Number(tmpprice1) + Number(tmpprice2) + Number(tmpprice3) + Number(tmpprice1arrange) + Number(tmpprice2arrange) + Number(tmpprice3arrange) );

//	var AllPrice = Number(tmpprice1) + Number(tmpprice2) + Number(tmpprice3) + Number(tmpprice1arrange) + Number(tmpprice2arrange) + Number(tmpprice3arrange);
////	var AllPrice = addFigure( Number(tmpprice1) + Number(tmpprice2) + Number(tmpprice3) + Number(tmpprice1arrange) + Number(tmpprice2arrange) + Number(tmpprice3arrange) + Number(surfaceprice1) + Number(surfaceprice2) + Number(surfaceprice3) );

//	AllPrice = AllPrice + Number(surfaceprice1) + Number(surfaceprice2) + Number(surfaceprice3);
//	AllPrice = addFigure( AllPrice );


				//合計結果が0ならば表示させないようにする
	if( AllPrice != '0' )
	{
//		document.getElementById('AllPrice').value = AllPrice;
		document.getElementById('AllPrice').innerHTML = AllPrice;
	}
	else
	{
//		document.getElementById('AllPrice').value = '';
		document.getElementById('AllPrice').innerHTML = "";
	}
}


//選択された情報に応じてallpriceの値を変更する
//（価格の情報）
function ChangeAllPriceOnlyZigane( product_code, ImageIdName, SelectIdName, urldir )
{

				//在庫切れの場合、これ以上進ませる必要がない場合があるので、即return
	if( !document.getElementById('AllPrice') ){ return; }

	var thisForm = document.ProductDetailForm;
	var Product1classcategory_id1 = 0;
	var Product1classcategory_id2 = 0;
	var varname = "";
	var tmpprice1 = 0;
	var tmpprice1arrange = 0;


					//最初に必ず初期化
//	thisForm.AllPrice.value = 0;
	document.getElementById('AllPrice').innerHTML = "";

//	kind = document.getElementById('Product1KindSelect').options[document.getElementById('Product1KindSelect').selectedIndex].value;
	kind = document.getElementById( SelectIdName ).options[document.getElementById( SelectIdName ).selectedIndex].value;


	if( !main_m_images[kind] )
	{
		return;
	}

	get_classcategory_id1OnlyZigane( kind );

	varname = "Product1" + kind;

	if( document.getElementById(varname) )
	{
		tmpprice1 = document.getElementById(varname).value;


		document.getElementById('Product1Price').value = tmpprice1;
	}


				//アレンジの価格についても変数化
	if( document.getElementById('Product1ArrangePrice') ){
		tmpprice1arrange = document.getElementById('Product1ArrangePrice').value;
	}

	var tmpPrice1 = addFigure( Number(tmpprice1) + Number(tmpprice1arrange) );

//	if( tmpPrice1 != '0' ){ document.getElementById('tmpPrice1').value = tmpPrice1; }
				//やはり全ての商品において、値を出すようにしたので修正
	if( tmpPrice1 != '0' )
	{
		if( document.getElementById('tmpPrice1') )
		{
			document.getElementById('tmpPrice1').innerHTML = tmpPrice1;
		}
	}

	var AllPrice = addFigure( Number(tmpprice1) + Number(tmpprice1arrange) );

				//合計結果が0ならば表示させないようにする
	if( AllPrice != '0' )
	{
		document.getElementById('AllPrice').innerHTML = AllPrice;
	}
	else
	{
		document.getElementById('AllPrice').innerHTML = "";
	}


	main_m_image = product_code + "-" + main_m_images[kind] + "m.jpg";
	document.getElementById(ImageIdName).src = urldir + "upload/save_image/" + main_m_image;
}



function addFigure(str)
{
	var num = new String(str).replace(/,/g, "");
	while(num != (num = num.replace(/^(-?\d+)(\d{3})/, "$1,$2")));
	return num;
}


function favoriteAction( flg, product_id, formname, MessageDiv )
{
	var url = "";
	var tid = "";
	var params = 'product_ids=';

	if( flg == 1 ){ //登録
		url = '/shopping/Index/favoriteput';
	}
	else{	//削除
		url = '/shopping/Index/favoriteout';
	}

	if( formname != '' )
	{
		var length = document.favoriteform.product_ids.length;

				//checkboxは値が１つしかないと、JavaScriptは配列にならないので、
				//それを解決させるための特殊な動き。
		if( length )
		{
			for( var i=0; i<length; i++ )
			{
				if( document.favoriteform.product_ids[i].checked == true )
				{
					params = params + document.favoriteform.product_ids[i].value + ",";
				}
			}
		}
		else
		{
			if( document.favoriteform.product_ids.checked == true )
			{
				params = params + document.favoriteform.product_ids.value;
			}
		}
	}
	else
	{
		params = params + product_id;
	}


			//XMLデータの取得
	new Ajax.Request(
					url,
					{
						method: 'post',
					    onSuccess: request_ok,
					    onFailure: request_ng,
						parameters: params
					});

	function request_ok(req)
	{
		if( flg == 1 )
		{
			document.getElementById( MessageDiv ).innerHTML = "<br />登録しました。";
			tid = setTimeout("favoriteMessageClose()",2000);
		}
		else
		{
			alert("削除しました。");
//			document.getElementById( MessageDiv ).innerHTML = "<br />削除しました。";
//			tid = setTimeout("favoriteMessageClose()",2000);
			window.location.reload();
		}
	}

	function request_ng(req){}
}


function favoriteMessageClose()
{
	document.getElementById('favoriteMessage').innerHTML = "";
	document.getElementById('favoriteMessage2').innerHTML = "";
}

function sendKunoAction()
{
	var length = document.favoriteform.product_ids.length;
	var product_ids = "";

				//checkboxは値が１つしかないと、JavaScriptは配列にならないので、
				//それを解決させるための特殊な動き。
	if( length )
	{
		for( var i=0; i<length; i++ )
		{
			if( document.favoriteform.product_ids[i].checked == true )
			{
				product_ids = product_ids + document.favoriteform.product_ids[i].value + ",";
			}
		}
	}
	else
	{
		if( document.favoriteform.product_ids.checked == true )
		{
			product_ids = product_ids + document.favoriteform.product_ids.value;
		}
	}

	if( product_ids == '' )
	{
		alert('商品を選択してください。');
		return;
	}

	window.document.favoriteform.src_product_ids.value = product_ids;
	window.document.favoriteform.submit();
}

function cellphone_send_open( MessageDiv )
{
	$params = "";

				//XMLデータの取得
	new Ajax.Request(
				'/shopping/Index/cellphone',
				{
					method: 'post',
					onSuccess: request_ok,
					onFailure: request_ng,
					parameters: $params
				});

	function request_ok(req)
	{
		if( MessageDiv == '' ){
			document.getElementById('favoriteMessage').innerHTML = req.responseText;
		}else{
			document.getElementById( MessageDiv ).innerHTML = req.responseText;
		}
	}

	function request_ng(req){}
}


function cellphone_send_submit()
{
	var params = "cellphone_send_email=" + document.getElementById('cellphone_send_email').value;
	var length = document.favoriteform.product_ids.length;
	var product_ids = "";

				//checkboxは値が１つしかないと、JavaScriptは配列にならないので、
				//それを解決させるための特殊な動き。
	if( length )
	{
		for( var i=0; i<length; i++ )
		{
			if( document.favoriteform.product_ids[i].checked == true )
			{
				product_ids = product_ids + document.favoriteform.product_ids[i].value + ",";
			}
		}
	}
	else
	{
		if( document.favoriteform.product_ids.checked == true )
		{
			product_ids = product_ids + document.favoriteform.product_ids.value;
		}
	}

	if( product_ids == '' )
	{
		alert('商品を選択してください。');
		return;
	}
	else
	{
		params = params + '&product_ids=' + product_ids;
	}


			//XMLデータの取得
	new Ajax.Request(
					'/shopping/Index/cellphonesend',
					{
						method: 'post',
					    onSuccess: request_ok,
					    onFailure: request_ng,
						parameters: params
					});

	function request_ok(req)
	{
//		alert(req.responseText);
		alert("送信しました。");
//		document.getElementById('favoriteMessage').innerHTML = "<br />送信しました。";
//		tid = setTimeout("favoriteMessageClose()",2000);
	}

	function request_ng(req){}
}


function ChangeZigane( product_code, pchangeName, ImageIdName, SelectIdName, urldir, SurfacePrice )
{
	zigane = document.getElementById( SelectIdName ).options[document.getElementById( SelectIdName ).selectedIndex].value;

	if( main_m_images[zigane] == undefined ){ main_m_images[zigane] = ""; }

	main_m_image = product_code + "-" + main_m_images[zigane] + "m.jpg";

	document.getElementById(ImageIdName).src = urldir + "upload/save_image/" + main_m_image;



//表面加工が存在していない場合を考慮に入れる必要あり。
//これを忘れるとJavaScriptエラー
//2009/05/18
//結局、ChangeZiganeを要求する商品は必ず表面加工を１つ設定しているので、これは不要と思われる？
//	if( document.ProductDetailForm.pchangeName != undefined )
//	if( !!document.ProductDetailForm.pchangeName )
	if( !!document.getElementById(pchangeName) )
	{
		ChangeSurface( product_code, pchangeName, ImageIdName, SelectIdName, urldir, SurfacePrice );
	}

	ChangeAllPrice();
}





function ChangeSurface( product_code, pchangeName, ImageIdName, SelectIdName, urldir, SurfacePrice )
{
	var zigane = document.getElementById( SelectIdName ).options[document.getElementById( SelectIdName ).selectedIndex].value;
	var ProductArrangePrice = '';
	var tmpArrangePrice = '';

	if( zigane == '' )
	{
		alert('金属を選択してください。');
		return;
	}

	if( !main_m_images[zigane] )
	{
		return;
	}

	if( SurfacePrice == 'Product1SurfacePrice' )
	{
		ProductArrangePrice = 'Product1ArrangePrice';
		tmpArrangePrice = 'tmpArrangePrice1';
	}
	else if( SurfacePrice == 'Product2SurfacePrice' )
	{
		ProductArrangePrice = 'Product2ArrangePrice';
		tmpArrangePrice = 'tmpArrangePrice2';
	}
	else if( SurfacePrice == 'Product3SurfacePrice' )
	{
		ProductArrangePrice = 'Product3ArrangePrice';
		tmpArrangePrice = 'tmpArrangePrice3';
	}

//新しいhidden値を用意し、表面加工の価格を登録しておく。
//ChangeSurfaceが動作するたびに上記のhidden値をチェックしArrangePriceに足す
//	var pchange = document.getElementById( pchangeName );
	var pchange = document.getElementsByName( pchangeName );
	var pchangeValue = 0;

	for( i=0; i<pchange.length; i++ )
	{
		if( pchange[i].checked ){ pchangeValue = pchange[i].value; }
	}

	if( pchangeValue == '2' || pchangeValue == '3' )
	{
		document.getElementById( SurfacePrice ).value = 5250;
		tmpprice =  Number( document.getElementById( ProductArrangePrice ).value ) + 5250;
		document.getElementById( tmpArrangePrice ).innerHTML = addFigure( tmpprice );
//		document.getElementById( ProductArrangePrice ).value = tmpprice;
	}
	else
	{
		document.getElementById( SurfacePrice ).value = 0;
		tmpprice =  Number( document.getElementById( ProductArrangePrice ).value );
		if( tmpprice == '0' ){ tmpprice = ""; }

		document.getElementById( tmpArrangePrice ).innerHTML = addFigure( tmpprice );
//		document.getElementById( ProductArrangePrice ).value = tmpprice;
	}

	if( zigane == '' )
	{
		alert('金属を先に選択してください。');
		return;
	}

	main_m_image = product_code + '-' + main_m_images[ zigane ] + 'm';

				//pchangeの値取得
	pchangeGroup = document.getElementsByName( pchangeName );
	for( i=0; i<pchangeGroup.length; i++ )
	{
		if( pchangeGroup[i].checked == true )
		{
			pchange = pchangeGroup[i].value;
		}
	}

	main_m_image = main_m_image + "-k" + pchange + ".jpg";


//if( product_code == 'ORM-32L' )
//{
	document.getElementById(ImageIdName).src = urldir + "upload/save_image/" + main_m_image;
//}

	ChangeAllPrice();
}


//サイズを選択し直したら、オプションの文字数の関係でやり直しさせる事になる。
//そのアラートとkokuin_charの抹消？
function ChangeSize( oldsizeIdName, sizeIdName, ArrangePriceIdName, ProductArrangePrice, disneyflgInit, disneyflg )
{
	messageflg = 0;
	old_size = document.getElementById( oldsizeIdName ).value;
	size = document.getElementById( sizeIdName ).options[document.getElementById( sizeIdName ).selectedIndex].value;

	if( old_size != '' && old_size != '-1' )
	{
		if( Number(old_size) != Number(size) )
		{
			messageflg = 1;
			document.getElementById( oldsizeIdName ).value = '-1';
			document.getElementById( ArrangePriceIdName ).innerHTML = "";
			document.getElementById( ProductArrangePrice ).value = 0;
		}
	}


	if( old_size == '' )
	{
		document.getElementById( oldsizeIdName ).value = size;
	}

	if( messageflg )
	{
						//ディズニーオプションは発生しないように
						//全ての情報を修正してあげないといけない
						//ディズニー商品かどうか？は
						//Product*disneyflgInit
						//刻印にディズニーが入ってディズニー商品になったかどうか？は
						//Product*disneyflg
		if( document.getElementById( disneyflgInit ).value != '1' )
		{
			document.getElementById( disneyflg ).value = "0";
		}


		alert('サイズが変更になると刻印や裏石・裏彫りの入力文字数が変更となるため、再度オプション選択画面よりご入力ください');

	}

	ChangeAllPrice();
}


//色別に合わせて、メイン画像が変わるようにする
//古い情報を保持しておき、消しにいく必要がある。
//smartRollover.jsを使用しているので、
//_on.gif
//_off.gif
//は特殊な意味がある。そのためこれを使用すると書き換えた後にsmartRollover.jsは上書きしにくるので、
//_on2.gif
//という、実質的に_on.gifと同じファイルを用意して、
//それを利用する。
var NowMainImage = "";
function ChangeMainImage( newImage, newImageDiv, newImageDirection )
{
	var OldDivName = NowMainImage + "_image";

	if( NowMainImage != '' )
	{
		document.getElementById( OldDivName ).src = "img/product/color_variation/" + NowMainImage + "_off.gif";
	}
	document.getElementById( newImageDiv ).src = "img/product/color_variation/" + newImageDirection + "_on2.gif";
	document.getElementById('MainImage').src = "upload/color_image/" + newImage;
	NowMainImage = newImageDirection;

//	alert(newImageDirection+"_on.gif");
}

//ベビーリングで、誕生石を変更した場合の処理を行う
function ChangeStone()
{
	var new_product_id = document.getElementById('product_idByStone').options[document.getElementById('product_idByStone').selectedIndex].value;
	document.location.href = "product_detail" + new_product_id + ".html";
}


function StockCheck(product_idId, kindId, sizeId, pchangeName, MessageId )
{
	var url = "Index/stockcheck";
	var tid = "";
	var params = "";
	var product_id = document.getElementById( product_idId ).value;
	var kind = document.getElementById( kindId ).options[document.getElementById( kindId ).selectedIndex].value;
	var size = document.getElementById( sizeId ).options[document.getElementById( sizeId ).selectedIndex].value;
				//pchangeの値取得
	var pchange = "";
	var pchangeGroup = document.getElementsByName( pchangeName );

	for( i=0; i<pchangeGroup.length; i++ )
	{
		if( pchangeGroup[i].checked == true )
		{
			pchange = pchangeGroup[i].value;
		}
	}

	if( kind == '' || kind == '0' || size == '' || size == '0' ){ return; }

	document.getElementById( MessageId ).innerHTML = "";

	var classcategory_id1 = get_classcategory_id1( kind, size );
	params = 'product_id=' + product_id + '&classcategory_id1=' + classcategory_id1 + '&pchange=' + pchange;


			//XMLデータの取得
	new Ajax.Request(
					url,
					{
						method: 'post',
					    onSuccess: request_ok,
					    onFailure: request_ng,
						parameters: params
					});

	function request_ok(req)
	{
		var mes = req.responseText;
		if( mes != '' )
		{
//			document.getElementById( MessageId ).innerHTML = mes;
//			tid = setTimeout("stockMessageClose('" + MessageId + "')",3000);
		}
	}

	function request_ng(req){}
}


function StockCheckOnlyZigane(product_idId, kindId )
{
	var url = "Index/stockcheck";
	var tid = "";
	var params = "";

	var product_id = document.getElementById( product_idId ).value;
	var kind = document.getElementById( kindId ).options[document.getElementById( kindId ).selectedIndex].value;

	if( kind == '' || kind == '0' ){ return; }

	var classcategory_id1 = get_classcategory_id1OnlyZigane( kind );

	params = 'product_id=' + product_id + '&classcategory_id1=' + classcategory_id1;

			//XMLデータの取得
	new Ajax.Request(
					url,
					{
						method: 'post',
					    onSuccess: request_ok,
					    onFailure: request_ng,
						parameters: params
					});

	function request_ok(req)
	{
		var mes = req.responseText;
		if( mes != '' )
		{
//			document.getElementById('stockMessage').innerHTML = mes;
//			tid = setTimeout("stockMessageClose('stockMessage')",3000);
		}
	}

	function request_ng(req){}
}


function stockMessageClose( MessageId )
{
	document.getElementById( MessageId ).innerHTML = "";
}

function scwindow()
{
	var AllPrice = document.getElementById('AllPrice').innerHTML;
	if( AllPrice == '' ){ AllPrice = '0'; }

	AllPrice = AllPrice.replace(",","");

	var url = "charge.html?AllPrice=" + AllPrice;
	var charge = window.open( url, '_blank', 'width=760,height=550,scrollbars=yes');
}





function GetDisneyOption( disneyflgidname, price )
{
	disneyflg = document.getElementById( disneyflgidname ).value;

	tax = Math.floor( Number(price) * 5 / 105 );

	if( disneyflg == '1' )
	{
				//2011/04/26
				//10%から15%にアップ
//		DisneyOption = Math.floor( ( Number( price ) - Math.floor( Number(price) * 5 / 105 ) ) * 0.1 );
		DisneyOption = Math.floor( ( Number( price ) - Math.floor( Number(price) * 5 / 105 ) ) * 0.15 );
	}
	else
	{
		DisneyOption = 0;
	}

	DisneyOption = Math.floor( DisneyOption * 1.05 );
	return DisneyOption;
}

//ディズニー刻印の関係でかなりの端数が出るので、
//10桁以下は0にしてしまうよう修正
function Erase10( price )
{
	var price_count = String(price).length;
	var price_tmp = String(price).substring( 0,price_count-2);
	var price_formal = String(price_tmp) + '00';
	price = price_formal;

	return price;
}



//お花の販売用　個数が変更されたら合計価格が変わるように。
function ChangeQuantity()
{
	var Product1Price = document.getElementById('Product1Price').value;
	var quantity = document.getElementById('quantity').value;
	var DisneyOption = GetDisneyOption( 'Product1disneyflg', Product1Price );
	Product1Price = Number(Product1Price) + Number(DisneyOption);

	var AllPrice = 0;

				//合計する前に個別商品の１０桁未満切り捨て処理
	var Product1PriceErase = Erase10( Product1Price );
	AllPrice = Number(Product1PriceErase) * Number(quantity);

	AllPrice = Erase10( AllPrice );
	
	document.getElementById( 'AllPrice' ).innerHTML = addFigure( AllPrice );
}

function FlowerInit()
{
	var Product1Price = document.getElementById('Product1Price').value;
	var DisneyOption = GetDisneyOption( 'Product1disneyflg', Product1Price );

	var Product1Price = Number( Product1Price ) + Number( DisneyOption );

	Product1Price = Erase10( Product1Price );
	document.getElementById('AllPrice').innerHTML = addFigure( Product1Price );
	document.getElementById('quantity').selectedIndex = 0;
}

