/* Bouncing down overlay */
$(document).ready(function(){
	// click to draw contact form
	$('.open').click(function(){
		// open .panel-1 to 500px then shrink back fast to 425px
		$("div.panel").animate({height: "300px"}).animate({height: "260px" }, "fast");
		
		
			// using window.setTimeout to delay .panel-2 for 100 ms
		window.setTimeout(function(){$("div.panel-contents").fadeIn("slow");});
		

	});
 
	// this function closes the panels and is loaded in the click function below
	function closePanels(){
		// extend panel-1 to 520px then send it up, to hide
		$(".panel").animate({height: "280px"}).animate({height: "0px",top:"0px"}, "fast", function(){$(this).hide();});
		// using window.setTimeout to delay .panel-2 for 100 ms

	} // end closePanels() function
 
	// on click fadeOut content then call closePanels() to send them up
	$('.close').click(function(){					
		$('div.panel-contents').fadeOut("fast",closePanels());	
	});     
});


/* Menu Slider */
$(function() {
            $("#1, #2, #3").lavaLamp({
                fx: "backout", 
                speed: 700,
                click: function(event, menuItem) {
                    return true;
                }
            });
        });


/* Drop Down Menus */
$(document).ready(function(){

	$("ul.topnav li a").hover(function() { //When mouse hovers...
		
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").stop().slideDown('fast').show('slow', function(){
			$(this).height("auto");
		}); //Drop down the subnav on click
 
 
		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.subnav").stop().slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});
 
		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
 
});



/* EXTERNAL LINKS - Keeps W3C Happy */
/* Script to launch link whilst still being strict compliant */
function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
} 
window.onload = externalLinks;




