$(document).ready(function() {
  $("#formID").validationEngine();
	$("#formID1").validationEngine();

	$("a.fancybox-form").fancybox({
		'titleShow'		: false
	});
	$("a.fancybox").fancybox({
		'titleShow'		: false
	});
	
	$("a.signin").fancybox({
		'autoDimensions'	: true,
		'overlayOpacity'	: 0.6,
		'overlayColor'		: '#222',
		'titleShow'				: false,
		'showNavArrows'		: false,
		'padding'					: 20,
		// 'width'						: 400,
		// 'height'					: 300,
		'type'						: 'ajax',
		'onClosed'				: function() {
			    $(".formError").hide();
			}
	});
	$('.form-white input[type="text"], .form textarea#specialnotes').addClass("idleField");
  		$('.form-white input[type="text"], .form textarea#specialnotes').focus(function() {
  			$(this).removeClass("idleField").addClass("focusField");
	    if (this.value == this.defaultValue){ 
	    	this.value = '';
		}
	});
	$('.form-white input[type="text"], .form textarea#specialnotes').blur(function() {
	    if ($.trim(this.value) == ''){
			$(this).removeClass("focusField").addClass("idleField");
	    	this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
	$("label.inlined + input.inputText").each(function (type) {
		var form = $(this);
		$(window).load(function () {
			if(form.val() != "") {
				form.prev("label.inlined").addClass("has-text");
			}
		});
		$(this).focus(function () {
			$(this).prev("label.inlined").addClass("focus");
		});
		$(this).keypress(function () {
			$(this).prev("label.inlined").addClass("has-text").removeClass("focus");
		});
		$(this).blur(function () {
			if($(this).val() == "") {
			 $(this).prev("label.inlined").removeClass("has-text").removeClass("focus");
			}
		});
	});
	// var page = 1;
	// $("#left-nav li a").each(function(){
	// 	var url = $(this).attr('href');
	// 	var lower = $(this).attr('title').toLowerCase(); // to lower case
	// 	var hyp = lower.replace(/ /g,"-");
	// 	console.log(hyp, url);
	// 	$("<div id='pages-load-"+page+"' class='panel " +hyp+"'></div>").appendTo('#loaded-pages');
	// 	$("#pages-load-" +page).load(url + " ."+hyp);
	// 	page++;
	// });
	// $("#left-nav li").live('click', function() {
	// 	$("#left-nav li").removeClass("active"); //Remove any "active" class
	// 	$(this).addClass("active"); //Add "active" class to selected tab
	// 	var url = $(this).find("a").attr('href'),
	// 			lower = $(this).find("a").attr('title').toLowerCase(), // to lower case
	// 			hyp = lower.replace(/ /g,"-");
	// 	history.pushState(null, document.title, url);
	// 	$('.panel').hide();
	// 	$('.panel.'+hyp).fadeIn("slow");
	// 	return false;
	// });

});

$(window).load(function() {
	if ($('#feature').length){
		$('#feature').orbit({
		     animation: 'fade',   // fade, horizontal-slide, vertical-slide, horizontal-push
		     animationSpeed: 800,                // how fast animtions are
		     timer: true, 			 // true or false to have the timer
		     advanceSpeed: 5000, 		 // if timer is enabled, time between transitions 
		     pauseOnHover: false, 		 // if you hover pauses the slider
		     startClockOnMouseOut: false, 	 // if clock should start on MouseOut
		     startClockOnMouseOutAfter: 1000, 	 // how long after MouseOut should the timer start again
		     directionalNav: false, 		 // manual advancing directional navs
		     captions: false, 			 // do you want captions?
		     captionAnimation: 'fade', 		 // fade, slideOpen, none
		     captionAnimationSpeed: 800, 	 // if so how quickly should they animate in
		     bullets: true,			 // true or false to activate the bullet navigation
		     afterSlideChange: function(){} 	 // empty function 
		});
	}
	if ($('#feature2 img').length){
		$('#feature2 img').first().ready(function (){
			$('#feature2').orbit({
			     animation: 'horizontal-push',   // fade, horizontal-slide, vertical-slide, horizontal-push
			     animationSpeed: 800,                // how fast animtions are
			     timer: false, 			 // true or false to have the timer
			     advanceSpeed: 5000, 		 // if timer is enabled, time between transitions 
			     pauseOnHover: false, 		 // if you hover pauses the slider
			     startClockOnMouseOut: false, 	 // if clock should start on MouseOut
			     startClockOnMouseOutAfter: 1000, 	 // how long after MouseOut should the timer start again
			     directionalNav: true, 		 // manual advancing directional navs
			     bullets: true,			 // true or false to activate the bullet navigation
			     afterSlideChange: function(){} 	 // empty function 
			});
		});
  }
});

