function validate(val){
if (""+val+""=="undefined"){val="";return val;}
return val;
}
var _domain=""+document.domain+"";
if (_domain.indexOf("www")==-1){var _domain="www.dallashotelseye.com";}
var _subd="reservations."+_domain.substring(4,_domain.length)+"";
_domain=""+document.domain+"";

function eng(formname,currency,cid,country,stateprov,city,hotid,lmark,lmarkname,subd,divid){
var args=eng.arguments;
formname=validate(formname);
currency=validate(currency);
cid=validate(cid);
country=validate(country);
city=validate(city);
hotid=validate(hotid);
stateprov=validate(stateprov);
lmark=validate(lmark);
lmarkname=validate(lmarkname);
subd=validate(subd);
divid=validate(divid);
if (formname==""){alert("FORM NAME is invalid");return;}
if (currency==""){alert("CURRENCY is invalid");return;}
if (cid==""){alert("CID is invalid");return;}
if (divid==""){alert("DIV ID is invalid");return;}
	
var _params="formname="+formname+"&currency="+currency+"&cid="+cid+"&country="+country+"&stateprovince="+stateprov+"&city="+city+"&hotid="+hotid+"&landmarkid="+lmark+"&landmarkname="+lmarkname+"&linkdomain="+_subd+"";
var _url="booking_eng.php?"+_params+"";
engload(_url,divid,formname,cid);
}

function engload(url,posId,formname,cid) {
var http_request = null;
	if (window.XMLHttpRequest) {
	http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) { 
		http_request.overrideMimeType("application/xhtml+xml");
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
http_request.onreadystatechange = function() { showEng(http_request,posId,formname,cid,url); };
http_request.open('GET', (url), true);
http_request.send(null);
}

function showEng(http_request,posId,formname,cid,url) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			if (posId.indexOf("|")>-1){
				var ids=posId.split("|");
				document.getElementById(ids[0]).innerHTML=getForm("hotSearch",http_request.responseText,cid);
				document.getElementById(ids[1]).innerHTML=getForm("hotSearch1",http_request.responseText,cid);
			}else{
				var _frmtxt=replaceTxt(http_request.responseText,formname);
				document.getElementById(posId).innerHTML=_frmtxt;
			}
			
			refresh(formname);
			
			if (formname=="airForm"){
				loadDates(document.forms[0].departureMonth,document.forms[0].departureDay,document.forms[0].returnMonth,document.forms[0].returnDay);
			}else if(formname=="carForm") {
				loadDates(document.forms[0].pickUpMonth,document.forms[0].pickUpDay,document.forms[0].dropOffMonth,document.forms[0].dropOffDay);
			}else if(formname.indexOf("hotSearch")>-1 || formname=="vacationRentals") {
				loadDates(document.forms[0].arrivalMonth,document.forms[0].arrivalDay,document.forms[0].departureMonth,document.forms[0].departureDay);
				try{
					loadDates(document.forms[1].arrivalMonth,document.forms[1].arrivalDay,document.forms[1].departureMonth,document.forms[1].departureDay);
				}catch(ex){}
			}else if(formname=="AdvancedForm") {
				loadCruiseDates(document.forms[0].Month);
			}
		
		} else {
			//if (confirm('There was a problem with the request.')){
				//window.open(url,'','');	
			//}
		}
	}
}

function getForm(frm,txt,cid){
var _retTxt="<form name=\""+frm+"\" action=\"http://"+_subd+"/index.jsp?cid="+cid+"\" onsubmit=\"return submitForm(this,"+cid+");\" method=\"post\" style=\"margin:0px\">";
_retTxt+=replaceTxt(txt,frm);
_retTxt+="</form>";
return _retTxt;
}

function replaceTxt(txt,name){
var _txt=txt.replace("<PARAMTAG>","<div id=\""+name+"_params\" style=\"display:none;\"></div>");
_txt=_txt.replace(/<FORMNAME>/g,name);
return _txt;
}


///////////////////////////////////////////////

