jQuery(function ($) {

//Accordion
$('#accordion').accordion({
			active: false,
			autoHeight: false,
			navigation: true
		});

//AJAX

	//$('#flip ul li:nth-child(2)').addClass('activeSlide');

	jQuery(document).ready(function ($) {
	    function load(num) {
	        $('.property').load(num).hide().fadeIn();
	    }
	
	    $.history.init(function(url){
	        if(url == "") {
	           $('#flip ul li:nth-child(2)').addClass('activeSlide');
	        } else {
	            load(url == "" ? "1" : url);
	            $('#flip ul li a[href*="'+url+'"]').parent().addClass('activeSlide');
	        }
	    },
	    { unescape: ",/" });
	
	        //Real Estate
	        $('#flip ul li a').live('click', function (e) {
	            $('.property').html('<p class="loader">loading...</p>');
	            $('#flip ul li').removeClass('activeSlide');
	            //$(this).parent().addClass('activeSlide');
	            var url = $(this).attr('href');	            
		            if ($('body').hasClass('tax-states')) {
		            	var url = url.substr(30); // Change to 30 when site goes live
		            	url = url.replace(/\//, '');
		            	$('#flip ul li a[href*="'+url+'"]').parent().addClass('activeSlide');
		            } else if ($('body').hasClass('page-id-132')) {
		            	var url = url.substr(30); // Change to 30 when site goes live
		            	url = url.replace(/\//, '');		            	
		            	$('#flip ul li a[href*="'+url+'"]').parent().addClass('activeSlide');
		            }
					else {
		            	var url = url.substr(26); // Change to 26 when site goes live
		            	url = url.replace(/\//, '');
		            	$('#flip ul li a[href*="'+url+'"]').parent().addClass('activeSlide');
		            }

	            $.history.load(url);
	            e.preventDefault();
	        });
	
	}); //End AJAX

	$(window).load(function() {
		$(".carousel").jCarouselLite({
		    btnNext: " .next",
		    btnPrev: " .prev",
		    visible: 4,
		    scroll: 1
		});
	});	 
       		
//End        
}); 
