$(document).ready(function() {
	
	$("#category").change(function(){
		if($("#category option:selected").val() == "residential"){
			$('.loadSearch').load('/search_residential.php');
		}
		
		if($("#category option:selected").val() == "land"){
			$('.loadSearch').load('/search_land.php');
		}
		
		if($("#category option:selected").val() == "commercial"){
			$('.loadSearch').load('/search_commercial.php');
		}
		
	});
	
	
	// Code for Utility Navigation
    $("#nav ul li ul").hide();
    $("#nav ul li").hoverIntent(
    	function(){
            $(this).addClass('active').children('ul').slideDown('fast');
        },
        function(){
           $(this).removeClass('active').children('ul').slideUp('fast');
        }
    );

	// Pretty Photo
	$(".gallery").prettyPhoto();


/**
 * jQuery Resettable - A plugin function to make form fields reset to their initial values when left blank
 * Copyright (c) 2010 Ben Byrne - ben(at)fireflypartners(dot)com | http://www.fireflypartners.com
 * Dual licensed under MIT and GPL.
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Date: 03/12/2010
 * @author Ben Byrne
 * @version 0.2.0
 *
 */

  $.fn.resettable = function ( ) {
  
    fields = new Array();
  
    this.each(function() {
  
      //check to make sure the element has a name attribute. If not, do nothing!
      //if (!jQuery(this).attr("name")) return true;
    
      jQuery(this).data("original", jQuery(this).val()) ;
      
      jQuery(this).focus(function() {
        if ( jQuery(this).val() == jQuery(this).data("original") ) 	jQuery(this).val("");   
      }).blur(function() {
    		if (jQuery(this).val() == "") jQuery(this).val( jQuery(this).data("original") );
      });
      
    });
    return this;
  }

	// Call the function
	$('input[type="text"]').resettable();


		// ###
		// scrolling for anchor links! 
		// ###
			$("a[href*='#']").click(function(event){
				//prevent the default action for the click event
				event.preventDefault();
		
				//get the full url - like mysitecom/index.htm#home
				var full_url = this.href;

				//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
				var parts = full_url.split("#");
				var trgt = parts[1];

				//get the top offset of the target anchor
				var target_offset = $("#"+trgt).offset();
				var target_top = target_offset.top-40;
		
				//goto that anchor by setting the body scroll top to anchor top
				$('html, body').animate({scrollTop:target_top}, 500);
			});




});	// END $(document).ready(function()
