$(document).ready(function() {

	$('body a.lightBox').lightBox();
	
	$("#contactForm").validate();
	
	$("#quickContact").validate();
	
	if (scroll == "yes" ) {
		$(".scroll").jScrollPane();
	} 
		
	$("a.smoothScroll").anchorAnimate()
	
	// fix for target='_blank'
	$('a[href^="http://"], a[href^="https://"]').attr({
	target: "_blank", 
	title: "Opens in a new window"
	});		
	
	$(".testimonials p:even").addClass("even");
		
	
	//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");
	}

    $(".slider").easySlider({
		auto: true,
		continuous: true,
		speed: 600,
		pause: 6000
	});
    
    imageResize(70);
  
});

function imageResize(maxWidth) {

	$(".thumb").each(function(){
		var width = $(this).width();
		var height = $(this).height();
		if(width > maxWidth){
			var ratio = height/width;
			var newWidth = maxWidth;
			var newHeight = newWidth*ratio;
			$(this).attr("width",newWidth);
			$(this).attr("height",newHeight);
		}
	});

}

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")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}