function isBrowserSupp() {version = parseFloat(navigator.appVersion);if ((version>=2.0)&&(version<2.1)&&(navigator.appName.indexOf("Netscape")!=-1)){return false;}else{return true;}return true;}
function isLeapYear(yrStr) {var leapYear=false;var year=parseInt(yrStr,10);if(year%4 ==0){leapYear=true;if(year%100==0){leapYear=false;if(year%400==0){leapYear=true;}}}return leapYear;}
function getDaysInMonth(mthIdx,YrStr){var maxDays=31;if(mthIdx==1){if(isLeapYear(YrStr)){maxDays=29;}else{maxDays=28;}}if(mthIdx==3||mthIdx==5||mthIdx==8||mthIdx==10){maxDays=30;}return maxDays;}

function adjustDate(mthIdx,Dt){
var value=0;
var today=new Date()
var theYear=parseInt(today.getYear(),10)
if(mthIdx<today.getMonth()){theYear=(parseInt(today.getYear(),10)+1)}
if(theYear<100){theYear="19"+theYear
}else{
if((theYear-100)<10){theYear="0"+(theYear-100)}else{theYear=(theYear-100)+""}theYear="20"+theYear}
var numDays=getDaysInMonth(mthIdx,theYear);
	if(mthIdx==1){
		if(Dt.options.selectedIndex+1<numDays){
			return 0;
		}else{
		Dt.options.selectedIndex=numDays-1;
			if(numDays==29){return 99;}else{return 1;}
		}
	}
	if(Dt.options.selectedIndex+1<numDays){
		value=0;
	}else{
		if(Dt.options.selectedIndex+1>numDays){
			Dt.options.selectedIndex--;
			value=3;
		}else{
			value=2;
		}
	}
return value;
}

function amadChange(inM,inD,outM,outD){
if(!isBrowserSupp()){
	return;
}
var res=adjustDate(inM.options.selectedIndex,inD);
if(res!=0){
	outD.options.selectedIndex=0;
	if(outM.options.selectedIndex==11){
		outM.options.selectedIndex=0
	}else{
		outM.options.selectedIndex=inM.options.selectedIndex+1;
		outD.options.selectedIndex=1;
	}
}else{
	outM.options.selectedIndex=inM.options.selectedIndex;
	if(outD.options.selectedIndex<=inD.options.selectedIndex){
		outD.options.selectedIndex=inD.options.selectedIndex+2;
	}
}
return;
}

function dmddChange(outM,outD){
	if(!isBrowserSupp()){return;}
	adjustDate(outM.options.selectedIndex,outD);
return;
}

function loadDates(arrivalMonthSelect,arrivalDaySelect,departureMonthSelect,departureDaySelect){
	var calendar=new Date();
	var calendar2=new Date();
	var cal; var cal2; var date;var month;var year;var date2;var month2;var year2;
	var advanceArrival=14;
	var advanceDeparture=16;
	calendar.setDate(calendar.getDate()+advanceArrival);date=calendar.getDate();month=calendar.getMonth();
	calendar2.setDate(calendar2.getDate()+advanceDeparture);
	date2=calendar2.getDate();
	month2=calendar2.getMonth();
	arrivalMonthSelect.value=month;
	arrivalDaySelect.value=date;
	departureMonthSelect.value=month2;
	departureDaySelect.value=date2;
}

function loadCruiseDates(mnth){
	var cal=new Date();
	var _mnths = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	mnth.options.length=0;
	mnth.options[0]=new Option("All Dates","ALL");
	var _mth=cal.getMonth()-1;
	var _yr=cal.getFullYear();
	var _mInc=-1;
	for (jj=1; jj<=18; jj++){
		_mth++;
		if (_mth>11){_mth=0;_yr++;}
		mnth.options[jj]=new Option(""+_mnths[_mth]+" "+_yr+"",""+(_mth+1)+"/1/"+_yr+"");
	}

}

function update(themonth,theday){
	document.forms[fName].elements[formType+'Day'].options[theday - 1].selected = true;
	document.forms[fName].elements[formType+'Month'].options[themonth].selected = true;
	testWindow.close();
}

