		var xpos = 0;
								var mediaw = 0;
								var curslide = 1;
								var idc;
								var idn;
								var shade;
								var count = 1;
								
            $(document).ready(function() {
            	
								$('#mentions').click(function(){
									Shadowbox.init({skipSetup: true, players:["html"], troubleElements: ["select","canvas"], onOpen: moveCloseLink});
												Shadowbox.open({
												content:    '<br/><p style="text-align:center;font-family:\'Cocon-LightRegular\';font-size:16px;"><span style="font-weight:bold;">Conception / Cr&eacute;ation du site</span><br/><img src="http://www.fram-printempsete.fr/img/new-bbdo.jpg" alt="NewBBDO" style="display:inline;" /><br/>Chef de projet : Marc Fernandez<br/>D&eacute;veloppement technique : Blazign<br/>Graphisme : Pierre Mass&eacute;<br/><br/><span style="font-weight:bold;">Cr&eacute;dits photos</span><br/>Phototh&eacute;que FRAM<br/>Phototh&egrave;que FRAM / J.Sierpinski<br/>S.Villain-Dakar<br/>L.Gerrere<br/>O.Ozay<br/>Aeroviaggi<br/>Mada2047<br/>K.Bakkali<br/></p>',
												player:     "html",
												title:      "",
												width : "901",
												height: "445"
												});
								});
            	
								$('#pan1').find("img").css("display","inline");
								
								$("#arrg").mouseover(function(){
									$(this).find("img").css("display","inline");
								});
								$("#arrg").mouseout(function(){
									$(this).find("img").css("display","none");
								});
								$("#arrd").mouseover(function(){
									$(this).find("img").css("display","inline");
								});
								$("#arrd").mouseout(function(){
									$(this).find("img").css("display","none");
								});
								$(".pagin").mouseover(function(){
									$(this).find("img").css("display","inline");
								});
								$(".pagin").mouseout(function(){
									var cla  = $(this).attr("id");
									var cur = Number(cla.substr(3,1));
									if(cur != curslide){
										$(this).find("img").css("display","none");
									}
								});
								$(".pagin").click(function(){
									var cla  = $(this).attr("id");
									$('#pan'+curslide).find("img").css("display","none");
									curslide = Number(cla.substr(3,1));
									$('#pan'+curslide).find("img").css("display","inline");
									xpos = -(curslide-1)*990;
									$('#slide').animate({'left':xpos}, 1000);
								});
								
								loadSlide();
								
            });
            
            function loadSlide(){
									$.ajax({
									type: "POST",
									url: "panel"+count+".html",
				      		dataType: "html",
									success: function(html){
				   				 	$("#slide").append(html);
				   				 	if(count < 7){
				   				 		count++;
				   				 		loadSlide();
				   				 	}else{
				   				 		$("#panel1").before('<div id="fake7"></div>');
				   				 		$("#panel7").after('<div id="fake1"></div>');
				   				 		$("#fake1").html($("#panel1").html());
				   				 		$("#fake7").html($("#panel7").html());
				   				 		setSlide();
				   					}
									}
								 });
								}
     
     function setLinks(){
									$(".case").mouseover(function(){
										$(this).children("div:first").css("display","inline");
									});
									$(".case").mouseout(function(){
										$(this).children("div:first").css("display","none");
									});
									$(".case").click(function(){
										idc = $(this).attr("id");
										if(idc == "voeux"){
											window.open("voeux2012/");
										}else if(idc == "undefined"){
											
										}else{
											idn = idc.substr(1,3);
											//xt_med('C','','collection2012::offre'+idn,'N');
											$.ajax({
											type: "POST",
											url: "offre"+idn+".html",
						      		dataType: "html",
						      		context: document.body,
											success: function(html){
						   					//var shade = $(html).find("#presentation");
						   					var exejs = getScriptAndHtml(html);
						   				 	Shadowbox.init({skipSetup: true, players:["html"], troubleElements: ["select","canvas"], onOpen: moveCloseLink, onFinish: function(){ eval(exejs.script); adjustBox(); }});
												Shadowbox.open({
													content:    exejs.html,
							          	player:     "html",
							          	title:      "",
							          	width : "901",
							           	height: "445"
												});
											}
										 });
										}
									});
				   				 		if(showOffer != 0){
				   				 			setTimeout("showBox()", 2000);
											}
								}     

function adjustBox(){
	if($('#sb-container').length==0) return;
	$('#sb-container').height( $(document).height() );
	//$('#sb-wrapper').css({margin:'0 auto',position:'relative',left:''});
}

    function showBox(){
    	$.ajax({
				type: "POST",
				url: "offre"+showOffer+".html",
				dataType: "html",
				context: document.body,
				success: function(html){
					//var shade = $(html).find("#presentation");
					var exejs = getScriptAndHtml(html);
					Shadowbox.init({skipSetup: true, players:["html"], troubleElements: ["select","canvas"], onOpen: moveCloseLink, onFinish: function(){ eval(exejs.script); }});
					Shadowbox.open({
					content:    exejs.html,
					player:     "html",
					title:      "",
					width : "901",
					height: "445"
					});
				}
			});
    }        
            
  	function setSlide(){
									//alert(mediaw);	
						   		mediaw = $('#slide').width();
									$('#arrg').click(function(){
										if(xpos < 0){
											xpos += 990;
											$('#pan'+curslide).find("img").css("display","none");
											curslide --;
											$('#pan'+curslide).find("img").css("display","inline");
											$('#slide').animate({'left':'+=990'}, 1000);
										}else{
											$('#pan7').find("img").css("display","inline");
											$('#pan1').find("img").css("display","none");
											curslide = 7;
											xpos = -5940;
											$('#slide').animate({'left':'+=990'}, 1000,function(){
													$('#slide').css('left', -5940);
											});
										}
									});
									$('#arrd').click(function(){
										if((xpos+mediaw) > 990){
											xpos -= 990;
											$('#pan'+curslide).find("img").css("display","none");
											curslide ++;
											$('#pan'+curslide).find("img").css("display","inline");
											$('#slide').animate({'left':'-=990'}, 1000);
										}else{
											$('#pan1').find("img").css("display","inline");
											$('#pan7').find("img").css("display","none");
											curslide = 1;
											xpos = 0;
											$('#slide').animate({'left':'-=990'}, 1000,function(){
													$('#slide').css('left', 0);
											});
										}
									});
									setLinks();
								}

function getScriptAndHtml( html ){
	if(typeof(html)=="undefined") return;
	var tostop = false, exescript = "", newhtml = "", scrstart = '<script', scrend = '</script>';
	var html_start = html.indexOf('<body',0), html_end = html.indexOf('</body>',0);
	html_start = html.indexOf( '>', html_start+1 )+1;
	var new_html = html.substr(html_start, html_end-html_start);
	var posfirst = 0;
	var ipos = new_html.indexOf( scrstart, posfirst );
	while( !tostop ) {
		var pstart = ipos;
		var jstart = new_html.indexOf( '>', pstart+1 )+1;
		var jend = new_html.indexOf( scrend, jstart );
		var pend = jend + scrend.length+1;
		exescript = exescript + new_html.substr( jstart, jend - jstart );
		posfirst = pend;
		ipos = new_html.indexOf( scrstart, posfirst );
		if(ipos<0) {
			tostop = true;
		}
	}
	var retobj = { 'html':new_html, 'script':exescript.stripSlashes() };
	return retobj;
}


	function moveCloseLink(){ 
		var cb=document.getElementById('sb-nav-close'); 
		var tb=document.getElementById('sb-title'); 
		if(tb) tb.appendChild(cb); 
	}

