// JavaScript Document

$(function(){
	
	//会議室一覧の「印刷する」ボタン
	$('#space #btn_space li#btn_print div').hover(function(){
		$(this).css({'background-position':'-150px -30px'});										   
	},function(){
		$(this).css({'background-position':'-150px 0'});
	});
	
	$('#space #btn_space li#btn_print div').click(function(){
		print();
	});
	
	$('#space .plate').hover(function(){
		$('#space #layout_room .plate .picon').show();
	},function(){
		$('#space #layout_room .plate .picon').hide();
	});
	
	$('#space .plate .picon').click(function(){
		this_id = $(this).attr('id');
		this_space = this_id.split('_').slice(1,2);//idのspace名を取得
		this_html = this_space + '_print.html';
		var win = window.open(this_html,"hotShot",",width=740,height=760,toolbar=yes,scrollbars=yes,resizable=yes,menubar=yes");
		win.focus();
	});
	
	
	/* 会議室一覧のwinとMacの文字サイズ調整 */
	if (navigator.appVersion.indexOf("Macintosh") != -1){
		$('#space table.tbl_room th').css({'font-size':'10px'});
		$('#space table.tbl_room td').css({'font-size':'10px'});
	}else{
		$('#space table.tbl_room th').css({'font-size':'11px'});
		$('#space table.tbl_room td').css({'font-size':'12px'});
	}
	
	/* お弁当お飲物のwinとMacの文字サイズ調整 */
	if (navigator.appVersion.indexOf("Macintosh") != -1){
		$('#catering .tbl th').css({'font-size':'11px'});
		$('#catering .tbl td').css({'font-size':'11px'});
	}else{
		$('#catering .tbl th').css({'font-size':'12px'});
		$('#catering .tbl td').css({'font-size':'12px'});
	}
	
	
	/* カレンダーの三番目の右マージンを0にする */
	for (i=1; i<6 ;i++) {
		$('#type_'+i+' table:eq(2)').css({'margin-right':'0'});	
	}
	
	//informationのタイトル幅を調整
	if (navigator.appVersion.indexOf("Macintosh") != -1){
		$('dl#info_list dt div span.title').css({'width':'565px'});
	}
	
	//右側の住所画像の縦サイズの修正
	$('#inquiry_s div img:eq(1)').attr('height','94');
	
	
	//お問い合わせの備考の文言変更
	
	$('#contact form th:last').html('備考<br />（ご利用用途や希望レイアウト等）');
	
	//WEB申込みボタン(空室状況カレンダーボタン)
	$('#secondary div#btn_webreserve').hover(function(){
		$(this).css('background-position','0 -70px');
	},function(){
		$(this).css('background-position','0 0');
	});
	
	$('#secondary div#btn_webreserve').click(function(){
		var win = window.open("../reserve/index.html","hotShot",",width=800,height=800,toolbar=yes,scrollbars=yes,resizable=yes");
		win.focus();
	});
	
	//ウインターキャンペーンの会議室タイトル
	$('#space #stype_4').html('<a href="#cam_6"><img src="../parts/img/space/title_type_4_winter.gif" alt="" height="21" width="665" /></a>');
	//ウインターキャンペーンの会議室タイトル
	$('#space #stype_5').html('<a href="#cam_6"><img src="../parts/img/space/title_type_5_winter.gif" alt="" height="21" width="665" /></a>');
	//ウインターキャンペーンの会議室タイトル
	$('#space #stype_3').html('<a href="#cam_6"><img src="../parts/img/space/title_type_3_winter.gif" alt="" height="21" width="665" /></a>');
	
	
});


function checkForm(){
	
	var errorMsg = "";
	
	var usedate = $('#use_year').val() + $('#use_month').val() +  $('#use_day').val() + $('#use_hour').val();
	
	//alert(usedate);
	
	if(usedate == ""){
		errorMsg = errorMsg + "ご利用日時を入力してください。\n";
	} else {
		if($('#use_year').val()==""){
			errorMsg = errorMsg + "ご利用日時の年を入力してください。\n";
		}
		if($('#use_month').val()==""){
			errorMsg = errorMsg + "ご利用日時の月を入力してください。\n";
		}
		if($('#use_day').val()==""){
			errorMsg = errorMsg + "ご利用日時の日を入力してください。\n";
		}
		if($('#use_hour').val()==""){
			errorMsg = errorMsg + "ご利用日時の時間帯を入力してください。\n";
		}
	}
	
	if($('input#use_num').val()==""){
		errorMsg = errorMsg + "ご利用人数を入力してください。\n";
	}
	
	if($('input#comname').val()==""){
		errorMsg = errorMsg + "会社名／団体名を入力してください。\n";
	}
	
	if($('input#chargename').val()==""){
		errorMsg = errorMsg + "ご担当者名を入力してください。\n";
	}
	
	var phoneNumber = $('input#ph_1').val() +  $('input#ph_2').val() +  $('input#ph_3').val();
	
	if(phoneNumber==""){
		errorMsg = errorMsg + "ご連絡先電話番号を入力してください\n";
	} else {
		if($('input#ph_1').val()==""){
			errorMsg = errorMsg + "ご連絡先の最初の番号を入力してください。\n";
		}
		if($('input#ph_2').val()==""){
			errorMsg = errorMsg + "ご連絡先の2番目の番号を入力してください。\n";
		}
		if($('input#ph_3').val()==""){
			errorMsg = errorMsg + "ご連絡先の3番目の番号を入力してください。\n";
		}
	}
	
	if($('input#email').val()==""){
		errorMsg = errorMsg + "Eメールアドレスを入力してください。\n";
	}
	
	if($("input[@id='inq_1']:checked").val() == undefined && $("input[@id='inq_2']:checked").val() == undefined && $("input[@id='inq_3']:checked").val() == undefined){
		errorMsg = errorMsg + "お問い合わせ事項を選択してください。\n";
	}
	
	if($("input[@id='ans_1']:checked").val() == undefined && $("input[@id='ans_2']:checked").val() == undefined){
		errorMsg = errorMsg + "ご希望の回答方法を選択してください。\n";
	}
	
	if(errorMsg==""){
		if(confirm("お問い合わせを送信してよろしいですか？")){
			return true;
		}else{return false;}
	} else {
		alert(errorMsg);
		return false;
	}
	

}
