// Quick function for integer
function is_int(value){
  if((parseFloat(value) == parseInt(value)) && !isNaN(parseInt(value))){
      return true;
 } else {
      return false;
 } 
}

// this is repeated on property9.js
function getLastSearchResults(searchString,fromPage,houseSwapInfo) {
	// ---------------------------------------------------------------------------------
	// combine cookie settings and url (or newly chosen) settings
	
	//alert ( searchString );
	
	// get the cookie
	var cookieSettings = $.cookie("searchSettings");
	
	// if 'searchSettings' cookie exists (and isn't empty)
	if (cookieSettings!=null && cookieSettings!='') {
		
		// if coming from paginate, get rid of format=var and next=var (otherwise they'll be seen as urlSettings below)
		if( searchString.match(/format/) ) {
			
			// split it at format= to separate the criteria and settings (now in [0]) from the paginate (in [1])
			var urlCriteriaAndSettingsAndPaginate = searchString.split('&format');
			var urlCriteriaAndSettings = urlCriteriaAndSettingsAndPaginate[0];
			var paginateStuff = '&format' + urlCriteriaAndSettingsAndPaginate[1];

		} else {
			var paginateStuff = '';
		}
		
		// separate the criteria (location, dates, sleeps) from the settings (sort, per page view)
		var urlCriteriaAndSettings = searchString.split('?');
		var urlCriteria = urlCriteriaAndSettings[0];
		var urlSettings = urlCriteriaAndSettings[1];
		
		// create some arrays
		var cookieSetting = new Array();
		var urlSetting = new Array();
		var finalSetting = new Array();
		
		// put all of the cookie settings into separate array items (empty array items if there's no cookie setting)
		if( cookieSettings.match(/sort/) ) { cookieSetting[0] = cookieSettings.replace(/.*(sort=[\w]*[^-]).*/,'$1'); }
		else { cookieSetting[0] = ''; }
		
		if( cookieSettings.match(/limit/) ) { cookieSetting[1] = cookieSettings.replace(/.*(limit=[\d]*[^-]).*/,'$1'); }
		else { cookieSetting[1] = ''; }
			
		if( cookieSettings.match(/view/) ) { cookieSetting[2] = cookieSettings.replace(/.*(view=[\w]*[^-]).*/,'$1'); }
		else { cookieSetting[2] = ''; }
			
		if( cookieSettings.match(/images/) ) { cookieSetting[3] = cookieSettings.replace(/.*(images=[\w]*[^-]).*/,'$1'); }
		else { cookieSetting[3] = ''; }
		
		// if there are some url settings as well, they should override any cookie settings
		if( urlSettings ) {
			
			// put all of the url settings into separate array items (if we don't find this, use the cookie instead)
			if( urlSettings.match(/sort/) ) { finalSetting[0] = urlSettings.replace(/.*(sort=[\w]*[^&]).*/,'$1'); }
			else if ( cookieSetting[0] != '' ) { finalSetting[0] = cookieSetting[0]; }
			else { finalSetting[0] = ''; }
			
			if( urlSettings.match(/limit/) ) { finalSetting[1] = urlSettings.replace(/.*(limit=[\d]*[^&]).*/,'$1'); }
			else if ( cookieSetting[1] != '' ) { finalSetting[1] = cookieSetting[1]; }
			else { finalSetting[1] = ''; }
				
			if( urlSettings.match(/view/) ) { finalSetting[2] = urlSettings.replace(/.*(view=[\w]*[^&]).*/,'$1'); }
			else if ( cookieSetting[2] != '' ) { finalSetting[2] = cookieSetting[2]; }
			else { finalSetting[2] = ''; }
				
			if( urlSettings.match(/images/) ) { finalSetting[3] = urlSettings.replace(/.*(images=[\w]*[^&]).*/,'$1'); }
			else if ( cookieSetting[3] != '' ) { finalSetting[3] = cookieSetting[3]; }
			else { finalSetting[3] = ''; }
		
		// if there aren't any url settings, just use the cookie settings as final
		} else {
			
			finalSetting[0] = cookieSetting[0];
			finalSetting[1] = cookieSetting[1];
			finalSetting[2] = cookieSetting[2];
			finalSetting[3] = cookieSetting[3];
			
		}
		
		
		var finalSettings = finalSetting[0] + '-' + finalSetting[1] + '-' + finalSetting[2] + '-' + finalSetting[3];
		
		finalSettings = finalSettings.replace(/[-]{2,}/g,'-');
		finalSettings = finalSettings.replace(/^-/,'');
		finalSettings = finalSettings.replace(/-$/,'');
		finalSettings = finalSettings.replace(/[-]/g, '&');
		
		
		searchString = urlCriteria + '?' + finalSettings + paginateStuff;
		//alert ( 'final settings ' +  urlCriteria + '?' + finalSettings);
		
		//alert ( searchString );
		
	} // end if 'searchSettings' cookie exists (and isn't empty)
	
	
	if(fromPage=='home') { var theUrl = "http://www.rentfortheholidays.com/vacation-rentals#"+searchString; }
	
	if(fromPage=='houseSwap') { var theUrl = "http://www.rentfortheholidays.com/house-swap/search#"+houseSwapInfo+searchString; }
	
	if(fromPage=='bnbPage') { var theUrl = "http://www.rentfortheholidays.com/bed-and-breakfast/search#"+searchString; }
	
	window.location=theUrl;
	
	//return false;


} // end the getLastSearchResults function
	

