// JavaScript Document
var country = '\
AF:Afghanistan|\
AL:Albania|\
DZ:Algeria|\
AS:American Samoa|\
AD:Andorra|\
AO:Angola|\
AI:Anguilla|\
AQ:Antarctica|\
AG:Antigua and Barbuda|\
AR:Argentina|\
AM:Armenia|\
AW:Aruba|\
AU:Australia|\
AT:Austria|\
AZ:Azerbaijan|\
AP:Azores|\
BS:Bahamas|\
BH:Bahrain|\
BD:Bangladesh|\
BB:Barbados|\
BY:Belarus|\
BE:Belgium|\
BZ:Belize|\
BJ:Benin|\
BM:Bermuda|\
BT:Bhutan|\
BO:Bolivia|\
BA:Bosnia And Herzegowina|\
XB:Bosnia-Herzegovina|\
BW:Botswana|\
BV:Bouvet Island|\
BR:Brazil|\
IO:British Indian Ocean Territory|\
VG:British Virgin Islands|\
BN:Brunei Darussalam|\
BG:Bulgaria|\
BF:Burkina Faso|\
BI:Burundi|\
KH:Cambodia|\
CM:Cameroon|\
CA:Canada|\
CV:Cape Verde|\
KY:Cayman Islands|\
CF:Central African Republic|\
TD:Chad|\
CL:Chile|\
CN:China|\
CX:Christmas Island|\
CC:Cocos (Keeling) Islands|\
CO:Colombia|\
KM:Comoros|\
CG:Congo|\
CD:Congo, The Democratic Republic O|\
CK:Cook Islands|\
XE:Corsica|\
CR:Costa Rica|\
CI:Cote d` Ivoire (Ivory Coast)|\
HR:Croatia|\
CU:Cuba|\
CY:Cyprus|\
CZ:Czech Republic|\
DK:Denmark|\
DJ:Djibouti|\
DM:Dominica|\
DO:Dominican Republic|\
TP:East Timor|\
EC:Ecuador|\
EG:Egypt|\
SV:El Salvador|\
GQ:Equatorial Guinea|\
ER:Eritrea|\
EE:Estonia|\
ET:Ethiopia|\
FK:Falkland Islands (Malvinas)|\
FO:Faroe Islands|\
FJ:Fiji|\
FI:Finland|\
FR:France (Includes Monaco)|\
FX:France, Metropolitan|\
GF:French Guiana|\
PF:French Polynesia|\
TA:French Polynesia (Tahiti)|\
TF:French Southern Territories|\
GA:Gabon|\
GM:Gambia|\
GE:Georgia|\
DE:Germany|\
GH:Ghana|\
GI:Gibraltar|\
GR:Greece|\
GL:Greenland|\
GD:Grenada|\
GP:Guadeloupe|\
GU:Guam|\
GT:Guatemala|\
GN:Guinea|\
GW:Guinea-Bissau|\
GY:Guyana|\
HT:Haiti|\
HM:Heard And Mc Donald Islands|\
VA:Holy See (Vatican City State)|\
HN:Honduras|\
HK:Hong Kong|\
HU:Hungary|\
IS:Iceland|\
IN:India|\
ID:Indonesia|\
IR:Iran|\
IQ:Iraq|\
IE:Ireland|\
EI:Ireland (Eire)|\
IL:Israel|\
IT:Italy|\
JM:Jamaica|\
JP:Japan|\
JO:Jordan|\
KZ:Kazakhstan|\
KE:Kenya|\
KI:Kiribati|\
KP:Korea, Democratic People\'S Repub|\
KW:Kuwait|\
KG:Kyrgyzstan|\
LA:Laos|\
LV:Latvia|\
LB:Lebanon|\
LS:Lesotho|\
LR:Liberia|\
LY:Libya|\
LI:Liechtenstein|\
LT:Lithuania|\
LU:Luxembourg|\
MO:Macao|\
MK:Macedonia|\
MG:Madagascar|\
ME:Madeira Islands|\
MW:Malawi|\
MY:Malaysia|\
MV:Maldives|\
ML:Mali|\
MT:Malta|\
MH:Marshall Islands|\
MQ:Martinique|\
MR:Mauritania|\
MU:Mauritius|\
YT:Mayotte|\
MX:Mexico|\
FM:Micronesia, Federated States Of|\
MD:Moldova, Republic Of|\
MC:Monaco|\
MN:Mongolia|\
MS:Montserrat|\
MA:Morocco|\
MZ:Mozambique|\
MM:Myanmar (Burma)|\
NA:Namibia|\
NR:Nauru|\
NP:Nepal|\
NL:Netherlands|\
AN:Netherlands Antilles|\
NC:New Caledonia|\
NZ:New Zealand|\
NI:Nicaragua|\
NE:Niger|\
NG:Nigeria|\
NU:Niue|\
NF:Norfolk Island|\
MP:Northern Mariana Islands|\
NO:Norway|\
OM:Oman|\
PK:Pakistan|\
PW:Palau|\
PS:Palestinian Territory, Occupied|\
PA:Panama|\
PG:Papua New Guinea|\
PY:Paraguay|\
PE:Peru|\
PH:Philippines|\
PN:Pitcairn|\
PL:Poland|\
PT:Portugal|\
PR:Puerto Rico|\
QA:Qatar|\
RE:Reunion|\
RO:Romania|\
RU:Russian Federation|\
RW:Rwanda|\
KN:Saint Kitts And Nevis|\
SM:San Marino|\
ST:Sao Tome and Principe|\
SA:Saudi Arabia|\
SN:Senegal|\
XS:Serbia-Montenegro|\
SC:Seychelles|\
SL:Sierra Leone|\
SG:Singapore|\
SK:Slovak Republic|\
SI:Slovenia|\
SB:Solomon Islands|\
SO:Somalia|\
ZA:South Africa|\
GS:South Georgia And The South Sand|\
KR:South Korea|\
ES:Spain|\
LK:Sri Lanka|\
NV:St. Christopher and Nevis|\
SH:St. Helena|\
LC:St. Lucia|\
PM:St. Pierre and Miquelon|\
VC:St. Vincent and the Grenadines|\
SD:Sudan|\
SR:Suriname|\
SJ:Svalbard And Jan Mayen Islands|\
SZ:Swaziland|\
SE:Sweden|\
CH:Switzerland|\
SY:Syrian Arab Republic|\
TW:Taiwan|\
TJ:Tajikistan|\
TZ:Tanzania|\
TH:Thailand|\
TG:Togo|\
TK:Tokelau|\
TO:Tonga|\
TT:Trinidad and Tobago|\
XU:Tristan da Cunha|\
TN:Tunisia|\
TR:Turkey|\
TM:Turkmenistan|\
TC:Turks and Caicos Islands|\
TV:Tuvalu|\
UG:Uganda|\
UA:Ukraine|\
AE:United Arab Emirates|\
UK:United Kingdom|\
GB:Great Britain|\
US:United States|\
UM:United States Minor Outlying Isl|\
UY:Uruguay|\
UZ:Uzbekistan|\
VU:Vanuatu|\
XV:Vatican City|\
VE:Venezuela|\
VN:Vietnam|\
VI:Virgin Islands (U.S.)|\
WF:Wallis and Furuna Islands|\
EH:Western Sahara|\
WS:Western Samoa|\
YE:Yemen|\
YU:Yugoslavia|\
ZR:Zaire|\
ZM:Zambia|\
ZW:Zimbabwe|\
';

