// CUSTOM JAVASCRIPT FILE
// Image loaded one by one
$(function () {
	$('#location img').hide();//hide all the images on the page
	$('.portfolio_style3 img').hide();//hide all the images on the page
	$('.flickr_stream img').hide();//hide all the images on the page
});

var i = 0;//initialize
var int=0;//Internet Explorer Fix
$(document).ready(function() {//The load event will only fire if the entire page or document is fully loaded
	var int = setInterval("doThis(i)",150);//500 is the fade in speed in milliseconds
});

function doThis() {
		var images = $('img').length;//count the number of images on the page
		if (i >= images) {// Loop the images
			clearInterval(int);//When it reaches the last image the loop ends
		}
		$('#location img:hidden').eq(0).fadeIn(350);//fades in the hidden images one by one	
		$('.portfolio_style3 img:hidden').eq(0).fadeIn(350);//fades in the hidden images one by one	
		$('.flickr_stream img:hidden').eq(0).fadeIn(350);//fades in the hidden images one by one	
		i++;//add 1 to the count
}

// Dropdown menu
$(document).ready(function(){
	$("#navigation a").addClass('level1');
	$("#navigation li").hover(function(){
		$(this).find("a").addClass('current');
		$(this).find("ul").css("display","block");
		$(this).find("li a").removeClass('current');
		$(this).find("li a").removeClass('level1');
	},
	function(){
		$(this).find("a").removeClass('current');
		$(this).find("ul").css("display","none");
	});
});
$(document).ready(function(){
	$("#navigation ul a").wrapInner("<span></span>");
	$("#navigation ul li").hover(function(){
		$(this).find("span").stop().animate({marginLeft:'10px'},{queue:false, duration:250, easing: 'easeOutSine'})
	},
	function(){
		$(this).find("span").stop().animate({marginLeft:'0px'},{queue:false, duration:250, easing: 'easeOutSine'})
	});
});
$(document).ready(function(){
	$("#sidebar ul a").wrapInner("<span></span>");
	$("#sidebar ul li").hover(function(){
		$(this).find("span").stop().animate({marginLeft:'10px'},{queue:false, duration:250, easing: 'easeOutSine'})
	},
	function(){
		$(this).find("span").stop().animate({marginLeft:'0px'},{queue:false, duration:250, easing: 'easeOutSine'})
	});
});

$(document).ready(function(){
	$("#slideshowNav a").wrapInner("<span></span>");
});

// Social network hover animation
$(document).ready(function(){
	$(".social_network li").hover(function(){
		$(this).find("span").animate({opacity: "show", top: "-20"}, 350);
	},
	function(){
		$(this).find("span").animate({opacity: "hide", top: "-45"}, 200);
	});
});

// Logo Home return animation
$(document).ready(function(){
	$("#logo a").hover(function(){
		$(".home_icon").animate({opacity: "show"}, 350);
	},
	function(){
		$(".home_icon").animate({opacity: "hide"}, 200);
	});
});

// Fade on hover images with class .fade
$(document).ready(function(){
	$(".fade").hover(function(){
		$(this).stop().animate({opacity: "0.5"}, 350);
	},
	function(){
		$(this).stop().animate({opacity: "1"}, 125);
	});
});

// Flickr fade animation
$(document).ready(function(){
	$(".flickr_stream img").hover(function(){
		$(this).stop().animate({opacity: "0.5"}, 350);
	},
	function(){
		$(this).stop().animate({opacity: "1"}, 125);
	});
});

// Portfolio 3
$(document).ready(function(){
	$(".portfolio_style3 .infos").css("opacity","0");
	$(".portfolio_style3").hover(function() {

            $(this).find(".infos").stop().animate({
                opacity: "1"
            }, {duration:350});
			$(this).find(".infos").css("z-index","70");
			
    },function() {

            $(this).find(".infos").stop().animate({
                opacity: "0"
            }, {duration:200});
			$(this).find(".infos").css("z-index","61");
			
    });
});

// Customiz'Me panel
$(document).ready(function(){
	$("#customiz").css("marginLeft","-230px");
	$("#open").click(function() {

        if ($("#customiz").css("marginLeft") == "-230px") {
            $("#customiz").animate({
                marginLeft: "0"
            }, {duration:600 , easing : "easeOutExpo"});
        }
        if ($("#customiz").css("marginLeft") == "0px") {
            $("#customiz").animate({
                marginLeft: "-230px"
            }, {duration:600 , easing : "easeInExpo"});
        }
	$("#open").toggleClass("closer");
    });
});


 $(document).ready(function() {
        $("#contact-form").validate();
    });


$(document).ready(function(){
	$("a[rel^='prettyPhoto']").prettyPhoto({theme:'dark_rounded'});
});
