MC=0
ArrivalMonth=0
AM = 0
AD = 0
DM = 0
DD = 0
ADL = 0
CLD = 0
CityPage = ""

var PrevID
var TRc
var LastID
var Dscnts
var Process
var LastFrameRatio


function GetFormData(){
    
  AM = document.hotelSearchCriteriaForm.arrivalMonth.value
  AD = document.hotelSearchCriteriaForm.arrivalDay.value
  DM = document.hotelSearchCriteriaForm.departureMonth.value
  DD = document.hotelSearchCriteriaForm.departureDay.value
  ADL = document.hotelSearchCriteriaForm.adults.value
  CLD = document.hotelSearchCriteriaForm.children.value

}

function removeMapInfo(City){

  GetFormData()
  
  if (window.innerWidth) {
      FrameWidth = window.innerWidth - 260
      FrameHeight=window.innerHeight-110}
  else {
      FrameWidth = document.documentElement.clientWidth - 250
      FrameHeight=document.documentElement.clientHeight-106}

  if (FrameWidth > 1340) {
      FrameWidth = 1340}
  if (FrameHeight > 950) {
      FrameHeight = 950}

  FrameRatio = (FrameWidth/FrameHeight).toFixed(2)
  LastFrameRatio = FrameRatio

  document.location = "http://www.i-maps.com/hotel-locator/usa/hotels/" + City + ".html?AM=" + AM + "&AD=" + AD + "&DM=" + DM + "&DD=" + DD + "&ADL=" + ADL + "&CLD=" + CLD + "&MC=1&FR=" + FrameRatio

}

var timer
function Resize(City){

  if (MC>0) {  // don't go here on initial intro page
    clearTimeout(timer)
    timer=setTimeout("GetFormData(); document.location = 'http://www.i-maps.com/hotel-locator/usa/hotels/" + City + ".html?AM=" + AM + "&AD=" + AD + "&DM=" + DM + "&DD=" + DD + "&ADL=" + ADL + "&CLD=" + CLD + "&MC=2&FR=" + FrameRatio + "'",1000)
  }

}

function Reload_Map(City){

	if (navigator.userAgent.indexOf("Mac") == -1) {		// If not Macintosh
		
		if ( MC>1 ) {   // Don't go here on the initial intro page or the div swap

			GetFormData()

			if (window.innerWidth) {
				FrameWidth = window.innerWidth - 260
				FrameHeight=window.innerHeight-110}
			else {
				FrameWidth = document.documentElement.clientWidth - 250
				FrameHeight=document.documentElement.clientHeight-106}

			if (FrameWidth > 1340) {
				FrameWidth = 1340}
			if (FrameHeight > 950) {
				FrameHeight = 950}

			FrameRatio = (FrameWidth/FrameHeight).toFixed(2)

			if (FrameRatio!=LastFrameRatio) {  // Go here if the window was moved during the resize event
				LastFrameRatio = FrameRatio
				document.location = "http://www.i-maps.com/hotel-locator/usa/hotels/" + City + ".html?AM=" + AM + "&AD=" + AD + "&DM=" + DM + "&DD=" + DD + "&ADL=" + ADL + "&CLD=" + CLD + "&MC=2&FR=" + FrameRatio
			}
		}
	}
}

function Page(ID, Type){
	parent.parent.document.hotelSearchCriteriaForm.ClickID.value=ID
	winheight=screen.availHeight-200
	winwidth=screen.availWidth/1.04
	wintop=25
	winleft=((screen.availWidth - winwidth)/2)-6
	if (Type=="I") {
		window.open("http://www.i-maps.com/hotel-locator/usa/hotelinfo/"+ID+".html?AM=" + document.hotelSearchCriteriaForm.arrivalMonth.value + "&AD=" + document.hotelSearchCriteriaForm.arrivalDay.value + "&DM=" + document.hotelSearchCriteriaForm.departureMonth.value + "&DD=" + document.hotelSearchCriteriaForm.departureDay.value + "&ADL=" + document.hotelSearchCriteriaForm.adults.value + "&CLD=" + document.hotelSearchCriteriaForm.children.value + "&MC=" + MC + "&FR=" + FrameRatio, "I_"+ID, "width="+winwidth+",height="+winheight+",top="+wintop+",left="+winleft+",toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,dependent=no,resizable=yes,scrollbars=yes");
	}
	else {
		window.open("http://www.i-maps.com/hotel-locator/usa/trend/T"+ID+".html?AM=" + document.hotelSearchCriteriaForm.arrivalMonth.value + "&AD=" + document.hotelSearchCriteriaForm.arrivalDay.value + "&DM=" + document.hotelSearchCriteriaForm.departureMonth.value + "&DD=" + document.hotelSearchCriteriaForm.departureDay.value + "&ADL=" + document.hotelSearchCriteriaForm.adults.value + "&CLD=" + document.hotelSearchCriteriaForm.children.value + "&MC=" + MC + "&FR=" + FrameRatio, "T_"+ID, "width="+winwidth+",height="+winheight+",top="+wintop+",left="+winleft+",toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,dependent=no,resizable=yes,scrollbars=yes");
  }
}