function TrimString(sInString) {
   
   if ( sInString ) {

      sInString = sInString.replace( /^\s+/g, "" );// strip leading
      return sInString.replace( /\s+$/g, "" );// strip trailing
   }
}

// Populates the country select with the counties from the country list
//
function populateCountry(idName) {

   var countryLineArray = country.split('|');      // Split into lines

   var selObj = document.getElementById( idName );

   selObj.options[0] = new Option('Select Country','');
   selObj.selectedIndex = 0;

   for (var loop = 0; loop < countryLineArray.length; loop++) {

      lineArray = countryLineArray[loop].split(':');

      countryCode  = TrimString(lineArray[0]);
      countryName  = TrimString(lineArray[1]);
   
      if ( countryCode != '' ) {

         selObj.options[loop + 1] = new Option(countryName);
      }
   }
}

window.dbIE  = document.all ? true : false;                                // IE 4+
window.dbDOM = (document.getElementById && ! document.all) ? true : false; // NS6, Mozilla, other DOM2 compartible browsers


function dateBox(name, month, day, year) {
   this.name            = name;
   this.day             = day;
   this.month           = month;
   this.year            = year;
   this.id;
 //  this.version         = "2.0.1 [Date Box; 20020109] ";
   this.type            = "dateBox";
   this.startYear       = 2009;
   this.endYear         = 2010;
   this.height          = 20;
   this.shortMonthWidth = 47;
   this.longMonthWidth  = 87;
   this.dayWidth        = 38;
   this.yearWidth       = 54;
   this.fontFamily      = 'Arial, Verdana, Helvetica, Espy, Sans-Serif';
   this.fontSize        = '8pt';
   this.dateBoxStyle    = 'short';

        
   this.shortMonth = [ 'Jan', 'Feb', 'Mar', 
                       'Apr', 'May', 'Jun', 
                       'Jul', 'Aug', 'Sep', 
                       'Oct', 'Nov', 'Dec'
                     ]; 

   this.longMonth  = [ 'January', 'February', 'March', 
                       'April', 'May', 'June', 
                       'July', 'August', 'September', 
                       'Octovber', 'Novvember', 'December'
                     ]; 
                                         
// Other Properties;                                     

   this.HTMLcontainer;
   this.objForm;
   this.objMonth;
   this.objDay;
   this.objYear;
        
// Methods
        
   this.getName            = getName;
        
   this.setDay             = setDay;
   this.getDay             = getDay;
        
   this.setMonth           = setMonth;
   this.getMonth           = getMonth;

   this.setYear            = setYear;
   this.getYear            = getYear;

   this.getID              = getID;
        
   this.setStartYear       = setStartYear;
   this.getStartYear       = getStartYear;
   this.setEndYear         = setEndYear;
   this.getEndYear         = getEndYear;
        
   this.getDateBoxStyle    = getDateBoxStyle;
        
   this.setHeight          = setHeight;
   this.getHeight          = getHeight;
        
   this.setShortMonth      = setShortMonth;
   this.getShortMonth      = getShortMonth;

   this.setLongMonth       = setLongMonth;
   this.getLongMonth       = getLongMonth;
        
   this.getMonthWidth      = getMonthWidth;
        
   this.setDayWidth        = setDayWidth;
   this.getDayWidth        = getDayWidth;
        
   this.setYearWidth       = setYearWidth;
   this.getYearWidth       = getYearWidth;

   this.getMonthName       = getMonthName;

   this.setFontFamily      = setFontFamily;
   this.getFontFamily      = getFontFamily;

   this.setFontSize        = setFontSize;
   this.getFontSize        = getFontSize;
        
   this.setObjPointers     = setObjPointers;
   this.makeDateHTML       = makeDateHTML;
   this.printHTML          = printHTML;
   this.monthDays          = monthDays;
   this.limitList          = limitList
        
   this.getObjForm         = getObjForm;
   this.getObjDay          = getObjDay;
   this.getObjMonth        = getObjMonth;
   this.getObjYear         = getObjYear;
        
   this.getObjSelectedDate = getObjSelectedDate;
   this.setRawDate         = setRawDate;
   this.setObjDate         = setObjDate;
                
//Events
   this.onSelectDate       = onSelectDate;

   var curDate = new Date();
   if (!month) { this.month = curDate.getMonth()+1 };
   if (!day)   { this.day   = curDate.getDate() };
   if (!year)  { 
       if (window.dbDOM) {              
           this.year  = curDate.getYear()+1900;
        } else {
           this.year  = curDate.getYear();
        }
   };
        
   if (!window.dateBoxes) window.dateBoxes = new Array(); 
   this.id=window.dateBoxes.length;
   window.dateBoxes[window.dateBoxes.length] = this;
        
}

