$(document).ready(function(){
	
// Coda Slider 2.0
	$('#coda-slider-1').codaSlider({
		dynamicArrows: false,
		dynamicTabs: false,
		autoSlide: true,
		autoSlideInterval: 4000,
		autoSlideStopWhenClicked: true
	});

// Clickable Logo
	$('.logo').click(function() {document.location.href='/';});

// Autofill and clear text input - http://snipplr.com/view/26706/
	autoFill($("#FirstName"), "First");
	autoFill($("#LastName"), "Last");
	
	//auto fill search field
	function autoFill(id, v){
		$(id).css({
			'color':'#a8a8a8', 'font-size':'11px', 'font-style':'italic'
		}).attr({
			value: v
		}).focus(function(){
			if($(this).val()==v){
				$(this).val("").css({
					'color':'#666', 'font-size':'13px', 'font-style':'normal'
				});
			}
		}).blur(function(){
			if($(this).val()==""){
				$(this).css({
					'color':'#a8a8a8', 'font-size':'11px', 'font-style':'italic'
				}).val(v);
			}			
		});	
	}

// Random <body> bg image
	var randomImages = ['01','02','03'];
	var rndNum = Math.floor(Math.random() * randomImages.length);
	$("body").css({ background: "#fff url(/assets/images/bg-photo-" + randomImages[rndNum] + ".jpg) no-repeat center top" });
	
// jQuery hide/show
	// hides the slickbox as soon as the DOM is ready (a little sooner than page load)					  
	$('.slick-hide').hide();
	// shows the slickbox on clicking the noted link	
	$('.slick-show').click(function() {
		$(this).next().slideToggle(400);
	});

// Swap Box
	$(".swap_box").hover(function () {
		if (! $(this).hasClass("inactive")){
			$(".secondary", this).css({'display':'block'});
		}
	},function () {
		$(".secondary", this).css({'display':'none'});
	});
	
// ColorBox v1.3.16
	$(".colorbox").colorbox({opacity:0.75});
	$(".CBwintersale").colorbox({inline:true, width:"50%", opacity:0.75});
	$("a[rel='agricultural'], a[rel='commercial'], a[rel='equestrian'], a[rel='suburban']").colorbox({opacity:0.75, width:"auto", slideshow:true, slideshowSpeed: 4000});
	/*$(".colorboxinline").colorbox({opacity:0.75, width:"700px", inline:true, href:".photogallery"});
	$(".colorboxinlinegal1").colorbox({opacity:0.75, width:"700px", inline:true, href:".galleria1"});
	$(".colorboxinlinegal2").colorbox({opacity:0.75, width:"700px", inline:true, href:".galleria2"});
	$(".colorboxinlinegal3").colorbox({opacity:0.75, width:"700px", inline:true, href:".galleria3"});
	$(".colorboxinlinegal4").colorbox({opacity:0.75, width:"700px", inline:true, href:".galleria4"});*/
	
// Galleria v1.2.4

	/*
	// Load the classic theme
	Galleria.loadTheme('/assets/scripts/jquery.galleria/themes/classic/galleria.classic.js');
	
	// Initialize Galleria
	$(".photogallery").galleria({
		width: 682,
		height: 515,
		autoplay: 5000
	});
	$(".galleria1, .galleria2, .galleria3, .galleria4").galleria({
		width: 682,
		height: 515,
		autoplay: 5000
	});
	
	$(".btnphotogallery a").click(function() {
		$(".colorboxinline").colorbox({
			opacity:0.75,
			width:"700px",
			height:"600px",
			inline:true,
			href:".photogallery",
			onClosed: function() {
				alert( 'complete' );
			}
		});
		$(".photogallery").galleria({
			width: 682,
			height: 515,
			autoplay: 5000,
			lightbox: true
		});
	});
	
	$(function(){
	    Galleria.loadTheme('/assets/scripts/jquery.galleria/themes/classic/galleria.classic.js');
	    $('a.colorboxinlinegal2')
	    .click(function(){
		   $(".colorboxinlinegal4").colorbox({
				opacity:0.75,
				width:"700px",
				inline:true,
				href:".galleria4"
			});
		   $('.galleria2').galleria({
			 width: 682,
			 height: 515,
			 autoplay: 5000
		  });
		   return false;
	    })
	    .first()
	    .trigger('click');
	});
	*/
	
// Tabs (Gallery) VERSION1
// http://www.sohtanaka.com/web-design/simple-tabs-w-css-jquery/

	/*
	//Default Action
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active");		
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});
	*/
});