function Photos(ID){
  winheight=screen.availHeight-200
	winwidth=screen.availWidth/1.04
	wintop=25
  winleft=((screen.availWidth - winwidth)/2)-6
  window.open("http://www.ihsadvantage.com/h/hotelinfo/" + document.hotelSearchCriteriaForm.city.value + "/" + document.hotelSearchCriteriaForm.state.value + "/us/" + ID + "/?showAvailWithList=false&pfs=3355&arrivalMonth=" + document.hotelSearchCriteriaForm.arrivalMonth.value + "&arrivalDay=" + document.hotelSearchCriteriaForm.arrivalDay.value + "&departureMonth=" + document.hotelSearchCriteriaForm.departureMonth.value + "&departureDay=" + document.hotelSearchCriteriaForm.departureDay.value + "&adults=" + document.hotelSearchCriteriaForm.adults.value + "&children=" + document.hotelSearchCriteriaForm.children.value + "#photos", "P_"+ID, "width="+winwidth+",height="+winheight+",top="+wintop+",left="+winleft+",toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,dependent=no,resizable=yes,scrollbars=yes")
}

function Rates(ID){
  winheight=screen.availHeight-200
	winwidth=screen.availWidth/1.04
	wintop=25
  winleft=((screen.availWidth - winwidth)/2)-6
  window.open("http://www.ihsadvantage.com/h/hotelAvailAll.do?hotelID=" + ID + "&pfs=3355&spfs=0&city=" + document.hotelSearchCriteriaForm.city.value + "&state=" + document.hotelSearchCriteriaForm.state.value + "&country=US&arrivalMonth=" + document.hotelSearchCriteriaForm.arrivalMonth.value + "&arrivalDay=" + document.hotelSearchCriteriaForm.arrivalDay.value + "&departureMonth=" + document.hotelSearchCriteriaForm.departureMonth.value + "&departureDay=" + document.hotelSearchCriteriaForm.departureDay.value + "&adults=" + document.hotelSearchCriteriaForm.adults.value + "&children=" + document.hotelSearchCriteriaForm.children.value, ID, "width="+winwidth+",height="+winheight+",top="+wintop+",left="+winleft+",toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,dependent=no,resizable=yes,scrollbars=yes")
  
  // document.hotelSearchCriteriaForm.hotelID.value=ID,
  // document.hotelSearchCriteriaForm.submit();
}

function AllRates(){
  winheight=screen.availHeight-200
	winwidth=screen.availWidth/1.04
	wintop=25
  winleft=((screen.availWidth - winwidth)/2)-6
  window.open("http://www.ihsadvantage.com/h/hotelAvail.do?showAvailWithList=true&hotelID=&pfs=3355&spfs=0&city=" + document.hotelSearchCriteriaForm.city.value + "&state=" + document.hotelSearchCriteriaForm.state.value + "&country=US&arrivalMonth=" + document.hotelSearchCriteriaForm.arrivalMonth.value + "&arrivalDay=" + document.hotelSearchCriteriaForm.arrivalDay.value + "&departureMonth=" + document.hotelSearchCriteriaForm.departureMonth.value + "&departureDay=" + document.hotelSearchCriteriaForm.departureDay.value + "&adults=" + document.hotelSearchCriteriaForm.adults.value + "&children=" + document.hotelSearchCriteriaForm.children.value, "_blank", "width="+winwidth+",height="+winheight+",top="+wintop+",left="+winleft+",toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,dependent=no,resizable=yes,scrollbars=yes")

  // document.location = "http://www.ihsadvantage.com/h/hotelAvail.do?showAvailWithList=true&hotelID=&pfs=3355&spfs=0&city=" + document.hotelSearchCriteriaForm.city.value + "&state=" + document.hotelSearchCriteriaForm.state.value + "&country=US&arrivalMonth=" + document.hotelSearchCriteriaForm.arrivalMonth.value + "&arrivalDay=" + document.hotelSearchCriteriaForm.arrivalDay.value + "&departureMonth=" + document.hotelSearchCriteriaForm.departureMonth.value + "&departureDay=" + document.hotelSearchCriteriaForm.departureDay.value + "&adults=" + document.hotelSearchCriteriaForm.adults.value + "&children=" + document.hotelSearchCriteriaForm.children.value 
}

