			var bedrooms_slider_min = 0;
			//var bedrooms_slider_max = 30;
			var sleeps_slider_min = 0;
			//var sleeps_slider_max = 30;
			// var cots_slider_min = 0;
			// var cots_slider_max = 30;
			var wait_dialog;


			function searchHover(el,imgname) {
				if (document.images) {
					if( el ) {
						el.src = imgname;
					}
				}
			}

	    if (swfobject.hasFlashPlayerVersion("6.0.0")) {
	      var fn = function() {
	        var att = { data:"swf/h4h.swf", width:"576", height:"462" };
	        var par = { flashvars:"foo=bar", loop:"false" };
	        var id = "blurbAd";
	        var myObject = swfobject.createSWF(att, par, id);
	      };
	      swfobject.addDomLoadEvent(fn);
	    }

			function toggleAdvanced() {
				var toggleText = '';
				var el = document.getElementById( "advSearchContainer" );
				if( el ) {
					if (el.style.display == 'none' ) {
						el.style.display = 'block';
						toggleText = '[-]';
					} else {
						el.style.display = 'none';
						toggleText = '[+]';
					}
				}
				el = document.getElementById( "advToggler" );
				if( el ) {
					el.innerHTML = toggleText;
				}
			}



// P1 START

	var sd_calendar;
	var ed_calendar;

	var currentGeography = 2;

			function getSearchCriteria() {
				var criteria = '';//bedroommin=' + bedrooms_slider_min;
				//criteria = criteria + '&bedroommax=' + bedrooms_slider_max;
				//criteria = criteria + '&sleepsmin=' + sleeps_slider_min;
				//criteria = criteria + '&sleepsmax=' + sleeps_slider_max;
//				criteria = criteria + '&cotsmin=' + cots_slider_min;
//				criteria = criteria + '&cotsmax' + cots_slider_max;
				var el = document.getElementById( "selBedrooms" );
				if( el ) {
					criteria = criteria + "bedroommin=" + el.value;
				}
				el = document.getElementById( "selBedroomsMax" );
				if( el ) {
					if( el.value != 'any' ) {
						criteria = criteria + "&bedroommax=" + el.value;
					}
				}
				el = document.getElementById( "selSleeps" );
				if( el ) {
					criteria = criteria + "&sleepsmin=" + el.value;
				}
				el = document.getElementById( "selSleepsMax" );
				if( el ) {
					if( el.value != 'any' ) {
						criteria = criteria + "&sleepsmax=" + el.value;
					}
				}
				el = document.getElementById( "disabled_friendly" );
				if( el ) {
					if( el.checked ) {
						criteria = criteria + "&disabled_friendly=1";
					}
				}
				el = document.getElementById( "child_friendly" );
				if( el ) {
					if( el.checked ) {
						criteria = criteria + "&child_friendly=1";
					}
				}
				el = document.getElementById( "broadband" );
				if( el ) {
					if( el.checked ) {
						criteria = criteria + "&broadband=1";
					}
				}
				el = document.getElementById( "tv" );
				if( el ) {
					if( el.checked ) {
						criteria = criteria + "&tv=1";
					}
				}
				el = document.getElementById( "music_system" );
				if( el ) {
					if( el.checked ) {
						criteria = criteria + "&hifi=1";
					}
				}
				el = document.getElementById( "pets_welcome" );
				if( el ) {
					if( el.checked ) {
						criteria = criteria + "&pets=1";
					}
				}

				el = document.getElementById( "txtPriceMin" );
				if( el ) {
					criteria = criteria + "&pmin=" + escape(el.value);
				}
				el = document.getElementById( "txtPriceMax" );
				if( el ) {
					criteria = criteria + "&pmax=" + escape(el.value);
				}

				el = document.getElementById( "txtSearchCity" );
				if( el ) {
					criteria = criteria + "&city=" + escape(el.value);
				}
				var selDate = '';
				var selDateFormatted = '';
				if( typeof sd_calendar != 'undefined' ) {
					if (sd_calendar.getSelectedDates().length > 0) {
						selDate = sd_calendar.getSelectedDates()[0];
						if( selDate ) {
							selDateFormatted += selDate.getFullYear();
							selDateFormatted += '-';
							selDateFormatted += selDate.getMonth()+1;
							selDateFormatted += '-';
							selDateFormatted += selDate.getDate();
						}
					}
					if( selDateFormatted != '' ) {
						criteria += '&sd='+escape(selDateFormatted);
					}
				}
				if( typeof ed_calendar != 'undefined' ) {
					selDate = '';
					selDateFormatted = '';
					if (ed_calendar.getSelectedDates().length > 0) {
						selDate = ed_calendar.getSelectedDates()[0];
						if( selDate ) {
							selDateFormatted += selDate.getFullYear();
							selDateFormatted += '-';
							selDateFormatted += selDate.getMonth()+1;
							selDateFormatted += '-';
							selDateFormatted += selDate.getDate();
						}
					}
					if( selDate != '' ) {
						criteria += '&ed='+escape(selDateFormatted);
					}
				}
				return criteria;
			}

	function getGeography(locid,is_auto) {
		currentGeography = locid;
		var el = document.getElementById( "geocontainer" );
		if( el ) {
			el.innerHTML = '<p>Loading geography...</p><p><img src="http://l.yimg.com/a/i/us/per/gr/gp/rel_interstitial_loading.gif" alt="Loading..." /></p>';
		}

		var submitURL = "get_geography.php?l=" + locid;
		submitURL += "&" + getSearchCriteria();
		YAHOO.util.Connect.asyncRequest("GET", submitURL, {
			success: function (o) {
				var el;
				el = document.getElementById( "geocontainer" );
				if( el ) {
					var output = '';
					var r = eval('(' + o.responseText + ')');
					if( typeof r !== 'undefined' ) {
						if( r.length > 0 ) {
							for( var i in r ) {
								if( i == 0 ) {
									if( locid != 2 ) {
										output += '<b><a class="geolink" href="javascript:getGeography('+r[i].parent_id+',true)">&#0171; Back To ' + r[i].description + '</a> (' + r[i].cnt + ')</b><br /><br />';
									}
								} else {
									if( r[i].cnt > 0 ) {
										output += '<a class="geolink" href="javascript:getGeography('+r[i].id+',true)">' + r[i].description + '</a> (' + r[i].cnt + ')<br />';
									} else {
										output += r[i].description + ' (0)<br />';
									}
								}
							}
						} else {
							el.innerHTML = '<p>No geography found</p>';
						}
					} else {
						output = '<p>Unable to find geography</p>';
					}
					el.innerHTML = output;
					if( is_auto === true ) {
						doSearch();
					}
				}
			},

			failure: function (o) {
			}
			});

	}

