// Image loaded one by one
$(function () {
	$('#portfolio .one_col_shadow_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
		}
		$('#portfolio img.one_col_shadow_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
}


$(document).ready(function() {
	//Tooltips
	$(".flickr_stream a").append("<span></span>");
	$(".flickr_stream a").hover(function(){
		$(this).find("img").stop().animate({opacity: "0.5"}, 60);
		var hoverText = $(this).find("img").attr("title");
		$(this).find("span").addClass("tip").text(hoverText);
		tip = $(this).find("span");
		tip.animate({opacity: "show", top: "3px"}, "fast").show(); //Show tooltip
	}, function() {
		$(this).find("img").stop().animate({opacity: "1"}, 60);
		tip.animate({opacity: "hide", top: "-25"}, "fast").show(); //Hide tooltip		  
	});
});


// Captcha system
$(document).ready(function(){
$("#errorcaptcha").css({opacity: "0"});
$("#check").keyup(function () {
		var rep = $(this).val();
		var n1 = document.getElementById('num1').innerHTML;
		var n2 = document.getElementById('num2').innerHTML;
		var n3 = parseInt(n1) + parseInt(n2);
      		if( n3 == rep ){
			$("#submitter").prepend('<input type="submit" name="contact_submit" id="contact_submit" value="OK" />').animate({opacity: "1"},{duration:350});
			$("#errorcaptcha").text(" ").animate({opacity: "0"},{duration:150});
		}
		else {
			$("#errorcaptcha").text("Not good!").animate({opacity: "1"},{duration:350});
			$("#submitter").prepend('').animate({opacity: "0"},{duration:150}).empty();
		}
    });
});


// Portfolio Grid
$(function(){
	$(".portfolio_grid_item h5").css("opacity","0");
	$(".preview_folio .zoom").css("opacity","0");
	$(".preview_folio .detailgo").css("opacity","0");
	$(".preview_folio").hover(function(){
		$(this).find(".zoom").stop().animate({opacity: "1"});
		$(this).find(".detailgo").stop().animate({opacity: "1"});
	},function(){
		$(this).find(".zoom").stop().animate({opacity: "0"});
		$(this).find(".detailgo").stop().animate({opacity: "0"});
	});
	$(".preview_folio").hover(function(){
		$(this).parent(".portfolio_grid_item").find("h5").stop().animate({opacity: "1", marginTop: "-25px"},{ duration: 100});
	},function(){
		$(this).parent(".portfolio_grid_item").find("h5").stop().animate({opacity: "0", marginTop: "0px"},{ duration: 100});
	});
	$(".zoom").hover(function(){
		$(this).find("img").stop().animate({marginTop: "-5px"});
	},function(){
		$(this).find("img").stop().animate({marginTop: "0"});
	});
	$(".detailgo").hover(function(){
		$(this).find("img").stop().animate({marginTop: "-5px"});
	},function(){
		$(this).find("img").stop().animate({marginTop: "0"});
	});
	
});


// Border radius Jquery Hack ! ;)
$(function(){
	$(".notice_infos").addClass("radius");
	$(".notice_success").addClass("radius"); 
	$(".notice_help").addClass("radius"); 
	$(".notice_email").addClass("radius"); 
	$(".notice_warning").addClass("radius"); 
	$(".notice_error").addClass("radius"); 
	$(".notice_validation").addClass("radius");
	
		$(".radius").css("-moz-border-radius","6px");
		$(".radius").css("-webkit-border-radius","6px");
		$(".radius").css("-khtml-border-radius","6px");
		$(".radius").css("border-radius","6px");
});