/////////////////////////////////////////////////////////////
// dateBox.getName()
function getName() {
   return this.name;
}                

/////////////////////////////////////////////////////////////
// dateBox.setDay()
function setDay(day) {
   this.day=day;
}                

/////////////////////////////////////////////////////////////
// dateBox.getDay()
function getDay() {
   return this.day;
}                

/////////////////////////////////////////////////////////////
// dateBox.setMonth()
function setMonth(month) {
   this.month = month;
}                

/////////////////////////////////////////////////////////////
// dateBox.getMonth()
function getMonth() {
   return this.month;
}                

/////////////////////////////////////////////////////////////
// dateBox.setYear()
function setYear(year) {
   this.year=year;
}                

/////////////////////////////////////////////////////////////
// dateBox.getYear()
function getYear() {
   return this.year;
}                

/////////////////////////////////////////////////////////////
// dateBox.getID()
function getID() {
   return this.id;
}                

/////////////////////////////////////////////////////////////
// dateBox.setStartYear()
function setStartYear(year) {
   this.startYear = year;
}                

/////////////////////////////////////////////////////////////
// dateBox.getStartYear()
function getStartYear() {
   return this.startYear;
}                

/////////////////////////////////////////////////////////////
// dateBox.setEndYear()
function setEndYear(year) {
   this.endYear = year;
}                

