$(function(){
	// DatePickerを生成する（日付書式を日本語にローカライズ）
		$("#nouhin_date").datepicker({
		dateFormat  : "yy/mm/dd",
		dayNamesMin : [' 日', '月', '火', '水', '木', '金', '土'],
		monthNames  : ['1 月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
		minDate : +1, maxDate: +365  
		});

	//サイドメニュー開閉の実装
	$("div#sidebar .sub_menu").hide();
	$("div#sidebar h4").each(function(i)
	{
		var elementVal = $(this).next(".sub_menu");
		
		$(this).click(function()
		{
			elementVal.toggle("normal");
			//$(".sub_menu + h4").css.("border-top", "1px solid #FFF");
		});
	});
	//サイドメニュー開閉しない項目のためのCSS切替
	$("div#sidebar h4").hover(
		function(){
			$(this).children().css( 'color', '#FFFFFF' );
		}
		,
		function(){
			$(this).children().css( 'color', '#000000' );
		}
	);
　//Ltoneデザイン名刺のセレクタ切替
　$("#meishi_type_sl").change(function () {
		//alert($("#meishi_type_sl").val());
		$("#meishi_no_sl option").hide();
		$('#meishi_no_sl .c_' + $("#meishi_type_sl").val()).show();
	}).trigger('change');
	
	//colorbox-mochu
	$(".mochu_menu a").colorbox({transition:"none", height:"90%"});
	
	//colorbox-nenga
	$(".nenga_item_check a").colorbox({transition:"none", height:"90%"});
	$("#d_no").change(function () {
		var index = this.selectedIndex;
		
		if (index > 1 && index < 10) {
			index = index -1;
			my_str = '<a href="http://www.erutone.com/LT/wp-content/uploads/n0' + index + '.jpg" target="_blank">［クリックで確認］</a>';
		} else if (index == 12) {
			index = index -3;
			my_str = '<a href="http://www.erutone.com/LT/wp-content/uploads/n0' + index + '.jpg" target="_blank">［クリックで確認］</a>';
		} else if (index > 12 && index < 54) {
			index = index -3;
			my_str = '<a href="http://www.erutone.com/LT/wp-content/uploads/n' + index + '.jpg" target="_blank">［クリックで確認］</a>';
		} else if (index > 55 && index < 60) {
			index = index -5;
			my_str = '<a href="http://www.erutone.com/LT/wp-content/uploads/n' + index + '.jpg" target="_blank">［クリックで確認］</a>';
		} else if (index > 61 && index < 82) {
			index = index -7;
			my_str = '<a href="http://www.erutone.com/LT/wp-content/uploads/n' + index + '.jpg" target="_blank">［クリックで確認］</a>';
		} else {
			my_str = '［デザインが選択されていません］';
		}
		
		$(".nenga_item_check").html(my_str);
		$(".nenga_item_check a").colorbox({transition:"none", height:"90%"});
	});
	
	$("#d_no2").change(function () {
		var index = this.selectedIndex;
		
		if (index > 1 && index < 10) {
			index = index -1;
			my_str = '<a href="http://www.erutone.com/LT/wp-content/uploads/n0' + index + '.jpg" target="_blank">［クリックで確認］</a>';
		} else if (index == 12) {
			index = index -3;
			my_str = '<a href="http://www.erutone.com/LT/wp-content/uploads/n0' + index + '.jpg" target="_blank">［クリックで確認］</a>';
		} else if (index > 12 && index < 54) {
			index = index -3;
			my_str = '<a href="http://www.erutone.com/LT/wp-content/uploads/n' + index + '.jpg" target="_blank">［クリックで確認］</a>';
		} else if (index > 55 && index < 60) {
			index = index -5;
			my_str = '<a href="http://www.erutone.com/LT/wp-content/uploads/n' + index + '.jpg" target="_blank">［クリックで確認］</a>';
		} else if (index > 61 && index < 82) {
			index = index -7;
			my_str = '<a href="http://www.erutone.com/LT/wp-content/uploads/n' + index + '.jpg" target="_blank">［クリックで確認］</a>';
		} else {
			my_str = '';
		}
		
		$(".nenga_item_check2").html(my_str);
		$(".nenga_item_check2 a").colorbox({transition:"none", height:"90%"});
	});

	$("#d_no3").change(function () {
		var index = this.selectedIndex;
		
		if (index > 1 && index < 10) {
			index = index -1;
			my_str = '<a href="http://www.erutone.com/LT/wp-content/uploads/n0' + index + '.jpg" target="_blank">［クリックで確認］</a>';
		} else if (index == 12) {
			index = index -3;
			my_str = '<a href="http://www.erutone.com/LT/wp-content/uploads/n0' + index + '.jpg" target="_blank">［クリックで確認］</a>';
		} else if (index > 12 && index < 54) {
			index = index -3;
			my_str = '<a href="http://www.erutone.com/LT/wp-content/uploads/n' + index + '.jpg" target="_blank">［クリックで確認］</a>';
		} else if (index > 55 && index < 60) {
			index = index -5;
			my_str = '<a href="http://www.erutone.com/LT/wp-content/uploads/n' + index + '.jpg" target="_blank">［クリックで確認］</a>';
		} else if (index > 61 && index < 82) {
			index = index -7;
			my_str = '<a href="http://www.erutone.com/LT/wp-content/uploads/n' + index + '.jpg" target="_blank">［クリックで確認］</a>';
		} else {
			my_str = '';
		}
		
		$(".nenga_item_check3").html(my_str);
		$(".nenga_item_check3 a").colorbox({transition:"none", height:"90%"});
	});

	$("#d_no4").change(function () {
		var index = this.selectedIndex;
		
		if (index > 1 && index < 10) {
			index = index -1;
			my_str = '<a href="http://www.erutone.com/LT/wp-content/uploads/n0' + index + '.jpg" target="_blank">［クリックで確認］</a>';
		} else if (index == 12) {
			index = index -3;
			my_str = '<a href="http://www.erutone.com/LT/wp-content/uploads/n0' + index + '.jpg" target="_blank">［クリックで確認］</a>';
		} else if (index > 12 && index < 54) {
			index = index -3;
			my_str = '<a href="http://www.erutone.com/LT/wp-content/uploads/n' + index + '.jpg" target="_blank">［クリックで確認］</a>';
		} else if (index > 55 && index < 60) {
			index = index -5;
			my_str = '<a href="http://www.erutone.com/LT/wp-content/uploads/n' + index + '.jpg" target="_blank">［クリックで確認］</a>';
		} else if (index > 61 && index < 82) {
			index = index -7;
			my_str = '<a href="http://www.erutone.com/LT/wp-content/uploads/n' + index + '.jpg" target="_blank">［クリックで確認］</a>';
		} else {
			my_str = '';
		}
		
		$(".nenga_item_check4").html(my_str);
		$(".nenga_item_check4 a").colorbox({transition:"none", height:"90%"});
	});

	//詳細開閉
	$("div#form_onoff .sub_content").hide();
	$("div#form_onoff .on_off").each(function(i)
	{
		var elementVal = $(this).next(".sub_content");
		$(this).click(function()
		{
			elementVal.toggle("normal");
		});
	});

	//詳細開閉
	$("div#form_mochu_onoff .m_sub_content").hide();
	$("div#form_mochu_onoff .m_on_off").each(function(i)
	{
		var elementVal = $(this).next(".m_sub_content");
		$(this).click(function()
		{
			elementVal.toggle("normal");
		});
	});

	//喪中フォーム
	$("#m_no").change(function () {
		var index = this.selectedIndex +810;
		if (index > 810 && index < 831) {
			my_str = '<img src="./images/' + index + '.jpg" width="250px" height="369px" />' + index;
		} else {
			my_str = '［デザインが選択されていません］';
		}
		$(".mochu_img_area").html(my_str);
		if (index==811 || index==812 ||index==819 ||index==820 ||index==824 ||index==828 ||index==829) {
			my_opt_str = '亡くなられた月：<input type="text" name="亡くなられた月" size="6" maxlength="6"> 月<br /> ';
			my_opt_str = my_opt_str + '亡くなられた方の続柄：<input type="text" name="続柄" size="8" maxlength="8"><br />';
			my_opt_str = my_opt_str + '亡くなられた方のお名前：<input type="text" name="亡くなられた方のお名前" size="14"><br />';
			my_opt_str = my_opt_str + '享年<input type="text" name="享年" size="6" maxlength="6"> 才<br />';
			$(".mochu_opt").html(my_opt_str);
		} else if (index==815 || index==816) {
			my_opt_str = '亡くなられた月：<input type="text" name="亡くなられた月" size="6" maxlength="6"> 月<br /> ';
			my_opt_str = my_opt_str + '亡くなられた方の続柄：<input type="text" name="続柄" size="8" maxlength="8"><br />';
			$(".mochu_opt").html(my_opt_str);
		} else if (index==817 || index==818) {
			my_opt_str = '亡くなられた方の続柄：<input type="text" name="続柄" size="8" maxlength="8"><br />';
			$(".mochu_opt").html(my_opt_str);
		} else {
			my_opt_str = 'このデザインには、差替項目はございません。 ';
			$(".mochu_opt").html(my_opt_str);
		}
	$("#more_order :checkbox:checked").attr("checked", "");
	});
	
	$("#more_order").change(function () {
			my_opt_opt_str = '同一デザイン、同一住所の場合には、続柄や差出人を変更することが可能です。<br />';
			
			var $select = $("#m_no");
			var index = $select.get(0).selectedIndex + 810;
			//my_opt_opt_str = my_opt_opt_str + "(" + index + "）<br />";
			
			if (index==813 || index==814 ||index==821 ||index==822 ||index==823 ||index==825 ||index==826 ||index==827 ||index==830) {		
				my_opt_opt_str = my_opt_opt_str + '差出人名：<input type="text" name="追加２（差出人名）" size="14">　';
				my_opt_opt_str = my_opt_opt_str + '発注枚数：<input type="text" name="追加２（発注枚数）" size="6" maxlength="6"> 枚<br />';
				my_opt_opt_str = my_opt_opt_str + '差出人名：<input type="text" name="追加３（差出人名）" size="14">　';
				my_opt_opt_str = my_opt_opt_str + '発注枚数：<input type="text" name="追加３（発注枚数）" size="6" maxlength="6"> 枚<br />';
			} else {
				my_opt_opt_str = my_opt_opt_str + '変更する続柄：<input type="text" name="追加２（続柄）" size="6" maxlength="6">　';
				my_opt_opt_str = my_opt_opt_str + '差出人名：<input type="text" name="追加２（差出人名）" size="14">　';
				my_opt_opt_str = my_opt_opt_str + '発注枚数：<input type="text" name="追加２（発注枚数）" size="6" maxlength="6"> 枚<br />';
				my_opt_opt_str = my_opt_opt_str + '変更する続柄：<input type="text" name="追加３（続柄）" size="6" maxlength="6">　';
				my_opt_opt_str = my_opt_opt_str + '差出人名：<input type="text" name="追加３（差出人名）" size="14">　';
				my_opt_opt_str = my_opt_opt_str + '発注枚数：<input type="text" name="追加３（発注枚数）" size="6" maxlength="6"> 枚<br />';
			}
			
			//my_opt_opt_str = my_opt_opt_str + 'デザインを変更する場合は、一度、追加発注のチェックボックスのチェックをはずしてください。';
			if (index < 823) {
				my_opt_opt_str_d = '<input type="hidden" name="デザイン選択番号" value="墨-' + index + '"><br />';
			} else {
				my_opt_opt_str_d = '<input type="hidden" name="デザイン選択番号" value="カ-' + index + '"><br />';
			}
			
			if (this.checked) {
				$(".mochu_opt_opt").html(my_opt_opt_str);
				$("#m_no").attr("disabled", true);
				$(".mochu_opt_opt_aten").html('デザインを変更する場合は、一度、複数発注のチェックボックスのチェックをはずしてください。');
				$(".mochu_opt_opt_aten_hid").html(my_opt_opt_str_d);
			} else {
				$(".mochu_opt_opt").html('');
				$("#m_no").attr("disabled", false);
				$(".mochu_opt_opt_aten").html('');
				$(".mochu_opt_opt_aten_hid").html('');
			}

	});

});

