<!--
		/**
		* Highlights the 'in brief' box, or wish-list box, depending on theType
		*/
		function infoMouseOver(propertyIndex, theType){
			var theObj = document.getElementById(theType + propertyIndex);
			theObj.className="inBriefOn";
			var downArrowObj = document.getElementById(theType + "DownArrow" + propertyIndex);
			downArrowObj.src="/ts/images/openshut/downArrowRed.gif";
			var theTextObj = document.getElementById(theType + "Text" + propertyIndex);
			theTextObj.className = "catalogueRed11";
			menuBoxOpen = false;
		}
		
		/**
		* Turns off the highlighting of the 'in brief' box, or wish-list box, depending on theType
		*/
		function infoMouseOut(propertyIndex, theType){
			if(currentInfoBox == null){
				var theObj = document.getElementById(theType + propertyIndex);
				if(theObj == null){
					return;
				}
				theObj.className="inBriefOff";
				var downArrowObj = document.getElementById(theType + "DownArrow" + propertyIndex);
				downArrowObj.src="/ts/images/openshut/downArrowSmall.gif"
				var theTextObj = document.getElementById(theType + "Text" + propertyIndex);
				theTextObj.className = "catalogueBrn11";
			}//end if
		}

		var menuBoxOpen = false;
		
		/**
		* Toggles the chosen infobox on or off
		*/
		function toggleMenuBox(callingObj, propertyIndex, theType, isWishList){
			//if it's already open, then we shut it when we click again on InBrief
			if(menuBoxOpen){
				closeMenuBox();
				menuBoxOpen = false;
				//but make sure inBrief is still lit up, because we're still in it
				callingObj.className = "inBriefOn";
			}else{
				menuBoxOpen = true;
				getMenuBox(callingObj, propertyIndex, theType, isWishList);
				callingObj.className="inBriefOn";				
			}
			
		}

		/**
		* Brings the chosen infobox onscreen, according to theType, 'inBrief' or 'wishList'.
		* The wish-list is positioned absolutely, so we have to calculate the menubox positioning 
		* differently, hence the importance of the isWishList variable.
		*/
		function getMenuBox(callingObj, propertyIndex, theType, isWishList){
			var theOffsetTop = calculateOffset(callingObj, "offsetTop");
			var theOffsetLeft = calculateOffset(callingObj, "offsetLeft");
			if(isWishList){
				theOffsetTop = callingObj.offsetTop;
				theOffsetLeft = callingObj.offsetLeft;
			}
			var infoBox = document.getElementById(theType + "InfoBox" + propertyIndex);
			infoBox.style.top = (theOffsetTop + callingObj.offsetHeight - 1) + "px";
			infoBox.style.left = (theOffsetLeft + 0) + "px";
			infoBox.style.position = "absolute";
			infoBox.style.zIndex = 3;
			infoBox.propertyIndex = propertyIndex;
			currentInfoBox = infoBox;
//			addAMenuShadow(infoBox.id, '/gifimages/maps/shadow.png')
		}
	//didn't look much good	
