//Cufon font replacement Cufon.replace('.slide_title, .content_slide_title', { fontFamily: 'Diavlo Medium' }); 

//Cufon.replace('h1', { fontFamily: 'Diavlo Book' });

jQuery(document).ready(function() {


	//===== PrettyPhoto =====//
	$(function(){
		$("a[rel^='prettyPhoto']").prettyPhoto();
	});


	//===== Orbit Slider =====//
	$(window).load(function() {
		$('#featured').orbit({
			animation: 'horizontal-push',                  // fade, horizontal-slide, vertical-slide, horizontal-push
			animationSpeed: 800,                // how fast animtions are
			timer: true, 			 // true or false to have the timer
			advanceSpeed: 4000, 		 // if timer is enabled, time between transitions 
			pauseOnHover: false, 		 // if you hover pauses the slider
			startClockOnMouseOut: false, 	 // if clock should start on MouseOut
			startClockOnMouseOutAfter: 1000, 	 // how long after MouseOut should the timer start again
			directionalNav: true, 		 // manual advancing directional navs
			captions: true, 			 // do you want captions?
			captionAnimation: 'fade', 		 // fade, slideOpen, none
			captionAnimationSpeed: 800, 	 // if so how quickly should they animate in
			bullets: true,			 // true or false to activate the bullet navigation
			bulletThumbs: true,		 // thumbnails for the bullets
			bulletThumbLocation: '../images/content/orbit/thumbs',		 // location from this file where thumbs will be
			afterSlideChange: function(){} 	 // empty function 
		});
	});
			
			
		
	//===== Nivo slider =====//	
    $(window).load(function() {
        $('#slider').nivoSlider();
    });
	
	
	
	//===== Content slider =====//
	$(function(){
		$('#slider1').bxSlider({
		auto: true, //Auto rotation
		speed: 800, //Slide changing speed
		autoHover: true, //pause on hover
		pause: 8000, //delay in m.s. before change
		});
 	});
	
	
	
	//===== Clients slider =====//
	$(function(){
		$('#bottomSlider').jcarousel({
			wrap: 'circular'
		});
	});



	//===== Hover button animation =====//	
	$(function(){
		$(".social a").fadeTo("slow", 1.0); // This sets the opacity of the thumbs to fade down to 30% when the page loads
		$(".social a").hover(function(){
		$(this).fadeTo("fast", 0.8); // This should set the opacity to 100% on hover
		},function(){					   
		$(this).fadeTo("fast", 1.0); // This should set the opacity back to 30% on mouseout
		});
	});
	
	
	
	//===== Tabs =====//	
	$(function() {
		$( "#tabs" ).tabs();
	});
	
	

	//===== Fade animation effect =====//
	$(function(){
		$(".topRight li a").fadeTo("slow", 1.0); // This sets the opacity of the thumbs to fade down to 30% when the page loads
		$(".topRight li a").hover(function(){
		$(this).fadeTo("fast", 0.8); // This should set the opacity to 100% on hover
		},function(){					   
		$(this).fadeTo("fast", 1.0); // This should set the opacity back to 30% on mouseout
		});
	});
	
	
	
	//===== Top panel hover effect =====//
	$(function(){
		$(".panel").fadeTo("slow", 1.0); // This sets the opacity of the thumbs to fade down to 30% when the page loads
		$(".panel").hover(function(){
		$(this).fadeTo("fast", 0.7); // This should set the opacity to 100% on hover
		},function(){					   
		$(this).fadeTo("fast", 1.0); // This should set the opacity back to 30% on mouseout
		});
	});
	


	//===== Clients slider image border and background animation =====//	
	$(function(){
		$(".portfolio-slider .wrapper ul li, .img_side img").hover(function() {
		$(this).stop().animate({ backgroundColor: "#2D2D2D" }, 300);
		},function() {
		$(this).stop().animate({ backgroundColor: "#3B3B3B" }, 300);
		});
	});
	
	
	//===== Buttons background animation =====//
	$(function(){
		$(".bred").hover(function() {
		$(this).stop().animate({ backgroundColor: "#3B3B3B" }, 300);
		},function() {
		$(this).stop().animate({ backgroundColor: "#973838" }, 300);
		});
	});
	
	
	$(function(){
		$(".blightBlue").hover(function() {
		$(this).stop().animate({ backgroundColor: "#193647" }, 300);
		},function() {
		$(this).stop().animate({ backgroundColor: "#284D63" }, 300);
		});
	});
	
	
	$(function(){
		$(".bsea").hover(function() {
		$(this).stop().animate({ backgroundColor: "#164942" }, 300);
		},function() {
		$(this).stop().animate({ backgroundColor: "#205D55" }, 300);
		});
	});
	
	
	$(function(){
		$(".bblack").hover(function() {
		$(this).stop().animate({ backgroundColor: "#313131" }, 300);
		},function() {
		$(this).stop().animate({ backgroundColor: "#000000" }, 300);
		});
	});
	
	
	$(function(){
		$(".bbrightRed").hover(function() {
		$(this).stop().animate({ backgroundColor: "#6c2b2b" }, 300);
		},function() {
		$(this).stop().animate({ backgroundColor: "#7F0909" }, 300);
		});
	});
	
	
	$(function(){
		$(".bbrightBlue").hover(function() {
		$(this).stop().animate({ backgroundColor: "#1a4259" }, 300);
		},function() {
		$(this).stop().animate({ backgroundColor: "#0C5A87" }, 300);
		});
	});
	
	
	$(function(){
		$(".blowGreen").hover(function() {
		$(this).stop().animate({ backgroundColor: "#175235" }, 300);
		},function() {
		$(this).stop().animate({ backgroundColor: "#013C3B" }, 300);
		});
	});
	
	
	$(function(){
		$(".bbrightGreen").hover(function() {
		$(this).stop().animate({ backgroundColor: "#1e3928" }, 300);
		},function() {
		$(this).stop().animate({ backgroundColor: "#11582A" }, 300);
		});
	});
	
	
	$(function(){
		$(".bbrown").hover(function() {
		$(this).stop().animate({ backgroundColor: "#6a3218" }, 300);
		},function() {
		$(this).stop().animate({ backgroundColor: "#814123" }, 300);
		});
	});
	
	
	$(function(){
		$(".bgrey").hover(function() {
		$(this).stop().animate({ backgroundColor: "#973838" }, 300);
		},function() {
		$(this).stop().animate({ backgroundColor: "#2D2D2D" }, 300);
		});
	});
	
	
	$(function(){
		$(".submit").hover(function() {
		$(this).stop().animate({ backgroundColor: "#2D2D2D" }, 300);
		},function() {
		$(this).stop().animate({ backgroundColor: "#973838" }, 300);
		});
	});
	
	
	$(function(){
		$(".portNav ul li a, .pages li a").hover(function() {
		$(this).stop().animate({ backgroundColor: "#3d3d3d" }, 300);
		},function() {
		$(this).stop().animate({ backgroundColor: "#252525" }, 300);
		});
	});
	

	$(function(){
		$(".portNav .active, .pages li .active").hover(function() {
		$(this).stop().animate({ backgroundColor: "#252525" }, 300);
		},function() {
		$(this).stop().animate({ backgroundColor: "#893434" }, 300);
		});
	});
	
	
	
	
	//===== 3 blocks image border and background animation =====//
	$(function(){
		$(".imgBlock, .img, .imgFull, .imgSide, .imgTop, .newsImg, .imgTeam").hover(function() {
		$(this).stop().animate({ backgroundColor: "#2D2D2D" }, 300);
		},function() {
		$(this).stop().animate({ backgroundColor: "#F7F7F7" }, 300);
	});
	
	
	//===== Sidebar navigation animation =====//
	$(function()
		{slide("#sidebar-navigation", 5, 0, 100, .8);
	});
	
	function slide(navigation_id, pad_out, pad_in, time, multiplier)
	{
	// creates the target paths
	var list_elements = navigation_id + " li";
	var link_elements = list_elements + " a";
	
	// initiates the timer used for the sliding animation
	var timer = 0;
	
	// creates the slide animation for all list elements 
	$(list_elements).each(function(i)
	{
	// margin left = - ([width of element] + [total vertical padding of element])
	if($(this).attr('class') !== 'active' && $(this).attr('class') !== 'heading') {
	
	$(this).css("margin-left","0px");
	// updates timer
	timer = (timer*multiplier + time);
	$(this).animate({ marginLeft: "0" }, timer);
	$(this).animate({ marginLeft: "0" }, timer);
	$(this).animate({ marginLeft: "0" }, timer);
	}
	});
	
	// creates the hover-slide effect for all link elements 		
	$(link_elements).each(function(i)
	{
	if($(this).parent().attr('class') !== 'active' && $(this).parent().attr('class') !== 'heading') {
	$(this).hover(
	function()
	{
	$(this).animate({ marginLeft: pad_out }, 150);
	},		
	function()
	{
	$(this).animate({ marginLeft: pad_in }, 150);
	});
	}
	});
	}
	});
	
	
	//===== Toggle =====//
	$(function() {
		// --- Using the default options:
		$(".trigger").toggler();
		// --- Other options:
		//$("h2.expand").toggler({method: "toggle", speed: 0});
		//$("h2.expand").toggler({method: "toggle"});
		//$("h2.expand").toggler({speed: "fast"});
		//$("h2.expand").toggler({method: "fadeToggle"});
		//$("h2.expand").toggler({method: "slideFadeToggle"});    
		$(".toggle_container").expandAll({trigger: ".trigger"});
	}); 
	
	
	
	//===== Clear form fields on click =====//
	var el = $('input[type=text], textarea');
    el.focus(function(e) {
        if (e.target.value == e.target.defaultValue)
            e.target.value = '';
    });
    el.blur(function(e) {
        if (e.target.value == '')
            e.target.value = e.target.defaultValue;
    });


	//===== Dropdown menu =====//
	$(function() {
		ddsmoothmenu.init({
		mainmenuid: "menu", //menu DIV id
		orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
		classname: 'dd', //class added to menu's outer DIV
		//customtheme: ["#1c5a80", "#18374a"],
		contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
		});
	});
	
	
	//===== Obfuscate email links =====//
	$(document).ready(function() {	
		$(".cloaked").obfuscate();
		
		//$(".hidden").obfuscate({cssClass: 'email'});
	});	
	
	
});
