var v_intWindWidth = window.screen.width;
v_intWindWidth -= 760;
if (v_intWindWidth >= 0){
v_intWindWidth = v_intWindWidth/2;
}
var NS4 = (document.layers) ? 1 : 0;
var IE4 = (document.all) ? 1 : 0;
var gecko = (document.getElementById) ? 1 : 0;
//multi language var
var g_strLang = 'EN';
var folderColor = "../../Template//" + g_strLang +"/";
var g_strCiDayEmpty = convertUniToASCII(g_strLang,'Please enter Check-In Date')
var g_strCoDayEmpty = convertUniToASCII(g_strLang,'Please enter Check-Out date')
var g_strCiMonthYearEmpty = convertUniToASCII(g_strLang,'Please select month and year of Check-In Date')
var g_strCoMonthYearEmpty = convertUniToASCII(g_strLang,'Please select month and year of Check-Out Date')
var g_strCiIncorrect = convertUniToASCII(g_strLang,'Check-In Date input is incorrect. Please verify.')
var g_strCoIncorrect = convertUniToASCII(g_strLang,'Check-Out Date input is incorrect. Please verify.')
var g_strCoearlierthanci = convertUniToASCII(g_strLang,'Check-Out Date cannot be earlier than Check-In Date')
var g_strCiearlierthannow = convertUniToASCII(g_strLang,'Check-In Date must be the same as or later than Hotel date')
var g_strOneYearCi1 = convertUniToASCII(g_strLang,'Are you sure that the Check-In date is')
var g_strOneYearCi2 = convertUniToASCII(g_strLang,'')
var g_strMonthYearCi = convertUniToASCII(g_strLang,'Are you sure that the period of stay is more than 30 days?')
var g_strChildAge = convertUniToASCII(g_strLang,'Child Age')
var g_strLimitRoom1 = convertUniToASCII(g_strLang,'You are limited to reserve for maximum of')
var g_strLimitRoom2 = convertUniToASCII(g_strLang,'room(s)')
var g_strErrChildAge = convertUniToASCII(g_strLang,'Please enter Children age')
var g_strErrOneYear1 = convertUniToASCII(g_strLang,'Are you sure that the Check-In date is')
var g_strErrOneYear2 = convertUniToASCII(g_strLang,'')
var g_strErrOneMonthCi = convertUniToASCII(g_strLang,'Are you sure that the period of stay is more than 30 days?')
var g_strErrGuestEmail = convertUniToASCII(g_strLang,'Please enter Main Guest Email Address')
var g_strErrInvEmail = convertUniToASCII(g_strLang,'Email Address is invalid. Please verify')
var g_strRoomToAccoAdult = convertUniToASCII(g_strLang,'Please enter number of room to accommodate the number of adult entered')
var g_strErrPromoCode = convertUniToASCII(g_strLang,'Please enter Access Code')
function doSubmitReservation(p_strResvType, p_strAction, p_strIuVerCd){
with(document.forms[0]){
var v_strForm;
var v_strErr;
var v_bolRoom = true;
var v_bolOneYear = true;
var v_dteHotelDate = new Date(HID_HotelDateTime.value);
var v_intnumOfChild;
var v_strPath;
if(typeof(slcChild) != 'undefined'){
v_intnumOfChild = slcChild.options[slcChild.selectedIndex].value;
}else{
v_intnumOfChild = 0;
}
v_dteHotelDate.setHours(0,0,0);
v_strErr = doValidateCICO();
/* eka 11May07
if(typeof(txtPromoCode) == "object")
{
if(getTrim(txtPromoCode.value) == "")
{
v_strErr += g_strErrPromoCode + "\n";
if (v_strErr == "") { txtPromoCode.focus() };
}
}
*/
if(p_strResvType == "ROOM"){
if((v_bolRoom) && (getTrim(txtNumOfRoom.value) != "")){
if (getTrim(HID_HEM060_LimitRoom.value) != "") {
if (parseInt(txtNumOfRoom.value) > parseInt(HID_HEM060_LimitRoom.value)) {
v_bolRoom = false
if (v_strErr == "") { txtNumOfRoom.focus() };
v_strErr += g_strLimitRoom1 + " " + HID_HEM060_LimitRoom.value + " " + g_strLimitRoom2 + "\n";
}
}
}
var v_bolResult = true;
if(v_intnumOfChild > 0){
for(i=1; i <= v_intnumOfChild; i++){
if(eval("txtChildAge" + i).value == ""){
v_bolResult = false;
break;
}
}
if(!v_bolResult){
//Please enter Children age
v_strErr += g_strErrChildAge + "\n";
}
}
}
if(getTrim(v_strErr) != ""){
alert(v_strErr);
}else{
var v_dteCIMonthYear = slcCheckInMonthYear.value.split("/");
var v_dteCOMonthYear = slcCheckOutMonthYear.value.split("/");
if(!compareBetweenTwoDate(slcCheckInMonthYear.options[slcCheckInMonthYear.selectedIndex].value, txtCheckInDay.value, v_dteHotelDate.getMonth() +"/"+ v_dteHotelDate.getUTCFullYear() , v_dteHotelDate.getDate() ,"COMPARE1YEAR"))
{v_bolOneYear = window.confirm(g_strErrOneYear1 + " "+ getMonthName(v_dteCIMonthYear[0]) +" "+ txtCheckInDay.value +", "+ v_dteCIMonthYear[1] +" "+ g_strErrOneYear2 +"\n");}
if(v_bolOneYear){
if (!compareBetweenTwoDate(slcCheckInMonthYear.options[slcCheckInMonthYear.selectedIndex].value, txtCheckInDay.value, slcCheckOutMonthYear.options[slcCheckOutMonthYear.selectedIndex].value, txtCheckOutDay.value ,"COMPARE30"))
{v_bolOneYear = window.confirm(g_strErrOneMonthCi + "\n")}
}
if(v_bolOneYear){
var v_strChildAge = "";
if(v_intnumOfChild > 0){
for(i=1; i <= v_intnumOfChild; i++){
if(typeof(eval("txtChildAge" + i)) == "object"){
v_strChildAge += eval("txtChildAge" + i).value + "|#|"
}
}
}
HID_ChildAge.value = v_strChildAge
HID_CheckIn.value = v_dteCIMonthYear[0] + "/" + getTrim(txtCheckInDay.value) + "/" + v_dteCIMonthYear[1]
HID_CheckOut.value = v_dteCOMonthYear[0] + "/" + getTrim(txtCheckOutDay.value) + "/" + v_dteCOMonthYear[1]
HID_NumOfRoom.value = getTrim(txtNumOfRoom.value)
if((typeof(txtNumOfAdult) == "object")){
HID_NumOfAdult.value = getTrim(txtNumOfAdult.value)
}else
{
HID_NumOfAdult.value = ''
}
HID_NumOfChild.value = v_intnumOfChild
if(typeof(txtPromoCode) == "object")
{
HID_PromoCode.value = getTrim(txtPromoCode.value)
}
if (p_strIuVerCd == "BEIUV1") {
v_strPath = "Iuser-multi/BOtherRsv.asp";
} else {
v_strPath = "ver2.0/Iuser/BOtherRsv.asp"
}
action = get_strPhysicalPath(false) + v_strPath;
target = getTargetWindow();
submit();
if (p_strAction == "CLOSE") {
window.close();
}
}
}
}
}
function getTargetWindow()
{
var v_strResult = "";
var v_strParentWindow;
var v_strDontPopUp = "";
with(document.forms[0]){
if(typeof(HID_ParentWindow) != 'undefined')
{
v_strParentWindow = HID_ParentWindow.value;
}
if(typeof(HID_DontPopUp) != 'undefined')
{
v_strDontPopUp = HID_DontPopUp.value
}
if(HID_PopUpWindow.value == 'Y' && v_strDontPopUp != 'Y'){
v_strResult = "_blank";
}else{
if(v_strParentWindow == 'Y')
{
v_strResult = "_blank";
}
}
}
return v_strResult
}
function doValidateCICO(){
with(document.frmRoomResv){
var v_dteCIDay = txtCheckInDay.value;
var v_dteCIMonthYear = slcCheckInMonthYear.value;
var v_dteCIMonth;
var v_dteCIYear;
var v_dteCIDate;
var v_dteCODay = txtCheckOutDay.value;
var v_dteCOMonthYear = slcCheckOutMonthYear.value;
var v_dteCOMonth;
var v_dteCOYear;
var v_dteCODate;
var v_strErrMsg = "";
if(getTrim(v_dteCIDay) == "" || getTrim(v_dteCIMonthYear) == "pick"){
v_strErrMsg = g_strCiDayEmpty + "\n";
txtCheckInDay.focus();
}
if(getTrim(v_dteCODay) == "" || getTrim(v_dteCOMonthYear) == "pick"){
if(getTrim(v_strErrMsg) == ""){txtCheckOutDay.focus();}
v_strErrMsg += g_strCoDayEmpty + "\n";
}
if(getTrim(v_strErrMsg) == ""){
v_dteCIMonthYear = v_dteCIMonthYear.split("/");
v_dteCIMonth = parseInt(v_dteCIMonthYear[0],10);
v_dteCIYear = parseInt(v_dteCIMonthYear[1],10)
v_dteCIDate = new Date(v_dteCIYear, v_dteCIMonth-1, parseInt(v_dteCIDay,10));
v_dteCOMonthYear = v_dteCOMonthYear.split("/");
v_dteCOMonth = parseInt(v_dteCOMonthYear[0],10);
v_dteCOYear = parseInt(v_dteCOMonthYear[1],10)
v_dteCODate = new Date(v_dteCOYear, v_dteCOMonth-1, parseInt(v_dteCODay,10));
if (!isDate(v_dteCIMonth +"/"+ v_dteCIDay +"/"+ v_dteCIYear, 0)) {
if(getTrim(v_strErrMsg) == ""){txtCheckInDay.focus();}
v_strErrMsg += g_strCiIncorrect + "\n";
}
if (!isDate(v_dteCOMonth +"/"+ v_dteCODay +"/"+ v_dteCOYear, 0)) {
if(getTrim(v_strErrMsg) == ""){txtCheckOutDay.focus();}
v_strErrMsg += g_strCoIncorrect + "\n";
}
if((typeof(txtNumOfAdult) == "object")){
if(typeof(txtNumOfAdult) == "object"){
if(txtNumOfAdult.value != ""){
if(getTrim(txtNumOfRoom.value) == ""){
v_bolRoom = false;
if(getTrim(v_strErrMsg) == ""){txtNumOfRoom.focus();}
v_strErrMsg += g_strRoomToAccoAdult + "\n";
}
}
}
}
}
return v_strErrMsg;
}
}
function showChildAge(){
with(document.forms[0]){
var v_intnumOfChild = slcChild.options[slcChild.selectedIndex].value;
var v_strRowChildAge = "";
var i;
//if(v_intnumOfChild != "0"){
v_strRowChildAge = "
"
divChildAge.innerHTML = v_strRowChildAge
divChildAge.style.display = "block";
//}
}
}
function fSearchAmend() {
with(document.frmAmendment) {
var v_strErrMessage = "";
var v_strFocus = "";
var v_arrDateTimeHotel;
var v_dteDateTimeHotel;
var v_arrTemp;
//get hotel date time
v_arrTemp = HID_HotelDateTime.value.split(" ");
v_arrDateTimeHotel = v_arrTemp[0].split("/");
v_dteDateTimeHotel = new Date(v_arrDateTimeHotel[2], v_arrDateTimeHotel[0]-1, v_arrDateTimeHotel[1])
//start validasi
if (getTrim(txtAmendEmail.value, " ") == "") {
v_strErrMessage += g_strErrGuestEmail + "\n";
if (v_strFocus == "") {
v_strFocus = "txtAmendEmail";
}
} else {
if (!isEmail(getTrim(txtAmendEmail.value))) {
v_strErrMessage += g_strErrInvEmail + "\n";
if (v_strFocus == "") {
v_strFocus = "txtAmendEmail";
}
}
}
if (getTrim(txtAmendDay.value, "") == "" || slcAmendMonthYear.selectedIndex == 0) {
v_strErrMessage += g_strCiDayEmpty + "\n";
if (v_strFocus == "") {
v_strFocus = "txtAmendDay";
}
} else {
v_arrTemp = slcAmendMonthYear.options[slcAmendMonthYear.selectedIndex].value.split("/");
if (!isDate(v_arrTemp[0]+"/"+txtAmendDay.value+"/"+v_arrTemp[1])) {
v_strErrMessage += g_strCiIncorrect + "\n";
if (v_strFocus == "") {
v_strFocus = "txtAmendDay";
}
}
}
if (v_strErrMessage != "") {
alert(v_strErrMessage);
eval(v_strFocus).focus();
} else {
v_arrTemp = slcAmendMonthYear.options[slcAmendMonthYear.selectedIndex].value.split("/");
//set data to hidden
HID_EmailAddress.value = getTrim(txtAmendEmail.value);
HID_CheckIn.value = v_arrTemp[0] +"/"+ getTrim(txtAmendDay.value) +"/"+ v_arrTemp[1];
//to list
action = get_strPhysicalPath(false) + "Ver2.0/Iuser/BOtherRsv.asp";
target = getTargetWindow()
submit();
}
}
}
function fSearchCancellation() {
with(document.frmCancellation) {
var v_strErrMessage = "";
var v_strFocus = "";
var v_arrDateTimeHotel;
var v_dteDateTimeHotel;
var v_arrTemp;
//get hotel date time
v_arrTemp = HID_HotelDateTime.value.split(" ");
v_arrDateTimeHotel = v_arrTemp[0].split("/");
v_dteDateTimeHotel = new Date(v_arrDateTimeHotel[2], v_arrDateTimeHotel[0]-1, v_arrDateTimeHotel[1])
//start validasi
if (getTrim(txtCancelEmail.value, " ") == "") {
v_strErrMessage += g_strErrGuestEmail + "\n";
if (v_strFocus == "") {
v_strFocus = "txtCancelEmail";
}
} else {
if (!isEmail(getTrim(txtCancelEmail.value))) {
v_strErrMessage += g_strErrInvEmail + "\n";
if (v_strFocus == "") {
v_strFocus = "txtCancelEmail";
}
}
}
if (getTrim(txtCancelDay.value, "") == "" || slcCancelMonthYear.selectedIndex == 0) {
v_strErrMessage += g_strCiDayEmpty + "\n";
if (v_strFocus == "") {
v_strFocus = "txtCancelDay";
}
} else {
v_arrTemp = slcCancelMonthYear.options[slcCancelMonthYear.selectedIndex].value.split("/");
if (!isDate(v_arrTemp[0]+"/"+txtCancelDay.value+"/"+v_arrTemp[1])) {
v_strErrMessage += g_strCiIncorrect + "\n";
if (v_strFocus == "") {
v_strFocus = "txtCancelDay";
}
}
}
if (v_strErrMessage != "") {
alert(v_strErrMessage);
eval(v_strFocus).focus();
} else {
v_arrTemp = slcCancelMonthYear.options[slcCancelMonthYear.selectedIndex].value.split("/");
//set data to hidden
HID_EmailAddress.value = getTrim(txtCancelEmail.value);
HID_CheckIn.value = v_arrTemp[0] +"/"+ getTrim(txtCancelDay.value) +"/"+ v_arrTemp[1];
//to list
//action = "M199/List.asp";
action = get_strPhysicalPath(false) + "Ver2.0/Iuser/BOtherRsv.asp";
target = getTargetWindow()
submit();
}
}
}
function getTrim(param){
var value = param
while (value.substring(0,1) == ' ') {
value = value.substring(1,value.length);
}
while (value.substring(value.length-1,value.length) == ' ') {
value = value.substring(0,value.length-1);
}
return value;
}
function getReplace(varString,strRead,strWrite,Sensitivity){
var v_strReCondition
if (arguments.length < 4) {
Sensitivity = 0;
}
v_strReCondition = "g";
if(Sensitivity == 0)
{v_strReCondition = v_strReCondition + "i"}
var re = new RegExp(strRead,v_strReCondition)
return varString.replace(re,strWrite)
};
function convertUniToASCII(p_strLang, p_strUni) {
var tmp,results,i
var tmp2,tmp3;
results = ""
p_strLang = p_strLang.toLowerCase()
if(p_strLang=="ch" || p_strLang=="kr" || p_strLang=="jp" || p_strLang=="cs") {
//tmp = getReplace(p_strUni,";","")
tmp = p_strUni;
tmp = getReplace(tmp,""","\"")
tmp = tmp.split(";")
for(var i=0;i Date.UTC(v_date2.getFullYear(), v_date2.getMonth(), v_date2.getDate())) {
return false;
} else {
return true;
}
}
if (p_option == "COMPARE2") {
if (Date.UTC(v_date1.getFullYear(), v_date1.getMonth(), v_date1.getDate()) >= Date.UTC(v_date2.getFullYear(), v_date2.getMonth(), v_date2.getDate())) {
return false;
} else {
return true;
}
}
if (p_option == "COMPARE_EQUAL") {
if (Date.UTC(v_date1.getFullYear(), v_date1.getMonth(), v_date1.getDate()) != Date.UTC(v_date2.getFullYear(), v_date2.getMonth(), v_date2.getDate())) {
return false;
} else {
return true;
}
}
if (p_option == "COMPARE30") {
if (dateDiff("d", v_date1, v_date2) > 30) {
return false;
} else {
return true;
}
}
if (p_option == "COMPARE1YEAR") {
v_date2.setYear(v_date2.getFullYear() + 1);
if( v_date1 > v_date2 ) {
return false;
} else {
return true;
}
}
}
function dateDiff(p_strType, p_dtFrom, p_dtTo){
var v_dblMicroSecond;
v_dblMicroSecond = Date.UTC( p_dtTo.getFullYear(), p_dtTo.getMonth(), p_dtTo.getDate() ) -
Date.UTC( p_dtFrom.getFullYear(), p_dtFrom.getMonth(), p_dtFrom.getDate() );
switch(p_strType){
case "d":
return v_dblMicroSecond/1000/60/60/24;
break;
case "m":
return v_dblMicroSecond/1000/60/60;
break;
case "n":
return v_dblMicroSecond/1000/60;
break;
case "s":
return v_dblMicroSecond/1000;
break;
}
return true;
}
function isEmail(who) {
var email=/^[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/i;
return(email.test(getTrim(who)));
}
function showCalWithOpt(p_objCaller, p_objForm, p_option, p_intDefLOS) {
with (eval("document."+p_objForm)) {
if (typeof(HID_HotelDateTime) == "object") {
var dateHtl = new Date();
//alert(HID_HotelDateTime.value);
//alert(dateHtl);
//alert("1");
} else {
var dateHtl = new Date(window.opener.document.forms[0].HID_HotelDateTime.value);
//alert("2");
}
//alert(HID_HotelDateTime.value);
//alert(dateHtl);
var monthHtl = dateHtl.getMonth()+1;
var yearHtl = dateHtl.getFullYear();
var yearTo = dateHtl.getFullYear()+1;
var ArrDateInit;
var monthYearObj;
var dayObj;
var monthInit;
var yearInit;
var v_strReserv;
var dayToObj = "";
var monthYearToObj = "";
switch (p_option) {
case "REQUEST" : ArrDateInit = slcCheckInMonthYearReq.value.split('/');
dayObj = "txtCheckOutDayReq";
monthYearObj = "slcCheckOutMonthYearReq";
v_strReserv = "request";
break;
case "REQUEST-CI" : ArrDateInit = slcCheckInMonthYearReq.value.split('/');
dayObj = "txtCheckInDayReq";
monthYearObj = "slcCheckInMonthYearReq";
v_strReserv = "request";
dayToObj = eval(p_objForm +"."+ "txtCheckOutDayReq");
monthYearToObj = eval(p_objForm +"."+ "slcCheckOutMonthYearReq");
break;
case "ROOM" : ArrDateInit = slcCheckInMonthYear.value.split('/');
dayObj = "txtCheckOutDay";
monthYearObj = "slcCheckOutMonthYear";
v_strReserv = "reserv";
break;
case "ROOM-CI" : ArrDateInit = slcCheckInMonthYear.value.split('/');
dayObj = "txtCheckInDay";
monthYearObj = "slcCheckInMonthYear";
v_strReserv = "reserv";
dayToObj = eval(p_objForm +"."+ "txtCheckOutDay");
monthYearToObj = eval(p_objForm +"."+ "slcCheckOutMonthYear");
break;
}
monthInit = ArrDateInit[0];
yearInit = ArrDateInit[1];
if (monthInit == "pick"){
monthInit = '';
yearInit = '';
}
PopCalendar(p_objCaller, '2', eval(p_objForm+'.'+dayObj), eval(p_objForm+'.'+monthYearObj), '', monthInit, yearInit, monthHtl, yearHtl, monthHtl, yearTo, '', '', dayToObj, monthYearToObj, '', p_intDefLOS);
}
}
function writeYearCombo() {
var v_dteToday = new Date()
var v_intMonth = v_dteToday.getMonth()
var v_intYear = v_dteToday.getFullYear()
var v_arrMonthArray = new Array("January", "February", "March", "April", "May", "June", "July", "August",
"September", "October", "November", "December");
for (var i=0;i<24;i++) {
//alert(v_intMonth+1);
document.write("")
v_intMonth += 1
if(v_intMonth > 11) {
v_intMonth = 0;
v_intYear += 1
}
}
}