/*DROPDOWN MENU*/
var timeout = 600; var closetimer = 0;var submenuitem = 0;
function dropdown_open(){ dropdown_canceltimer(); submenuitem = $(this).find('.sub-menu');submenuitem.slideDown('fast');$('.sub-menu').not(submenuitem).css('display', 'none');}
function dropdown_close(){ if(submenuitem) submenuitem.css('display', 'none');}
function dropdown_timer(){ closetimer = window.setTimeout(dropdown_close, timeout);}
function dropdown_canceltimer(){  if(closetimer){window.clearTimeout(closetimer); closetimer = null;}}
$(document).ready(function(){$('#main_menu > li').bind('mouseover', dropdown_open); $('#main_menu > li').bind('mouseout',  dropdown_timer);});
/***************/

/**FORM SUBMITION HANDLER**/

 jQuery(document).ready(function(){ 
	jQuery(".form_validate").validator({	// initialize validator with the new effect
	   effect: 'wall', 
	   container: '#errors', 
	   errorInputEvent: null
	   
	}).submit(function(e)  { 	// custom form submission logic  
		if (!e.isDefaultPrevented()) {	   // when data is valid  
			jQuery('#conversionFrame').html('<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1004708951/?label=JzyLCJnvqAMQ18iK3wM&amp;guid=ON&amp;script=0"/>');
			jQuery("#errors h1").hide();
	      	jQuery("#errors p").hide();
			jQuery(".error_text").hide();
			
			jQuery(".one_col").hide();
			jQuery(".two_col").hide();
			
			jQuery(".thankyou").fadeIn();
			
	      	jQuery("#errors").fadeIn();
	      	jQuery("#success").fadeIn(500);
			
			
	
			
			jQuery(".submit_form").addClass("disabled");
			jQuery(".submit_form").attr('disabled','disabled');
			jQuery(".close_button").removeClass("disabled");
			jQuery(".close_button").attr('disabled','');
			
			
			
			// tell user that everything is OK
	   		jQuery("#success").after('');
			jQuery("#success").delay(6000).fadeOut('slow');
			
			e.submit();
			e.preventDefault();	      // prevent the form data being submitted to the server
	   	   
	   	} 
	});
	jQuery.tools.validator.addEffect("wall", function(errors, event) {
		var wall = jQuery(this.getConf().container).fadeIn();		// get the message wall
		wall.find("p").remove();		// remove all existing messages
		jQuery("#errors").show();
		jQuery('.highlight').removeClass('highlight');
		jQuery('.complete-this-form').hide();
		jQuery.each(errors, function(index, error) {		// add new ones
			error.input.addClass('highlight');
		});
	}, function(inputs)  {	// the effect does nothing when all inputs are valid		
	});
	
	jQuery(".form_validate").validator({	// initialize validator with the new effect
	   effect: 'wall', 
	   container: '#errors', 
	   errorInputEvent: null
	   
	}).submit(function(e)  { 	// custom form submission logic  
		if (!e.isDefaultPrevented()) {	   // when data is valid  
			jQuery("#errors h1").remove();
	      	jQuery("#errors p").remove();
	      	jQuery("#success").fadeIn('fast'); // tell user that everything is OK
	      	jQuery("#success").delay(3000).fadeOut('slow');
	   		form.load("");
	   	   e.preventDefault();	      // prevent the form data being submitted to the server	
		   
	   	}
	});
});
