var mapname = "&nbsp;";

function updateLabel(destname)
		{
		var myReturnString = "";
		//test the passed in value
		if(destname.length > 0)
			{myReturnString		=	destname;}
		else
			{myReturnString		=	mapname;}
		document.getElementById("FileLabel").innerHTML		=	myReturnString;
		}
function sh(num)
	{
	obj=eval('m'+num+'.style');
	if (eval('document.checkform.chk'+num).checked)
		{
		obj.visibility = "visible";
		}
	else
		{
		obj.visibility = "hidden";
		}
	};
function findPosX(obj)
	{
		var curleft = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
		return curleft;
	};
function findPosY(obj)
	{
		var curtop = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	};
function setDot(xoffset,yoffset,what)
	{
	var x = findPosX(map) - 8;
	var y = findPosY(map) - 8;
	document.getElementById(what).style.top  = y + yoffset + 'px';
	document.getElementById(what).style.left = x + xoffset + 'px';
	};
function SetCFCookie (name, value) {
	var name = name.toUpperCase();
	var path = "/";
	var now = new Date();
	now.setFullYear(now.getFullYear()+1);
	//now.setTime(now.getTime() + 1000 * 60 * 60 * 24 * 365);
	if(location.href.indexOf('hotelbook.com')>0) {
		document.cookie = name + "=" + escape (value) +"; path=" + path + "; expires=" + now.toGMTString() + "; domain=.hotelbook.com;";
	} else if (location.href.indexOf('i-sites.com')>0) {
		document.cookie = name + "=" + escape (value) +"; path=" + path + "; expires=" + now.toGMTString() + "; domain=.i-sites.com;";
	} else {
		document.cookie = name + "=" + escape (value) +"; path=" + path + "; expires=" + now.toGMTString() + ";";
	}
};
	
function GetCFCookie(name)
	{
	var cname = name.toUpperCase() + "="; //the cookie name is given an equal signs after it and assigned as cname
	var dc = document.cookie; //the main document.cookie code that will follow is assigned to dc
	var bl = "";
	if (dc.length > 0)
		{ //here the length of the cookie is checked, if it is above 0 the function continues and if not then it returns null
		begin = dc.indexOf(cname); //here the indexOf() method is used to find the location of the cookie's name and it is assigned to begin
		if (begin != -1)
			{ //if the cookie's name is not found in dc then begin is given a value of -1
			begin += cname.length; //if the name is found begin is increased by the length of the cname
			end = dc.indexOf(";", begin); //the indexOf() method now searches for a semicolon to be given to the variable end
			if (end == -1) end = dc.length;
			return unescape(dc.substring(begin, end)); //here is where is made sure that the value of the cookie is extracted and returned using the substring() method on dc
			}
		}
	return bl;
	};

function GetCookie(name)
	{
	var cname = name + "="; //the cookie name is given an equal signs after it and assigned as cname
	var dc = document.cookie; //the main document.cookie code that will follow is assigned to dc
	var bl = "";
	if (dc.length > 0)
		{ //here the length of the cookie is checked, if it is above 0 the function continues and if not then it returns null
		begin = dc.indexOf(cname); //here the indexOf() method is used to find the location of the cookie's name and it is assigned to begin
		if (begin != -1)
			{ //if the cookie's name is not found in dc then begin is given a value of -1
			begin += cname.length; //if the name is found begin is increased by the length of the cname
			end = dc.indexOf(";", begin); //the indexOf() method now searches for a semicolon to be given to the variable end
			if (end == -1) end = dc.length;
			return unescape(dc.substring(begin, end)); //here is where is made sure that the value of the cookie is extracted and returned using the substring() method on dc
			}
		}
	return bl; 
	}

function getCookieVal (offset)
	{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
	};