var TdElem         // This is the Rate Table cell highlighting fuction
var origBgColor    // It uses the HiLtID form just above the rate table 

function HiLt(elem){
	var tdID
	if (elem==null) {
		tdID = document.getElementById("HiLtID").value
		if (tdID!='') {
			elem=document.getElementById(tdID)
			elem.bgColor='#FFFFDD';
			TdElem = elem;
		}
	}
	else {
		document.getElementById("HiLtID").value = elem.id
		origBgColor = elem.bgColor
		if(typeof(TdElem)!='undefined') {
			TdElem.bgColor = origBgColor;
		}
		elem.bgColor='#FFFFDD';
		TdElem = elem;
	}	
}


function showGraph(ID) {
	var TDleft = TDtop = 0;
  obj = document.getElementById(ID)
	if (obj.offsetParent) {
		TDleft = obj.offsetLeft
		TDtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			TDleft += obj.offsetLeft
			TDtop += obj.offsetTop
		}
	}
  
  obj = document.getElementById("graph")

	SH=screen.height
	if (SH < 700) {
		if (MC>0) {
			TopOffset = 340}
		else {
			TopOffset = 630}
		LeftOffset = 540}
	else if (SH < 800) {
		if (MC>0) {
		  TopOffset = 536}
	  else {
			TopOffset = 506}
		LeftOffset = 630}
	else if (SH < 900) {
		if (MC>0) {
			TopOffset = 630}
		else {
			TopOffset = 490}
		LeftOffset = 650}
	else if (SH < 1000) {
		if (MC>0) {
			TopOffset = 696}
		else {
			TopOffset = 490}
		LeftOffset = 650}
	else if (SH < 1100) {
		if (MC>0) {
			TopOffset = 790}
		else {
			TopOffset = 480}
		LeftOffset = 640}
	else {
		if (MC>0) {
			TopOffset = 960}
		else {
			TopOffset = 480}
	  LeftOffset = 650}
	if (navigator.appName=="Netscape") {
		 LeftOffset = LeftOffset-210
		 if (SH > 1000 && MC>0) {
		   TopOffset = TopOffset+30}
		 if (SH > 800) {
			 TopOffset = TopOffset-30}
		 else {
			 TopOffset = TopOffset-0}
	}
    
	obj.style.top=TDtop-TopOffset+"px";
	obj.style.left=TDleft-LeftOffset+"px";
	document.getElementById("graph").innerHTML = '<img src="/hotel-locator/usa/graphs/' + ID + '.gif" width="540" height="380">';
}

function clearGraph()
{
 obj = document.getElementById("graph")
 obj.style.top=0;
 obj.style.left=0;
 document.getElementById("graph").innerHTML = "";
}

function RateCapture() {
  var Update = new Date()
  var hours = Update.getHours()
  var minutes = Update.getMinutes()
  if (minutes < 10) {minutes = "0" + minutes}
  if(hours > 11) {
    if(hours > 12){
      hours = hours - 12
    }
    Time = hours + ":" + minutes + " PM"
  }
  else {Time = hours + ":" + minutes + " AM"}
  var month = Update.getMonth() + 1
  var day = Update.getDate()
  var year = Update.getFullYear()
  document.getElementById("ListCapture").innerHTML = Time+" on "+month + "/" + day + "/" + year
  document.getElementById("RateCapture").innerHTML = Time+" on "+month + "/" + day + "/" + year
}
 
