//index.js

var winID=null;

function hideITable() {
	//alert("hidden!");
	//document.myTable.style.visibility = 'hidden';
	document.getElementById("myTable").style.visibility = 'hidden';
}

function getEvent(){     //相容 IE 及 Firefox 的寫法  

	if(document.all)    return window.event;          

	func=getEvent.caller;              

	while(func!=null){      

		var arg0=func.arguments[0];  

		if(arg0){  

			if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){
				return arg0;  
			}

    }  
		func=func.caller;  

	}  
	return null;  

}  

function showITable(inx,myLang) {

	//alert("event.clientX="+event.clientX+",event.clientY="+event.clientY);
	//alert("event.offsetX="+event.offsetX+",event.offsetY="+event.offsetY);
	
	//alert(myLang);
	var subname = new Array(2);
	var sublink = new Array(2);
	var new_path="/"+GetLangPath(GV_Language)+"/";
	switch(myLang) {
		case "EN":
			subname[0]=["Standard Single Room","Superior Single Room","Executive Single Room","Deluxe Single Room","Family Double Bed Room","VIP Suite"];
			subname[1]=["Restaurant","Breakfast","Lunch","Tea"];		
			break;
		case "JP":
			subname[0]=["スタンダードルーム","スペリアルーム","エグゼクティブルーム","デラックスルーム","ファミリールーム","VIPスイート"];
			subname[1]=["レストラン紹介","朝食","ランチ","ティータイム"];		
			break;
		case "KR":
			subname[0]=["표준 1인실","고급 1인실","호화 1인실","최고급 1인실","가족형 더블 베드 룸","VIP 룸"];
			subname[1]=["다이닝","아침 식사","점심 식사","애프터눈 티"];		
			break;			
		default:
			subname[0]=["儷人房","主題房","經典房","豪華房","親子房","貴賓房"];
			subname[1]=["餐廳介紹","早餐","午餐","下午茶"];		
	}
		
	sublink[0]=["room-sts.html","room-sps.html","room-exs.html","room-dxs.html","room-fat.html","room-vip.html"];
	sublink[1]=["restaurant.html","breakfast.html","lunch.html","tea.html"];
	var idx=0;
	var menu_str='<table width="100" border="0" cellpadding="3" cellspacing="0">';
	for(idx=0; idx < subname[inx].length ; idx++)
	{
			//menu_str += '<tr><td bgcolor="#CCCCCC" nowrap><a href="' + new_path + sublink[inx][idx] + '">' + subname[inx][idx] + '</a></td></tr>';
			menu_str += '<tr><td bgcolor="#FDF7E3" style="cursor:hand" onmouseover="ColorShow(this,\'#ffe6e6\');" onmouseout="ColorShow(this,\'#FDF7E3\');" onClick="location.href=\'' + new_path + sublink[inx][idx] + '\';" nowrap>' + subname[inx][idx] + '</td></tr>';
	}
	menu_str += '</tabel>';
	document.getElementById("submenu").innerHTML=menu_str;

	var evt=getEvent();
	posY = 60;
	//alert(myTable.offsetWidth);
	//myTable.offsetWidth = myTable.offsetWidth + 10;
	if(document.all)
	{
		posX = event.clientX;
	}
	else
	{
		posX = evt.clientX;
		//posX = 340;
	}
	//alert("posX="+posX);
	document.getElementById("myTable").style.position = 'absolute';
	document.getElementById("myTable").style.left = posX;
	document.getElementById("myTable").style.top = posY;		
	document.getElementById("myTable").style.visibility = '';
	
}
/*
function GoToPage(myPage) {
	var my_path=GetLangPath(GV_Language);
	var myURL="/"+my_path+"/"+myPage;
	//alert("myURL="+myURL);
	location.href=myURL;
}
*/
function ColorShow(myObj,my_color)
{
	myObj.style.backgroundColor=my_color;
}


