$(document).ready(function() {
	
// GENERAL
	$('a[rel*=facebox]').facebox();
	
// TWITTER FEED	
//	var tweet = $('#twitter-feed ul li');
//	tweet.html(tweet.html().replace(/urbannashville:/, ""));	

	$(".post-excerpt").attr("style", "");
	$('.post-excerpt h1').wrapInner('<p/>').children().unwrap();
	$('.post-excerpt a').contents().unwrap();


	
	$("#twitter-feed ul").cycle({
			next: '#next-tweet',
			prev: '#prev-tweet',
			pause: 1,
			speed: 500,
			timeout: 6000,
			cleartypeNoBg: true
	});	

	$("#twitter-feed ul li").each(function() {
	if ($(this).height() > 56) {	
     	$(this).addClass('wrap-tweet');
	}
	});
	
	$("#contact-form").validate();
		
	// LISTINGS
	var zoomOverlay = '<span class="zoom-overlay"></span>';
	$(".listing-thumbs li").append(zoomOverlay);
	$(".listing-thumbs li").hover( function() {			
			// $(this).find('img').fadeTo("normal", 0.5);
			$(this).find('.zoom-overlay').fadeTo("fast", 0.7);			
		}, function() {
			// $(this).find('img').fadeTo("normal", 1.0);
			$(this).find('.zoom-overlay').fadeTo("normal", 0.0);		
		});
	$(".listing-thumbs li").css('cursor','pointer');
	$('.listing-thumbs li').click(function() {
			var href = $(this).find("a").attr("href");
			if(href) {
				window.location = href;
			}
		});			
	$(".listing-thumbs li:nth-child(3n+1)").addClass('clear');	
		
	function sidebarListingOn(){
		$(this).css('z-index','1000');
		//	$(this).siblings().stop().fadeTo(200,0.5);
			$(this).find('.listing-details').fadeIn("fast");
	}	
	function sidebarListingOff(){ 
	 	$(this).css('z-index','0');
		//	$(this).siblings().stop().fadeTo(200,1.0);
			$(this).find('.listing-details').fadeOut("fast");
	}
	var config = {    
		 sensitivity: 2, 
		 interval: 100, 
		 over: sidebarListingOn, 
		 timeout: 300, 
		 out: sidebarListingOff 
	};
	$(".sidebar-listings li").hoverIntent(config);
	$('.sidebar-listings li .listing-details').click(function() {
			var href = $(this).find("a").attr("href");
			if(href) {
				window.location = href;
			}
		});		
	
	var hiddenListings = $('.expanding li:gt(11)').hide();  
  if (hiddenListings.size() > 0) {
      var showCaption = '...' + hiddenListings.size() + ' More Listings';
      $('.expanding').append(
          $('<li id="toggler">' + showCaption + '</li>')
              .toggle(
                  function() {
                      hiddenListings.fadeIn('normal');
                      $(this).text('...View Less');
                  },
                  function() {
                      hiddenListings.fadeOut('normal');
                      $(this).text(showCaption);
                  }
              )
      );
  }	
		
		
// LISTING DETAILS
	$("#email-this-form,#request-showing-form").hide();		
		
		
	// DEVELOPMENTS 
	//	$(".development-thumbs li").hover( function() {
	//		$(this).find('img').fadeTo("normal", 0.5);
	//	}, function() {
	//		$(this).find('img').fadeTo("normal", 1.0);
	//	});
	//	$(".development-thumbs li").css('cursor','pointer');
	//	$('.development-thumbs li').click(function() {
	//			var href = $(this).find("a").attr("href");
	//			if(href) {
	//				window.location = href;
	//			}
	//		});
	
	$(".development-thumbs li").append(zoomOverlay);
	$(".development-thumbs li").hover( function() {			
			// $(this).find('img').fadeTo("normal", 0.5);
			$(this).find('.zoom-overlay').fadeTo("fast", 0.7);			
		}, function() {
			// $(this).find('img').fadeTo("normal", 1.0);
			$(this).find('.zoom-overlay').fadeTo("normal", 0.0);		
		});
	$('.development-thumbs li').click(function() {
			var href = $(this).find("a").attr("href");
			if(href) {
				window.location = href;
			}
		});	

  
	
	// EQUAL COL HEIGHT
	var max_height = 0;
	$("div.container").each(function(){
	if ($(this).height() > max_height) { max_height = $(this).height(); }
	});
	$("div.container").height(max_height);

	
	
	// STIPED TABLES
	$("table.striped tr:odd").addClass("alt-row");


	
 });
