$(document).ready(function (){
	
	highlightActive();
	
	$('#menu li a:not(.active) img').hover(
		function () {
			src = $(this).attr("src");
			
			$(this).attr("src",src.replace(/.jpg/, "-active.jpg"));		
		},
		function () {
			src = $(this).attr("src");
			$(this).attr("src",src.replace(/-active.jpg/, ".jpg"));
		}
	);
	
	$("#leftColumn a[rel='lb']").lightBox();
	$("#leftColumn .gallery a").lightBox();
			
	$(".faqQuestion a").click( function(){
		$(this).parent().parent().next().slideToggle();
	});
	
	$("#submitForm").click( function(){
		$("form").submit();
	} );
	
	/*$(".gallery img").each(function(){
		var pic=new Image();
		pic.src= $(this).attr("src");

		if(pic.complete) $(this).parent().parent().centerImage();
		else $(".gallery img").load(function(){
			$(this).parent().parent().centerImage();
		});
	});*/

});

/*$(window).load(function(){
	
	$(".gl, .gr").centerImage();
	
});*/

function highlightActive() {
	
	src = $('#menu li a.active img').attr("src");
	$('#menu li a.active img').attr("src", src.replace(/.jpg/, "-active.jpg"));
	
}

$.fn.centerImage = function() {
	
	
	
	return this.each(function () {
		
		containerHeight = $(this).height();
		img = $(this).find("img");
		
		
		imgHeight = img.height();
		
		//alert(img.attr("src")+": "+containerHeight+"-"+imgHeight);
		
		if(imgHeight < containerHeight) {
			
			ch = Math.round(containerHeight/2);
			ih = Math.round(imgHeight/2);
			xtop = ch-ih;
			
			//alert(xtop);
			
			img.css({
				position: "relative",
				top: xtop + "px"
			});
			
		}
		
	});
	
};

function nW(url)
{
   var Win = window.open(url,'newPlyrWnd','width=777, height=444, resizable=0, scrollbars=no, menubar=no' );
}

