$(document).ready(function() {

	$('body a.lightBox').lightBox();
	 	
	$("a.smoothScroll").anchorAnimate();


	
	// fix for target='_blank'
	$('a[href^="http://"], a[href^="https://"]').attr({
		target: "_blank", 
		title: "Opens in a new window"
	});		
	
	
	//call the jQuery Hover Over and Out
    $('.mainNav').find("li").hover(over, out);
  
    function over(event) {
        $(this).find("ul.subNav").slideDown("fast");
    }
    
    function out(event) {
	    $(this).find("ul.subNav").slideUp("fast");
	}
    
    //clear search box text on click
    $(".text").click(function(){
    	$(this).val("");
    });

	
});





//smooth scroll function
jQuery.fn.anchorAnimate = function(settings) {

	settings = jQuery.extend({
		speed : 1100
	}, settings);	
	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = $(caller).attr("href")
			$(".faq").find("div").removeClass("selected");
			$("div").find(elementClick).addClass("selected");
			
			var destination = $(elementClick).offset().top;
		
			
			if (elementClick == "#top") {
				$(".faq").find("div").removeClass("selected");
			}
			
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}