/////////////////////////////////////////////////////////////
// dateBox.getEndYear()
function getEndYear() {
   return this.endYear;
}                

/////////////////////////////////////////////////////////////
// dateBox.getDateBoxStyle()
function getDateBoxStyle() {
   return this.dateBoxStyle;
}

/////////////////////////////////////////////////////////////
// dateBox.setShortMonth()
function setShortMonth(monthArray) {
   this.shortMonth=monthArray;
}

/////////////////////////////////////////////////////////////
// dateBox.getShortMonth()
function getShortMonth(monthIndex) {
   return this.shortMonth[monthIndex-1];
}

/////////////////////////////////////////////////////////////
// dateBox.setLongMonth()
function setLongMonth(monthArray) {
   this.longMonth=monthArray;
}

/////////////////////////////////////////////////////////////
// dateBox.getLongMonth()
function getLongMonth(monthIndex) {
   return this.longMonth[monthIndex-1];
}

/////////////////////////////////////////////////////////////
// dateBox.getMonthName()
function getMonthName(monthIndex) {
   if (this.getDateBoxStyle() == 'short') {
      return this.getShortMonth(monthIndex);
   } else {
      return this.getLongMonth(monthIndex);
   }
}

/////////////////////////////////////////////////////////////
// dateBox.setHeight()
function setHeight(height) {
   this.height = height;
}                

/////////////////////////////////////////////////////////////
// dateBox.getHeight()
function getHeight() {
   return this.height;
}

/////////////////////////////////////////////////////////////
// dateBox.setShortMonthWidth()
function setShortMonthWidth(width) {
   this.shortMonthWidth = width;
}                

/////////////////////////////////////////////////////////////
// dateBox.setLongMonthWidth()
function setLongMonthWidth(width) {
   this.longMonthWidth = width;
}                

/////////////////////////////////////////////////////////////
// dateBox.getMonthWidth()
function getMonthWidth() {
   if (this.getDateBoxStyle() == 'short') {
      return this.shortMonthWidth;
   } else {
      return this.longMonthWidth;
   }
}

/////////////////////////////////////////////////////////////
// dateBox.setDayWidth()
function setDayWidth(width) {
   this.dayWidth = width;
}                

/////////////////////////////////////////////////////////////
// dateBox.getDayWidth()
function getDayWidth() {
   return this.dayWidth;
}

/////////////////////////////////////////////////////////////
// dateBox.setYearWidth()
function setYearWidth(width) {
   this.yearWidth = width;
}                

/////////////////////////////////////////////////////////////
// dateBox.getYearWidth()
function getYearWidth() {
   return this.yearWidth;
}

/////////////////////////////////////////////////////////////
// dateBox.setFontFamily()
function setFontFamily(family) {
   this.fontFamily=family;
}

/////////////////////////////////////////////////////////////
// dateBox.getFontFamily()
function getFontFamily() {
   return this.fontFamily;
}

/////////////////////////////////////////////////////////////
// dateBox.setFontSize()
function setFontSize(size) {
   this.fontSize=size;
}

/////////////////////////////////////////////////////////////
// dateBox.getFontSize()
function getFontSize() {
   return this.fontSize;
}

/////////////////////////////////////////////////////////////
// dateBox.getObjForm()
function getObjForm() {
   return this.objForm;
}

/////////////////////////////////////////////////////////////
// dateBox.getObjDay()
function getObjDay() {
   return this.objDay;
}

/////////////////////////////////////////////////////////////
// dateBox.getObjMonth()
function getObjMonth() {
   return this.objMonth;
}

/////////////////////////////////////////////////////////////
// dateBox.getObjYear()
function getObjYear() {
   return this.objYear;
}

