$(document).ready(function(){
	draw();
	
	$('body.page_sommaire').css({background:'#000'});
	
		
	
	$('h3.spip').prepend('<p class="ph3">&nbsp;</p>');
	$('h3.titre').prepend('<p class="ph3">&nbsp;</p>');
	//$('h2.titre').prepend('<p class="ph3">&nbsp;</p>');
	//$('h1.titre').prepend('<p class="ph3">&nbsp;</p>');
	
	$('body#pm2').css({background:'#bf89b7'});
	$('body#pm2 .tm2').css({color:'#bf89b7'});
	$('body#pm2 .ph3').css({background:'#bf89b7'});
		
	$('body#pm3').css({background:'#169ec6'});
	$('body#pm3 .tm2').css({color:'#169ec6'});	
	
	$('body#pm4').css({background:'#ce9769'});
	$('body#pm4 .tm2').css({color:'#ce9769'});
	$('body#pm4 .ph3').css({background:'#ce9769'});	
	
	$('body#pm5').css({background:'#90bb11'});
	$('body#pm5 .tm2').css({color:'#90bb11'});
	$('body#pm5 .ph3').css({background:'#90bb11'});
	
	$('.liste-articles ul li').hover(
		function(){
			$(this).children('h3').children('a').children('img').show(200);
				
		},
		function(){
			$(this).children('h3').children('a').children('img').hide(100);
		}		
	);	
	
	
	// le menu
	$('.menuitem').hover(
		function(){
			$(this).children('p').slideDown(200);
			
		},
		function(){
			$(this).children('p').slideUp(100);
		}   
	);
	// plan du site
	$(".page_plan ul  ul").hide();
    $(".page_plan ul  li").css("cursor","pointer");
    
    $(".page_plan ul  li").click(function(){
        $(this).children("ul").show("slow");
        
    });

    //$(".page_plan li strong").click(function(){
    //    $(this).parent("li").children("ul:visible").hide("slow");
    //})	
	$('#input-3-ligne_4').attr("value",document.referrer);
		
});

$(window).resize(function(){
  		draw();
	});

function draw(){
		$('#entete').dropShadow({'left':1,'top':6,'opacity':.3,'blur':2});
		$("#page").jqcanvas(function(canvas, width, height){
			var corner = 15;
			var ctx = canvas.getContext("2d");
			ctx.clearRect(0,0,width,height);
			ctx.fillStyle = "white";
			ctx.beginPath();
			ctx.arc(0,0,corner,Math.PI+(Math.PI*0)/2,Math.PI+(Math.PI*1)/2,0);
			ctx.lineTo(width,0);
			ctx.arc(width,0,corner,Math.PI+(Math.PI*1)/2,Math.PI+(Math.PI*2)/2,0);
			ctx.lineTo(width,height-corner);
			ctx.arc(width-corner,height-corner,corner,Math.PI+(Math.PI*2)/2,Math.PI+(Math.PI*3)/2,0);
			ctx.lineTo(corner,height);
			ctx.arc(corner,height-corner,corner,Math.PI+(Math.PI*3)/2,Math.PI+(Math.PI*0)/2,0);
			ctx.closePath();
			ctx.fill();
			return false;
		 });

		if ($('#wrapx').length){
			$('#wrap').css({width:$(window).width(), height:Math.max($(window).height(),$(document).height())});		 
			$("#wrap").jqcanvas(function (canvas, width, height) {
				var ctx = canvas.getContext("2d");
		        ctx.clearRect(0,0,width,height);
		        var lingrad = ctx.createLinearGradient(0,0,0,height);
		        lingrad.addColorStop(0, '#000');
		        lingrad.addColorStop(1, '#ccc');
		        ctx.fillStyle = lingrad;
		        ctx.fillRect(0, 0, width, height);
		        return false;
			 });
		 }
		 
		 if ($('h1.titre').length){
					 
			$("h1.titre").jqcanvas(function (canvas, width, height) {
				var ctx = canvas.getContext("2d");
		        ctx.clearRect(0,0,width,height);
		        var lingrad = ctx.createLinearGradient(0,0,width,0);
		        lingrad.addColorStop(0, '#169ec6');
		        lingrad.addColorStop(0.01483, '#169ec6');
				lingrad.addColorStop(0.015, '#ececed');
				lingrad.addColorStop(1, '#fff');		        
		        ctx.fillStyle = lingrad;
		        ctx.fillRect(0, 0, width, height);
		        return false;
			 });
		 };
		 
		if ($('h2.mg').length){
					 
			$("h2.mg").jqcanvas(function (canvas, width, height) {
				var ctx = canvas.getContext("2d");
		        ctx.clearRect(0,0,width,height);
		        var lingrad = ctx.createLinearGradient(0,0,width,0);
		        lingrad.addColorStop(0, '#169ec6');
		        lingrad.addColorStop(0.01483, '#169ec6');
				lingrad.addColorStop(0.015, '#ececed');
				lingrad.addColorStop(1, '#fff');		        
		        ctx.fillStyle = lingrad;
		        ctx.fillRect(0, 0, width, height);
		        return false;
			 });
		 };		 
		 
	}


var x=0;

function reset()
{
document.getElementById("defil").style.left=0;
x=0;
}


function droite()
{
x=x+7;

if(document.getElementById)
			{
			document.getElementById("defil").style.left = x+"px";
			d=setTimeout('droite()',25);
			}

}

function stopD()
{
clearTimeout(d);
}

function gauche()
{
x=x-7;

if(document.getElementById)
			{
			document.getElementById("defil").style.left = x+"px";
			g=setTimeout('gauche()',25);
			}
}
function stopG()
{
clearTimeout(g);
}