/*		function addAMenuShadow(menuId, shadowSrc){
			var menuObj = $(menuId);
			//don't need z-index because the menu already has a high z-index
			var shadow = new Element('img',{
				src: shadowSrc,
				id: 'shadowImg',
				styles: {
					position: 'absolute',
					width: menuObj.offsetWidth + 'px',
					height: menuObj.offsetHeight + 'px',
					top: (menuObj.getPosition().y - 1) + 'px',
					left: (menuObj.getPosition().x + 1) + 'px'
				}
			});
			shadow.inject($$('body')[0]);
		}
*/



		/**
		* Puts the chosen infobox off screen
		*/
		function closeMenuBox(){
			if(currentInfoBox == null){
				return;
			}
			currentInfoBox.style.top = "-2000px";
			var propertyIndex = currentInfoBox.propertyIndex;
			currentInfoBox = null;	
			infoMouseOut(propertyIndex, "inBrief");
			infoMouseOut(propertyIndex, "wishList");
		}
		
		/**
		* Holds the current infoBox that is open on the page
		*/
		var currentInfoBox;
		
		document.onmousedown = function (evt) {
			closeMenuBox();
			return true;
		}
		
		/**
		* keeps the propertyindex for when the ajax call comes back
		*/
		var currentPropertyIndex = -1;
		
		/**
		* keeps the infoType ('inBrief' or 'wishList') for when the ajax call comes back
		*/
		var currentInfoType;
		var introXmlHttp;
		var isWishListStatic = false;
		/**
		* Keeps the in brief event screenY for when the ajax call comes back, because we might need to 
		* scroll down. Internet Explorer refused to save the event in its own instance variable..
		*/
		var inBriefEventScreenY;
		
		/**
		* Gets the house introduction via Ajax
		*/
		function getIntro(evt, nomecasaEncoded, stagione, language, propertyIndex, infoType, isWishList){

			currentPropertyIndex = propertyIndex;
			currentInfoType = infoType;
			isWishListStatic = isWishList;
			inBriefEventScreenY = evt.clientY;

			introXmlHttp = createXMLHttpRequest();
			introXmlHttp.onreadystatechange = handleStateChangeIntro;
			var URL = "/ts/house/Introduction.jsp";
			URL += "?nomecasa=" + nomecasaEncoded;
			URL += "&stagione=" + stagione;
			URL += "&language=" + language;
			URL += "&tm=" + new Date().getTime();
			introXmlHttp.open("GET", URL, true);
			introXmlHttp.send(null);
		}
		
		function handleStateChangeIntro(){
			if(introXmlHttp.readyState == 4){
        		if(introXmlHttp.status == 200){
        			showInfo(introXmlHttp.responseText);
				}//end if
    		}//end if
		}
		
		var accXmlHttp;
		/**
		* Object interior description via ajax
		*/
		function getAccommodation(evt, nomecasaEncoded,nomeOggettoEncoded, codice, pax, stagione, language, propertyIndex, infoType){
			currentPropertyIndex = propertyIndex;
			currentInfoType = infoType;
			inBriefEvent = evt;
			inBriefEventScreenY = evt.clientY;
			accXmlHttp = createXMLHttpRequest();
    		accXmlHttp.onreadystatechange = handleStateChangeAcc;
    		var URL = "/ts/house/SingleAccommodation.jsp";
    		URL += "?nomecasa=" + nomecasaEncoded;
	   		URL += "&codice=" + codice;
    		URL += "&pax=" + pax;
   			URL += "&stagione=" + stagione;
    		URL += "&language=" + language;
    		URL += "&nome_oggetto=" + nomeOggettoEncoded;
			URL += "&tm=" + new Date().getTime();
    		accXmlHttp.open("GET", URL, true);
    		accXmlHttp.send(null);
		}
		
		function handleStateChangeAcc(){
			if(accXmlHttp.readyState == 4){
        		if(accXmlHttp.status == 200){
        			showInfo(accXmlHttp.responseText);
				}//end if
    		}//end if
		}
		

		var amensXmlHttp;
		/**
		* Gets the property amenities via ajax
		*/
		function getAmenities(evt, nomecasaEncoded, stagione, codice, propertyIndex, infoType, isWishList){
			currentPropertyIndex = propertyIndex;
			currentInfoType = infoType;
			inBriefEvent = evt;
			inBriefEventScreenY = evt.clientY;
			amensXmlHttp = createXMLHttpRequest();
			amensXmlHttp.onreadystatechange = handleStateChangeAmens;
			var URL = "/ts/house/HouseServiziSmall.jsp";
			URL += "?nomecasa=" + nomecasaEncoded;
			URL += "&stagione=" + stagione;
			URL += "&codice=" + codice;
			URL += "&tm=" + new Date().getTime();
			amensXmlHttp.open("GET", URL, true);
			amensXmlHttp.send(null);
		}
		
		function handleStateChangeAmens(){
			if(amensXmlHttp.readyState == 4){
        		if(amensXmlHttp.status == 200){
        			showInfo(amensXmlHttp.responseText);
				}//end if
    		}//end if
		}
	
		/**
		* Shows the info box directly under the obj that called it
		*/
		function showInfo(responseText){
		
			//we can't remove infoDiv because the wish-list is an infoDiv!
			if(!isWishListStatic){
				removeInfoDiv();
			}
			//reset isWishList
			isWishListStatic = false;
			
			var infoDiv = document.createElement("div");
			infoDiv.id = "infoDiv";
			infoDiv.style.visibility = "hidden";
			
			document.body.appendChild(infoDiv);
			infoDiv.innerHTML = responseText;

			var theObj = document.getElementById(currentInfoType + currentPropertyIndex);
			var theOffsetTop = calculateOffset(theObj, "offsetTop");
			var theOffsetLeft = calculateOffset(theObj, "offsetLeft");
			
			infoDiv.style.position = "absolute";
			infoDiv.style.top = (theOffsetTop + theObj.offsetHeight - 1) + "px";
			infoDiv.style.left = (theOffsetLeft + 0) + "px";
			infoDiv.className = "inBriefBits";
			infoDiv.style.visibility = "";
			
			//if(inBriefEvent != null){
				scrollIfNecessary(inBriefEventScreenY, infoDiv.offsetHeight + 25, infoDiv);
			//}
		}
		
		
		/**
		* Removes the current info box (intro, accommodation, wish-list ecc.) from the document
		*/
		function removeInfoDiv(){
			var infoDiv = document.getElementById("infoDiv");	
			if(infoDiv != null){
				infoDiv.innerHTML = "";		
				removeChildFromDocBody("infoDiv");
			}
		}
		
		
		var wishListAddXmlHttp;	
			
		/**
		* Adds or removes a property in the wish-list
		*/
		function doWishList(wishListQueryString, sessionId, propertyIndex){
			//remove any info div that might be open on the page
			removeInfoDiv();
			var addOrRemoveObj = document.getElementById("addOrRemove" + propertyIndex);
			var addOrRemoveParam = addOrRemoveObj.value.toLowerCase();
			//set currentPropertyIndex static variable
			currentPropertyIndex = propertyIndex;
			wishListAddXmlHttp = createXMLHttpRequest();
			if(!isBigWishList){
				//if we're in the big wish-list we don't wait for this answer, we just update
				//the wish-list by calling it again
				wishListAddXmlHttp.onreadystatechange = handleStateChangeWishListToggle;
			}else{
				//toggle it back again in case we need it, probably not
				isBigWishList = false;
			}//end if
			var URL = "/ts/house/DoWishList.jsp;jsessionid=" + sessionId;
			URL += "?" + wishListQueryString;
			URL += "&doWishList=" + addOrRemoveParam;
			URL += "&tm=" + new Date().getTime();
			wishListAddXmlHttp.open("GET", URL, true);
			wishListAddXmlHttp.send(null);
		}
				
		function handleStateChangeWishListToggle(){
			if(wishListAddXmlHttp.readyState == 4){
				if(wishListAddXmlHttp.status == 200){
					toggleAddOrRemove(wishListAddXmlHttp.responseText);
				}//end if
 			}//end if
		}
		
		/**
		* This is different from doWishList: this removes a property visually from the small
		* wish-list (which is open at the moment) and also removes it from the WishList
		* in the session, and finally checks whether the code is currently on the page and
		* changes 'Remove the property' to 'Add the property'
		*/
		var wishListRemoveXmlHttp;
		function removeFromWishList(eventClientY, wishListQueryString, sessionId, codice, propertyIndex, mainPropertyIndex){
			currentPropertyIndex = mainPropertyIndex;
			//save the client Y pos
			inBriefEventScreenY = eventClientY;
			wishListRemoveXmlHttp = createXMLHttpRequest();
			wishListRemoveXmlHttp.onreadystatechange = handleStateChangeWishListRemove;

			var URL = "/ts/house/DoWishList.jsp;jsessionid=" + sessionId;
			URL += "?" + wishListQueryString;
			URL += "&tm=" + new Date().getTime();
			//these next two are not necessary unless we try again to remove directly
			//from the short wish-list without recalling it
			//URL += "&codice=" + codice;
			//URL += "&mainPropertyIndex=" + mainPropertyIndex;

			wishListRemoveXmlHttp.open("GET", URL, true);
			wishListRemoveXmlHttp.send(null);

			toggleAllAddsAndRemoves(codice);

		}

		function handleStateChangeWishListRemove(){
		    if(wishListRemoveXmlHttp.readyState == 4 && wishListRemoveXmlHttp.status == 200){
		    	//var theArray = wishListRemoveXmlHttp.responseText.split(":");
		    	//var mainPropertyIndex = theArray[1];
			    //removeWishListDescription(mainPropertyIndex);
			    //var codice = theArray[0];
				//toggleAllAddsAndRemoves(codice);
				removeWishListDescription();
		    }
		}

		
		function toggleAllAddsAndRemoves(codice){
			if(codice == null || codice.length < 1){
				return;
			}
			var codiceObj;
			var codiceText;
			for(var i = 0; i < 14; i = i + 1){
				codiceObj = document.getElementById("codice" + i);
				if(codiceObj == null){
					//we might be on a page where there are less than 14 objects
					break;
				}
				if(codiceObj.value == codice){
					var addOrRemoveTextObj = document.getElementById("addOrRemove" + i);
					addOrRemoveTextObj.innerHTML = ADD;
					var houseObj = document.getElementById("house" + i);
					flagWishList(houseObj, REMOVE);
				}//end if
			}//end for
		}
		
		
		/**
		* The property has already been removed from the wish-list in the session
		* so all we have to do is to refresh it by showing it again. The currentPropertyIndex
		* was set with the index of the property on the catalogue page which asked to see the
		* wish-list
		*/
		function removeWishListDescription(){
		/*
			We could try to just remove the house by setting the innerhtml to "", but we have the 
			problem that all the properties have index numbers and we'd have to move down each 
			index number.
			if(mainPropertyIndex == null || mainPropertyIndex.length < 1){
				return;
			}//end if
			var smallWishListObj = document.getElementById("wishListHouse" + mainPropertyIndex);
			if(smallWishListObj != null){
				smallWishListObj.innerHTML = "";
			}
		*/
			showWishList(inBriefEventScreenY, currentSessionId, currentPropertyIndex, "wishList");
		}
		
		function toggleAddOrRemove(responseText){
			var addOrRemoveObj = $('addOrRemove' + currentPropertyIndex);
			var houseObj = $('house' + currentPropertyIndex);
			
			var addOrRemoveText = addOrRemoveObj.value;
			if(addOrRemoveText == ADD){
				addOrRemoveObj.value = REMOVE;
				flagWishList(houseObj, ADD);
			}else{
				addOrRemoveObj.value = ADD;
				flagWishList(houseObj, REMOVE);
			}//end if
		}
		
		var ADD = "Add";
		var REMOVE = "Remove";
		var ADD_LONG = "Add to wish-list";
		var REMOVE_LONG = "Drop from wish-list";
		
		/**
		* Changes the background colour of the house div to indicate it's on the wish-list
		* and the button text
		*/
		function flagWishList(houseObj, addOrRemove){
			if(addOrRemove == ADD){
				var currentClassName = houseObj.className;
				var classArray = currentClassName.split(" ");
				houseObj.className = classArray[0] + " " + "inWishList";
				$('wlButton' + currentPropertyIndex).value = REMOVE_LONG;
			}else{
				var currentClassName = houseObj.className;
				var classArray = currentClassName.split(" ");
				houseObj.className = classArray[0];
				$('wlButton' + currentPropertyIndex).value = ADD_LONG;
			}//end if
		}
		
		var showWishListXmlHttp;
		
		/**
		* Shows the wish-list
		*/
		
		function showWishList(evtClientY, sessionId, propertyIndex, infoType){
			currentPropertyIndex = propertyIndex;
			currentInfoType = infoType;
			inBriefEventScreenY = evtClientY;
			showWishListXmlHttp = createXMLHttpRequest();
			showWishListXmlHttp.onreadystatechange = handleStateChangeShowWishList;
			var URL = "/ts/house/ShowWishList.jsp;jsessionid=" + sessionId;
			URL += "?mainPropertyIndex=" + propertyIndex;
			URL += "&tm=" + new Date().getTime();
			showWishListXmlHttp.open("GET", URL, true);
			showWishListXmlHttp.send(null);
		}

		function handleStateChangeShowWishList(){
			if(showWishListXmlHttp.readyState == 4){
				if(showWishListXmlHttp.status == 200){
					showInfo(showWishListXmlHttp.responseText);
				}//end if
			}//end if
		}
		
		/**
		* Opens or closes the short description and photo for a house in the wishlist
		*/
		var OPEN_ARROW = "downArrowSmall.gif";
		var CLOSE_ARROW = "rightArrowGrey.gif";
		var currentSessionId;
		var SHORT_HOUSE_DESCRIPTION_HEIGHT = 155;
		var BOTTOM_MARGIN = 100;


		function toggleWishListDescription(callingObj, sessionId, propertyIndex, mainPropertyIndex, event){


			currentPropertyIndex = propertyIndex;
			currentSessionId = sessionId;

			var arrowObj = document.getElementById("wishListArrow" + propertyIndex);

			if(descriptionIsOpen(arrowObj)){
				arrowObj.src = "/ts/images/openshut/" + CLOSE_ARROW;
				closeWishListDescription();
			}else{
				arrowObj.src = "/ts/images/openshut/" + OPEN_ARROW;
				openWishListDescription(callingObj, sessionId, propertyIndex, mainPropertyIndex);
				scrollIfNecessary(event.screenY, SHORT_HOUSE_DESCRIPTION_HEIGHT, $('wishListHouse' + currentPropertyIndex));
			}
		}//end toggleWishListDescription()
		

		function scrollIfNecessary(theScreenY, distanceFromBottomRequested, currentObj){

 			var windowInnerHeight;
			if(navigator.appName.indexOf("Microsoft") > -1){
				windowInnerHeight = document.documentElement.offsetHeight;
			}else{
				windowInnerHeight = window.innerHeight;
			}
			
    		var pageY;
			if(navigator.appName.indexOf("Microsoft") > -1){
       			pageY=document.documentElement.scrollTop;
   		 	} else {
       			pageY=window.pageYOffset;
    		}

 			var distanceFromBottom = windowInnerHeight - theScreenY;
 			
			if(distanceFromBottom < distanceFromBottomRequested){
//				Scroller1.speed = 10;
//				Scroller1.interval=setInterval('Scroller1.scroll('+ (theScreenY + pageY + distanceFromBottomRequested - windowInnerHeight) +')',10);
				var scrollIt = new Fx.Scroll(window,{
		       		duration: 500,
       				offset: {
       				'x': 0,
       				'y': -200
       				}
       			});
       			scrollIt.toElement(currentObj);

			}//end if
		}//end scrollIfNecessary()

		function descriptionIsOpen(arrowObj){
			if(arrowObj.src.indexOf(OPEN_ARROW) > -1){
				return true;
			}
			return false;
		}
		
		function closeWishListDescription(){
			var wListDescriptionDiv = document.getElementById("wishListDescription" + currentPropertyIndex);
			wListDescriptionDiv.innerHTML = "";
			wListDescriptionDiv.style.marginTop = "";
			wListDescriptionDiv.style.height = "";
			wListDescriptionDiv.style.width = "";
			
		}
		
		
		var wlistXmlHttp;
		/**
		* Opens an individual property description for an item on the wish-list, propertyIndex
		* is the index in the Wish-list, mainPropertyIndex is the index in the catalogue of the
		* property that asked to see the wish-list
		*/
		function openWishListDescription(callingObj, sessionId, propertyIndex, mainPropertyIndex){
			wlistXmlHttp = createXMLHttpRequest();
			wlistXmlHttp.onreadystatechange = handleStateChangeWList;
			var URL = "/ts/house/WishListDescription.jsp;" + sessionId;
			URL += "?index=" + propertyIndex;
			URL += "&mainPropertyIndex=" + mainPropertyIndex;
			URL += "&wishListPropertyIndex=" + propertyIndex;
			URL += "&wishList=true";
			URL += "&tm=" + new Date().getTime();
			wlistXmlHttp.open("GET", URL, true);
			wlistXmlHttp.send(null);
			callingObj.blur();
		}
		
		function handleStateChangeWList(){
			if(wlistXmlHttp.readyState == 4){
        		if(wlistXmlHttp.status == 200){
        			showWListDescription(wlistXmlHttp.responseText);
				}//end if
    		}//end if
		}
		
		function showWListDescription(responseText){
			var wListDescriptionDiv = document.getElementById("wishListDescription" + currentPropertyIndex);
			wListDescriptionDiv.innerHTML = responseText;
			wListDescriptionDiv.style.marginTop = "7px";
			wListDescriptionDiv.style.height = "138px";
			wListDescriptionDiv.style.width = "100%";
		}
		
		/**
		* if true, we are in the big wish-list, the one like the catalogue index
		*/
		var isBigWishList;
		function setIsBigWishList(setOn){
			if(setOn){
				isBigWishList = true;
			}else{
				isBigWishList = false;			
			}	
		}
		
		function submitRemoveForm(){
			var removeFormObj = document.getElementById("removeForm");
			removeFormObj.submit();
		}
		
// end hide -->