$(document).ready(function() {
	$(".tabContent:not(:first)").hide();
	
	$(".tabContent").each(function(i){
		this.id = "#" + this.id;
	});
	
	$("#listSites a").click(function() {
		var idTab = $(this).attr("href");
		$(".tabContent").hide();
		$("div[id='" + idTab + "']").fadeIn();
		return false;
	});
	
	$('ul#portfolio').innerfade({speed: 1000, timeout: 5000, type: 'sequence', containerheight: '75px'});

	$("a[href^='http://']").click(function(){
		if(($(this).attr("class"))=='internal')
			return true;
		window.open(this.href);
		return false;
	});

	//Select menu label when browsing the page
	var cur_filename = document.location.href.split("/");
	var cur_filename = cur_filename[cur_filename.length-1].split("?");
	if (cur_filename[0] == "")
		cur_filename = "#home_menu";
	else if (cur_filename[0] == "albums" || cur_filename[0] == "lives" || cur_filename[0] == "studio" || cur_filename[0] == "collaborations" || cur_filename[0] == "credits_links" || cur_filename[0] == "guestbook" || cur_filename[0] == "license" || cur_filename[0] == "member_area"){
		cur_filename = "#"+cur_filename[0]+"_menu";
		$(cur_filename).attr("src", $(cur_filename).attr("onmouseover"));
		$(cur_filename).attr("onmouseout", "");
		cur_filename = "#music_menu";
	}
	else
		cur_filename = "#"+cur_filename[0]+"_menu";

	$(cur_filename).attr("src", $(cur_filename).attr("onmouseover"));
	$(cur_filename).attr("onmouseout", "");

	//Build last posted on FlickR
	$('#flickr_view').jflickrfeed({limit: 10,qstrings:{id:'46241909@N03'}, useTemplate: false, itemCallback: function(item){$(this).append('<li><img src="'+item.image_s+'"/></li>');}});

	//Lightboxes for photosets
	$(function() {
		$('a.lightbox').lightBox();
	});
});

$(document).ready(function(){
	$("#contactLink").click(function(){
		if ($("#contactForm").is(":hidden")){
			$("#contactForm").slideDown("slow");
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: $("#contactForm").offset().top}, "1100", function() {window.location.hash = "#contactForm"});
		}else{
			$("#contactForm").slideUp("slow");
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: $("#contactForm").offset().top}, "1100", function() {window.location.hash = "#header"});
		}
	});
});

function closeForm(){
	$.post("mail.py", { name: $('#name').val(), email: $('#Email').val(), message: $('#Message').val() },
		function(data){
		alert(data);
	});

	$("#messageSent").show("slow");
	setTimeout('$("#messageSent").hide(); $("#contactForm").slideUp("slow")', 2000);
	$("html:not(:animated),body:not(:animated)").animate({ scrollTop: $("#header").offset().top}, "1100", function() {window.location.hash = "#header"});
}

function closeForm2(){
	$("#contactForm").slideUp("slow");
	$("html:not(:animated),body:not(:animated)").animate({ scrollTop: $("#header").offset().top}, "1100", function() {window.location.hash = "#header"});
}





// Open the lightbox
function openbox(formtitle){
  var box = document.getElementById('box'); 
  document.getElementById('filter').style.display='block';

  var btitle = document.getElementById('boxtitle');
  btitle.innerHTML = formtitle;
  box.style.display='block';
        $('#photoform').slidinglabels({
                /* these are all optional */
                className    : 'form_slider', // the class you're wrapping the label & input with -> default = slider
                topPosition  : '5px',  // how far down you want each label to start
                leftPosition : '5px',  // how far left you want each label to start
                axis         : 'x',    // can take 'x' or 'y' for slide direction
                speed        : 'fast'  // can take 'fast', 'slow', or a numeric value

        });

}

// Close the lightbox
function closebox(){
   document.getElementById('box').style.display='none';
   document.getElementById('filter').style.display='none';
}

$(function(){
	$('#photoform').slidinglabels({
		/* these are all optional */
                className    : 'form_slider', // the class you're wrapping the label & input with -> default = slider
		topPosition  : '5px',  // how far down you want each label to start
		leftPosition : '5px',  // how far left you want each label to start
		axis         : 'x',    // can take 'x' or 'y' for slide direction
		speed        : 'fast'  // can take 'fast', 'slow', or a numeric value

	});

});


//Google Analytics
 var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-6358498-1']);
  _gaq.push(['_setDomainName', '.nicolaskern.fr']);
  _gaq.push(['_trackPageview']);
  _gaq.push(['_trackPageLoadTime']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