function loadCalendar(viewMonth) {
testWindow.document.close();
testWindow.document.open();
var day_of_week = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
var month_of_year = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var dateObj = new Date();
var year = dateObj.getYear();
var month = dateObj.getMonth();
var today = dateObj.getDate();
var weekday = dateObj.getDay();
var DAYS_OF_WEEK = 7;
var DAYS_OF_MONTH = 31;
var cal;
if (viewMonth<month) {
year = year+1;
}
if(year<1900){year += 1900;}
month = viewMonth;
dateObj.setDate(1);
dateObj.setMonth(month);
dateObj.setYear((year));

var TR_start = '<tr>\n';
var TR_end = '</tr>\n';
var highlight_start = '<td width="30"><table align="center" cellspacing="0" cellpadding="0" border="0"><tr>\n<td align="center"><b>';
var highlight_end   = '</td>\n</tr>\n</table>';
var TD_start = '<td width="30" align="center">';
var TD_end = '</td>\n';
var prevM = month - 1;
var nextM = month + 1;
if (nextM == 12) {
nextM = 0;
}
if (prevM == -1) {
prevM = 11;
}
cal ='<?xml version="1.0" encoding="UTF-8"?>\n'+
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n'+
'<html xmlns="http://www.w3.org/1999/xhtml">\n'+
'<head>\n'+
'<title>Calendar</title>\n'+
'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\n'+
'<style type="text/css">'+
'body {margin: 5px;padding: 0px;}'+
'* {font-family: "Trebuchet MS", Tahoma, Verdana;font-size: 12px;}\n'+
'.tbl a{text-align: center;text-decoration: none;cursor:pointer;}\n'+
'.tbl th {padding:3px 0px;background-color: #FFFF99; color: #000066;}'+
'.tbl .days th {color: #FFFFFF;background-color: #000066;}'+
'.tbl a,a{text-align: center;text-decoration: none;cursor:pointer;}\n'+
'.tbl a div{padding:3px 0px;text-align: center;cursor:pointer;}\n'+
'.tbl a:link,a:visited,a:active{color: #000080;background-color: #CCCCCC;}\n'+
'.tbl a:hover{color: #FFFFFF;background-color: #FF9900;}\n'+
'.nav a:link,.nav a:visited,.nav a:hover,.nav a:active{color: #000080;background-color: #FFFFFF;}\n'+
'</style>\n'+
'</head>\n'+
'<body>\n'+
'<table border="0" cellpadding="0" cellspacing="1" class="tbl">\n'+
'<tr class="days">\n'+
'<th colspan="7">'+month_of_year[month]+' '+year+'</th>\n'+
'</tr>\n';
cal+= TR_start;
for(index=0; index < DAYS_OF_WEEK; index++) {
cal += '<th width="30">'+day_of_week[index]+'</th>';
}
cal += TR_end;
if (dateObj.getDay()!=0){
cal += TR_start;
for(index=0; index < dateObj.getDay(); index++) {
cal += '<td width="30">&nbsp;</td>';
}
}
for(index=0; index < DAYS_OF_MONTH; index++) {
if( dateObj.getDate() > index ) {
week_day =dateObj.getDay();
if(week_day == 0) {
cal += TR_end+'\n'+TR_start;
}
if(week_day != DAYS_OF_WEEK) {
var day  = dateObj.getDate();
__day=day;
if (day<10){__day='0'+day}
cal += '<td width="30"><a href="JavaScript:window.opener.update('+month+','+day+')"><div style="width:30px;">'+__day+'</div></a></td>\n';
}
if(week_day == DAYS_OF_WEEK) {
cal += TR_end;
}
}
dateObj.setDate(dateObj.getDate()+1);
}
cal +='</td>\n</tr>'+
'<tr>\n'+
'<td colspan="7" class="nav"><div align="center"><a href="javascript:" onClick="window.opener.loadCalendar('+prevM+');"><span style="font-size:15px;">&laquo;</span> Previous Month</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:" onClick="window.opener.loadCalendar('+nextM+');">Next Month <span style="font-size:15px;">&raquo;</span></a></div></td>'+
'</tr>\n'+
'</table>\n'+
'</body></html>';
testWindow.document.write(cal);
}

var testWindow;var formType;var fName;

function openCalendar(formName,type) {
formType=type;
fName=formName;
testWindow = window.open( '', 'dates', 'width=220,height=240,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0' );
loadCalendar(document.forms[fName].elements[formType+'Month'].selectedIndex);
}

function setCSC(city,state,country){
if(city!=""){
document.hotSearch.cityRadio2.checked=false;
document.hotSearch.cityText.value='';
document.hotSearch.city.value=city;
document.hotSearch.stateProvince.value=state;
document.hotSearch.country.value=country;
}
}