/////////////////////////////////////////////////////////////
// dateBox.makeDateHTML()
function makeDateHTML() {
   var dateStr = "";
                
   // Build Month
   dateStr += '<select name="' + this.getName() + 'Month' + 
              '" style="font-family : ' + this.getFontFamily() + 
              '; HEIGHT: ' + this.getHeight() + 'px; WIDTH:' +
              this.getMonthWidth() + 'px; font-size: ' + this.getFontSize() +
              ';" onChange="window.dateBoxes[' + this.getID() + '].onSelectDate()">';

   for (i=1; i<=12;i++) {
       if (this.getMonth() == i) {
          dateStr += '<option selected value=' + i + '>' + this.getMonthName(i);
       } else {
          dateStr += '<option value=' + i + '>' + this.getMonthName(i);
       }
   }
   dateStr += "</select>";

   // Build Day
   dateStr += '<select name="' + this.getName() + 'Day' + 
              '" style="font-family : ' + this.getFontFamily() + 
              '; HEIGHT: ' + this.getHeight() + 'px; WIDTH: ' + 
              this.getDayWidth() + 'px; font-size: ' + this.getFontSize() + 
              ';"  onChange="window.dateBoxes[' + this.getID() + 
              '].onSelectDate()">';

   for (i=1; i<=31; i++) {
       if (this.getDay() == i) {
           dateStr += '<option selected>'+i;
       } else {
         dateStr += '<option>'+i;
       }
   }
   dateStr += "</select>";

   // Build Year
   dateStr += '<select name="' + this.getName() + 'Year' + 
              '" style="font-family : ' + this.getFontFamily() + '; HEIGHT: ' + 
              this.getHeight() + 'px; WIDTH: ' + this.getYearWidth() + 
              'px; font-size: ' + this.getFontSize() + 
              ';" onChange="window.dateBoxes[' + this.getID() + '].onSelectDate()">';
                        
   for (i=this.getStartYear(); i<=this.getEndYear(); i++) {
        if (this.getYear() == i) {
           dateStr += '<option selected>' + i;
        } else {
           dateStr += '<option>' + i;
        }
   }
   dateStr += "</select>";
        
   this.HTMLcontainer=dateStr;     
}

/////////////////////////////////////////////////////////////
// dateBox.printHTML()
function printHTML() {
   document.write(this.HTMLcontainer);
   this.setObjPointers(document.forms[document.forms.length-1]);
   this.limitList(this.monthDays(this.getMonth(),this.getYear()));
}

/////////////////////////////////////////////////////////////
// dateBox.setObjPointers()
function setObjPointers(form) {
   this.objForm  = form;
   this.objDay   = eval("form."+this.getName()+"Day");
   this.objMonth = eval("form."+this.getName()+"Month");
   this.objYear  = eval("form."+this.getName()+"Year");
}

// How many days in the month?
/////////////////////////////////////////////////////////////
// dateBox.monthDays()
function monthDays(month,year) {
   var day = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
   month--;
   if ((year % 4 == 0) && (month==1)) {
       if (year % 100 == 0) {
          if (year % 400 == 0) {
              return 29;
          } else {
              return 28;
          }
       } else {
          return 29;
       }   
  } else { 
     return day[month];
  }
}       

// Event processor
/////////////////////////////////////////////////////////////
// dateBox.onSelectDate()
function onSelectDate() {
   if (window.dbIE || window.dbDOM) {
      var objDay=this.getObjDay();
      var objYear=this.getObjYear();
      var objMonth=this.getObjMonth();

      yearVal=objYear.options[objYear.selectedIndex].text;
      monthVal=objMonth.options[objMonth.selectedIndex].value;
      this.limitList(this.monthDays(monthVal,yearVal));

      this.setDay(objDay.selectedIndex+1);
      this.setMonth(objMonth.selectedIndex+1);
      this.setYear(objYear.selectedIndex+this.startYear);
   }
} 

//Rebuilds dropdown list of day options according to the month
/////////////////////////////////////////////////////////////
// dateBox.limitList()
function limitList(length) {
   list=this.getObjDay();
   if (length<(list.selectedIndex+1)) {
      list.selectedIndex=length-1; 
   }
   if (window.dbIE || window.dbDOM) {
      if (list.options.length<length) {
         for (var i=list.options.length+1; i<=length; i++) { 
             var oOption = document.createElement('OPTION');
             if (window.dbIE) {
                list.options.add(oOption);
                oOption.innerText = i;
                oOption.Value = i;
             } else if (window.dbDOM) {      
                oOption.text = ' '+i;
                oOption.Value = i;
                list.add(oOption,null);
             }
          }
      } else if (list.options.length>length) {
         for (var i=list.options.length; i>=length; i--) { 
             list.remove(i);
         }               
      }
  }
}