function SetCookie (name, value)
	{
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (2 < argc) ? argv[2] : null;
	var path = (3 < argc) ? argv[3] : null;
	var path = "/";
	var domain = (4 < argc) ? argv[4] : null;
	var secure = (5 < argc) ? argv[5] : false;
	document.cookie = name + "=" + escape (value);
	//((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	//((path == null) ? "" : ("; path=" + path)) +
	//((domain == null) ? "" : ("; domain=" + domain)) +
	//((secure == true) ? "; secure" : "");
	};

// Date Validation scripts
// Declaring valid date character, minimum year and maximum year
	var dtCh= "/";
	var minYear=1899;
	var maxYear=2100;
	
	function isInteger(s){
		var i;
	    for (i = 0; i < s.length; i++){   
	        // Check that current character is number.
	        var c = s.charAt(i);
	        if (((c < "0") || (c > "9"))) return false;
	    }
	    // All characters are numbers.
	    return true;
	}
	
	function stripCharsInBag(s, bag){
		var i;
	    var returnString = "";
	    // Search through string's characters one by one.
	    // If character is not in bag, append to returnString.
	    for (i = 0; i < s.length; i++){   
	        var c = s.charAt(i);
	        if (bag.indexOf(c) == -1) returnString += c;
	    }
	    return returnString;
	}
	
	function daysInFebruary (year){
		// February has 29 days in any year evenly divisible by four,
	    // EXCEPT for centurial years which are not also divisible by 400.
	    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
	}
	function DaysArray(n) {
		for (var i = 1; i <= n; i++) {
			this[i] = 31
			if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
			if (i==2) {this[i] = 29}
	   } 
	   return this
	}
	
	function isDate(dtStr){
		var daysInMonth = DaysArray(12)
		var pos1=dtStr.indexOf(dtCh)
		var pos2=dtStr.indexOf(dtCh,pos1+1)
		var strMonth=dtStr.substring(0,pos1)
		var strDay=dtStr.substring(pos1+1,pos2)
		var strYear=dtStr.substring(pos2+1)
		strYr=strYear
		if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
		if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
		for (var i = 1; i <= 3; i++) {
			if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
		}
		month=parseInt(strMonth)
		day=parseInt(strDay)
		year=parseInt(strYr)
		if (pos1==-1 || pos2==-1){
			return false
		}
		if (strMonth.length<1 || month<1 || month>12){
			return false
		}
		if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
			return false
		}
		if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
			return false
		}
		if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
			return false
		}
	return true
	}
function GetInList (list, index, delim)
{
	var flag = false, curr = 0;
	var posStart = "", posStop = "";

	// first, look for at least one occurance of the delimeter
	// if we can't find one, then just return the original
	if(list.indexOf(delim) == -1) return list;

	// alright, let's go through the string one character at a time
	for(x=0; x<list.length; x++)
	{
		/*/
		/ / We process if we find a delimeter, or we already found
		/ / a delimeter before and reached the end of the string.
		/*/
		if( (list.substr(x, 1) == delim) || (flag && (x == (list.length - 1))) )
		{
			// increment the current index if we need to
			if(index > 0) curr++;

			/*/ are we looking for the end or begining of the index? /*/
			if(flag)
			{	/*/ ending /*/

				/*/
				/ / Record the index for extraction later.  Remember, we want
				/ / the char before the delim, so we're done with this cycle.
				/ / But, we don't do this for the last index because there is
				/ / not delimeter for us to track, so we add one.
				/*/
				if(x == (list.length - 1))
					posStop = x + 1;
				else
					posStop = x;
				break;
			}
			else
			{	/*/ beginning /*/

				// did we find a match?
				if(curr == index)
				{
					/*/
					/ / We are on the index the caller wants.
					/ / So we record this for extraction later.
					/*/

					/*/ flag indicates we found the start /*/
					flag = true;

					/*/
					/ / Now, here's the tricky part.  If we're not on the first
					/ / index (0) we want posStart to be one greater than the
					/ / current iteration to pass up the delimeter; however,
					/ / if we are on the first index, we want posStart to be the
					/ / beginning and posStop to be what posStart was supposed to be.
					/*/
					if(curr == 0)
					{	/*/ zero /*/
						posStart = 0;
						posStop  = x;

						// we have the data we need
						break;
					}
					else
						/*/ non-zero /*/
						posStart = x + 1;
				}
			}
		}
	}

	/*/ if we made it here w/o flag being set, then we didn't find the index /*/
	if(!flag)
		return false;
	else
	{	/*/ we have what we need to extract the index /*/

		// return the data back to the caller
		return list.substring(posStart, posStop);
	}
}

