// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this notice.

// SETUPS:
// ===============================

// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><META HTTP-EQUIV=imagetoolbar CONTENT=no><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" oncontextmenu="return false" onselectstart="return false" ondragstart="return false" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
close();		
}}

function check_form() {
  if(document.reservations.title.value.length == 0 ){
    alert('Please select title...');
	document.reservations.title.focus();
    return false;
  }
  if (document.reservations.fname.value.length == 0) {
    alert("Please input your first name ...")
    document.reservations.fname.focus()
    return false
  }
  if (document.reservations.lname.value.length == 0) {
    alert("Please input your last name ...")
    document.reservations.lname.focus()
    return false
  }
  if (document.reservations.addr1.value.length == 0) {
    alert("Please input your address ...")
    document.reservations.addr1.focus()
    return false
  }
  if (document.reservations.city.value.length == 0) {
    alert("Please input your city ...")
    document.reservations.city.focus()
    return false
  }
  if (document.reservations.phone.value.length == 0) {
    alert("Please input your telephone ...")
    document.reservations.phone.focus()
    return false
  }
  if (document.reservations.handphone.value.length == 0) {
    alert("Please input your handphone ...")
    document.reservations.handphone.focus()
    return false
  }

  if (document.reservations.email.value.length == 0) {
    alert("Please input your e-mail ...")
    document.reservations.email.focus()
    return false
  }
  else {
  	if (document.reservations.email.value.indexOf('@') <= 0 || document.reservations.email.value.indexOf('.') <= 0 || document.reservations.email.value.indexOf('@') > document.reservations.email.value.lastIndexOf('.')) {
      alert("Sorry, invalid format of e-mail ...")
      document.reservations.email.focus()
      return false
    }
  }
  if (!document.reservations.ptype[0].checked && !document.reservations.ptype[1].checked) {
    alert("Please choose Regular Booking Rate or Special Package ...")
    return false
  }
  if (!document.reservations.zamrud.checked && !document.reservations.mutiara.checked && !document.reservations.berlian.checked) {
    alert("Please choose at least one option for Zamrud Cottage, Mutiara Cottage or Berlian Cottage ...")
    return false
  }
  if (document.reservations.zamrud.checked) {
    if (document.reservations.zamrudcottageno.value.length == 0) {
      alert("Please input number of cottages for Zamrud Cottage ...")
      document.reservations.zamrudcottageno.focus()
      return false
    }
    if (document.reservations.zamrudtnoperson.value.length == 0) {
      alert("Please input number of persons for Zamrud Cottage ...")
      document.reservations.zamrudtnoperson.focus()
      return false
    }
  }
  if (document.reservations.mutiara.checked) {
    if (document.reservations.mutiaracottageno.value.length == 0) {
      alert("Please input number of cottages for Mutiara Cottage ...")
      document.reservations.mutiaracottageno.focus()
      return false
    }
    if (document.reservations.mutiaratnoperson.value.length == 0) {
      alert("Please input number of persons for Mutiara Cottage ...")
      document.reservations.mutiaratnoperson.focus()
      return false
    }
  }
  if (document.reservations.berlian.checked) {
    if (document.reservations.berliancottageno.value.length == 0) {
      alert("Please input number of cottages for Berlian Cottage ...")
      document.reservations.berliancottageno.focus()
      return false
    }
    if (document.reservations.berliantnoperson.value.length == 0) {
      alert("Please input number of persons for Berlian Cottage ...")
      document.reservations.berliantnoperson.focus()
      return false
    }
  }
  for (nextchar = 0; nextchar <= eval(document.reservations.cindd.value.length - 1); nextchar++) {
    if (document.reservations.cindd.value.charCodeAt(nextchar) < 48 || document.reservations.cindd.value.charCodeAt(nextchar) > 57) {
      alert("Sorry, invalid format of check in date ...")
      document.reservations.cindd.focus()
      return false
    }
  }
  if (document.reservations.cindd.value < 1 || document.reservations.cindd.value > 31) {
    alert("Sorry, invalid format of check in date ...")
    document.reservations.cindd.focus()
    return false
  }
  if (document.reservations.cinyyyy[document.reservations.cinyyyy.selectedIndex].value < 2000 || document.reservations.cinyyyy[document.reservations.cinyyyy.selectedIndex].value > 2099) {
    alert("Sorry, invalid format of check in date ...")
    document.reservations.cinyyyy.focus()
    return false
  }
  for (nextchar = 0; nextchar <= eval(document.reservations.cinhh.value.length - 1); nextchar++) {
    if (document.reservations.cinhh.value.charCodeAt(nextchar) < 48 || document.reservations.cinhh.value.charCodeAt(nextchar) > 57) {
    alert("Please input check in time ...")
      document.reservations.cinhh.focus()
      return false
    }
  }
  if (document.reservations.cinhh.value.length == 0) {
    alert("Please input check in time ...")
    document.reservations.cinhh.focus()
    return false
  }
  else {
    if (document.reservations.cinhh.value < 0 || document.reservations.cinhh.value > 23) {
      alert("Sorry, invalid check in time ...")
      document.reservations.cinhh.focus()
      return false
    }
  }
  for (nextchar = 0; nextchar <= eval(document.reservations.cinmn.value.length - 1); nextchar++) {
    if (document.reservations.cinmn.value.charCodeAt(nextchar) < 48 || document.reservations.cinmn.value.charCodeAt(nextchar) > 57) {
    alert("Please input check in time ...")
      document.reservations.cinmn.focus()
      return false
    }
  }
  if (document.reservations.cinmn.value.length == 0) {
    alert("Please input check in time ...")
    document.reservations.cinmn.focus()
    return false
  }
  else {
    if (document.reservations.cinmn.value < 0 || document.reservations.cinmn.value > 59) {
      alert("Sorry, invalid check in time ...")
      document.reservations.cinmn.focus()
      return false
    }
  }
  for (nextchar = 0; nextchar <= eval(document.reservations.coutdd.value.length - 1); nextchar++) {
    if (document.reservations.coutdd.value.charCodeAt(nextchar) < 48 || document.reservations.coutdd.value.charCodeAt(nextchar) > 57) {
    alert("Sorry, invalid format of check out date ...")
      document.reservations.coutdd.focus()
      return false
    }
  }
  if (document.reservations.coutdd.value < 1 || document.reservations.coutdd.value > 31) {
    alert("Sorry, invalid format of check out date ...")
    document.reservations.coutdd.focus()
    return false
  }
  if (document.reservations.coutyyyy[document.reservations.coutyyyy.selectedIndex].value < 2000 || document.reservations.coutyyyy[document.reservations.coutyyyy.selectedIndex].value > 2099) {
    alert("Sorry, invalid format of check out date ...")
    document.reservations.coutyyyy.focus()
    return false
  }
  for (nextchar = 0; nextchar <= eval(document.reservations.couthh.value.length - 1); nextchar++) {
    if (document.reservations.couthh.value.charCodeAt(nextchar) < 48 || document.reservations.couthh.value.charCodeAt(nextchar) > 57) {
    alert("Please input check out time ...")
      document.reservations.couthh.focus()
      return false
    }
  }
  if (document.reservations.couthh.value.length == 0) {
    alert("Please input check out time ...")
    document.reservations.couthh.focus()
    return false
  }
  else {
    if (document.reservations.couthh.value < 0 || document.reservations.couthh.value > 23) {
      alert("Sorry, invalid check out time ...")
      document.reservations.couthh.focus()
      return false
    }
  }
  for (nextchar = 0; nextchar <= eval(document.reservations.coutmn.value.length - 1); nextchar++) {
    if (document.reservations.coutmn.value.charCodeAt(nextchar) < 48 || document.reservations.coutmn.value.charCodeAt(nextchar) > 57) {
    alert("Please input check out time ...")
      document.reservations.coutmn.focus()
      return false
    }
  }
  if (document.reservations.coutmn.value.length == 0) {
    alert("Please input check out time ...")
    document.reservations.coutmn.focus()
    return false
  }
  else {
    if (document.reservations.coutmn.value < 0 || document.reservations.coutmn.value > 59) {
      alert("Sorry, invalid check out time ...")
      document.reservations.coutmn.focus()
      return false
    }
  }

  checkin = new Date()
  checkin.setDate(document.reservations.cindd.value)
  cinmonth = eval(document.reservations.cinmm.value - 1)
  checkin.setMonth(cinmonth)
  checkin.setYear(document.reservations.cinyyyy.value)
  checkin.setHours(document.reservations.cinhh.value)
  checkin.setMinutes(document.reservations.cinmn.value)

  checkout = new Date()
  checkout.setDate(document.reservations.coutdd.value)
  coutmonth = eval(document.reservations.coutmm.value - 1)
  checkout.setMonth(coutmonth)
  checkout.setYear(document.reservations.coutyyyy.value)
  checkout.setHours(document.reservations.couthh.value)
  checkout.setMinutes(document.reservations.coutmn.value)

  if (checkin > checkout) {
    alert("Sorry, invalid between check in and check out ...")
    return false
  }
  return true;
}
function check_formLets() {
  if(document.form.name.value.length == 0 ){
    alert('Please input your name...');
	document.form.name.focus();
    return false;
  }
  if (document.form.email.value.length == 0) {
    alert("Please input your e-mail ...")
    document.form.email.focus()
    return false
  }
  else {
  	if (document.form.email.value.indexOf('@') <= 0 || document.form.email.value.indexOf('.') <= 0 || document.form.email.value.indexOf('@') > document.form.email.value.lastIndexOf('.')) {
      alert("Sorry, invalid format of e-mail ...")
      document.form.email.focus()
      return false
    }
  }
  if (document.form.phone.value.length == 0) {
    alert("Please input your telephone ...")
    document.form.phone.focus()
    return false
  }
  if (document.form.addr.value.length == 0) {
    alert("Please input your address ...")
    document.form.addr.focus()
    return false
  }
   if (document.form.comment.value.length == 0) {
    alert("Please input your comments ...")
    document.form.comment.focus()
    return false
  }
  return true;
}