/**
 * ---------------------- Subversion Information ------------------------------
 * ****************************************************************************
 * $Date: 2009-09-24 12:25:02 -0700 (Thu, 24 Sep 2009) $
 * $Rev: 311 $
 * $Author: phil $
 *
 * SVN URL of this file
 * $HeadURL: http://hal/svn/design-framework/main/lec2/inc/js/docready.js $
 * ****************************************************************************
 *
 * @copyright Real Estate Webmasters 2008
 */
$(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');

    if (idxresults == 'classic') {
        $('#idx-results> div.idx-listing').removeClass('thumbnail');
        $('#thumbnail').removeClass('current-view');
        $('#classic').addClass('current-view');
    }

    // Contact Us - 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;
  	});

    // Local Area Index - Show Hide
    $('li#contact> a').click(function() {
        $('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
    $('a.hide-ss').click(function() {
        $('a.hide-ss').css("display","none");
        $('a.show-ss').css("display","block");
        $('div#slideshow-wrap').slideUp('slow');
        $('div#slideshow-control> a')[0].blur();
        $.cookie('slideShow', 'collapsed', {path: '/'});
        return false;
    });

    $('a.show-ss').click(function() {
        $('a.show-ss').css("display","none");
        $('a.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') {
        $('a.hide-ss').css("display","none");
        $('a.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').click(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;
  	});

    $('#footer-links').find('ul').not(':lt(2)').addClass('no-margin');

    if (typeof bigframe == "function") {
        $('div.suggestionsBox').bgiframe();
    }

    $('#feat-listings').find('li').not(':lt(3)').addClass('no-margin');


	/* equal size cols, added by phil */

	$('#two-columns').each(function() {
		$('>div', this).css('height','auto');
		var $topHeight = 0;
		$('>div', this).each(function() {
			if($(this).innerHeight() > $topHeight) {
				$topHeight = $(this).innerHeight();
			}
		});
		$('>div', this).height($topHeight);
	});

});