(function () {
    YAHOO.namespace('example');

    var Dom = YAHOO.util.Dom;
    var Event = YAHOO.util.Event;

    // Slider has a range of 300 pixels
//    var range = 300;
//    var sleeps_range = 300;
//    var cots_range = 300;

    // Set up 10 pixel ticks
//    var tickSize = 10;
//    var sleeps_tickSize = 10;
//    var cots_tickSize = 10;

    // Some arbitrary ranges to cue status changes
//    var caution_range = 150,
//        danger_range  = 75,
//        boom_range    = 13;

    YAHOO.util.Event.onDOMReady(function () {
        
			// Initialize the temporary Panel to display while waiting for external content to load
			wait_dialog = 
				new YAHOO.widget.Panel("wait",  
					{ width:"240px", 
					  fixedcenter:true, 
					  close:false, 
					  draggable:false, 
					  zindex:4,
					  modal:true,
					  visible:false
					} 
				);

			wait_dialog.setHeader("Searching properties, please wait...");
			wait_dialog.setBody('<img src="http://l.yimg.com/a/i/us/per/gr/gp/rel_interstitial_loading.gif" alt="Loading..." />');
			wait_dialog.render(document.body);

        var reportSpan     = Dom.get("demo_range");

        // Create the DualSlider
//        var slider = YAHOO.widget.Slider.getHorizDualSlider("demo_bg", "demo_min_thumb", "demo_max_thumb",range, tickSize);
        
        // Decorate the DualSlider instance with some new properties and
        // methods to maintain the highlight element
//        YAHOO.lang.augmentObject(slider, {

//            // The current status
//            _status : 'ok',

//            // The highlight element
//            _highlight : Dom.get("demo_highlight"),

//            // A simple getter method for the status
//            getStatus : function () { return this._status; },

//            // A method to update the status and update the highlight
//            updateHighlight : function () {
//                var delta = this.maxVal - this.minVal,
//                    newStatus = 'ok';
//                
//                if (delta < boom_range) {
//                    newStatus = 'boom';
//                } else if (delta < danger_range) {
//                    newStatus = 'danger';
//                } else if (delta < caution_range) {
//                    newStatus = 'caution';
//                }

//                if (this._status !== newStatus) {
//                    // Update the highlight class if status is changed
//                    Dom.replaceClass(this._highlight,this._status,newStatus);
//                    this._status = newStatus;
//                }
//                if (this.activeSlider === this.minSlider) {
//                    // If the min thumb moved, move the highlight's left edge
//                    Dom.setStyle(this._highlight,'left', (this.minVal + 12) + 'px');
//                }
//                // Adjust the width of the highlight to match inner boundary
//                Dom.setStyle(this._highlight,'width', Math.max(delta - 12,0) + 'px');

//                bedrooms_slider_min = this.minVal / 10;
//                bedrooms_slider_max = this.maxVal / 10;
//            }
//        },true);

        // Attach the highlight method to the slider's change event
//        slider.subscribe('change',slider.updateHighlight,slider,true);

        // Create an event callback to update some display fields
//        var report = function () {
//            reportSpan.innerHTML = (slider.minVal/10) + ' - ' + (slider.maxVal/10);
//        };

        // Subscribe to the slider's change event to report the status.
//        slider.subscribe('change',report);

        // Attach the slider to the YAHOO.example namespace for public probing
//        YAHOO.example.slider = slider;

				// Sleeps Slider

//        var sleeps_reportSpan = Dom.get("sleeps_range");

        // Create the DualSlider
//        var sleeps_slider = YAHOO.widget.Slider.getHorizDualSlider("sleeps_bg",
//            "sleeps_min_thumb", "sleeps_max_thumb",
//            sleeps_range, sleeps_tickSize);
        
        // Decorate the DualSlider instance with some new properties and
        // methods to maintain the highlight element
//        YAHOO.lang.augmentObject(sleeps_slider, {

            // The current status
//            _status : 'ok',

            // The highlight element
//            _highlight : Dom.get("sleeps_highlight"),

            // A simple getter method for the status
//            getStatus : function () { return this._status; },

            // A method to update the status and update the highlight
//            updateHighlight : function () {
//                var delta = this.maxVal - this.minVal,
//                    newStatus = 'ok';

//                if (delta < boom_range) {
//                    newStatus = 'boom';
//                } else if (delta < danger_range) {
//                    newStatus = 'danger';
//                } else if (delta < caution_range) {
//                    newStatus = 'caution';
//                }

//                if (this._status !== newStatus) {
//                    // Update the highlight class if status is changed
//                    //Dom.replaceClass(this._highlight,this._status,newStatus);
//                    this._status = newStatus;
//                }
//                if (this.activeSlider === this.minSlider) {
//                    // If the min thumb moved, move the highlight's left edge
//                    //Dom.setStyle(this._highlight,'left', (this.minVal + 12) + 'px');
//                }
//                // Adjust the width of the highlight to match inner boundary
//                //Dom.setStyle(this._highlight,'width', Math.max(delta - 12,0) + 'px');

//                sleeps_slider_min = this.minVal / 10;
//                sleeps_slider_max = this.maxVal / 10;
//            }
//        },true);

        // Attach the highlight method to the slider's change event
//        sleeps_slider.subscribe('change',sleeps_slider.updateHighlight,sleeps_slider,true);

        // Create an event callback to update some display fields
//        var sleeps_report = function () {
//            sleeps_reportSpan.innerHTML = (sleeps_slider.minVal/10) + ' - ' + (sleeps_slider.maxVal/10);
//        };

        // Subscribe to the slider's change event to report the status.
//        sleeps_slider.subscribe('change',sleeps_report);

        // Attach the slider to the YAHOO.example namespace for public probing
//        YAHOO.example.sleeps_slider = sleeps_slider;

				// Cots Slider

//        var cots_reportSpan = Dom.get("cots_range");

        // Create the DualSlider
//        cots_slider = YAHOO.widget.Slider.getHorizDualSlider("cots_bg",
//            "cots_min_thumb", "cots_max_thumb",
//            cots_range, cots_tickSize);
        
        // Decorate the DualSlider instance with some new properties and
        // methods to maintain the highlight element
//        YAHOO.lang.augmentObject(cots_slider, {

            // The current status
//            _status : 'ok',

            // The highlight element
//            _highlight : Dom.get("cots_highlight"),

            // A simple getter method for the status
//            getStatus : function () { return this._status; },

            // A method to update the status and update the highlight
//            updateHighlight : function () {
//                var delta = this.maxVal - this.minVal,
//                    newStatus = 'ok';

//                if (delta < boom_range) {
//                    newStatus = 'boom';
//                } else if (delta < danger_range) {
//                    newStatus = 'danger';
//                } else if (delta < caution_range) {
//                    newStatus = 'caution';
//                }

//                if (this._status !== newStatus) {
                    // Update the highlight class if status is changed
//                    Dom.replaceClass(this._highlight,this._status,newStatus);
//                    this._status = newStatus;
//                }
//                if (this.activeSlider === this.minSlider) {
                    // If the min thumb moved, move the highlight's left edge
//                    Dom.setStyle(this._highlight,'left', (this.minVal + 12) + 'px');
//                }
                // Adjust the width of the highlight to match inner boundary
//                Dom.setStyle(this._highlight,'width', Math.max(delta - 12,0) + 'px');
                
//                cots_slider_min = this.minVal / 10;
//                cots_slider_max = this.maxVal / 10;
//            }
//        },true);

        // Attach the highlight method to the slider's change event
//        cots_slider.subscribe('change',cots_slider.updateHighlight,cots_slider,true);

        // Create an event callback to update some display fields
//        var cots_report = function () {
//            cots_reportSpan.innerHTML = (cots_slider.minVal/10) + ' - ' + (cots_slider.maxVal/10);
//        };

        // Subscribe to the slider's change event to report the status.
//        cots_slider.subscribe('change',cots_report);

        // Attach the slider to the YAHOO.example namespace for public probing
//        YAHOO.example.cots_slider = cots_slider;
        
        //var oBtnSearch = new YAHOO.widget.Button( "btnSearch" );

				var sd_dialog;
				var sd_showBtn = Dom.get("sd_show");
        YAHOO.util.Event.on(sd_showBtn, "click", function() {

            // Lazy Dialog Creation - Wait to create the Dialog, and setup document click listeners, until the first time the button is clicked.
            if (!sd_dialog) {
 
                // Hide Calendar if we click anywhere in the document other than the calendar
                YAHOO.util.Event.on(document, "click", function(e) {
                    var el = Event.getTarget(e);
                    var dialogEl = sd_dialog.element;
                    if (el != dialogEl && !Dom.isAncestor(dialogEl, el) && el != sd_showBtn && !Dom.isAncestor(sd_showBtn, el)) {
                        sd_dialog.hide();
                    }
                });
 
                function resetHandler() {
                    // Reset the current calendar page to the select date, or 
                    // to today if nothing is selected.
                    var selDates = sd_calendar.getSelectedDates();
                    var resetDate;
        
                    if (selDates.length > 0) {
                        resetDate = selDates[0];
                    } else {
                        resetDate = sd_calendar.today;
                    }
        
                    sd_calendar.cfg.setProperty("pagedate", resetDate);
                    sd_calendar.render();
                }
        
                function closeHandler() {
                    sd_dialog.hide();
                }
 
                sd_dialog = new YAHOO.widget.Dialog("sd_container", {
                    visible:false,
                    context:["sd_show", "tl", "bl"],
                    buttons:[ {text:"Reset", handler: resetHandler, isDefault:true}, {text:"Close", handler: closeHandler}],
                    draggable:false,
                    close:true
                });
                sd_dialog.setHeader('Pick A Date');
                sd_dialog.setBody('<div id="sd_cal"></div>');
                sd_dialog.render(document.body);
 
                sd_dialog.showEvent.subscribe(function() {
                    if (YAHOO.env.ua.ie) {
                        // Since we're hiding the table using yui-overlay-hidden, we 
                        // want to let the dialog know that the content size has changed, when
                        // shown
                        sd_dialog.fireEvent("changeContent");
                    }
                });
            }
 
            // Lazy Calendar Creation - Wait to create the Calendar until the first time the button is clicked.
            if (!sd_calendar) {
 
                sd_calendar = new YAHOO.widget.Calendar("sd_cal", {
                    iframe:false,          // Turn iframe off, since container has iframe support.
                    hide_blank_weeks:true  // Enable, to demonstrate how we handle changing height, using changeContent
                });
                sd_calendar.render();
 
                sd_calendar.selectEvent.subscribe(function() {
                    if (sd_calendar.getSelectedDates().length > 0) {
 
                        var selDate = sd_calendar.getSelectedDates()[0];
 
                        // Pretty Date Output, using Calendar's Locale values: Friday, 8 February 2008
                        //var wStr = sd_calendar.cfg.getProperty("WEEKDAYS_LONG")[selDate.getDay()];
                        var dStr = selDate.getDate();
                        var mStr = sd_calendar.cfg.getProperty("MONTHS_SHORT")[selDate.getMonth()];
                        var yStr = selDate.getFullYear();
        
                        Dom.get("sd_date").value = dStr + " " + mStr + " " + yStr;
                    } else {
                        Dom.get("sd_date").value = "";
                    }
                    sd_dialog.hide();
                });
 
                sd_calendar.renderEvent.subscribe(function() {
                    // Tell Dialog it's contents have changed, which allows 
                    // container to redraw the underlay (for IE6/Safari2)
                    sd_dialog.fireEvent("changeContent");
                });
            }
 
            var seldate = sd_calendar.getSelectedDates();
 
            if (seldate.length > 0) {
                // Set the pagedate to show the selected date if it exists
                sd_calendar.cfg.setProperty("pagedate", seldate[0]);
                sd_calendar.render();
            }
 
            sd_dialog.show();
        });

				var ed_dialog;
				var ed_showBtn = Dom.get("ed_show");
        YAHOO.util.Event.on(ed_showBtn, "click", function() {

            // Lazy Dialog Creation - Wait to create the Dialog, and setup document click listeners, until the first time the button is clicked.
            if (!ed_dialog) {
 
                // Hide Calendar if we click anywhere in the document other than the calendar
                YAHOO.util.Event.on(document, "click", function(e) {
                    var el = Event.getTarget(e);
                    var dialogEl = ed_dialog.element;
                    if (el != dialogEl && !Dom.isAncestor(dialogEl, el) && el != ed_showBtn && !Dom.isAncestor(ed_showBtn, el)) {
                        ed_dialog.hide();
                    }
                });
 
                function resetHandler() {
                    // Reset the current calendar page to the select date, or 
                    // to today if nothing is selected.
                    var selDates = ed_calendar.getSelectedDates();
                    var resetDate;
        
                    if (selDates.length > 0) {
                        resetDate = selDates[0];
                    } else {
                        resetDate = ed_calendar.today;
                    }
        
                    ed_calendar.cfg.setProperty("pagedate", resetDate);
                    ed_calendar.render();
                }
        
                function closeHandler() {
                    ed_dialog.hide();
                }
 
                ed_dialog = new YAHOO.widget.Dialog("ed_container", {
                    visible:false,
                    context:["ed_show", "tl", "bl"],
                    buttons:[ {text:"Reset", handler: resetHandler, isDefault:true}, {text:"Close", handler: closeHandler}],
                    draggable:false,
                    close:true
                });
                ed_dialog.setHeader('Pick A Date');
                ed_dialog.setBody('<div id="ed_cal"></div>');
                ed_dialog.render(document.body);
 
                ed_dialog.showEvent.subscribe(function() {
                    if (YAHOO.env.ua.ie) {
                        // Since we're hiding the table using yui-overlay-hidden, we 
                        // want to let the dialog know that the content size has changed, when
                        // shown
                        ed_dialog.fireEvent("changeContent");
                    }
                });
            }
 
            // Lazy Calendar Creation - Wait to create the Calendar until the first time the button is clicked.
            if (!ed_calendar) {
 
                ed_calendar = new YAHOO.widget.Calendar("ed_cal", {
                    iframe:false,          // Turn iframe off, since container has iframe support.
                    hide_blank_weeks:true  // Enable, to demonstrate how we handle changing height, using changeContent
                });
                ed_calendar.render();
 
                ed_calendar.selectEvent.subscribe(function() {
                    if (ed_calendar.getSelectedDates().length > 0) {
 
                        var selDate = ed_calendar.getSelectedDates()[0];
 
                        // Pretty Date Output, using Calendar's Locale values: Friday, 8 February 2008
                        //var wStr = ed_calendar.cfg.getProperty("WEEKDAYS_LONG")[selDate.getDay()];
                        var dStr = selDate.getDate();
                        var mStr = ed_calendar.cfg.getProperty("MONTHS_SHORT")[selDate.getMonth()];
                        var yStr = selDate.getFullYear();
        
                        Dom.get("ed_date").value = dStr + " " + mStr + " " + yStr;
                    } else {
                        Dom.get("ed_date").value = "";
                    }
                    ed_dialog.hide();
                });
 
                ed_calendar.renderEvent.subscribe(function() {
                    // Tell Dialog it's contents have changed, which allows 
                    // container to redraw the underlay (for IE6/Safari2)
                    ed_dialog.fireEvent("changeContent");
                });
            }
 
            var seldate = ed_calendar.getSelectedDates();
 
            if (seldate.length > 0) {
                // Set the pagedate to show the selected date if it exists
                ed_calendar.cfg.setProperty("pagedate", seldate[0]);
                ed_calendar.render();
            }
 
            ed_dialog.show();
        });

				// Pull initial geography for UK
				getGeography(2,false);
        
    });
})();

			function showSearchResults( searchData ) {
				var el = document.getElementById( "searchresults" );
				if( el ) {
					el.innerHTML = "";
					var searchResultHTML = "";
					if( searchData.length > 0 ) {
						searchResultHTML = "<h1>Search Results</h1><h2>Properties Found: " + searchData.length + "</h2>";
						el.innerHTML = searchResultHTML;
						
						for( var i = 0; i != searchData.length; i++ ) {
							searchResultHTML += '<div style="border: solid 1px #c0c0c0; width: 550px; overflow:hidden; padding: 5px; background:#ffffff;">';
							searchResultHTML += '<h3 style=\"padding:0 0 5px 0;margin:0;\">';
							searchResultHTML += '<a style="color:#9EC642;" href=\"javascript:showDetails('+searchData[i].id+')\">' + (searchData[i].h == '' ? searchData[i].pc : searchData[i].h) + '</a>';
							searchResultHTML += '</h3>';
							searchResultHTML += '<div style="float: left; width: 180px;">';
							searchResultHTML += '<a style="color:#9EC642;" href=\"javascript:showDetails('+searchData[i].id+')\">';
							if( searchData[i].img != '' ) {
								searchResultHTML += '<img style="width:152px;height:152px;border:solid 1px #c0c0c0;" src="' + searchData[i].img + '" alt="Property Image" title="Property Image" />';
							} else {
								searchResultHTML += '<img style="width:152px;height:152px;border:solid 1px #c0c0c0;" src="img/nopropertyimage.jpg" alt="No image available" title="No image available" />';
							}
							searchResultHTML += '</a>';
							searchResultHTML += '</div>';
							searchResultHTML += '<div style="float: left; width: 180px;">';
							searchResultHTML += '<a style="color:#9EC642;" href=\"javascript:showDetails('+searchData[i].id+')\">';
							if( searchData[i].lat && searchData[i].lng ) {
								searchResultHTML += '<img style="width:152px;height:152px;border:solid 1px #c0c0c0;" src="http://maps.google.com/maps/api/staticmap?center='+searchData[i].lat+','+searchData[i].lng+'&zoom=12&size=150x150&maptype=roadmap&sensor=false" />';
							} else {
								searchResultHTML += '<img style="width:152px;height:152px;border:solid 1px #c0c0c0;" src="http://maps.google.com/maps/api/staticmap?center='+searchData[i].pc+',UK&zoom=12&size=150x150&maptype=roadmap&sensor=false" />';
							}
							searchResultHTML += '</a>';
							searchResultHTML += '</div>';
							searchResultHTML += '<div style="float:left;">';
							searchResultHTML += '<p>Bedrooms: '+searchData[i].bdr+'</p>';
							searchResultHTML += '<p>Sleeps: '+searchData[i].s+'</p>';
							searchResultHTML += '<p>Bathrooms: '+searchData[i].bth+'</p>';
							searchResultHTML += '<p>Priced Between: '+searchData[i].pmin+' and '+searchData[i].pmax+'</p>';
							searchResultHTML += '<p>';
							if( searchData[i].p == 1 ) {
								searchResultHTML += '<img style="height:35px;width:35px;padding:5px;" src="img/petswelcome.gif" alt="Pets Welcome" title="Pets Welcome" />';
							}
							if( searchData[i].df == 1 ) {
								searchResultHTML += '<img style="height:35px;width:35px;padding:5px;" src="img/disabledfriendly.gif" alt="Disabled Friendly" title="Disabled Friendly" />';
							}
							if( searchData[i].inet == 1 ) {
								searchResultHTML += '<img style="height:35px;width:35px;padding:5px;" src="img/broadband.gif" alt="Broadband Available" title="Broadband Available" />';
							}
							searchResultHTML += '</p><p>';
							if( searchData[i].cf == 1 ) {
								searchResultHTML += '<img style="height:35px;width:35px;padding:5px;" src="img/childfriendly.gif" alt="Child friendly" title="Child friendly" />';
							}
							if( searchData[i].tv == 1 ) {
								searchResultHTML += '<img style="height:35px;width:35px;padding:5px;" src="img/tv.gif" alt="TV available" title="TV available" />';
							}
							if( searchData[i].hi == 1 ) {
								searchResultHTML += '<img style="height:35px;width:35px;padding:5px;" src="img/hifi.gif" alt="Music system available" title="Music system available" />';
							}
							searchResultHTML += '</p>';
							searchResultHTML += '</div>';
							searchResultHTML += '<div style="clear:both;"></div>';
							searchResultHTML += '</div>';
							searchResultHTML += '<br />';
						}
						
						el.innerHTML = searchResultHTML;
					} else {
						el.innerHTML = "<h1>Search Results</h1><h2>Sorry, no properties found matching your criteria</h2>";
					}
				}
			}

			function doSearch() {
				var el = document.getElementById( "mainContainer" );
				if( el ) {
					el.style.width = "574px";
				}
				el = document.getElementById( "detailscontainer" );
				if( el ) {
					el.style.display = "none";
				}
				el = document.getElementById( "searchresults" );
				if( el ) {
					el.style.display = "block";
				}
				el = document.getElementById( "adContainer" );
				if( el ) {
					el.style.display = "block";
				}

				wait_dialog.show();
				var criteria = "search.php?";
				criteria += getSearchCriteria();
				criteria += "&l=" + currentGeography;
				
				YAHOO.util.Connect.asyncRequest("GET", criteria, {
					success: function (o) {
						wait_dialog.hide();
						var i, r = eval('(' + o.responseText + ')');
						var curpos = r.length;
						showSearchResults(r);
						getGeography(currentGeography,false);
					},

					failure: function (o) {
						wait_dialog.hide();
						alert("Unable to get search results");
					}
					});

			}

	function closeDetails() {
		var el = document.getElementById( "detailscontainer" );
		if( el ) {
			el.style.display = "none";
		}
		el = document.getElementById( "mainContainer" );
		if( el ) {
			el.style.width = "574px";
		}
		el = document.getElementById( "searchresults" );
		if( el ) {
			el.style.display = "block";
		}
		el = document.getElementById( "adContainer" );
		if( el ) {
			el.style.display = "block";
		}
	}

	var geocoder;
	function doAddressLookup( address ) {
		
		if( !geocoder ) {
		 geocoder = new google.maps.Geocoder();
		}
		
		if( geocoder ) {
			geocoder.geocode( { 'address': address}, function(results, status) {
      	if (status == google.maps.GeocoderStatus.OK) {
        	map.setCenter(results[0].geometry.location);
        	map.setZoom(13);
        	if( marker ) {
        		marker.setMap( null );
        	}
							var markerOptions = {
								map: map,
								draggable: false,
								animation: google.maps.Animation.DROP,
								position: results[0].geometry.location,
								icon: new google.maps.MarkerImage('http://www.homes4holidays.co.uk/img/map_marker.png')
								};
								marker = new google.maps.Marker(markerOptions);
/*        	marker = new google.maps.Marker({
            	map: map,
          	  position: results[0].geometry.location,
          	  title:"Approximate Property Location",
          	  icon: new google.maps.MarkerImage('http://www.homes4holidays.co.uk/img/map_marker.png')
        	});*/
      	} else {
        	alert("Geocode was not successful for the following reason: " + status);
      	}
    		});
		}
	}

	var calAv;
	function renderCellStyleH4H_Red(workingDate, cell) {
		YAHOO.util.Dom.addClass(cell, "h4h_cal_red");
	}

	function showDetails( property_id ) {
		var el = document.getElementById( "detailsDescription" );
		if( el ) {
			el.innerHTML = "<p><img src=\"img/loading.gif\" title=\"Loading...\"  alt=\"Loading...\" width=\"42\" height=\"42\" /></p><p style=\"color:#808080;\">Loading...</p>";
		}
		el = document.getElementById( "detailsPricing" );
		if( el ) {
			el.innerHTML = "<p><img src=\"img/loading.gif\" title=\"Loading...\"  alt=\"Loading...\" width=\"42\" height=\"42\" /></p><p style=\"color:#808080;\">Loading...</p>";
		}
		el = document.getElementById( "adContainer" );
		if( el ) {
			el.style.display = "none";
		}

		el = document.getElementById( "mainContainer" );
		if( el ) {
			el.style.width = "754px";
		}

		el = document.getElementById( "detailscontainer" );
		if( el ) {
			el.style.display = "block";
		}
		el = document.getElementById( "searchresults" );
		if( el ) {
			el.style.display = "none";
		}

		// Get images
		imagesLeftPos = 0;
		minImagesLeftPos = 0;
		var submitURL = "get_image_urls.php?property_id=" + property_id;
		YAHOO.util.Connect.asyncRequest("GET", submitURL, {
			success: function (o) {
				var tw = 0;
				var el = document.getElementById( "imageScrollContainer" );
				if( el ) {
					var output = '';
					var r = eval('(' + o.responseText + ')');
					if( typeof r !== 'undefined' ) {
						if( r.length > 0 ) {
							for( var i in r ) {
								//output += '<div style="float:left;width:'+r[i].w+'px;"><img src="'+r[i].url+'" alt="'+r[i].d+'" title="'+r[i].d+'" /></div>';
								output += '<img src="'+r[i].url+'" alt="'+r[i].d+'" title="'+r[i].d+'" />';
								tw += (r[i].w*1);
							}
						}
					}
					el.innerHTML = output;
					el.style.width = tw+'px';
					minImagesLeftPos = tw * -1;
					minImagesLeftPos += 756;
				}
				
				$('#imageScrollContainer').galleria({
					width:756,
					height:420,
					autoplay: 5000
				});
			},

			failure: function (o) {
				var el = document.getElementById( "imageScrollContainer" );
				if( el ) {
					el.innerHTML = "<p>Unable to obtain property images, please try again later.</p>";
				}
			}
			});

		// Get descriptions
		var submitURL = "get_property_details.php?property_id=" + property_id;
		YAHOO.util.Connect.asyncRequest("GET", submitURL, {
			success: function (o) {
				var el = document.getElementById( "detailsDescription" );
				if( el ) {
					var output = '';
					var r = eval('(' + o.responseText + ')');
					if( typeof r !== 'undefined' ) {
						if( r.length > 0 ) {
							for( var i in r ) {
								output += '<h2>'+r[i][0]+'</h2>';
								output += '<div>'+r[i][1]+'</div>';
							}
						} else {
							output = '<p>Property description not available.</p>';
						}
					} else {
						output = '<p>Property description not available.</p>';
					}
					el.innerHTML = output;
				}
			},

			failure: function (o) {
				var el = document.getElementById( "detailsDescription" );
				if( el ) {
					el.innerHTML = "<p>Unable to obtain property description.</p>";
				}
			}
			});

		// Get main details
		var submitURL = "get_property_main.php?property_id=" + property_id;
		YAHOO.util.Connect.asyncRequest("GET", submitURL, {
			success: function (o) {
				var output = '';
				var r = eval('(' + o.responseText + ')');
				var el;
				if( typeof r !== 'undefined' ) {
					if( r.length > 0 ) {
						el = document.getElementById( "send_to" );
						if( el ) {
							el.innerHTML = r[0];
						}
						el = document.getElementById( "subject" );
						if( el ) {
							el.value = r[1];
						}
						el = document.getElementById( "detailsMain" );
						if( el ) {
							el.innerHTML = r[1];
						}
						
						output += '<p style="float:left;width:526px;color:#3D4C1A;font-weight:bold;font-size:10pt;margin:7px 0 0 10px;">Bedrooms: <span style="color:#f7941e;">' + r[3] + '</span>';
						output += ' Sleeps: <span style="color:#f7941e;">' + r[4] + '</span>';
						output += ' Bathrooms: <span style="color:#f7941e;">' + r[5] + '</span></p>';
						
						// Icons
// disabled_friendly 6
// child_friendly 7
// broadband 8
// tv 9
// hifi 10
// pets 11
						var icon_strip = '';
						if( r[6] == '1' ) {
							icon_strip += '<img style="margin:0 0 0 2px" src="img/green_disabledfriendly.gif" alt="Disabled friendly" title="Disabled friendly" />';
						}
						if( r[7] == '1' ) {
							icon_strip += '<img style="margin:0 0 0 2px" src="img/green_childfriendly.gif" alt="Child friendly" title="Child friendly" />';
						}
						if( r[8] == '1' ) {
							icon_strip += '<img style="margin:0 0 0 2px" src="img/green_broadband.gif" alt="Broadband available" title="Broadband available" />';
						}
						if( r[9] == '1' ) {
							icon_strip += '<img style="margin:0 0 0 2px" src="img/green_tv.gif" alt="TV available" title="TV available" />';
						}
						if( r[10] == '1' ) {
							icon_strip += '<img style="margin:0 0 0 2px" src="img/green_hifi.gif" alt="Music system available" title="Music system available" />';
						}
						if( r[11] == '1' ) {
							icon_strip += '<img style="margin:0 0 0 2px" src="img/green_petswelcome.gif" alt="Pets welcome" title="Pets welcome" />';
						}
						output += '<p style="float:left;width:220px;margin:0;text-align:right;">'+icon_strip+'</p>';
					} else {
						output = '<p>Main property details not available.</p>';
					}
				} else {
					output = '<p>Main property details not available.</p>';
				}
				el = document.getElementById( "maindetails" );
				if( el ) {
					el.innerHTML = output+"<div style=\"clear:both;\"></div>";
				}
			},

			failure: function (o) {
				var el = document.getElementById( "detailsMain" );
				if( el ) {
					el.innerHTML = "<p>Unable to obtain main property details.</p>";
				}
			}
			});

		// Get pricing
		var submitURL = "get_property_pricing.php?property_id=" + property_id;
		YAHOO.util.Connect.asyncRequest("GET", submitURL, {
			success: function (o) {
				var el = document.getElementById( "detailsPricing" );
				if( el ) {
					var output = '';
					var r = eval('(' + o.responseText + ')');
					if( typeof r !== 'undefined' ) {
						if( r.length > 0 ) {
							for( var i in r ) {
								output += '<div style=\"font-weight:bold;margin:0 0 10px 0;\">Priced between <span style="color:#F7941E">'+r[i][0]+'</span> and <span style="color:#F7941E">'+r[i][1]+'</span></div>';
								output += '<div>'+r[i][2]+'</div>';
							}
						} else {
							output = '<p>Property description not available.</p>';
						}
					} else {
						output = '<p>Property description not available.</p>';
					}
					el.innerHTML = output;
				}
			},

			failure: function (o) {
				var el = document.getElementById( "detailsPricing" );
				if( el ) {
					el.innerHTML = "<p>Unable to obtain property pricing.</p>";
				}
			}
			});

		// Get location
		var submitURL = "get_property_location.php?property_id=" + property_id;
		YAHOO.util.Connect.asyncRequest("GET", submitURL, {
			success: function (o) {
				//var el = document.getElementById( "detailsPricing" );
				if( !map ) {
					// Lazy load Google maps to ensure rendering is okay after hidden container
					myLatlng = new google.maps.LatLng(0,0);
					myOptions = {
						zoom: 10,
						center: myLatlng,
						mapTypeId: google.maps.MapTypeId.ROADMAP
					}
					map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
				}
				if( map ) {
					var output = '';
					var r = eval('(' + o.responseText + ')');
					if( typeof r !== 'undefined' ) {
						if( r.length > 0 ) {
							for( var i in r ) {
								if( r[i][1] != '' && r[i][2] != '' ) {
									myLatlng = new google.maps.LatLng(r[i][2], r[i][1]);
									map.setCenter( myLatlng );
									map.setZoom( 13 );
									if( marker ) {
										marker.setMap( null );
									}
							var markerOptions = {
								map: map,
								draggable: false,
								animation: google.maps.Animation.DROP,
								position: myLatlng,
								title:"Approximate Property Location",
								icon: new google.maps.MarkerImage('http://www.homes4holidays.co.uk/img/map_marker.png')
								};
								marker = new google.maps.Marker(markerOptions);
									/*marker = new google.maps.Marker({
										position: myLatlng,
										map: map,
										title:"Approximate Property Location",
										icon: new google.maps.MarkerImage('http://www.homes4holidays.co.uk/img/map_marker.png')
									});*/
								} else {
									// Need to look up post code
									if( r[i][0] != '' ) {
										doAddressLookup( r[i][0] );
									}
								}
							}
						} else {
							output = '<p>Property location not available.</p>';
						}
					} else {
						output = '<p>Property location not available.</p>';
					}
				}
			},

			failure: function (o) {
				alert( "Unable to obtain property location." );
			}
			});

		// Get availability
		YAHOO.util.Connect.asyncRequest("GET", "get_calendar_info.php?property_id=" + property_id, {
			success: function (o) {
				var i, r = eval('(' + o.responseText + ')');
				curpos = r.length;

				if( typeof calAv != 'undefined' ) {
					calAv.destroy();
				}
				calAv = new YAHOO.widget.CalendarGroup( "calAv", "calAvContainer", {navigator:true,pages:3} );
				for (i = 0; i < curpos; i++) {
					switch( r[i].renderer ) {
						case 'red':
							calAv.addRenderer(r[i].start_date+"-"+r[i].end_date, renderCellStyleH4H_Red);
							break;
						case 'amber':
							calAv.addRenderer(r[i].start_date+"-"+r[i].end_date, renderCellStyleH4H_Red);
							break;
						case 'green':
							calAv.addRenderer(r[i].start_date+"-"+r[i].end_date, renderCellStyleH4H_Red);
							break;
						default:
							calAv.addRenderer(r[i].start_date+"-"+r[i].end_date, renderCellStyleH4H_Red);
							break;
					}
				}
				calAv.render();

			},

			failure: function (o) {
				alert("Unable to get availability");
			}
			});

	}

	var imagesLeftPos = 0;
	var minImagesLeftPos = 0;
	function doImagesScroll( scrollAmount ) {
		var el = document.getElementById( "imageScrollContainer" );
		if( el ) {
			imagesLeftPos += scrollAmount;
			if( imagesLeftPos > 0 ) {
				imagesLeftPos = 0;
			}
			if( imagesLeftPos < minImagesLeftPos ) {
				imagesLeftPos = minImagesLeftPos;
			}
			el.style.left = imagesLeftPos + 'px';
		}
	}

	function sendMessage() {
		// Send message to owner
		var submitURL = "send_message.php?to=";
		var el = document.getElementById("send_to");
		if( el ) {
			submitURL += escape(el.innerHTML);
		}
		el = document.getElementById("subject");
		if( el ) {
			submitURL += '&s='+escape(el.value);
		}
		el = document.getElementById("msg");
		if( el ) {
			submitURL += '&m='+escape(el.value);
		}
		
		YAHOO.util.Connect.asyncRequest("GET", submitURL, {
			success: function (o) {
				alert( 'Message sent!' );
			},

			failure: function (o) {
				alert( 'Send message failed' );
			}
			});

	}

	function toggleElementById( id ) {
		if( id ) {
			var el = document.getElementById( id );
			if( el ) {
				if( el.style.display == 'block' ) {
					el.style.display = 'none';
				} else {
					el.style.display = 'block';
				}
			}
		}
	}

	// Initialize Google maps
	var myLatlng, myOptions, map, marker;

