$(document).ready(function(){
	
	//-----------------------//
	//---Navigation effects--//
	//-----------------------//
	$(".sub_nav").hide();
	$(".tab").fadeTo(0, 0.8);
	$("div.nav_item").hover(
	  function () {
	    $(this).find(".sub_nav").show();
	    $(this).find(".sub_nav").fadeTo(0, 0.7);
	    $(this).find(".tab").css("background-color", "#009400");
	    $(this).find(".tab").css("color", "#ffffff");
	    $("div.nav_item_selected").find(".sub_nav").hide();
	  }, 
	  function () {
	    $(this).find(".sub_nav").hide();
	    $(this).find(".tab").css("background-color", "#cdedcc");
	    $(this).find(".tab").css("color", "#222222");
	    $("div.nav_item_selected").find(".sub_nav").show();
	  }
	);
	$("div.nav_item_selected").find(".sub_nav").show().fadeTo(0, 0.7);
	$("#contact_form").validate();
	
	//-------------------------//
	//--Image slider effects --//
	//-------------------------//
	//Get our elements for faster access and set overlay width
	var div = $('div#img_slider'),
		ul = $('#img_slider ul'),
		ulPadding = 15;
	
	//Get menu width
	var divWidth = div.width();

	//Remove scrollbars	
	div.css({overflow: 'hidden'});
	
	//Find last image container
	var lastLi = ul.find('li:last-child');
	
	//When user move mouse over menu
	div.mousemove(function(e){
		//As images are loaded ul width increases,
		//so we recalculate it each time
		var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;	
		var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
		div.scrollLeft(left);
	});
	
	//-------------------------------//
	//--Homepage background effects--//
	//-------------------------------//
	$.fn.supersized.options = {  
		startwidth: 1800,  
		startheight: 1200,
		vertical_center: 1,
		slideshow: 1,
		navigation: 0,
		transition: 0, //0-None, 1-Fade, 2-slide top, 3-slide right, 4-slide bottom, 5-slide left
		pause_hover: 0,
		slide_counter: 0,
		slide_captions: 0,
		slide_interval: 3000  
	};
	$('#supersize').supersized(); 
			
});
