$(document).ready(function()
{
	// IDX RESULT VIEW
	
	
	 $('#thumbnail').click(function(){
	    $('#idx-results> div.idx-listing').addClass('thumbnail');
		$('#thumbnail').addClass('current-view');
		$('#classic').removeClass('current-view');
		$.cookie('idxresults', 'thumbnail', {path: '/'});
	 });
	
	 $('#classic').click(function(){
	    $('#idx-results> div.idx-listing').removeClass('thumbnail');
		$('#thumbnail').removeClass('current-view');
		$('#classic').addClass('current-view');
		$.cookie('idxresults', 'classic', {path: '/'});
	 });
	
		var idxresults = $.cookie('idxresults');
			// Set the user's selection for the left column
			if (idxresults == 'classic') {
				$('#idx-results> div.idx-listing').removeClass('thumbnail');
				$('#thumbnail').removeClass('current-view');
				$('#classic').addClass('current-view');
			};
	
	
	
	
	// Local Area Index - Show Hide	
	   $('#local-area-index-wrap:visible').hide();
	   $('#contact-us-wrap:visible').hide();
	
	
	   	$('li#area-index> a').click(function() {
			 $('div#local-area-index-wrap').slideToggle('slow').siblings('div#contact-us-wrap:visible').slideUp('slow');
			 $('li#area-index> a')[0].blur();
			  $(this).toggleClass('opened');
			  $('li#contact> a.opened').removeClass('opened');
	
			 return false;
	  	});
	
	
	// Contact Us - Show Hide
		$('li#contact> a').click(function()
		{
			var contact_regx = new RegExp("<!--Drop Down Contact Page -->", "i");
	        if(!contact_regx.test($('div#contact-us').html())) {
	            $('div#contact-us').load("/inc/php/drop-down-contact.inc.php");
	        }
	        
			 $('div#contact-us-wrap').slideToggle('slow').siblings('div#local-area-index-wrap:visible').slideUp('slow');
			 $('li#contact> a')[0].blur();
			 $(this).toggleClass('opened');
			 $('li#area-index> a.opened').removeClass('opened');
	
			 return false;
	  	});
	
	// Slide show
	
	  $('.hide-ss').click(function() {
	  		$('.hide-ss').css("display","none");
			$('.show-ss').css("display","block");
			$('div#slideshow-wrap').slideUp('slow');
			$('div#slideshow-control> a')[0].blur();
			$.cookie('slideShow', 'collapsed', {path: '/'});
			return false;
	  	});
	
	  $('.show-ss').click(function() {
			$('.show-ss').css("display","none");
			$('.hide-ss').css("display","block");
			$('div#slideshow-wrap').slideDown('slow');
			$('div#slideshow-control> a')[0].blur();
			$.cookie('slideShow', 'expanded');
			 return false;
	  	});
	
		  var slideShow = $.cookie('slideShow');
			// Set the user's selection for the left column
			if (slideShow == 'collapsed') {
				$('.hide-ss').css("display","none");
				$('.show-ss').css("display","block");
				$('div#slideshow-wrap').hide();
			};
	
	
	
	// Quick Search Effects
	
		$('div#quick-search> dl:eq(0)> dd:gt(0)').hide();
		$('div#quick-search dt#qs-nav-city').addClass('qs-dt-current');
	
		$('#quick-search> dl:eq(0)> dt').mouseover(function() {
			$(this).next('dd:hidden').show().siblings('dd:visible').hide();
			$(this).addClass('qs-dt-current').siblings('dt').removeClass('qs-dt-current');
		 return false;
		});
	
	// Account Sign in
	
	if(typeof( window[ 'showRegister' ] ) != "undefined") {
		if(showRegister == "true") {
			$('div#log-in:visible').show();
		} else {
			$('div#log-in:visible').hide();
		}
	}
		$('div#my-account> a').click(function() {
			 $('div#log-in').slideToggle('slow');
			 $('div#my-account> a')[0].blur();
	
			 return false;
	  	});
	
	
	$('#feat-listings').find('li').not(':lt(3)').addClass('no-margin');
	$('#footer-links').find('ul').not(':lt(2)').addClass('no-margin');
	
	if(typeof bigframe == "function") {
	    $('.suggestionsBox').bgiframe();
	}


	$('div#quick-search dl:eq(0) dt').live('click', function()
	{
	    $.get('/inc/php/quick_search/quick-search.inc.php', {
            ajax: true,
            qs: $(this).children('a').attr('class')
        }, function (data, status) {
            $('div#quick-search dl:eq(0)').after(data).remove();
	    });
        $(this).addClass('qs-dt-current').siblings('dt').removeClass('qs-dt-current');
        return false;
	});
	
	$('#quick-search-dynamic').load('/inc/php/quick_search/quick-search.inc.php', function () {
		$('div#quick-search dt.qs-dt-current').trigger('click');
	});
	
});

function subLookup(inputString) {
    if(inputString.length == 0) {
        // Hide the suggestion box.
        $('#sub_suggestions').hide();
    } else {
        $.post("/inc/php/quick_search/subdivisions.php", {queryString: ""+inputString+""}, function(data){
            if(data.length >0) {
                $('#sub_suggestions').show();
                $('#sub_autoSuggestionsList').html(data);
            }
        });
    }
}

function subFill(thisValue) {
    $('#subdivision').val(thisValue);
   $('#sub_suggestions').hide();
}

function schlLookup(inputString) {
    if(inputString.length == 0) {
        // Hide the suggestion box.
        $('#schl_suggestions').hide();
    } else {
        $.post("/inc/php/quick_search/schools.php", {queryString: ""+inputString+""}, function(data){
            if(data.length >0) {
                $('#schl_suggestions').show();
                $('#schl_autoSuggestionsList').html(data);
            }
        });
    }
}

function schlFill(thisValue, thisField) {
    $('#school').val(thisValue);
    $('#school_type').val(thisField);
    $('#schl_suggestions').hide();
}