function ShowCalendar(myobj,mydatename) {
	//myform=myobj.form;
	
	with(myobj.form) {
		
		//alert("CheckDate!");
		var evt=getEvent();

		if(document.all)
		{
			posX=event.clientX - 290;
			posY=event.clientY - 80;			
		}
		else
		{
			posX=evt.clientX - 290;
			posY=evt.clientY - 80;			
		}		
		var winFeature ="width=290,height=160,innerHeight=160,innerWidth=290";
		winFeature += ",screenX="+posX+",screenY="+posY+",left="+posX+",top="+posY;
		
		winFeature += ",status=1";
		var myURL="/util/calendar.php?datename="+mydatename;
		
		//alert(myobj.value);
		
		if(myobj.value.length > 0)
		{
			var date_ary = new Array;
			date_ary = myobj.value.split("-");
			//alert("&qyear="+date_ary[0]+"&qmonth="+date_ary[1]);
			myURL += "&qyear="+date_ary[0]+"&qmonth="+date_ary[1];
		}
		
		winID = window.open(myURL,"carlendar_win",winFeature);
		winID.focus();
	}
}

function CheckCheckInDate() {
	
	with(document.DateForm) {
	  if(CheckInDate.value.length==0)
	  {
	  	alert("請輸入入住日期！");
	  	return;
	  }
		if(CheckOutDate.value.length > 0)
		{
			var in_ary=CheckInDate.value.split("-");
			var out_ary=CheckOutDate.value.split("-");
			
			var CheckOutTime = new Date();
			CheckOutTime.setFullYear(out_ary[0]);
			CheckOutTime.setMonth(out_ary[1]-1);
			CheckOutTime.setDate(out_ary[2]);
			//alert("CheckOutDate:" + out_ary[0]+"-"+out_ary[1]+"-"+out_ary[2]);
			//alert("CheckOutDate:"+CheckOutTime);
			var CheckInTime = new Date();
			CheckInTime.setFullYear(in_ary[0]);
			CheckInTime.setMonth(in_ary[1]-1);
			CheckInTime.setDate(in_ary[2]);
			//alert("CheckInDate:" + in_ary[0]+"-"+in_ary[1]+"-"+in_ary[2]);
			//alert("CheckInDate:"+CheckInTime);

			//alert("CheckOutDate:"+CheckOutTime.getTime());
			//alert("CheckInDate:"+CheckInTime.getTime());
			if(CheckInTime.getTime() >= CheckOutTime.getTime())
			{
				alert("請確認輸入的日期是否正確！");
				return;
			}
		}
		submit();
	}
	
}

function CheckDate(myform) {
	with(myform) {
		
		if( (CheckInYear.value.length == 0) || (isNaN(CheckInYear.value)) )
		{
			alert("請確認輸入的日期是否正確！");
			CheckInYear.focus();
			return false;
		}
		if( (CheckInMonth.value.length == 0) || (isNaN(CheckInMonth.value)) )
		{
			alert("請確認輸入的日期是否正確！");
			CheckInMonth.focus();
			return false;
		}
		if( (CheckInDay.value.length == 0) || (isNaN(CheckInDay.value)) )
		{
			alert("請確認輸入的日期是否正確！");
			CheckInDay.focus();
			return false;
		}
		if( (CheckOutYear.value.length == 0) || (isNaN(CheckOutYear.value)) )
		{
			alert("請確認輸入的日期是否正確！");
			CheckOutYear.focus();
			return false;
		}
		if( (CheckOutMonth.value.length == 0) || (isNaN(CheckOutMonth.value)) )
		{
			alert("請確認輸入的日期是否正確！");
			CheckOutMonth.focus();
			return false;
		}
		if( (CheckOutDay.value.length == 0) || (isNaN(CheckOutDay.value)) )
		{
			alert("請確認輸入的日期是否正確！");
			CheckOutDay.focus();
			return false;
		}
		var CheckOutDate = new Date();
		CheckOutDate.setFullYear(CheckOutYear.value);
		CheckOutDate.setMonth(CheckOutMonth.value-1);
		CheckOutDate.setDate(CheckOutDay.value);
		
		//alert(CheckOutDate);		
		var CheckInDate = new Date();
		CheckInDate.setFullYear(CheckInYear.value);
		CheckInDate.setMonth(CheckInMonth.value-1);
		CheckInDate.setDate(CheckInDay.value);
		
		//alert(CheckInDate);

		if(CheckInDate.getTime() >= CheckOutDate.getTime())
		{
			alert("請確認輸入的日期是否正確！");
			CheckInYear.focus();
			return false;
		}
		
		return true;
	}
}


//========