// Convert form fields to Date object
/////////////////////////////////////////////////////////////
// dateBox.getObjSelectedDate()
function getObjSelectedDate() {
   if (window.dbIE || window.dbDOM) {
      var objDay=this.getObjDay();
      var objYear=this.getObjYear();
      var objMonth=this.getObjMonth();
                 
      var day=objDay.options[objDay.selectedIndex].text;
      var month=objMonth.options[objMonth.selectedIndex].value-1;
      var year=objYear.options[objYear.selectedIndex].text;
                 
      var dateObj = new Date(year, month, day);
      return dateObj;
   }
}

// Set specified Date
/////////////////////////////////////////////////////////////
// dateBox.setRawDate()
function setRawDate(month,day,year) {
   if (window.dbIE || window.dbDOM) {
      var objDay=this.getObjDay();
      var objYear=this.getObjYear();
      var objMonth=this.getObjMonth();

      this.limitList(this.monthDays(month,year));                    
      objDay.selectedIndex=day-1;
      objMonth.selectedIndex=month-1;
      objYear.selectedIndex=year-this.startYear;
   }
}

/////////////////////////////////////////////////////////////
// dateBox.setObjDate()
function setObjDate(date){
   if (window.dbIE || window.dbDOM) {
       var month = date.getMonth()+1;
       var day   = date.getDate();
       if (window.dbDOM) {             
          var year  = date.getYear()+1900;
       } else {
          var year  = date.getYear();
       }
       this.setRawDate(month,day,year);
   }
}

var date1 = new dateBox("date1"); 
var date2 = new dateBox("date2"); 
	date1.makeDateHTML();
	date2.makeDateHTML(); 
						
function formValidator()
{
	var Name=document.getElementById('Name');
	var Address=document.getElementById('Address');
	var Email=document.getElementById('Email');
	var ValidateEmail=document.getElementById('ValidateEmail');
	var Phone=document.getElementById('Phone');
	//var Country=document.getElementById('countrySelect');
	var Hotel=document.getElementById('Hotel');
	var HotelLocation=document.getElementById('HotelLocation');
	var NoOfGuests=document.getElementById('NoOfGuests');
	var NoofRoom=document.getElementById('NoofRoom');
	var RoomType=document.getElementById('RoomType');
	var Request=document.getElementById('Request');
	
	var frmvalidator  = new Validator('form');

 	frmvalidator.addValidation("Name","req","Please enter your Name");
 	//frmvalidator.addValidation("Name","maxlen=50", "Max length for FirstName is 50");
  	frmvalidator.addValidation("Name","alpha");
	
 	//frmvalidator.addValidation("Address","req","Please enter your Address");
 	//frmvalidator.addValidation("Address","maxlen=50", "Max length for Address is 50");	

 	frmvalidator.addValidation("Email","req","Please enter your Email");
  	//frmvalidator.addValidation("Email","maxlen=50");
  	frmvalidator.addValidation("Email","email");
  
    frmvalidator.addValidation("ValidateEmail","req","Please enter your Email");
  	//frmvalidator.addValidation("Email","maxlen=50");
  	frmvalidator.addValidation("ValidateEmail","ValidateEmail");
	
 	frmvalidator.addValidation("Phone","maxlen=50");
 	frmvalidator.addValidation("Phone","numeric");

 	frmvalidator.addValidation("Hotel","req","Please enter your Hotel");
 	//frmvalidator.addValidation("Hotel","maxlen=50", "Max length for Hotel is 50");	

 	//frmvalidator.addValidation("HotelLocation","req","Please enter your HotelLocation");
 	//frmvalidator.addValidation("HotelLocation","maxlen=50", "Max length for HotelLocation is 50");	

 	frmvalidator.addValidation("Adults","req","Please enter No of Adults");
	frmvalidator.addValidation("Adults","maxlen=3");
	frmvalidator.addValidation("Adults","numeric");
 
	frmvalidator.addValidation("Child","maxlen=3");
	frmvalidator.addValidation("Child","numeric");
	
 	frmvalidator.addValidation("NoofRoom","req","Please enter No of Room");
	frmvalidator.addValidation("NoofRoom","maxlen=3");
	frmvalidator.addValidation("NoofRoom","numeric");
	
	frmvalidator.addValidation("RoomType","req","Please enter the room type");
		
 	frmvalidator.addValidation("Country","dontselect=0");
	frmvalidator.setAddnlValidationFunction("DoCustomValidation")
}

