$(document).ready(function(){
        $(document).bind("contextmenu", function(e) {
            return false;
         });

	//  Initialize Backgound Stretcher	
	
	var arrImages = new Array();
	
	switch($("body").attr("id")){
		case "portfolio":
			arrImages.push("bg/niv_2.jpg");
		break;
		
		case "profil":
			arrImages.push("images/bg_profil.jpg");
		break;
		
		default:
		var nbSet = 4; //4 groupes
		var setLength = 5; //de 5 photos
		var cpt = (Math.floor(Math.random()*nbSet)*setLength)+1;
		for(var j=0; j<setLength; j++){
			index = cpt+j;
			arrImages.push("bg/" + index + ".jpg");
		}
	}
	
	if(document.images){
		image_objects = new Array();
		for(var i=0; i <= arrImages.length; i++){
			image_objects[i] = new Image();
			image_objects.src = arrImages[i];
		}
	}
	
	$(document).bgStretcher({
		images: arrImages,
		imageWidth: 1440, imageHeight: 900
	});		
	
	$("#doucetMusique").tipTip({maxWidth: "180px", edgeOffset: 4, delay: 20});
	$("#doucetFacebook").tipTip({maxWidth: "100px", edgeOffset: 4, delay: 20});


	/*if (document.images){
		image_objects = new Array();
		image_url = new Array();
		image_url[0] = "images/profil2.png";
		image_url[1] = "images/nouvelles2.png";
		image_url[2] = "images/portfolio2.png";
		image_url[3] = "images/soumission2.png";
		image_url[3] = "images/contact2.png";
		for(var i=0; i <= image_url.length; i++){
			image_objects[i] = new Image();
			image_objects.src = image_url[i];
		}
	}*/
	
	$(window).resize(function(){
		resizeRepos();
	});
	
	/* Changement de cat�gorie dans le portfolio */
	$('#f_category #cat').change(function(){
		$('#f_category').submit();
	});
	
	/* Apparition du choix "autre" */
	$('#f_soumission #categorie, #f_soumission #endroit').change(function(){
		if($(this).val()=="Autre"){
			$(this).parent().find('.bloc_specifiez').fadeIn();
		}else{
			$(this).parent().find('.bloc_specifiez').fadeOut();	
		}
	});
	
});

$(window).load(function(){
    resizeRepos();
})

function resizeRepos(){


	/* Repositionnement */
	var position_content = $(window).height() - $('#content li:first-child').height() - $('#menu').height() - $('#entete').height() - ($('#portfolio #entete').length?10:5);
	if(position_content<0){
		position_content = 0;
	}
	$('#wrap_content').stop().animate({top:position_content}, 500);
	
}

/* Google Analytics */
var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-21167622-1']);
  _gaq.push(['_trackPageview']);

  (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);
  })();