// ---------------------------------------------------------------------------------
// when the page has loaded

$(document).ready(function() {
						   
	
	// ---------------------------------------------------------------------------------
	// when search now is clicked
	
	$('.searchBtn').click(function() {
								   
		// get values from the form
		//var theLocation = "/" + $('#locationString').val();
		var theLocation = "/" + getLocationString($('#locationString').val());
        var theCheckIn = $('#checkInDate').val();
		var theCheckOut =  $('#checkOutDate').val();
		var basedOnLocation = $('#basedOnLocation').val();
		var theKeywords = '';
		var theKeyWordsFinal = '';
		
		// If its a property ID
		if (is_int($('#locationString').val())) {
			window.location="http://www.rentfortheholidays.com/redirect.php?pid="+$('#locationString').val();
			return false;
		}
		
		//alert ( theCheckOut );
		
		// if values are empty don't add them to hash or search string (check in/out done later)
		if (theLocation=='/' || theLocation=='/Where do you want to go?' || theLocation=='/i want to travel to...') { theLocation = '/all'; }
		if (theCheckIn=='' || theCheckIn=='undefined' || theCheckIn=='Check in') { theCheckIn = ''; }
		if (theCheckOut=='' || theCheckOut=='undefined' || theCheckOut=='Check out') { theCheckOut = ''; }
		
		// check basedOnLocation field - if true, perform a normal location search else keyworks search...
		if (basedOnLocation=='true') { 
			theLocation = theLocation.replace(/ /g,'+'); //g modifier means replace all i/o just first instance
		} 
		if (basedOnLocation!='true' && theLocation != '' && $('#locationString').val() != 'Where do you want to go?' && $('#locationString').val() != 'I want to travel to...') {
			theLocation = '/all';
			theKeyWords =  $('#locationString').val();
			theKeyWords = theKeyWords.replace(/ /g,'+');
			theKeyWordsFinal = '/terms:' + theKeyWords;	
		}
		
		// if check in/out aren't empty, create string
		if(theCheckIn!='' && theCheckOut!='') {
			theCheckInOut = '/period:' + theCheckIn + '_' + theCheckOut;
		} else {
			theCheckInOut = '';
		}
		
		//alert ( theLocation );
		
		// set the search string
		var searchString = theLocation + theCheckInOut + theKeyWordsFinal;
		
		// if this is coming from the house swap page
		if( $(this).hasClass('houseSwapPage') ) {
			
			// grab (then modify) the client's location
			var theClientLocation = getLocationString($('#theClientLocation').val());
			if (theClientLocation=='' || theClientLocation=='my home is located in...') { theClientLocation = ''; }
			theClientLocation = theClientLocation.replace(/ /g,'+');
			
			// if client location isn't empty
			if(theClientLocation!='') {
				// get just the most specific part of the location (usually the city)
				theClientLocation = theClientLocation.split(/\//g);
				theClientLocation = theClientLocation[theClientLocation.length-1];
				
				// start it with /my-location:
				theClientLocation = '/my-location:' + theClientLocation;
			}
			
			// get the data from the hidden fields
			var theCity = $('#hs_city').val();
			var theState =  $('#hs_state').val();
			var theCountry = $('#hs_country').val();
			
			// only include hidden data if it's not empty
			if (theCity!='') { theCity = '/hs-city:' + theCity; }
			if (theState!='') { theState =  '/hs-state:' + theState; }
			if (theCountry!='') { theCountry =  '/hs-country:' + theCountry; }
			
			// set the searchString			
			var searchString = searchString+theClientLocation+'/swap:1'+ theCity + theState + theCountry;
			
			var houseSwapInfo = '';
			var fromPage = 'houseSwap';
		} else if( $(this).hasClass('bnbPage') ) { 
			var houseSwapInfo = '';
			var fromPage = 'bnbPage';
		}			

		// if this is coming from the home page
		else {
			var houseSwapInfo = '';
			var fromPage = 'home';
		}
		
		// search and ajax the results
		getLastSearchResults(searchString,fromPage,houseSwapInfo);
		
		// Reset basedOnLocation
		$('#basedOnLocation').val('false');
		
		return false;
	});
	
	
	
	
	// ---------------------------------------------------------------------------------
	// when links that go to search page are clicked (this is repeated on property9.js)
	
	$('.searchLink').click(function() {
								   
		// get value from the link
		var theLocation = $(this).attr('href');
		
		// remove the excess (everything before '/location')
		theLocation = theLocation.replace(/vacation-rentals\/#/, '');
		
		// turn spaces into '+'
		theLocation = theLocation.replace(/ /g, '+');
		
		// set the search string
		var searchString = theLocation;
		
		// if this is coming from the house swap page
		if( $(this).hasClass('houseSwapPage') ) {
			var fromPage = 'houseSwap';
			var houseSwapInfo = '/swap:1';
		}

		// if this is coming from the home page
		else { var fromPage = 'home'; var houseSwapInfo = ''; }
		
		// search and ajax the results
		getLastSearchResults(searchString,fromPage,houseSwapInfo);
		
		return false;
	});
	
	

		
            
       // --------------------------------------------------------------------------------
       // Datepicker
        $("#checkInDate").datepicker({ dateFormat: 'yy-mm-dd',
                                    minDate: 0,
                                    beforeShow: customRange
                                    });
        $("#checkOutDate").datepicker({ dateFormat: 'yy-mm-dd',
                                    beforeShow: customRange
                                    });




	

}); // end document ready function



// ---------------------------------------------------------------------------------
// when an area in the map is clicked

function getLastSearchResultsFromMap(searchString,fromPage) {
							   
	// turn spaces into '+'
	theLocation = searchString.replace(/ /g, '+');
	
	// add swap:1 if this is from the house swap page
	if(fromPage=='houseSwap') {
		theLocation = theLocation+'/swap:1';
	}
	
	// search and ajax the results
	getLastSearchResults(theLocation,fromPage,'');
	
	return false;
}




// ---------------------------------------------------------------------------------
// function that cleans the search string

function cleanSearchString(remove,add){

	// get the search string from the hash
	var searchString = window.location.hash;
	
	// format the searchString
	//formatSearchString(searchString);
	
	// delete any #/ from the search string
	searchString = searchString.replace(/#\//g,'');

	//alert ( searchString );
	
	// turn all '?' and '&' into '|'
	searchString = searchString.replace(/[\?\&]/g,'|');
	
	//alert ( searchString );
	searchString = searchString.replace(/format=[a-z]+/gi,'');
	searchString = searchString.replace(/next=[0-9]+/g,'');
	searchString = searchString.replace(/startAt=[0-9\/]{1,}/gi,'');

	if(remove=='show'){
		searchString = searchString.replace(/limit=[0-9]+/g,'');
		searchString = searchString + '|limit='+add;
	}
	
	if(remove=='sort'){
		searchString = searchString.replace(/sort=[a-z\_]+/g,'');
		searchString = searchString + '|sort='+add;
	}
	
	if(remove=='view'){
		searchString = searchString.replace(/view=[a-z]+/g,'');
		searchString = searchString + '|view='+add;
	}
	
	if(remove=='images'){
		searchString = searchString.replace(/images=[a-z]+/g,'');
		searchString = searchString + '|images='+add;
	}
	//alert ( searchString );
	
	//turn any '||', '|||', '||||' etc into '|'
	searchString = searchString.replace(/[\|]{2,}/g,'|'); // now our search string is clean: crieria/var=var/var=var/var=var
	
	// now replace the first '|' with a '?'
	searchString = searchString.replace(/\|/,'?');
	// replace the rest of the '/' with '&'
	searchString = searchString.replace(/\|/g,'&'); // now our string is back to GET format
	
	return searchString;
	//alert ( searchString );


} // end clean search string function


// ---------------------------------------------------------------------------------
// function that shows the ajax loading gif (b/c the sort dropdowns are complex)

function showAjaxLoadingGif(target){
	$(target).parent().parent().parent().find('ul').css({ visibility: 'hidden' });
	$(target).parent().parent().parent().find('.active').css({ backgroundColor: '#2575AD', '-moz-border-radius' : '5px' }).html('<img src="/adam.more.ajaxloader.rev.gif" />');
}







formatSearchString = function(searchString){

	// delete any #/ from the search string
	searchString = searchString.replace(/#\//g,'');
	searchStringArray = searchString.split(/[\&\?]/);

	for(var i = 0; i <= searchStringArray.length; i++){
		
		
	}

	searchString = searchString+format+startAt+limit+next+sortBy;
	alert ( searchStringArray[2] );
	//alert ( searchString[0] + ' // ' + searchString[1] );	
	
	// from sort: #/allrmat=results&startAt=0&limit=10&next=11&sort=name_asc
	// from paginate: /vacation-rentals-search/allrmat=results&startAt=0&limit=10?next=21
	
}




// Datepicker
function customRange(input)
{
        var min = new Date(); //Set this to your absolute minimum date
        var dateMin = min;
        var dateMax = null;
        var today = new Date();

        if (input.id == "checkInDate") // Click on checkIn field | Min Date: Today - Max Date: Current Checkout date or today+1year
        {
            if ($("#checkOutDate").datepicker("getDate") != null && $("#checkOutDate").val() != "Check out")
            {
                dateMax = $("#checkOutDate").datepicker("getDate");
                dateMin = today;
                if (dateMin < min)
                {
                        dateMin = min;
                }
             }
             else
             {
                dateMin = 0;
                dateMax = today; //Set this to today
                dateMax.setDate(today + 365);

             }
        }
        else if (input.id == "checkOutDate" && $("#checkInDate").val() != "Check in")
        {

                if ($("#checkInDate").datepicker("getDate") != null)
                {
                        dateMin = $("#checkInDate").datepicker("getDate");
                        dateMax = new Date(); //Set this to today
                        dateMax.setDate(dateMin + 365);
                }
        }
    return {
                minDate: dateMin,
                maxDate: dateMax
            };

}

// Get the location in a proper formet: Country, states, city -> Country/states/city
function getLocationString(string) {
    // Split string: delimiter ","

    var data = string.split(",").reverse();
    var nbArg = data.length;
    var location = '';
    var loc;
    if (string != "Where do you want to go?") {
        // 3 differents cases
        for (var i=0;i < nbArg;i++ ) {
            loc = trim(data[i]).toLowerCase(); // .replace(/ /,"-") .. seo url?
            location = location + loc;
            if (i != nbArg-1) {
                location = location + '/';
            }
        }
    }
    return location;
}


/**
*
*  Javascript trim, ltrim, rtrim
*  http://www.webtoolkit.info/
*
**/

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}





/* ------------------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------------------- */
/* grabbed from property9.js */




//changed name of this function so they wouldn't conflict

function getLastSearchResults2(section,id,startAt,show,shown) {
	//alert ( 'hi' +  {$smarty.session.lastSearch_url} );
	$.ajax({
		type: "POST",
		
		url: "http://www.rentfortheholidays.com/vacation-rentals-search/"+lastSearchUrl+"&format=more&startAt="+startAt+"&limit="+show+"&current_id="+id,
		//data: "section=" + section + "&pid=" + id + "&startAt= " + startAt + "&show= " + show,
		cache: false,
		success: function(html){
			//alert ( {smarty.session.lastSearch_url} );
			$("#more_updates-"+section).append('<div id="'+startAt+'-'+section+'" style="display:none;">'+html+'</div>');
			$("#"+startAt+"-"+section).show();
			//$("#"+startAt+"-"+section).slideDown(500);
			$("#morebutton-"+section).html('&nbsp;&nbsp;<a id="'+section+'-'+id+'-'+shown+'-'+show+'" class="more" href="#">More results from your last search</a> <img style="visibility:hidden;" class="ajaxLoader" src="/adam.more.ajaxloader.gif" />');
			//alert ('hi');
			//$(".more").remove();
			//vacation-rentals-search/min:100/max:200/
		}
	});	
}







$(document).ready(function() {


	// More Search result
	$(".moreSearch").click(function() {
		var element = $(this);
		var elementId = element.attr('id');
		if ( elementId.indexOf("morebutton-") > -1 ) { element = element.find('a'); }
		var infoFromId = element.attr("id");
		var infoFromId = infoFromId.split('-');
		var section = 'lastSearchResults';
		var id = infoFromId[1];
		var startAt = infoFromId[2];
		var show = infoFromId[3];
		// First lauch
		if (startAt == '') {
			var startAt = '0';
			var show = '4';
		}
		var shown = parseInt(startAt) + parseInt(show);
		
		getLastSearchResults2(section,id,startAt,show,shown);
		
	});
	
	// Top tabs, middle tabs, and bottom tabs
	var listView = false; // so the read more link knows we're in tabView
	$.fn.simpleTabs = function(){ 
		// do this right away
		$(this).find(".tabContent").hide(); //Hide all content
		$(this).find("ul.tabs li:first").addClass("active").show(); //Activate first tab
		$(this).find(".tabContent:first").fadeIn(); //Show first tab content
	
		// if any tab clicked (including List View, which counts as a tab)
		$("ul.tabs li").click(function() {
			
			// if Switch to List View button clicked
			if( $(this).find("a").attr("href") == '#listView' ) {
				// figure out which tab we're on and give it the class 'current'
				var $setOfTabs = $(this).parent().parent().attr('class').split(' ').slice(-1); //Figure out which set of tabs was clicked
				$('.current').removeClass('current');
				$("."+$setOfTabs+" .tabContent").each(function(){
					if( $(this).css('display') === 'block' ){
						$(this).addClass('current');
					};
				});
				var $target = $(".current");
				
				// show content and hide tabs
				$(".middleTabs .tabContent, .bottomTabs .tabContent").show(); //Show all content
				$(".middleTabs .tabContent, .bottomTabs .tabContent").find("h2").show(); //Show all h2s
				$(".middleTabs ul.tabs, .bottomTabs ul.tabs").hide(); //Hide the tabs
				$(".middleTabs .tabContainer").css({ border: "none", width: "928px" });
				$(".bottomTabs .tabContainer").css({ borderTop: "solid 1px #cccccc", borderLeft: "solid 1px #cccccc", borderRight: "solid 1px #cccccc", borderBottom: "solid 1px #cccccc", width: "926px" });//middleTabs and bottomTabs differ here
				$(".middleTabs .tabContent").css({ padding: "0" });
				$(".bottomTabs .tabContent").css({ padding: "7px" });//middleTabs and bottomTabs differ here
				
				// use target to send down the page
				$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
				if ($target.length) {
					var targetOffset = $target.offset().top;
					$('html,body').animate({scrollTop: targetOffset}, 500);
				}
				
				// final steps
				listView=true;
				makeCookie();
				return false;

			}// end if List View button clicked
			
			// if any tab other than List View clicked
			else {
				$(this).parent().parent().find("ul.tabs li").removeClass("active"); //Remove any "active" class
				$(this).addClass("active"); //Add "active" class to selected tab
				$(this).parent().parent().find(".tabContent").fadeOut("fast", function(){
					$(activeTab).fadeIn("fast"); //Fade in the active ID content
				}); //Hide all tab content
				var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content (this must go after it's called above or it flashes twice)
			}
			
			return false;
		});//end tab clicked function
		
	};//end simpleTabs function
	
	
	// Read more
	$("a.readMore[href*=#]").click(function() {

		//to keep it from firing twice
		var alreadyRan = false;
		
		//if it hasn't run (this just keeps it from firing twice, which it likes to do)
		if(alreadyRan==false){
			//if we're in tab view
			if(listView==false){
				//set the target, fade the correct tab in
				var $target = $(".middleTabs");
				$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
				if ($target.length) {
					var targetOffset = $target.offset().top-14;
					$('html,body').animate({scrollTop: targetOffset}, 500, function(){ 
						$(".middleTabs ul.tabs li").removeClass("active"); //Remove any "active" class
						$(".middleTabs ul.tabs li:eq(1)").addClass("active"); //Add "active" class to selected tab
						$(".middleTabs .tabContent").fadeOut("fast", function(){
							$(".middleTabs #propertyDetailsTab").fadeIn("fast"); //Fade in the active ID content
						});
					
					});
					return false;
				}
			}//end if we're in tab view
			
			//if we're in list view
			else if(listView==true){
				//set the target, scroll down the page
				var $target = $("#propertyDetailsTab");
				$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
				if ($target.length) {
					var targetOffset = $target.offset().top;
					$('html,body').animate({scrollTop: targetOffset}, 500);
					return false;
				}
			}//end if we're in list view
			
			//so it won't run twice
			alreadyRan = true;
		}//end if hasn't run
		return false;
	});//end Read more clicked
	
	
	// Switch to Tab View
	$(".tabView").click(function() {

		//get info about selected set of tabs, selected tab button, selected tab content
		var $setOfTabs = $(this).parent().parent().parent().parent().attr('class').split(' ').slice(-1);
		if( $setOfTabs=='middleTabs' ) { var $otherSetOfTabs = 'bottomTabs' } else { var $otherSetOfTabs = 'middleTabs' }
		var $selectedTabButtonId = $(this).parent().parent().attr('id'); // get the selected container's id
		var $selectedTabContent = $(this).parent().parent(); // get the selected container div
		//alert ( $setOfTabs );

		//do this for the middle and bottom sets of tabs
		$(".middleTabs .tabContent, .bottomTabs .tabContent").hide(); //Hide all content
		$(".middleTabs .tabContent, .bottomTabs .tabContent").find("h2").hide(); //Hide H2s
		$(".middleTabs ul.tabs li, .bottomTabs ul.tabs li").removeClass("active"); //Remove any "active" class
		$(".middleTabs ul.tabs, .bottomTabs ul.tabs").show(); //Activate first tab

		//do this for just the selected set of tabs
		$("."+$setOfTabs+" ul.tabs li a[href*="+$selectedTabButtonId+"]").parent().addClass("active").show(); //Activate selected tab buttton
		$selectedTabContent.fadeIn(); //Show selected tab content

		//for the other (non-selected) set of tabs
		$("."+$otherSetOfTabs+" ul.tabs li:first").addClass("active").show(); //Activate first tab button
		$("."+$otherSetOfTabs+" .tabContent:first").fadeIn(); //Activate first tab content

		//for middle and bottom sets again	
		$(".middleTabs .tabContainer, .bottomTabs .tabContainer").css({ border: "1px solid #ccc", width: "926px" });
		$(".middleTabs .tabContent, .bottomTabs .tabContent").css({ padding: "20px 10px 20px 10px" });
		$(".middleTabs ul.tabs, .bottomTabs ul.tabs").css({ marginBottom: "-1px" });
		
		//set view type
		listView=false;
		
		//scroll up
		$target = $("."+$setOfTabs);
		$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
		if ($target.length) {
			var targetOffset = $target.offset().top-14;
			$('html,body').animate({scrollTop: targetOffset}, 500);
		}
		
		//final steps
		makeCookie();
		return false;
	});
	
	
	
	// Related properties (in the bottomTabs) rollover - NOTE: this is repeated in templates/includes/search-more.tpl, so if you change this change that as well
	$('.relatedProperty').mouseover(function() {
		$(this).css({ backgroundColor : 'white', cursor : 'pointer' });
	});
	$('.relatedProperty').mouseout(function() {
		$(this).css({ backgroundColor : '', cursor : 'arrow' });
	});
	
	
	//Things to fire
	$("div[class^='simpleTabs']").simpleTabs(); //Run function on any div with class name of "Simple Tabs"
	$('#virtualTourSelector0').find('img').css({ border : 'solid 1px white' });
	


	

}); // end pageLoaded