var arrRoomsName = new Array("Superior Single","Superior Twin","Superior Double","Deluxe Double");
var arrRoomsExt = new Array(0,0,0,0,0);
var arrSeasonsName = new Array("Peak Period","Peak Season","Green Season","Peak Season","Peak Period");
var disco;
var arrSeasonsStart = new Array();
t = new Date();
t.setFullYear(2000,0,1);
arrSeasonsStart[0] = t.getTime();
t = new Date();
t.setFullYear(2000,0,4);
arrSeasonsStart[1] = t.getTime();
t = new Date();
t.setFullYear(2000,4,1);
arrSeasonsStart[2] = t.getTime();
t = new Date();
t.setFullYear(2000,9,1);
arrSeasonsStart[3] = t.getTime();
t = new Date();
t.setFullYear(2000,11,28);
arrSeasonsStart[4] = t.getTime();
var arrSeasonsEnd = new Array();
t = new Date();
t.setFullYear(2000,0,3);
arrSeasonsEnd[0] = t.getTime();
t = new Date();
t.setFullYear(2000,3,30);
arrSeasonsEnd[1] = t.getTime();
t = new Date();
t.setFullYear(2000,8,30);
arrSeasonsEnd[2] = t.getTime();
t = new Date();
t.setFullYear(2000,11,27);
arrSeasonsEnd[3] = t.getTime();
t = new Date();
t.setFullYear(2000,11,31);
arrSeasonsEnd[4] = t.getTime();
var arrPrices = new Array();
arrPrices[0] = new Array();
arrPrices[0][0] = 2960;
arrPrices[0][1] = 3440;
arrPrices[0][2] = 3440;
arrPrices[0][3] = 3760;
arrPrices[0][4] = 0;
arrPrices[1] = new Array();
arrPrices[1][0] = 2560;
arrPrices[1][1] = 3040;
arrPrices[1][2] = 3040;
arrPrices[1][3] = 3360;
arrPrices[1][4] = 0;
arrPrices[2] = new Array();
arrPrices[2][0] = 1900;
arrPrices[2][1] = 2100;
arrPrices[2][2] = 2100;
arrPrices[2][3] = 2400;
arrPrices[2][4] = 0;
arrPrices[3] = new Array();
arrPrices[3][0] = 2560;
arrPrices[3][1] = 3040;
arrPrices[3][2] = 3040;
arrPrices[3][3] = 3360;
arrPrices[3][4] = 0;
arrPrices[4] = new Array();
arrPrices[4][0] = 2960;
arrPrices[4][1] = 3440;
arrPrices[4][2] = 3440;
arrPrices[4][3] = 3760;
arrPrices[4][4] = 0;
var nLine;
function addNewLine() {
line = nLine + 1;
tbl = document.getElementById("tblBook");
var newRow = tblBook.insertRow(line);
newRow.bgColor = "#FFFF99";
var newCell = newRow.insertCell(0);
strOptions = "\r\n";
for (i = 0;i < arrRoomsName.length;i++) {
strOptions += "\r\n";
}
newCell.innerHTML = " ";
newCell2 = newRow.insertCell(1);
newCell2.align = "right";
newCell2.innerHTML = "0";
newCell3 = newRow.insertCell(2);
newCell3.align = "right";
newCell3.innerHTML = "0";
nLine++;
document.getElementById("nLine").value = nLine;
}
function chkSel(obj) {
strchk = "sr" + nLine;
if (strchk == obj.name) {
addNewLine();
}
thisline = obj.name.substr(2);
nNight = document.getElementById("night").innerHTML;
aaDay = document.getElementById("aday");
aaMonth = document.getElementById("amonth");
aaYear = document.getElementById("ayear");
dateStart = new Date();
dateStart.setFullYear(aaYear.value,aaMonth.value - 1,aaDay.value);
nTotalPrice = 0;
strOut = "";
last = "";
xx = 1;
oldsea = 0;
stsea = 0;
for (o = 0;o < nNight;o++) {
sea = chkSeason(dateStart);
nTotalPrice += arrPrices[sea][obj.value - 1];
if (last != sea) {
if (last != "") {
if (xx > 0) strOut += ") x " + xx + "
\r\n";
}
else {
if (Math.abs(xx - 1) > 0) strOut += faceNum(arrPrices[oldsea][obj.value - 1]) + " (" + arrSeasonsName[oldsea] + ") x " + Math.abs(xx - 1) + "
\r\n";
}
strOut += faceNum(arrPrices[sea][obj.value - 1]) + " (" + arrSeasonsName[sea];
last = sea;
xx = 1;
stsea = sea;
}
else xx++;
oldsea = sea;
dateStart.setDate(dateStart.getDate() + 1 - 0);
}
if (strOut == "") {
strOut = faceNum(arrPrices[sea][obj.value - 1]) + " (" + arrSeasonsName[sea];
xx--;
}
strOut += ") x " + xx;
thisprice = arrPrices[0][obj.value - 1];
tbl.rows[thisline].cells[1].innerHTML = "" + strOut + "";
if (obj.value == 0) nTotalPrice = 0;
tbl.rows[thisline].cells[2].innerHTML = "" + faceNum(nTotalPrice) + "";
tbl.rows[thisline].cells[2].nnn = nTotalPrice;
updateTotal();
}
function chkNight() {
aaDay = document.getElementById("aday");
aaMonth = document.getElementById("amonth");
aaYear = document.getElementById("ayear");
ddDay = document.getElementById("dday");
ddMonth = document.getElementById("dmonth");
ddYear = document.getElementById("dyear");
dateStart = new Date();
dateStart.setFullYear(aaYear.value,aaMonth.value - 1,aaDay.value);
var toodstart = new Date();
toodstart = dateStart.getTime();
dateEnd = new Date();
dateEnd.setFullYear(ddYear.value,ddMonth.value - 1,ddDay.value);
if (dateEnd.getTime() <= dateStart.getTime()) {
dateEnd = dateStart;
dateEnd.setDate(dateEnd.getDate() + 1 - 0);
//alert(dateStart.getDate() + "(" + aaDay.value + ") > " + dateEnd.getDate());
ddDay.value = dateEnd.getDate();
ddMonth.value = dateEnd.getMonth() + 1 - 0;
ddYear.value = dateEnd.getYear();
}
for (i = 1;dateStart.getTime() < dateEnd.getTime();i++) {
dateStart.setDate(dateStart.getDate() + 1);
}
if (i > 1) i--;
var tood = new Date();
for (ito = 1;tood.getTime() < toodstart;ito++) {
tood.setDate(tood.getDate() + 1);
}
if (ito >= 30) disco = 1;
else disco = 0;
document.getElementById("night").innerHTML = i;
updateAll();
document.getElementById("nNight").value = i;
}
function chkSeason(tim) {
ychk = tim.getYear();
out = 0;
chk1 = new Date();
chk2 = new Date();
tim.setYear(2000);
for (i = 0;i < arrSeasonsName.length;i++) {
chk1.setTime(arrSeasonsStart[i]);
chk2.setTime(arrSeasonsEnd[i]);
chk2.setDate(chk2.getDate() + 1 - 0);
if (tim.getTime() >= chk1.getTime() && tim.getTime() <= chk2.getTime()) {
out = i;
}
}
return out;
}
function updateTotal() {
tbl = document.getElementById("tblBook");
allPrice = 0;
for (i = 1;i < nLine;i++) {
allPrice += tbl.rows[i].cells[2].nnn - 0;
}
if(disco == 1)
{
allPrice *= 0.85;
document.getElementById("disc").innerHTML = "Discounted!!";
}
else document.getElementById("disc").innerHTML = "";
airport = document.getElementById("airport");
allPrice += 100 * airport.value;
document.getElementById("total").innerHTML = faceNum(allPrice);
sendtotal = document.getElementById("sendtotal");
sendtotal.value = faceNum(allPrice);
}
function updateAll() {
tbl = document.getElementById("tblBook");
allPrice = 0;
for (ux = 1;ux < nLine;ux++) {
var ll = document.getElementById("sr" + ux);
if (ll.value > 0) chkSel(ll);
}
}
function faceNum(nFace) {
strOut = "";
nFace += "";
nFA = nFace.length;
ooo = 0;
for (ifn = Math.abs(nFA - 1);ifn >= 0;ifn--) {
ooo++;
strOut = nFace.substr(ifn,1) + strOut;
if (ooo >= 3 && ifn > 0) {
strOut = "," + strOut;
ooo = 0;
}
}
return strOut;
}
function chkRequire() {
bCheck = false;
if (form1.title.value == "") bCheck = true;
if (form1.name.value == "") bCheck = true;
if (form1.fname.value == "") bCheck = true;
if (form1.email.value == "") bCheck = true;
if (form1.address.value == "") bCheck = true;
if (form1.city.value == "") bCheck = true;
if (form1.province.value == "") bCheck = true;
if (form1.country.value == "") bCheck = true;
if (form1.national.value == "") bCheck = true;
if (form1.telephone.value == "") bCheck = true;
if (bCheck) {
alert("Please input all require field");
return false;
}
return true;
}
function autoFill() {
form2.automail.value = form1.automail.value;
form2.submit();
}
function chkFormat(obj) {
var pex = new RegExp("^\\d{1,3}$","g");
if (obj.value.match(pex)) return true;
else {
alert("Please input only digit number.");
obj.focus();
}
return false;
}