/*
*	Custom javascript functions for public website.
*	@author David Tym <davidtym@greensprocket.com>
*	@copyright Copyright (c) 2010, Visual Odyssey Inc.
*   @date Wednesday, October 12, 2011 - 9:40:03 AM
*/

	$().ready(function() {

		// XHTML Strict version of target="_blank"
		$("a[rel=\'external\']").attr("target","_blank");

		// Lightbox
		$().ready(function() {

			$(".photo a").lightBox({
				overlayBgColor: "#000",
				overlayOpacity: 0.8,
				containerResizeSpeed: 350
			});

		});

		// Slideshow Gallery
		$("#slider").nivoSlider({
			effect: "fade",						// Specify sets like: "fold,fade,sliceDown"
			slices: 15,								// For slice animations
			boxCols: 8,								// For box animations
			boxRows: 4,								// For box animations
			animSpeed: 250,							// Slide transition speed
			pauseTime: 2000,						// How long each slide will show
			startSlide: 0,							// Set starting Slide (0 index)
			directionNav: false,					// Next & Prev navigation
			directionNavHide: true,					// Only show on hover
			controlNav: false,						// 1,2,3... navigation
			controlNavThumbs: false,				// Use thumbnails for Control Nav
			controlNavThumbsFromRel: false,			// Use image rel for thumbs
			controlNavThumbsSearch: ".jpg",			// Replace this with...
			controlNavThumbsReplace: "_thumb.jpg",	// ...this in thumb Image src
			keyboardNav: true,						// Use left & right arrows
			pauseOnHover: true,						// Stop animation while hovering
			manualAdvance: false,					// Force manual transitions
			captionOpacity: 0,						// Universal caption opacity, eg: 0.8
			prevText: "Prev",						// Prev directionNav text
			nextText: "Next",						// Next directionNav text
			beforeChange: function(){},				// Triggers before a slide transition
			afterChange: function(){},				// Triggers after a slide transition
			slideshowEnd: function(){},				// Triggers after all slides have been shown
			lastSlide: function(){},				// Triggers when last slide is shown
			afterLoad: function(){}					// Triggers when slider has loaded
		});

		// Slideshow Gallery
		$("#slider-short").nivoSlider({
			effect: "fade",						// Specify sets like: "fold,fade,sliceDown"
			slices: 15,								// For slice animations
			boxCols: 8,								// For box animations
			boxRows: 4,								// For box animations
			animSpeed: 250,							// Slide transition speed
			pauseTime: 2000,						// How long each slide will show
			startSlide: 0,							// Set starting Slide (0 index)
			directionNav: false,					// Next & Prev navigation
			directionNavHide: true,					// Only show on hover
			controlNav: false,						// 1,2,3... navigation
			controlNavThumbs: false,				// Use thumbnails for Control Nav
			controlNavThumbsFromRel: false,			// Use image rel for thumbs
			controlNavThumbsSearch: ".jpg",			// Replace this with...
			controlNavThumbsReplace: "_thumb.jpg",	// ...this in thumb Image src
			keyboardNav: true,						// Use left & right arrows
			pauseOnHover: true,						// Stop animation while hovering
			manualAdvance: false,					// Force manual transitions
			captionOpacity: 0,						// Universal caption opacity, eg: 0.8
			prevText: "Prev",						// Prev directionNav text
			nextText: "Next",						// Next directionNav text
			beforeChange: function(){},				// Triggers before a slide transition
			afterChange: function(){},				// Triggers after a slide transition
			slideshowEnd: function(){},				// Triggers after all slides have been shown
			lastSlide: function(){},				// Triggers when last slide is shown
			afterLoad: function(){}					// Triggers when slider has loaded
		});

		// Slideshow Gallery
		$("#slider-gallery").nivoSlider({
			effect: "fade",						// Specify sets like: "fold,fade,sliceDown"
			slices: 15,								// For slice animations
			boxCols: 8,								// For box animations
			boxRows: 4,								// For box animations
			animSpeed: 250,							// Slide transition speed
			pauseTime: 2000,						// How long each slide will show
			startSlide: 0,							// Set starting Slide (0 index)
			directionNav: true,						// Next & Prev navigation
			directionNavHide: false,				// Only show on hover
			controlNav: false,						// 1,2,3... navigation
			controlNavThumbs: false,				// Use thumbnails for Control Nav
			controlNavThumbsFromRel: false,			// Use image rel for thumbs
			controlNavThumbsSearch: ".jpg",			// Replace this with...
			controlNavThumbsReplace: "_thumb.jpg",	// ...this in thumb Image src
			keyboardNav: true,						// Use left & right arrows
			pauseOnHover: true,						// Stop animation while hovering
			manualAdvance: false,					// Force manual transitions
			captionOpacity: 0,						// Universal caption opacity, eg: 0.8
			prevText: "Prev",						// Prev directionNav text
			nextText: "Next",						// Next directionNav text
			beforeChange: function(){},				// Triggers before a slide transition
			afterChange: function(){},				// Triggers after a slide transition
			slideshowEnd: function(){},				// Triggers after all slides have been shown
			lastSlide: function(){},				// Triggers when last slide is shown
			afterLoad: function(){}					// Triggers when slider has loaded
		});

		// Form change, call ajax results
		$('#homehunter').click(function() {

			$("#result").css("display","relative").fadeIn("fast");

				var dataString = "home-style=" + $("input[name=home-style]:checked").val() + "&bedrooms=" + $("input[name=bedrooms]:checked").val() + "&sqft=" + $("input[name=sqft]:checked").val() + "&price=" + $("input[name=price]:checked").val();

				$.ajax({
					type: "POST",
					url: "result.php",
					cache: false,
					data: dataString,
					success: function(html){
						$("#result").html(html);
					},
					error: function(){
						$("#result").html("Oops! There was a problem, please try again.");
					}
				});

		});

	});