function UpdateRates(ID, PrevID) {
  var xmlhttp
  xmlhttp = null
  if (window.XMLHttpRequest) {
   xmlhttp=new XMLHttpRequest()
  }
  else if (window.ActiveXObject) {
   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
  var inMon = document.hotelSearchCriteriaForm.arrivalMonth.value
  var inDay = document.hotelSearchCriteriaForm.arrivalDay.value
  var outMon = document.hotelSearchCriteriaForm.departureMonth.value
  var outDay = document.hotelSearchCriteriaForm.departureDay.value
  var adult = document.hotelSearchCriteriaForm.adults.value
  var child = document.hotelSearchCriteriaForm.children.value
  var url = "http://www.i-maps.com/hotel-locator/usa/xml_edit_ratetable.asp?HotelID=" + ID + "&inMon=" + inMon + "&inDay=" + inDay + "&outMon=" + outMon + "&outDay=" + outDay + "&adult=" + adult + "&child=" + child + "&city=" + CityPage
  xmlhttp.open("GET",url,true)
  xmlhttp.onreadystatechange=function() {
   if (xmlhttp.readyState==4) {
    if(xmlhttp.status == 200) {
     var Rates = new Array();
     Rates = xmlhttp.responseText.split(',')
     CL = Rates[0]
     CH = Rates[1]
		 if (PrevID!=undefined){document.getElementById("R" + PrevID).bgColor=TRc}
     TR = document.getElementById("R" + ID)
     TRc = TR.bgColor
     TR.bgColor = "#FFFF55"
     CLtd = document.getElementById("CL" + ID)
     CHtd = document.getElementById("CH" + ID)
     CLtd.innerHTML = CL
     CHtd.innerHTML = CH
     AL = document.getElementById("AL" + ID).innerHTML
     AH = document.getElementById("AH" + ID).innerHTML
     if (CL=="na") {LD = "na"}
		 else {LD = CL-AL}
     if (CH=="na") {HD = "na"}
		 else {HD = CH-AH}
     LDtd = document.getElementById("LD" + ID)
     HDtd = document.getElementById("HD" + ID)
     LDtd.innerHTML = LD
     HDtd.innerHTML = HD
 	   if (ID==LastID) {
 	     setTimeout("TR.bgColor = TRc",500)
 	     clearTimeout(Process);
 	     var element = document.getElementById("ReqDate2")
 	     element.style.color = "#000000";
 	     element.innerHTML = "Rates for <b>" + (document.hotelSearchCriteriaForm.arrivalMonth.selectedIndex + 1) + "/" + (document.hotelSearchCriteriaForm.arrivalDay.selectedIndex + 1) + "</b> to <b>" + (document.hotelSearchCriteriaForm.departureMonth.selectedIndex + 1) + "/" + (document.hotelSearchCriteriaForm.departureDay.selectedIndex + 1) + "</b> posted at "
       RateCapture()
       if (Dscnts=="T") {setTimeout("document.location = 'http://www.i-maps.com/hotel-locator/usa/hotels/" + CityPage + ".html?AM=" + AM + "&AD=" + AD + "&DM=" + DM + "&DD=" + DD + "&ADL=" + ADL + "&CLD=" + CLD + "&MC=" + MC + "&FR=" + FrameRatio + "#TopDiscounts'",200)}
       else {
       setTimeout("document.location = 'http://www.i-maps.com/hotel-locator/usa/hotels/" + CityPage + ".html?AM=" + AM + "&AD=" + AD + "&DM=" + DM + "&DD=" + DD + "&ADL=" + ADL + "&CLD=" + CLD + "&MC=" + MC + "&FR=" + FrameRatio + "#TableTop'",200)}
 	   }
     SendIDs()
    }
   }
  }
  xmlhttp.send (null)
 }

 var i=0
 var j=0
 var TRlist

 function SendIDs() {
 	i=i+1
	if (i<j+1) {
   	ID = TRlist[i].id.substr(1)
 	  UpdateRates (ID, PrevID)
    PrevID = ID
  }
 }
 
 function GetRates() {
  RTable = document.getElementById("srt")
  TRlist = RTable.getElementsByTagName("Tr")
  i=0
  j = TRlist.length-1
  LastID = TRlist[j].id.substr(1)
  SendIDs()
 }

 function Stop() {
   j=i
   clearTimeout(Process);
   var element = document.getElementById("ReqDate2")
   element.style.color = "#000000";
   element.innerHTML = "Rates for <b>" + (document.hotelSearchCriteriaForm.arrivalMonth.selectedIndex + 1) + "/" + (document.hotelSearchCriteriaForm.arrivalDay.selectedIndex + 1) + "</b> to <b>" + (document.hotelSearchCriteriaForm.departureMonth.selectedIndex + 1) + "/" + (document.hotelSearchCriteriaForm.departureDay.selectedIndex + 1) + "</b> posted at "
   RateCapture()
 }

 function Resume() {
  Processing()
  if(j!=TRlist.length-1) {i=j}
  j = TRlist.length-1
	LastID = TRlist[j].id.substr(1)
  SendIDs()
 }
 
 function UpdateDiscounts(City, D) {
  Processing()
  if (D=="T") {
    window.location="#TableTop"
    Dscnts="T"
  }
  AM = document.RateDatesForm.arrivalMonth.value
	AD = document.RateDatesForm.arrivalDay.value
	DM = document.RateDatesForm.departureMonth.value
	DD = document.RateDatesForm.departureDay.value
	ADL = document.hotelSearchCriteriaForm.adults.value
	CLD = document.hotelSearchCriteriaForm.children.value
	CityPage = City
  GetRates()
 }
 
 var clr = 1
 function Processing() {
	var interval = 500;
	var color1 = "#ff0000";
	var color2 = "#000000";
	document.getElementById("RateCapture").innerHTML="";
	var element = document.getElementById("ReqDate2");
	element.innerHTML="<font size=2><b>Processing</b></font>";
  if (clr==1) {element.style.color = color1; clr=2;}
  else {element.style.color = color2; clr=1;}
  Process = setTimeout("Processing()", interval);
 }


 function SetForms(Num) {
  if (Num==1) {
		document.RateDatesForm.arrivalMonth.selectedIndex = document.hotelSearchCriteriaForm.arrivalMonth.selectedIndex
		document.RateDatesForm.arrivalDay.selectedIndex = document.hotelSearchCriteriaForm.arrivalDay.selectedIndex
		document.RateDatesForm.departureMonth.selectedIndex = document.hotelSearchCriteriaForm.departureMonth.selectedIndex
		document.RateDatesForm.departureDay.selectedIndex = document.hotelSearchCriteriaForm.departureDay.selectedIndex
		document.RateTableForm.arrivalMonth.selectedIndex = document.hotelSearchCriteriaForm.arrivalMonth.selectedIndex
		document.RateTableForm.arrivalDay.selectedIndex = document.hotelSearchCriteriaForm.arrivalDay.selectedIndex
		document.RateTableForm.departureMonth.selectedIndex = document.hotelSearchCriteriaForm.departureMonth.selectedIndex
		document.RateTableForm.departureDay.selectedIndex = document.hotelSearchCriteriaForm.departureDay.selectedIndex
  }
  else if (Num==2) {
		document.hotelSearchCriteriaForm.arrivalMonth.selectedIndex = document.RateDatesForm.arrivalMonth.selectedIndex
		document.hotelSearchCriteriaForm.arrivalDay.selectedIndex = document.RateDatesForm.arrivalDay.selectedIndex
		document.hotelSearchCriteriaForm.departureMonth.selectedIndex = document.RateDatesForm.departureMonth.selectedIndex
		document.hotelSearchCriteriaForm.departureDay.selectedIndex = document.RateDatesForm.departureDay.selectedIndex
		document.RateTableForm.arrivalMonth.selectedIndex = document.RateDatesForm.arrivalMonth.selectedIndex
		document.RateTableForm.arrivalDay.selectedIndex = document.RateDatesForm.arrivalDay.selectedIndex
		document.RateTableForm.departureMonth.selectedIndex = document.RateDatesForm.departureMonth.selectedIndex
		document.RateTableForm.departureDay.selectedIndex = document.RateDatesForm.departureDay.selectedIndex
  }
  else if (Num==3) {
		document.hotelSearchCriteriaForm.arrivalMonth.selectedIndex = document.RateTableForm.arrivalMonth.selectedIndex
		document.hotelSearchCriteriaForm.arrivalDay.selectedIndex = document.RateTableForm.arrivalDay.selectedIndex
		document.hotelSearchCriteriaForm.departureMonth.selectedIndex = document.RateTableForm.departureMonth.selectedIndex
		document.hotelSearchCriteriaForm.departureDay.selectedIndex = document.RateTableForm.departureDay.selectedIndex
		document.RateDatesForm.arrivalMonth.selectedIndex = document.RateTableForm.arrivalMonth.selectedIndex
		document.RateDatesForm.arrivalDay.selectedIndex = document.RateTableForm.arrivalDay.selectedIndex
		document.RateDatesForm.departureMonth.selectedIndex = document.RateTableForm.departureMonth.selectedIndex
		document.RateDatesForm.departureDay.selectedIndex = document.RateTableForm.departureDay.selectedIndex
  }
  AM = document.RateDatesForm.arrivalMonth.selectedIndex+1
	AD = document.RateDatesForm.arrivalDay.selectedIndex+1
	DM = document.RateDatesForm.departureMonth.selectedIndex+1
	DD = document.RateDatesForm.departureDay.selectedIndex+1
	ADL = document.hotelSearchCriteriaForm.adults.selectedIndex+1
	CLD = document.hotelSearchCriteriaForm.children.selectedIndex+1
 }