function submitForm(form,cid){
if(form.numberOfRooms.selectedIndex==8){
window.location="http://"+_subd+"/index.jsp?pageName=groups&cid="+cid+"";
return false;
}
if(document.hotSearch.cityText.value==""&&document.hotSearch.city.value==""){
alert('You must enteracity.Please modify your search.');
return false;
}
if(document.hotSearch.cityText.value!=""){
document.hotSearch.city.value=document.hotSearch.cityText.value;
document.hotSearch.stateProvince.value='';
document.hotSearch.country.value='';
}
return submitGuestInfoForm(form);
}

// NOTE: customize variables in this javascript block as appropriate.
var defaultAdults="2";
var cellStyle=" class='index-11bold-text'";
var childHelp="Please provide the ages of children in each room. Children's ages should be their age at the time of travel.";
var adultHelp="";
var textRooms="Rooms:";
var textAdults="Adults: (age 18+)";
var textChildren="Children: (0-17)";
var textChildError="Please specify the ages of all children.";
var pad='<img src="http://travel.ian.com/images/p.gif" width="5" height="1">';
// NOTE: Question marks ("?") get replaced with a numeric value
var textRoomX="Room ?:";
var textChildX="Child ?:";


var adultsPerRoom=new Array(defaultAdults);
var childrenPerRoom=new Array();
var childAgesPerRoom=new Array();
var numRooms=1;
var maxChildren=0;

function setChildAge(room,child,age){
if(childAgesPerRoom[room]==null){
	childAgesPerRoom[room]=new Array();
}
childAgesPerRoom[room][child]=age;
}

function setNumAdults(room,numAdults){
	adultsPerRoom[room]=numAdults;
}

function setNumChildren(room,numChildren){
	childrenPerRoom[room]=numChildren;
	refresh();
}

function setNumRooms(x){
numRooms=x;
	for(i=0;i<x;i++){
		if(adultsPerRoom[i]==null){adultsPerRoom[i]=2;}
		if(childrenPerRoom[i]==null){childrenPerRoom[i]=0;}
	}
refresh();
}

function renderRoomSelect(){
var x='';
x+='<select name="numberOfRooms" onchange="setNumRooms(this.options[this.selectedIndex].value);">\n';
for(var i=1;i<9;i++){
x+='<option value="'+i+'"'+(numRooms==i?'selected':'')+'>'+i+'</option>\n';
}
x+='<option value="9"'+(numRooms==9?'selected':'')+'>9+</option>\n';
x+='</select>';
return x;
}

