jQuery(document).ready(function() {

    // Version check based upon the values
    if(typeof window.DetectFlashVer == 'function') {
        var hasReqestedVersion = DetectFlashVer(8, 0, 0);
        if (hasReqestedVersion) {
            jQuery('#slideshow-wrap').flash({
        		src: '/swf/cycler.swf',
        		width: 660,
        		height: 283,
        		wmode: 'transparent'
        	});
        } else {
            jQuery('#slideshow-wrap').html('This content requires the Flash Player. <a href="http://get.adobe.com/flashplayer/" target="_blank">Download Flash Player</a>.');
        }
    }

	jQuery('.tabbed .tab').hide();
	jQuery('.tabbed .tab:first').show();
	jQuery('.tabbed .tabset ul li:first').addClass('current');
	jQuery('.tabbed .tabset ul li a').click(function(){
		jQuery('.tabbed .tabset ul li').removeClass('current');
		jQuery(this).parent().addClass('current');
		var currentTab = jQuery(this).attr('href');
		jQuery('.tabbed .tab').hide();
		jQuery(currentTab).fadeIn();
		jQuery(this).blur();
		return false;
	});

	jQuery('img[align]').addClass('floated');
	jQuery('img[align=right]').addClass('alt');

    // IDX RESULT VIEW
    jQuery('#thumbnail').click(function(){
        jQuery('#idx-results> div.idx-listing').addClass('thumbnail');
    	jQuery('#thumbnail').addClass('current-view');
    	jQuery('#classic').removeClass('current-view');
    	jQuery.cookie('idxresults', 'thumbnail', {path: '/'});
    });

    jQuery('#classic').click(function(){
        jQuery('#idx-results> div.idx-listing').removeClass('thumbnail');
    	jQuery('#thumbnail').removeClass('current-view');
    	jQuery('#classic').addClass('current-view');
    	jQuery.cookie('idxresults', 'classic', {path: '/'});
    });

	var idxresults = jQuery.cookie('idxresults');
	// Set the user's selection for the left column
	if (idxresults == 'classic') {
		jQuery('#idx-results> div.idx-listing').removeClass('thumbnail');
		jQuery('#thumbnail').removeClass('current-view');
		jQuery('#classic').addClass('current-view');
	};

    // Contact Us - Show Hide
    jQuery('#local-area-index-wrap:visible').hide();
    jQuery('#contact-us-wrap:visible').hide();

   	jQuery('li#area-index> a').click(function() {
		 jQuery('div#local-area-index-wrap').slideToggle('slow').siblings('div#contact-us-wrap:visible').slideUp('slow');
		 jQuery('li#area-index> a')[0].blur();
		 jQuery(this).toggleClass('opened');
		 jQuery('li#contact> a.opened').removeClass('opened');

		 return false;
  	});

    // Local Area Index - Show Hide
	jQuery('li#contact> a').click(function() {
		 jQuery('div#contact-us-wrap').slideToggle('slow').siblings('div#local-area-index-wrap:visible').slideUp('slow');
		 jQuery('li#contact> a')[0].blur();
		 jQuery(this).toggleClass('opened');
		 jQuery('li#area-index> a.opened').removeClass('opened');

		 return false;
  	});

    // Slide show
    jQuery('.hide-ss').click(function() {
  		jQuery('.hide-ss').css("display","none");
		jQuery('.show-ss').css("display","block");
		jQuery('div#slideshow-wrap').slideUp('slow');
		jQuery('div#slideshow-control> a')[0].blur();
		jQuery.cookie('slideShow', 'collapsed', {path: '/'});
		return false;
  	});

    jQuery('.show-ss').click(function() {
		jQuery('.show-ss').css("display","none");
		jQuery('.hide-ss').css("display","block");
		jQuery('div#slideshow-wrap').slideDown('slow');
		jQuery('div#slideshow-control> a')[0].blur();
		jQuery.cookie('slideShow', 'expanded');
		 return false;
  	});

    var slideShow = jQuery.cookie('slideShow');
	// Set the user's selection for the left column
	if (slideShow == 'collapsed') {
		jQuery('.hide-ss').css("display","none");
		jQuery('.show-ss').css("display","block");
		jQuery('div#slideshow-wrap').hide();
	};
	// REWMOD
	if(slideShow == undefined || slideShow == '') {
		jQuery.cookie('slideShow', 'collapsed', {path: '/'});
	}

// Quick Search Effects

	jQuery('div#quick-search> dl:eq(0)> dd:gt(0)').hide();
	jQuery('div#quick-search dt#qs-nav-city').addClass('qs-dt-current');

	jQuery('#quick-search> dl:eq(0)> dt').mouseover(function() {
		jQuery(this).next('dd:hidden').show().siblings('dd:visible').hide();
		jQuery(this).addClass('qs-dt-current').siblings('dt').removeClass('qs-dt-current');
	 return false;
	});

// Account Sign in

if(showRegister == "true") {
	jQuery('div#log-in:visible').show();
} else {
	jQuery('div#log-in:visible').hide();
}
	jQuery('div#my-account> a').click(function() {
		 jQuery('div#log-in').slideToggle('slow');
		 jQuery('div#my-account> a')[0].blur();

		 return false;
  	});


jQuery('#feat-listings').find('li').not(':lt(3)').addClass('no-margin');
jQuery('#footer-links').find('ul').not(':lt(2)').addClass('no-margin');


	jQuery('#feat-listings li .fl-view a').each(function() {
		link = jQuery(this).attr('href');

		jQuery(this).parents().parents('li')

		.hover(
			   function() { jQuery(this).addClass('hover');},
			   function() { jQuery(this).removeClass('hover');
		})

//		.click(function() {
//			window.location = link;
//		});


	});

	jQuery('.marketstats tr:odd').addClass('odd');


});



