// JavaScript Document
//QUOVOLVER v1.0
(function($){$.fn.quovolver=function(speed,delay){if(!speed)speed=500;if(!delay)delay=6000;var quaSpd=(speed*4);if(quaSpd>(delay))delay=quaSpd;var quote=$(this),firstQuo=$(this).filter(':first'),lastQuo=$(this).filter(':last'),wrapElem='<div id="quote_wrap"></div>';$(this).wrapAll(wrapElem);$(this).hide();$(firstQuo).show();$(this).parent().css({height:$(firstQuo).height()});setInterval(function(){if($(lastQuo).is(':visible')){var nextElem=$(firstQuo);var wrapHeight=$(nextElem).height();}else{var nextElem=$(quote).filter(':visible').next();var wrapHeight=$(nextElem).height();}
$(quote).filter(':visible').fadeOut(speed);setTimeout(function(){$(quote).parent().animate({height:wrapHeight},speed);},speed);if($(lastQuo).is(':visible')){setTimeout(function(){$(firstQuo).fadeIn(speed*2);},speed*2);}else{setTimeout(function(){$(nextElem).fadeIn(speed);},speed*2);}},delay);};})(jQuery);
$(function() {
		//PLACEHOLDER  
		$('form').html5Forms();
		//TESTIMONIALS
		$('#testimonials blockquote').quovolver(600, 8000);
		//DROPDOWN 	
		$("#nav li ul").hide().css("visibility", "visible");		
		$("#nav li a").hover(
			function(){ 
			$(this).next().fadeIn("fast").show().hover(
				function() {
				$(this).show();					
				},
				function() {	
				$(this).hide();
				}
			);},
			function() {			
			$(this).next().hide();			
			});
			
		//SIMPLEMODAL FOR SERVICES
		$('#services li:nth-child(3n)').css("margin", "0"); //center padding		 
		$("#services li").each( function() {
			$(this).find("div").addClass('modalBox');
			
			$(".open_modal").click( function(){						
						$(this).parent().find('div').modal({								
						containerCss: {minHeight:320, minWidth:600, padding:30}					
						});
			});
		});
		
		//SIMPLEMODAL FOR THE TEAM		 
		$("#team .open_modal").each( function() {			
			$(this).click( function(){
					$(this).parent().next().modal({
					containerCss: {minWidth:400, padding:30}					
					});
			});
		});
		
		//SIMPLEMODAL FOR TOUR
		$(".open_tour").click( function(){
						var content = '<iframe allowfullscreen="" frameborder="0" height="315" src="http://www.youtube.com/embed/T380V4Dthfg?hd=1" width="560"></iframe>';
						$.modal(content, {
						opacity:70, //alpha css
						overlayCss: {backgroundColor:"#000"}	
						});
		});
		
		
		//SIMPLEMODAL FOR WELCOME
		$(".open_welcome").click( function(){
						var content = '<iframe allowfullscreen="" frameborder="0" height="349" src="http://www.youtube.com/embed/tnZsyn5o4IQ?rel=0" width="560"></iframe>';
						$.modal(content, {
						opacity:70, //alpha css
						overlayCss: {backgroundColor:"#000"}	
						});
		});
		//SIMPLEMODAL FOR WELCOME
		$(".open_appForm").click( function(){
						$("#appointmentForm").modal({
						persist: true, 
						opacity:70, //alpha css
						overlayCss: {backgroundColor:"#000"}	
						});
		});
		//simplemodal defaults
		$.extend($.modal.defaults, { 
		onOpen: 
			function(dialog) { //opening animation
				dialog.overlay.fadeIn("normal", function() {
					dialog.container.show();
					dialog.data.show();								
				});
		}});
});

