
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

var maximg=7;
var av=0;
var apr=nbimg-maximg;
var largeur=91;
function defileGall(sens){
	if(sens=='plus' && apr>0){
		MM_showHideLayers('iprec','','show');
		if((apr-1)==0){
			MM_showHideLayers('isuiv','','hide');
		}
		for(var i=0;i<nbimg;i++){
			/*if((av-i)==1){
				MM_changeProp('img'+i,'','style.visibility','visible','DIV');
			}else if((av+maximg)==1){
				MM_changeProp('img'+i,'','style.visibility','hidden','DIV');
			}*/
			var poschange=((i*largeur)-(av*largeur))-largeur;
			MM_changeProp('img'+i,'','style.left',poschange,'DIV');
		}
		av+=1;
		apr-=1;
	}else if(sens=='moins' && av>0){
		MM_showHideLayers('isuiv','','show');
		if((av-1)==0){
			MM_showHideLayers('iprec','','hide');
		}
		for(var i=0;i<nbimg;i++){
			/*if(av==i){
				MM_changeProp('img'+i,'','style.visibility','visible','DIV');
			}else if((i-1)==(maximg+av)){
				MM_changeProp('img'+i,'','style.visibility','hidden','DIV');
			}*/
			var poschange=((i*largeur)-(av*largeur))+largeur;
			MM_changeProp('img'+i,'','style.left',poschange,'DIV');
		}
		av-=1;
		apr+=1;
	}
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"='"+theValue+"'");
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}
function openPictureWindow_Fever(imageType,imageName,imageWidth,imageHeight,alt,posLeft,posTop) {  // v4.01
	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",scrollbars=no,left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	if (imageType == "swf"){
	newWindow.document.write('<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\">');
	newWindow.document.write('<param name=movie value=\"'+imageName+'\"><param name=quality value=high>');
	newWindow.document.write('<embed src=\"'+imageName+'\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\">');
	newWindow.document.write('</embed></object>');	}else{
	newWindow.document.write('<img src=\"'+imageName+'\" width='+imageWidth+' height='+imageHeight+' alt=\"'+alt+'\">'); 	}
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
//Défilant les magasins
var initdefile=false;
// pas de défilement :
var pas=1;
// hauteur de la partie visible
var h_fen="80px";
var h_fen_int=15;
var h_mrq=0;
var isPassed=0;
function scrollmrq2(){
initdefile=true;
h_mrq=mrq.offsetHeight;
if ( parseInt(mrq.style.top) > (h_mrq*-1) )
mrq.style.top = parseInt(mrq.style.top)-pas+"px"
else
mrq.style.top=fen.offsetHeight
}

function scrollmrqMag(nbElem){
	mrq=document.getElementById("marquee"); 
	mrq.style.top = 0;
	initdefileMenu=true;	
	var precPos;
	
		for(i=0;i<nbElem;i++){
		
	

		var mag=document.getElementById("mag"+i);
		
		
		h_mrq=mag.offsetHeight;
	
		if(isPassed<2){
			
			if(isPassed==0){
				isPassed=1;
				window.setTimeout("setPassed()",1000);	
			}
			//mag.style.top=1;
			
			//mag.style.top=mag.style.top-1;
			//alert(mag.style.height);
		}else{
			if ( parseInt(mag.style.top) > (h_mrq*-1) ){
				mag.style.top = parseInt(mag.style.top)-pas+"px";	
			}else{
				//alert(nbElem);
				mag.style.top=((nbElem-1)*h_fen_int)-1;
			}
		}
	}
}


function setPassed(){
	isPassed=3;
}
function init_mrqMag(nbElem, hfen_perso){
h_fen=hfen_perso;
mrq=document.getElementById("marquee"); 
fen=document.getElementById("fenetre2"); 
fen.onmouseover=function(){stoc=pas;pas=0};
fen.onmouseout=function(){pas=stoc};fen.style.height=h_fen;
h_mrq=mrq.offsetHeight;
with(mrq.style){position="absolute";top=h_fen;}

setInterval("scrollmrqMag("+nbElem+")",50);

}