function refresh(formname){
maxChildren=0;
for(var i=0;i<numRooms;i++){
	if(childrenPerRoom[i]>maxChildren){
		maxChildren=childrenPerRoom[i];
	}
}

var x='';
if(adultHelp.length>0){
	x=adultHelp+"<p>\n";
}

if(numRooms>8){
x+=textRooms;
x+=renderRoomSelect();

}else{
x+='<table border="0" cellspacing="2" cellpadding="0">\n';
x+='<tr>\n<td style="padding: 0px 5px 0px 0px;">'+textRooms+'</td>\n';
if(numRooms>1){
x+='<td>&nbsp;</td>\n';
}
x+='<td style="padding: 0px 5px 0px 0px;" nowrap>'+textAdults+'</td>\n<td nowrap>'+textChildren+'</td>\n</tr>\n';
for(var i=0;i<numRooms;i++){
x+='<tr>\n<td>';
if(i==0){
x+=renderRoomSelect();
}else{
x+='&nbsp;';
}
x+='</td>';
if(numRooms>1){
x+='<td nowrap>'+getValue(textRoomX,i+1)+'</td>';
}
x+='<td>';
x+=buildSelect('room-'+i+'-adult-total','setNumAdults('+i+',this.options[this.selectedIndex].value)',1,4,adultsPerRoom[i]);
x+='</td><td>';
x+=buildSelect('room-'+i+'-child-total','setNumChildren('+i+',this.options[this.selectedIndex].value)',0,6,childrenPerRoom[i]);
x+='</td>\n</tr>\n';
}
x+='</table>\n';

var didHeader=false;
for(var i=0;i<numRooms;i++){
if(childrenPerRoom[i]>0){
if(!didHeader){
x+='<table border="0" cellpadding="0" cellspacing="2">\n';
x+='<tr>\n<td colspan="'+(maxChildren+1)+'" style="padding:5px 0px 5px 0px">';
x+=childHelp;
x+='</td>\n</tr>';
x+='<tr>\n<td colspan="'+(maxChildren+1)+'">';
x+='<table border="0" cellpadding="0" cellspacing="0">\n';
x+='<tr>\n<td width="50" style="padding:0px 0px 2px 0px">&nbsp;</td>';
for(var j=0;j<maxChildren;j++){
x+='<td width="50" style="padding:0px 0px 2px 0px" nowrap>'+getValue(textChildX,j+1)+'</td>\n';
}
didHeader=true;
}
x+='</tr>\n<tr>\n<td width="50" style="padding:0px 0px 2px 0px" nowrap>'+getValue(textRoomX,i+1)+'</td>\n';
for(var j=0;j<childrenPerRoom[i];j++){
x+='<td style="padding:0px 0px 2px 0px" width="50">';
var def=-1;
if(childAgesPerRoom[i]!=null){
if(childAgesPerRoom[i][j]!=null){
def=childAgesPerRoom[i][j];
}
}
x+='<select name="room-'+i+'-child-'+j+'-age" onchange="setChildAge('+i+','+j+',this.options[this.selectedIndex].value);">';
x+='<option value="-1"'+(def==-1?' selected':'')+'>-?-</option>\n';
x+='<option value="0"'+(def==0?'selected':'')+'>&lt;1</option>\n';
for(var k=1;k<=18;k++){
x+='<option value="'+k+'"'+(def==k?' selected':'')+'>'+k+'</option>\n';
}
x+='</td>\n';
}
if(childrenPerRoom[i]<maxChildren){
for(var j=childrenPerRoom[i];j<maxChildren;j++){
x+='<td width="50">&nbsp;</td>\n';
}
}
x+='</tr>\n';
}
}
if(didHeader){
x+='</table></td>\n';
x+='</tr>\n';
x+='</table>\n';
}
}
try{

	try{
		document.getElementById("hotSearch_params").style.display="block";
		document.getElementById("hotSearch_params").innerHTML=x;
	}catch(ex){
	}
	try{
		document.getElementById("vacationRentals_params").style.display="block";
		document.getElementById("vacationRentals_params").innerHTML=x;
	}catch(ex){
	}	
	try{
		document.getElementById("hotSearch1_params").style.display="block";
		document.getElementById("hotSearch1_params").innerHTML=x;
	}catch(ex){
	
	}
		
}catch(ex){}

}



function buildSelect(name,onchange,min,max,selected){
var x='<select name="'+name+'"';
if(onchange!=null){
x+=' onchange="'+onchange+'"';
}
x+='>\n';
for(var i=min;i<=max;i++){
x+='<option value="'+i+'"';
if(i==selected){
x+='selected';
}

x+='>'+i+'</option>\n';
}
x+='</select>';
return x;
}

function validateGuests(form){
	if(numRooms<9){
	var missingAge=false;
		for(var i=0;i<numRooms;i++){
		var numChildren=childrenPerRoom[i];
			if(numChildren!=null&&numChildren>0){
				for(var j=0;j<numChildren;j++){
					if(childAgesPerRoom[i]==null||childAgesPerRoom[i][j]==null||childAgesPerRoom[i][j]==-1){missingAge=true;}
				}
			}
		}
	
		if(missingAge){
			alert(textChildError);
			return false;
		}else{
			return true;
		}
	}else{
	return true;
	}
}

function submitGuestInfoForm(form){
	if(!validateGuests(form)){return false;}
	printVals();
	return true;
}

function getValue(str,val){
	return str.replace(/\?/g,val);
}

function printVals(){
_txt="";for(ee=0;ee<document.forms[0].elements.length;ee++){
_txt+=""+document.forms[0].elements[ee].name+"|"+document.forms[0].elements[ee].value+"|"+document.forms[0].elements[ee].type+"<br>";
}
//document.write(_txt);
}

function chkPick(val){
	if (val==""){
		alert("Please enter 'Pick Up Destination' field.");
		return false;
	}
	return true;
}