function ListLen (list, delim)
{
	var curr = 0;
	var listToArray = "";

	listToArray = list.split(delim);
	
	curr = listToArray.length;
	
	//return the number of items in the list
	return curr;
}

function ListFind(list, item, delim) {
	var searchResult = false;
	//get the list length
	myListLength = ListLen(list, delim);
	//loop over the list using the GetInList() function
	for(i=0; i<=(myListLength-1); i++)
		{
		tempVar = GetInList(list, i, delim);
		if(tempVar == item)
			{searchResult = true; break;}
		}
	return searchResult;
}

function ListFindPos(list, item, delim) {
	var searchResult = 0;
	//get the list length
	myListLength = ListLen(list, delim);
	//loop over the list using the GetInList() function
	for(i=0; i<=(myListLength-1); i++)
		{
		tempVar = GetInList(list, i, delim);
		if(tempVar == item)
			{searchResult = i; break;}
		}
	return searchResult;
}

function SaveProperty(myPropID) {
	var myCurrentSavedProps = "";
	var countListItems = 0;
	var myNewCookieValue = "";
	var CheckForExistence = false;
	var foo = "";
	var theReturnMessage = "";
	var ImageName = "";
	var listToArray = "";
	var rolloverImageON = "remove";
	var rolloverImageOFF = "save";
	var myTDID = "ID_" + myPropID;
	
	//ImageName = 'document.UI;41253.src';
	//"UT;90104"
	myCurrentSavedProps = GetCFCookie("SAVEDPROPS");
	countListItems = ListLen(myCurrentSavedProps, ",");
	
	/*if(countListItems >= 20)
		{
		theReturnMessage = "You already have 20 Hotels in your saved list.";
		}
	else
		{*/	
			if(myCurrentSavedProps.length == 0)
				{
				myNewCookieValue = myPropID;
				}
			else
				{
				//check to see if the new value is already in the list
				CheckForExistence = ListFind(myCurrentSavedProps, myPropID, ",");
				if(CheckForExistence)
					{
					//convert the list into an array
					listToArray = myCurrentSavedProps.split(",");
					//find out the position of the element in the array
					CheckForExistenceA = ListFindPos(myCurrentSavedProps, myPropID, ",");
					//delete the element from the array
					foo = deleteElement(listToArray, CheckForExistenceA);
					//convert the array back into a list
					foo = listToArray.join(",");
					//update the cookie
					foo = SetCFCookie("SAVEDPROPS",listToArray);
					//switch the image on the page
					document.getElementById(myTDID).innerHTML = rolloverImageOFF;
					document.getElementById(myTDID).className  = "aqua";
					//document.images[myPropID].src = rolloverImageOFF;
					//Set the return message
					theReturnMessage = "You hotel has been removed from your list.";
					}
				else
					{
					myNewCookieValue = myCurrentSavedProps + ',' + myPropID;
					}
				}
			//if the new item has a length add it to the cookie
			if(myNewCookieValue.length > 0)
				{
				if(countListItems >= 20)
					{
					theReturnMessage = "You already have 20 Hotels in your saved list.";
					}
				else
					{
					foo = SetCFCookie("SAVEDPROPS",myNewCookieValue);
					//document.images[myPropID].src = rolloverImageON;
					document.getElementById(myTDID).innerHTML = rolloverImageON;
					document.getElementById(myTDID).className  = "ruby";
					theReturnMessage = "Your Hotel has been saved.";
					}
				}		
		//}
	alert(theReturnMessage);	
}