function init_mrq(){
mrq=document.getElementById("marquee"); 
fen=document.getElementById("fenetre2"); 
fen.onmouseover=function(){stoc=pas;pas=0};
fen.onmouseout=function(){pas=stoc};fen.style.height=h_fen;
h_mrq=mrq.offsetHeight;
with(mrq.style){position="absolute";top=h_fen;}
setInterval("scrollmrq2()",50);
}

//window.onLoad=init_mrq();
//-->
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//Aller à une URL
function gotourl(url){
    document.location.href=url;
}

var info = null;
function ow(theURL,larg,haut)
  {
larg = Math.ceil(screen.width * (larg/100)*(1024/screen.width));
if(larg > screen.width) {larg = Math.ceil(larg*(95/100));}
haut = Math.ceil(screen.height * (haut/100));
  if (info)
    {
      info.close();
      info =  window.open(theURL,"info","scrollbars=yes,menubar=yes,resizable=yes,width="+ larg +"px,height="+ haut +"px,outerwidth="+ larg +"px,outerheight="+ haut +"px,top=5,left=5,screenX=5,screenY=5");
      info.focus();
    }
  else  {
      info =  window.open(theURL,"info","scrollbars=yes,menubar=yes,resizable=yes,width="+ larg +"px,height="+ haut +"px,outerwidth="+ larg +"px,outerheight="+ haut +"px,top=5,left=5,screenX=5,screenY=5");
      info.focus();
    }
  }



//--- Partie Panorama d'images -----------------------------------------------

var imgname=new Array();
imgname[0]="/imgs_mag/paris_1/gallerie/pa1_thumb.jpg";
imgname[1]="/imgs_mag/bordeaux_4/gallerie/bo1_thumb.jpg";
imgname[2]="/imgs_mag/strasbourg_7/gallerie/st1_thumb.jpg";
imgname[3]="/imgs_mag/rennes_9/gallerie/re2_thumb.jpg";
imgname[4]="/imgs_mag/lille_6/gallerie/li1_thumb.jpg";
imgname[5]="/imgs_mag/toulouse_5/gallerie/toul1_thumb.jpg";

var imgpreload=new Array();
  for (i=0;i<=imgname.length-1;i++)
    {
      imgpreload[i]=new Image();
      imgpreload[i].src=imgname[i];
    }

var imgurl=new Array();
imgurl[0]="";
imgurl[1]="";
imgurl[2]="";
imgurl[3]="";
imgurl[4]="";
imgurl[5]="";

var imgdest=new Array();
imgdest[0]="self";
imgdest[1]="self";
imgdest[2]="self";
imgdest[3]="self";
imgdest[4]="self";
imgdest[5]="self";

var imgwidth=new Array();
imgwidth[0]=90;
imgwidth[1]=90;
imgwidth[2]=90;
imgwidth[3]=90;
imgwidth[4]=90;
imgwidth[5]=90;

var imgheight=new Array();
imgheight[0]=90;
imgheight[1]=90;
imgheight[2]=90;
imgheight[3]=90;
imgheight[4]=90;
imgheight[5]=90;

var bBoucle = true;
var nim=0;
var nimurl=0;
var plv = 3000;

function stopvaa()
  {
    bBoucle = false;
    nim=0;
  }

function runvaa(nim)
  {
    bBoucle = true;
  }

function changeImg(nim)
  {
    nimurl=nim;
	//limage=document.getElementById("imgmags");
    document.images['imgsmags'].src=imgname[nim];
  // limage.images[0].src=imgname[nim];
  }

function runurl(nim)
  {
    nim=nimurl;
    if ( imgdest[nim] == "self" )
      {
        document.location.href = imgurl[nim];
      }
    else
      {
        if ( imgdest[nim] == "none" )
        {
        void(0);
        }
        else
        {
        ow(imgurl[nim],imgwidth[nim],imgheight[nim]);
        }
      }
  }

function pvite(pmv) {
if (pmv == 0) { plv = (plv + 2000);
  alert((10-plv/1000)/2);}
else { if (plv > 1000)
  {plv = (plv - 2000); pmv = 1;}
  else {void(0);}
alert((10-plv/1000)/2);
  }
}

function initiate()
  {
    nim++;
    if (nim>imgname.length-1)
      {
      nim=0;
      }
    if (bBoucle)
      {
      changeImg(nim);
      }
    if (bBoucle)
      {
      setTimeout("initiate()",plv);
      }
  }

