/******************************************************************/
/*	Navigation												      */
/******************************************************************/

$(document).ready(function() {
$("#dropmenu ul").css({display: "none"}); // Opera Fix
$("#dropmenu li").hover(function(){
		$(this).find('ul:first').animate({height: "show"}, 150, "easeInOutCubic");
		},function(){
		$(this).find('ul:first').animate({height: "hide"}, 250, "easeInBack");
		});
		
});


/******************************************************************/
/*	Navigation *END*										      */
/******************************************************************/

/******************************************************************/
/*	Back to top Animation									      */
/******************************************************************/

$(document).ready(function() {
$('.hozbreak-top a').click(function(){
     $('html, body').animate({scrollTop: '0px'}, 300);
     return false;
});
});

/******************************************************************/
/*	Back to top Animation *END*								      */
/******************************************************************/


/******************************************************************/
/*	Drop Panel												      */
/******************************************************************/
$(document).ready(function() {
	
	// Expand Panel
	$("#open").click(function(){
		$("div#panel").animate({height: "show"}, 900, "easeInOutCubic");
	
	});	
	
	$(".contacttrigger").click(function(){
		$("div#panel").animate({height: "show"}, 900, "easeInOutCubic");
		$("#toggle a").toggle();
	
	});	

	$(".droppaneltrigger").click(function(){
		$("div#panel").animate({height: "show"}, 900, "easeInOutCubic");
		$("#toggle a").toggle();
	
	});	
	
	// Collapse Panel
	$("#close").click(function(){
		$("div#panel").animate({height: "hide"}, 600, "easeInBack");	
	});		
	
	// Switch buttons on click
	$("#toggle a").click(function () {
		$("#toggle a").toggle();
	});		

});
/******************************************************************/
/*	Drop Panel *END*										      */
/******************************************************************/



/******************************************************************/
/*	Contact Form										      	  */
/******************************************************************/

$(document).ready(function() {
	$('form#contactForm').submit(function() {
		$('form#contactForm .error').remove();
		var hasError = false;
		$('.requiredField').each(function() {
			if(jQuery.trim($(this).val()) == '') {
				var labelText = $(this).prev('label').text();
				$(this).parent().append('<span class="error">You forgot to enter your '+labelText+'.</span>');
				hasError = true;
			} else if($(this).hasClass('email')) {
				var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
				if(!emailReg.test(jQuery.trim($(this).val()))) {
					var labelText = $(this).prev('label').text();
					$(this).parent().append('<span class="error">You entered an invalid '+labelText+'.</span>');
					hasError = true;
				}
			}
		});
		if(!hasError) {
			$('form#contactForm li.buttons button').fadeOut('normal', function() {
				$(this).parent().append('<img src="/wp-content/themes/td-v3/images/template/loading.gif" alt="Loading&hellip;" height="31" width="31" />');
			});
			var formInput = $(this).serialize();
			$.post($(this).attr('action'),formInput, function(data){
				$('form#contactForm').slideUp("fast", function() {				   
					$(this).before('<p class="thanks"><strong>Thanks!</strong> Your email was successfully sent. One of the VBM team will be in touch soon.</p>');
				});
			});
		}
		
		return false;
		
	});
});

/******************************************************************/
/*	Contact Form *END*									      	  */
/******************************************************************/




/******************************************************************/
/*	Accordion											      	  */
/******************************************************************/
$(document).ready(function() {

	// Accordion
	$(".accordion").accordion({ header: "h3.accordionhead" });
	
	
});

/******************************************************************/
/*	Accordion *END*										      	  */
/******************************************************************/

/******************************************************************/
/*	Tabs												      	  */
/******************************************************************/
$(document).ready(function() {
	// Tabs
	$(".dyntabs").tabs({ fx: { height:'toggle', duration:'fast' }  });	
});

/******************************************************************/
/*	Tabs *END*											      	  */
/******************************************************************/	

/******************************************************************/
/*	Reveal Contnet 										      	  */
/******************************************************************/

$(document).ready(function() {
	
	$(".reveal-content").hide();
	
	// Toggle classes for reveal
	$("h4.reveal").toggle(function(){
		$(this).addClass("ui-state-active");}, function() {
		$(this).removeClass("ui-state-active ");
	});

	
	// Reveal content
	$("h4.reveal").click(function(){
	$(this).next(".reveal-content").animate({"height": "toggle"}, { duration: 300, easing: "easeInOutCubic" });
	});
	


});

/******************************************************************/
/*	Reveal Content *END*										      	  */
/******************************************************************/
