//	***************************************************************************************
//	This general.js file contains general setup information for the jQuery/JavaScript tools
//	***************************************************************************************
$(document).ready(function(){ 
						   
	// Dropdown Menu Setup
	// More information: http://users.tpg.com.au/j_birch/plugins/superfish/
	$("ul.sf-menu").supersubs({ 
		minWidth:    9,   // minimum width of sub-menus in em units 
		maxWidth:    20,   // maximum width of sub-menus in em units 
		extraWidth:  1,     // extra width can ensure lines don't sometimes turn over 
		dropShadows:   false
	}).superfish({ 
		delay:       500,                            	// one second delay on mouseout 
		animation:   {opacity:'show',height:'show'},  	// fade-in and slide-down animation 
		speed:       180,                          		// faster animation speed 
		autoArrows:  false,                           	// disable generation of arrow mark-up 
		dropShadows: false                            	// disable drop shadows 
	}).find('ul').bgIframe({opacity:false});  
	
	
	// Lightbox Setup
	// More information: http://leandrovieira.com/projects/jquery/lightbox/
	// LIGHTBOX SETUP MOVED TO HEADER.PHP - to pull in full nav path from wordpress
		
		
	// Hide element on click where it contains: class="clickhide"
	$('.clickhide').click(function() { $(this).fadeOut(600); });
	
	
	// Scroll to top animation
	$('.scroll-top').click(function(){ 
		$('html, body').animate({scrollTop:0}, 'slow'); return false; 
	});
	
	
	// contact form validation
		var hasChecked = false;
		$("#cf_submit").click(function () { 
			hasChecked = true;
			return checkForm();
		});
		
		$("#cf_name,#cf_email,#cf_message").live('change click', function(){
			if(hasChecked == true)
			{
				return checkForm();
			}
		});
		
		function checkForm()
		{
			var hasError = false;
			var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
			
			if($("#cf_name").val() == '') {
				$("#error-name").fadeIn();
				hasError = true;
			}else{
				$("#error-name").fadeOut();
			}
			
			if($("#cf_email").val() == '') {
				$("#error-email").fadeIn();
				hasError = true;
			}else if(!emailReg.test( $("#cf_email").val() )) {
				$("#error-email").fadeIn();
				hasError = true;
			}else{
				$("#error-email").fadeOut();
			}
			
			if($("#cf_message").val() == '') {
				$("#error-message").fadeIn();
				hasError = true;
			}else{
				$("#error-message").fadeOut();
			}
			
			if(hasError == true)
			{
				return false;
			}else{
				return true;
			}
		}
		// end contact form validation
		
}); 
