$(document).ready(function(){

// Google Analytics Configuration for jquery.google-analytics.js
$.trackPage('UA-6216439-1', {status_code: 404}); // Track a 404 error

//validate the quick-contact form in the slider
	// enable ajax submission of forms
	var use_ajax=true;
	
	$.validationEngine.settings={};
	$("#quick-form").validationEngine({
		liveEvent:true,
		inlineValidation: true,
		promptPosition: "topRight",
		success :  function(){use_ajax=true},
		failure : function(){use_ajax=false;}
	})
	//Ajax Error Handling and Contact Form Submission Below
	$("button").click(function(){
	$(".formError").hide();
	});
	
	$("#quick-form").submit(function(e){
	if(use_ajax)
	{
	$('#loading').css('visibility','visible');
	$.post('scripts/quickform.submit.php',$(this).serialize()+'&ajax=1',
	function(data){
	$("#quick-form").hide('slow').after('<h1>Thank you!</h1>');
	$('#loading').css('visibility','hidden');
	});}
	e.preventDefault();
	})
		
	// validate the contact.php contact form
	$.validationEngine.settings={};
	$("#contact-form").validationEngine({
		liveEvent:true,
		inlineValidation: true,
		promptPosition: "topRight",
		success :  function(){use_ajax=true},
		failure : function(){use_ajax=false;}
	 })

	$("#contact-form").submit(function(e){
	if(use_ajax)
	{
	$('#loading').css('visibility','visible');
	$.post('scripts/form.submit.php',$(this).serialize()+'&ajax=1',
	function(data){
	if(parseInt(data)==-1)
	$.validationEngine.buildPrompt("#captcha"," This sum is incorrect.","error");
	else
	{
	// $("#contact-form").hide('slow').after('<h1>Thank you!</h1>');
	// Edit Starts Below.
    $('#contact-form').hide('slow').after("<div id='success'></div>");
    $('#success').html("<img src='/images/success.png' width='400' height='333' alt='Thank You for Your Submission' />")
	  .hide()
    	.fadeIn(1500, function() {
    	$('#success');
	  });//fadeIn and End of Edit from original source
	}
	$('#loading').css('visibility','hidden');
	});}
	e.preventDefault();
	})
//end contact form scripting

	
// Sliding Panel Functions Below
	// Expand Panel
	$("#open").click(function(){
	$("div#panel").slideDown("slow");
	return false;
	});	
	// Collapse Panel
	$("#close").click(function(){
	$.validationEngine.closePrompt(".formError",true) //Hide Quick Form Errors
	$("div#panel").slideUp("slow");
	return false;
	});		
	// Switch buttons from "Log In | Register" to "Close Panel" on click
	$("#toggle a").click(function () {
	$("#toggle a").toggle();
	});
	// BELOW TEMPORARILY DISABLED TO PREVENT FORM ERRORS
	// Collapse the panel when the panel bg is clicked.
	// $("#panel").bind("click",function(event){
	// $.validationEngine.closePrompt(".formError",true)  // Hide Quick Form Errors
	// $("#panel").slideUp("slow");
	// $("#toggle a").toggle();
	// });
	// Prevent the panel form elements from trigging a panel close.
	// $("#panel *").bind("click",function(event){
	// event.stopPropagation();
	// event.preventDefault();
	// });

// NAV - Initialize Nav Sprites in attached jquery.sprites2.js
	$('#live').sprites();
	
// Initialize ColorBox Popups
// Set Colorbox to display Package Levels for Gold Silver and Platinum
	$(".silver").colorbox({inline:true, href:"#silver"});
	$(".gold").colorbox({inline:true, href:"#gold"});
	$(".platinum").colorbox({inline:true, href:"#platinum"});
	$("a[rel='brochure1']").colorbox({transition:"fade"});
	$("a[rel='brochure2']").colorbox({transition:"fade"});


	
// The below function is referenced directly in the image scroller for the index page.
// adjust the transition style and the scroller speed here.
// this function selects #flowplanes and make it scrollable. 
// This is using a circular, autoscroll, and icon navigation mod
	$("#flowpanes").scrollable({size: 1, clickable: false}).circular().autoscroll(7500,{autoplay: true}).navigator({
		// select #flowtabs to be used as navigator
		navi: "#flowtabs",
		// select A tags inside the navigator to work as items (not direct children)
		naviItem: 'a',
		// assign "current" class name for the active A tag inside navigator
		activeClass: 'current'
		});
	
// The below function is referenced directly in the image scrollers outside of the index page.
// adjust the transition style and the scroller speed here.
// this function selects #flowbanners and make it scrollable. 
// This is using a circular, autoscroll, and icon navigation mod
	$("#bannerpanes").scrollable({size: 1, clickable: false, easing: 'swing'}).circular().autoscroll(6000,{autoplay: true});	


//add custom animation effect for Jquery Tools Tabs
$.tools.tabs.addEffect("resortsupply", function(tabIndex, done) { 
     this.getPanes().hide().eq(tabIndex).fadeIn(600);
 	 done.call(); // necessary to call after creating effect.
});

});