//Valide le formulaire quand on clique sur "Entrée"
function chkEnter(form, ev)
{
	var code = ev.keyCode;
	if (code==13){
		eval("document."+form).submit();
	}
}

function go_produit(url, params)
{
	if(params == '')
	{
		window.location = url;	
	}
	else
	{

		window.location = url + "?" + params;
	}
	return false;
}

function go_produit_new(url, params)
{
	if(params == '')
	{
		window.open(url);	
	}
	else
	{

		window.open(url + "?" + params);
	}
	return false;
}
	
	var IE6 = false, IE7 = false,
	FIREFOX2 = false, FIREFOX = false,
	NETSCAPE7 = false, NETSCAPE = false,
	OPERA9 = false, OPERA = false,
	AUTRE = false;
	var strChUserAgent = navigator.userAgent;
	var intSplitStart = strChUserAgent.indexOf("(",0);
	var intSplitEnd = strChUserAgent.indexOf(")",0);
	var strChStart = strChUserAgent.substring(0,intSplitStart);
	var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);
	var strChEnd = strChUserAgent.substring(strChEnd);
	
	if(strChMid.indexOf("MSIE 7") != -1)
	IE7 = true;
	else if(strChMid.indexOf("MSIE 6") != -1)
	IE6 = true;
	else if(strChEnd.indexOf("Firefox/2") != -1)
	FIREFOX2 = true;
	else if(strChEnd.indexOf("Firefox") != -1)
	FIREFOX = true;
	else if(strChEnd.indexOf("Netscape/7") != -1)
	NETSCAPE7 = true;
	else if(strChEnd.indexOf("Netscape") != -1)
	NETSCAPE = true;
	else if(strChStart.indexOf("Opera/9") != -1)
	OPERA9 = true;
	else if(strChStart.indexOf("Opera") != -1)
	OPERA = true;
	else
	AUTRE = true;

	
	$(document).ready(function()
	{
		$(function()
		{
			$(".btnsp").toggle(
				function()
				{
					if( $("#panelplan").css('height') == '1px')
                    {
                    	deplie_plan();
                    }
                    else
                    {
                    	plie_plan();
                    }
                    return false;
				},
                function()
				{
                    if( $("#panelplan").css('height') == '1px')
                    {
                    	deplie_plan();
                    }
                    else
                    {
                    	plie_plan();
                    }
                    return false;
				}
			);
		});
	});
	
	function plie_plan()
    {
		transition_plan("#panelplan", '1', 500, '450', function () { $("#panelplan").css('display', 'none'); if (IE6) { $("select").css('visibility', 'visible'); } })
    }
    
    function deplie_plan()
    {
		if (IE6)
		{
			$("select").css('visibility', 'hidden'); 
		}
		$("#panelplan").css('display', 'block');
		transition_plan("#panelplan", '450', 500, '450');
	}
	
	function transition_plan(element, target_height, time, real_height, callback, interval)
	{
		cur_height = $(element).css('height');
		unit_pos = cur_height.indexOf('px');
		cur_height_val = parseInt(cur_height.substring(0, unit_pos));
		
		//nombre de pixels ajoutes ou soustraits a chaque etape
		step = 20;
		
		//calcul de l'interval
		if (interval == null) { interval = Math.floor(time / (Math.abs(cur_height_val - target_height) / step)); }
		
		new_height = null;
		
		//calcul de la nouvelle taille
		//plie
		if (cur_height_val > target_height)
		{
			if((cur_height_val - step) >= target_height)
			{
				new_height = (cur_height_val - step);
			}
			else if ((cur_height_val - step) < target_height)
			{
				new_height = target_height;
			}
		}
		//deplie
		else if (cur_height_val < target_height)
		{
			if((cur_height_val + step) <= target_height)
			{
				new_height = (cur_height_val + step);
			}
			else if ((cur_height_val + step) > target_height)
			{
				new_height = target_height;
			}
		}
		
		if(new_height != null)
		{
			 $(element).css('height', new_height + 'px');
			 window.setTimeout(function () { transition_plan(element, target_height, time, real_height, callback, interval); }, interval);
		}
		else
		{
			if(callback != null) { callback.call(); }
		}
	}