function deleteElement(array, delElement) 
	{
	size = array.length;
	delindex = delElement;
	validNo = (delindex != "NaN");
	inRange = ( (delindex >= 0) && (delindex <= array.length) );

	if (validNo && inRange) 
		{
		for (var i=0; i<=size; i++)
			array[i] = ((i == delindex) ? "delete" : array[i]);
		for (var j=delindex; j<size-1; j++)
			if (j != size) array[j] = array[j+1];
			array.length = size-1;
		}
	
	return array;
	}
	
function popup(href,width,height,scroll,Name)
	{
	Name = window.open(href,Name,'resizable=no,toolbar=no,left=200,top=200,status=yes,location=no,height=' + height + ',width=' + width + ',scrollbars=' + scroll);
	};
	
function emailPopup(href,width,height,scroll,Name)
	{
	Name = window.open(href,Name,'resizable=no,toolbar=no,left=200,top=200,status=no,toolbar=no,location=no,height=' + height + ',width=' + width + ',scrollbars=' + scroll);
	};	

function outputCrumbtrail()
		{
		//setup the vars
		var myCookie = "";
		var myTrail = '<P class="breadcrumb">';
		var myTrailEnd = '</P>';
		var myListLen = 0;
		var myReturn = "&nbsp;";
		//setup the real values
		myCookie = GetCFCookie('CRUMBTRAIL');
		if(myCookie.length > 0)
			{
			myListLen = ListLen(myCookie, "~");
			//loop over the list of items in the cookie
			for(i=1;i<myListLen;i++)
				{
				var myTempOutput = GetInList(myCookie, i, "~");
				var myOutputString = '<a href="' + GetInList(myTempOutput, 2, "|") + '" class="breadcrumb">' + GetInList(myTempOutput, 0, "|") + '</a>';
				if(myListLen != i+1)	
					{myOutputString = myOutputString + '&nbsp;<FONT class="smtxt">&gt;</FONT>&nbsp;';}
				myTrail = myTrail + myOutputString;
				}
			//setup the return value
			myReturn = myTrail + myTrailEnd;
			}
		return myReturn;
		}
		
function Left(str, n)
	{
	if (n <= 0)
	    {
		return "";
		}
	else if (n > String(str).length)
	    {
		return str;
		}
	else
		{
	    return String(str).substring(0,n);
		}
	};
	
function Right(str, n)
	{
    if (n <= 0)
       {
	   return "";
	   }
    else if (n > String(str).length)
       {
	   return str;
	   }
    else
		{
		var iLen = String(str).length;
		return String(str).substring(iLen, iLen - n);
		}
	};
	
function randomString()
	{
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = 5;
	var randomstring = '';
	for (var i=0; i<string_length; i++)
		{
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
		}
	return randomstring;
	}
	
function getFileName()
	{
	var myurl = window.location.href;
	var myArray = new Array();
	myArray = myurl.split('/');
	return (myArray[myArray.length-1]);
	}

function getLanguage()
	{
	var myurl = window.location.href;
	var myArray = new Array();
	myArray = myurl.split('/');
	return (myArray[myArray.length-2]);
	}	

function HBCookieCheck()
	{
	// Set the name of the pages the script does not get executed on
	var page1 = 'nocookies.cfm';
	var page2 = 'privacypolicy.cfm';
	// check to see if the user is on the nocookies or privacy policy page
	if( (getFileName() != page1) && (getFileName() != page2) )	
		{
		// sets the cookie on the client
		SetCFCookie('C',randomString());
		var cookieCheck = GetCFCookie('C');
		if (cookieCheck.length==0)
			{			
			gotoURL = '/' + getLanguage() + '/nocookies.cfm';
			window.location = gotoURL;
			}
		}	
	}; 
window.load = HBCookieCheck();


/*
	returns an object when given its id, cross-browser compatible [njs]
*/
function getObj(id) {
	if(document.getElementById)return document.getElementById(id);
	else if (document.all)return document.all[id];
	else if (document.layers)return document.layers[id];
	else return window[id];
}


/* Rollover functions added for birds eye view map */
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}