function Validator(frmname)
{
  this.formobj=document.forms[frmname];
	if(!this.formobj)
	{
	  alert("BUG: couldnot get Form object "+frmname);
		return;
	}
	if(this.formobj.onsubmit)
	{
	 this.formobj.old_onsubmit = this.formobj.onsubmit;
	 this.formobj.onsubmit=null;
	}
	else
	{
	 this.formobj.old_onsubmit = null;
	}
	this.formobj.onsubmit=form_submit_handler;
	this.addValidation = add_validation;
	this.setAddnlValidationFunction=set_addnl_vfunction;
	this.clearAllValidations = clear_all_validations;	
}

function set_addnl_vfunction(functionname)
{
  this.formobj.addnlvalidation = functionname;
}

function clear_all_validations()
{
	for(var itr=0;itr < this.formobj.elements.length;itr++)
	{
		this.formobj.elements[itr].validationset = null;
	}
}
function form_submit_handler()
{
	for(var itr=0;itr < this.elements.length;itr++)
	{
		if(this.elements[itr].validationset &&
	   !this.elements[itr].validationset.validate())
		{
		  return false;
		}
	}
	if(this.addnlvalidation)
	{
	  str =" var ret = "+this.addnlvalidation+"()";
	  eval(str);
    if(!ret) return ret;
	}
	return true;
}
function add_validation(itemname,descriptor,errstr)
{
  if(!this.formobj)
	{
	  alert("BUG: the form object is not set properly");
		return;
	}//if
	var itemobj = this.formobj[itemname];
  if(!itemobj)
	{
	  alert("BUG: Couldnot get the input object named: "+itemname);
		return;
	}
	if(!itemobj.validationset)
	{
	  itemobj.validationset = new ValidationSet(itemobj);
	}
  itemobj.validationset.add(descriptor,errstr);
}
function ValidationDesc(inputitem,desc,error)
{
  	this.desc=desc;
	this.error=error;
	this.itemobj = inputitem;
	this.validate=vdesc_validate;
}
function vdesc_validate()
{
 if(!V2validateData(this.desc,this.itemobj,this.error))
 {
    this.itemobj.focus();
		return false;
 }
 return true;
}
function ValidationSet(inputitem)
{
    this.vSet=new Array();
	this.add= add_validationdesc;
	this.validate= vset_validate;
	this.itemobj = inputitem;
}
function add_validationdesc(desc,error)
{
  this.vSet[this.vSet.length]= 
	  new ValidationDesc(this.itemobj,desc,error);
}
function vset_validate()
{
   for(var itr=0;itr<this.vSet.length;itr++)
	 {
	   if(!this.vSet[itr].validate())
		 {
		   return false;
		 }
	 }
	 return true;
}
function validateEmailv2(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
    if(email.length <= 0)
	{
	  return true;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}


function V2validateData(strValidateStr,objValue,strError) 
{ 
    var epos = strValidateStr.search("="); 
    var  command  = ""; 
    var  cmdvalue = ""; 
    if(epos >= 0) 
    { 
     command  = strValidateStr.substring(0,epos); 
     cmdvalue = strValidateStr.substr(epos+1); 
    } 
    else 
    { 
     command = strValidateStr; 
    } 
    switch(command) 
    { 
        case "req": 
        case "required": 
         { 
           if(eval(objValue.value.length) == 0) 
           { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : Required Field"; 
              }//if 
              alert(strError); 
              return false; 
           }//if 
           break;             
         }//case required 
        case "maxlength": 
        case "maxlen": 
          { 
             if(eval(objValue.value.length) >  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : "+cmdvalue+" characters maximum "; 
               }//if 
               alert(strError + "\n[Current length = " + objValue.value.length + " ]"); 
               return false; 
             }//if 
             break; 
          }//case maxlen 
        case "minlength": 
        case "minlen": 
           { 
             if(eval(objValue.value.length) <  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : " + cmdvalue + " characters minimum  "; 
               }//if               
               alert(strError + "\n[Current length = " + objValue.value.length + " ]"); 
               return false;                 
             }//if 
             break; 
            }//case minlen 
        case "alnum": 
        case "alphanumeric": 
           { 
              var charpos = objValue.value.search("[^A-Za-z0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
               if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only alpha-numeric characters allowed "; 
                }//if 
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//case alphanumeric 
        case "num": 
        case "numeric": 
           { 
              var charpos = objValue.value.search("[^0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only digits allowed "; 
                }//if               
                alert(strError); 
				// + "\n [Error character position " + eval(charpos+1)+"]"
                return false; 
              }//if 
              break;               
           }//numeric 
        case "alphabetic": 
        case "alpha": 
           { 
              var charpos = objValue.value.search("[^A-Za-z ]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only alphabet characters allowed "; 
                }//if                             
                alert(strError);
				// + "\n [Error character position " + eval(charpos+1)+"]"
                return false; 
              }//if 
              break; 
           }//alpha 
		case "alnumhyphen":
			{
              var charpos = objValue.value.search("[^A-Za-z0-9\-_]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": characters allowed are A-Z,a-z,0-9,- and _"; 
                }//if                             
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 			
			break;
			}
        case "email": 
          { 
               if(!validateEmailv2(objValue.value)) 
               { 
                 if(!strError || strError.length ==0) 
                 { 
                    strError = objValue.name+": Enter a valid Email address "; 
                 }//if                                               
                 alert(strError); 
                 return false; 
               }//if 
           break; 
          }//case email 
		case "ValidateEmail": 
          { 
		  var Email=document.getElementById('Email')
               if(objValue.value!=Email.value) 
               { 
                 if(!strError || strError.length ==0) 
                 { 
                    strError = objValue.name+": 'Both e-mail address entries must match"; 
                 }//if                                               
                 alert(strError); 
                 return false; 
               }//if 
           break; 
          }//case email 
        case "lt": 
        case "lessthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Should be a number "); 
              return false; 
            }//if 
            if(eval(objValue.value) >=  eval(cmdvalue)) 
            { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : value should be less than "+ cmdvalue; 
              }//if               
              alert(strError); 
              return false;                 
             }//if             
            break; 
         }//case lessthan 
        case "gt": 
        case "greaterthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Should be a number "); 
              return false; 
            }//if 
             if(eval(objValue.value) <=  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : value should be greater than "+ cmdvalue; 
               }//if               
               alert(strError); 
               return false;                 
             }//if             
            break; 
         }//case greaterthan 
        case "regexp": 
         { 
		 	if(objValue.value.length > 0)
			{
	            if(!objValue.value.match(cmdvalue)) 
	            { 
	              if(!strError || strError.length ==0) 
	              { 
	                strError = objValue.name+": Invalid characters found "; 
	              }//if                                                               
	              alert(strError); 
	              return false;                   
	            }//if 
			}
           break; 
         }//case regexp         
		case "dontselect": 
         { 
            if(objValue.selectedIndex == null) 
            { 
              alert("BUG: dontselect command for non-select Item"); 
              return false; 
            } 
            if(objValue.selectedIndex == eval(cmdvalue)) 
            { 
             if(!strError || strError.length ==0) 
              { 
              strError = objValue.name+": Please Select one option "; 
              }//if                                                               
              alert(strError); 
              return false;                                   
             } 
             break; 
         }//case dontselect 
    }//switch 
    return true; 
}

