
var months = new Array();
i = 0;
months[i] = 'January'; i++;
months[i] = 'February'; i++;
months[i] = 'March'; i++;
months[i] = 'April'; i++;
months[i] = 'May'; i++;
months[i] = 'June'; i++;
months[i] = 'July'; i++;
months[i] = 'August'; i++;
months[i] = 'September'; i++;
months[i] = 'October'; i++;
months[i] = 'November'; i++;
months[i] = 'December';

function printMonth(){
  var now = new Date();
  var current = now.getMonth();
  document.write('<select class="f" name="month">');
  for(i=0; i < months.length; i++) {
    txt = '<option value="' + months[i] + '"';
    if (i == current) {
      txt = txt + ' selected';
    }
    txt = txt + '>' + months[i] + '</option>';
    document.write(txt);
  }
  document.write('</select>');
}

function printDay() {
  var now = new Date();
  var current = now.getDate();
  document.write('<select class="f" name="day">');
  for(i=1; i <= 31; i++) {
    txt = '<option value="' + i + '"';
    if (i == current) {
      txt = txt + ' selected';
    }
    txt = txt + '>' + i + '</option>';
    document.write(txt);
  }
  document.write('</select>');
}

function printYear() {
  var now = new Date();
  var current = now.getFullYear();
  document.write('<select class="f" name="year">');
  for(i=0; i < 6; i++) {
    txt = '<option value="' + (current+i) + '"';
    if (i == 0) {
      txt = txt + ' selected';
    }
    txt = txt + '>' + (current+i) + '</option>';
    document.write(txt);
  }
  document.write('</select>');
}

function frmValid(theForm) {
  // buddy must have a name
  t = theForm.realname.value.toLowerCase();
  if( t == "" || t.length < 3 || t.indexOf("abc") >= 0 || t.indexOf("xyz") >= 0 || t.indexOf("fuck") >= 0 ){
    alert("Please enter your Name.");
    theForm.realname.focus();
    return (false);
  }

  // buddy must have a address
  t = theForm.address.value.toLowerCase();
  if( t == "" || t.length < 3 || t.indexOf("abc") >= 0 || t.indexOf("xyz") >= 0 || t.indexOf("fuck") >= 0 ){
    alert("Please enter your Address.");
    theForm.address.focus();
    return (false);
  }

  // buddy must have a country
  t = theForm.country.value.toLowerCase();
  if( t == "" || t.length < 3 || t.indexOf("abc") >= 0 || t.indexOf("xyz") >= 0 || t.indexOf("fuck") >= 0 ){
    alert("Please enter your Country Name.");
    theForm.country.focus();
    return (false);
  }

  // buddy must have a phone no.
  t = theForm.country_code.value.toLowerCase();
  if( t == "" || t.length < 1 || t.indexOf("abc") >= 0 || t.indexOf("xyz") >= 0 || t.indexOf("fuck") >= 0 ){
    alert("Please enter your Country Code.");
    theForm.country_code.focus();
    return (false);
  }

  // buddy must have a phone no.
  t = theForm.area_code.value.toLowerCase();
  if( t == "" || t.length < 1 || t.indexOf("abc") >= 0 || t.indexOf("xyz") >= 0 || t.indexOf("fuck") >= 0 ){
    alert("Please enter your Area Code.");
    theForm.area_code.focus();
    return (false);
  }

  // buddy must have a phone no.
  t = theForm.telephone.value.toLowerCase();
  if( t == "" || t.length < 3 || t.indexOf("abc") >= 0 || t.indexOf("xyz") >= 0 || t.indexOf("fuck") >= 0 ){
    alert("Please enter your Phone No.");
    theForm.telephone.focus();
    return (false);
  }

  // check e-mail
  t = theForm.email.value;
  if( t == "your@company.com" || t == "" || t.indexOf("@") == -1 || t.indexOf(".") == -1 || t.indexOf(" ")!=-1 || t.length < 6 || t.indexOf("xyz.com") > 0 || t.indexOf("abc.com") > 0 || t.indexOf("jagatniwaspalace.com") > 0 ) {
    alert("Your Email seems to be invalid!");
    theForm.email.focus();
    return (false);
  }


  // room type
  t = theForm.room_type.value.toLowerCase();
  if( t == "" || parseFloat(t) <= 0 ){
    alert("Please Select your Room Type.");
    theForm.room_type.focus();
    return (false);
  }

  // No of Rooms
  t = theForm.no_of_rooms.value;
  if( t == "" || parseFloat(t) <= 0 ){
    alert("Please enter the number of Rooms.");
    theForm.no_of_rooms.focus();
    return (false);
  }

  t = theForm.period_of_stay.value;
  if( t == "" || parseFloat(t) <= 0 ){
    alert("Please enter the number of days you intend to stay with us.");
    theForm.period_of_stay.focus();
    return (false);
  }


  // Message
  t = theForm.message.value;
  if( t == "" || parseFloat(t) <= 0 ){
    alert("Please enter your Message.");
    theForm.message.focus();
    return (false);
  }

  // all's well ends well
  return true;
}
