$(document).ready(function(){
$("[id^=collection_titre_]").click(function(){
	var id = $(this).attr("id").substring(17);
	if ($("#gray_"+id).is(":hidden")) {
	$("#gray_"+id).slideDown("slow");
	$.cookie('gray_'+id, 'visibility:visible', {expires: 7});
	}
	else{
	$("#gray_"+id).slideUp("slow");
	$.cookie('gray_'+id, 'display:none', {expires: 7});
	}
});

//~ $("[id^=video_]").click(function(){
	//~ var id = $(this).attr("id").substring(6);
	//~ alert(id);
	//~ $.post("ajaxfront.php",
	//~ {
	//~ fonction:'affichevideo',
	//~ idvideo: id
	//~ } ,function(data){
	//~ $("#runvideo_"+id).html("test");
	//~ })
//~ })

$("[id^=video_]").click(function(){
var id = $(this).attr("id").substring(6);
	$.post("ajaxfront.php",
	{
	fonction:'affichevideo',
	idvideo: id
	} ,function(data){
	$("#slideshow").html(data);
	})
})

$("[id^=novideo_]").click(function(){
$("#slideshow").html('');
})


//~ $("[class=play]").click(function(){



$("#cadenas").click(function(){
if ($('#opencadenas').is(":hidden")) {
	$('#opencadenas2').show();
	$('#opencadenas').slideDown("slow");
}
else{
$('#opencadenas').slideUp("slow");
$('#opencadenas2').hide();

}
});

$("#souvenir1").click(function(){
if ($('input[type=checkbox][id=souvenir1]:checked').length ==1){
//~ alert($('#login').val());
//~ alert($('#pswcook').val());
$.cookie('logincook',$('#login').val(), { expires:30});
$.cookie('pswcook',$('#psw').val(),{ expires:30});
$.cookie('remembercook',1,{ expires:30});
}else{
$.cookie('logincook',null);
$.cookie('pswcook',null);
$.cookie('remembercook',0);
}
})


$('[id^=affichefolio_]').click(function(){
var id = $(this).attr("id").substring(13); // on recupere l'id de l'element
//~ alert(id);
window.location.href=$('#submitfolio'+id).attr("href");
return false;
});


//~ alert(getWindowHeight());
//~ alert($('#contenu').height());
//~ $('#contenu').height(500);



$("a[href$=pdf]").addClass("pdf");
$("a[href$=doc]").addClass("doc");
$("a[href$=xls]").addClass("xls");
$("a[href$=html]").addClass("htm");
$("a[href$=htm]").addClass("htm");
$("a[href$=ppt]").addClass("ppt");

redimensionne();

})

function redimensionne(){
var xHauteur;
xHauteur=getWindowHeight()-(225+43+43-5);
$('#contenu').height(xHauteur);
if($('#contenu').height()<xHauteur){
$('#contenu').height(xHauteur);
}
}

$(window).resize(function(){
redimensionne();				
});
$(window).load(function(){
redimensionne();				
});

function efface(){
$("#slideshow").html('');
$("#slideshow").html('');
$("[id^=flashcontent]").hide();
}

function getWindowHeight() {
    var windowHeight=0;
    if (typeof(window.innerHeight)=='number') {
        windowHeight=window.innerHeight;
    }
    else {
     if (document.documentElement&&
       document.documentElement.clientHeight) {
         windowHeight = document.documentElement.clientHeight;
    }
    else {
     if (document.body&&document.body.clientHeight) {
         windowHeight=document.body.clientHeight;
      }
     }
    }
    return windowHeight;
}
