jQuery.noConflict();

/*
 * General DOM ready statemenets
 */
jQuery(function($) {
	
	//IE6
	if (($.browser.msie) && ($.browser.version <= 6)) {
		$('#meta-nav ul li:first-child').addClass('first-child');
		$('input:text').addClass('text')
		$('input:submit').addClass('submit')
	}
	
	//EmptyOnFocus
	$('.box form').emptyOnFocus();
			
	 equalHeight($('.column'));
	 
	 function equalHeight(group) {
	   tallest = 0;
	   group.each(function() {
	      thisHeight = $(this).height();
	      if(thisHeight > tallest) {
	         tallest = thisHeight;
	      }
	   });
	   group.css('min-height', tallest);
	}
		 
	 
	$('#type').change(function() {
	  $("#searchhouseform").attr("action",$(this).val()); 
	});
	
	var $tell = jQuery('#tell-a-friend');
	var $tellContent = jQuery('#tell-a-friend-content', $tell);
	
	//If no cookie is set, the element is hidden
	if (!jQuery('#tell-a-friend').is('.open')) $tellContent.hide();
	jQuery('.tipafriend').click(function(){
		if ($tellContent.is(':hidden')) {
			$tellContent.show('fast');
		} else {
			$tellContent.hide('fast');
		}		
	});
	
	//Lightbox
	$('#gallery').find('a').fancybox();
	
	$.fn.cycle.updateActivePagerLink = function(pager, currSlideIndex) { 
	    $(pager).find('li').removeClass('active') 
	        .filter('li:eq('+currSlideIndex+')').addClass('active'); 
	}; 
	
	$('#gallery').after('<ul id="gallery-nav">').cycle({
		fx:     'scrollBothWays', 
	    timeout: 0, 
	    pager:  '#gallery-nav',
	   // next:   '.next', 
	   // prev:   '.prev',
	    
	    
		pagerAnchorBuilder: function(idx, slide) {
			img = slide.getElementsByTagName('img')[0];
        	return '<li><a href="#"><img src="'+img.src+'" width="51" height="33" /></a></li>';
    	} 
	});

	
	//Carousel
	function thumbs_initCallback(carousel) {
		$('.next').bind('click', function() {
	        carousel.options.scroll = 1;
			carousel.next();
	        return false;
	    });

	    $('.prev').bind('click', function() {
	        carousel.options.scroll = 1;
	    	carousel.prev();
	        return false;
	    });

	}; 
	$('#gallery-nav:not(:empty)').jcarousel({ initCallback: thumbs_initCallback });

});