function dateSubmit() 
{
	firstDate  = date1.getObjSelectedDate();
	secondDate = date2.getObjSelectedDate();
	var now = new Date();
	now = now.getTime(); //NN3
	
		if (now>firstDate) 
		{
		alert("Selected date must be at\nleast one day ahead");
		return false;
		}
			else if (firstDate >= secondDate)
			{
				alert("Invalid check out date");
				return false;
			}
		else
	return true;
}

function Radio() {
with (document.form) {
var alertMsg = "The following REQUIRED fields\nhave been left empty:\n";
var message = "You have selected:\n";

radioOption = -1;
for (counter=0; counter<Airport.length; counter++) {
if (Airport[counter].checked) radioOption = counter ;
}
if (radioOption == -1) alertMsg += "\nAirport Transfer";

radioOption = -1;
for (counter=0; counter<Car.length; counter++) {
if (Car[counter].checked) radioOption = counter;
}
if (radioOption == -1) alertMsg += "\nCar Rental";

radioOption = -1;

if (alertMsg != "The following REQUIRED fields\nhave been left empty:\n") {
alert(alertMsg);
return false;
} 
else {
return true;
} } }


function DoCustomValidation()
{
	var frm=document.forms["form"];
	if(false == dateSubmit())
	{return false;}
	else 
	if(false == Radio())
	{return false;}
	else
	{return true;}
}
