// Calques
function findObj(theObj, theDoc)
{
  var p, i, foundObj;  
  if(document.getElementById) return(document.getElementById(theObj));
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length){
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);}
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  return foundObj;
}
function showHideLayers()
{ 
  var i, visStr, obj, args = showHideLayers.arguments;
  for (i=0; i<(args.length-1); i+=2){
    if ((obj = findObj(args[i])) != null){
      visStr = args[i+1];
      if (obj.style){
        obj = obj.style;
        if(visStr == 'show') visStr = 'visible';
        else if(visStr == 'hide') visStr = 'hidden';}
      obj.visibility = visStr;}
  }
}
function showcalq(calque){ // avec une liste établie
	var i,visi,obj;
	for(i=0; i<calq.length; i++){
		visi=calq[i]==calque?'show':'hide';
	    if ((obj = findObj(calq[i])) != null){
	      	if (obj.style){
    	    	obj = obj.style;
				visi=calq[i]==calque?'visible':'hidden';}
			obj.visibility=visi;
		}
	}
}
function show1calq(calque){
	var obj;
	if ((obj = findObj(calque)) != null){
		if (obj.style){
    	  obj = obj.style;
				obj.visibility='visible';}
		else obj.visibility='show';
	}
}
function hide1calq(calque){
	var obj;
	if ((obj = findObj(calque)) != null){
		if (obj.style){
    	  obj = obj.style;
				obj.visibility='hidden';}
		else obj.visibility='hide';
	}
}
function setLayersHeight(){ 
	var i, obj, args = setLayersHeight.arguments;
	h=screen.height-60;
	if (h<800) h=800;
  for (i=0; i<(args.length); i++){
    if ((obj = findObj(args[i])) != null){
			if (obj.style) obj = obj.style;
			if (document.layers) obj.height=h;
			else obj.height = h+'px';
		}
	}
}
if(top!= self) top.location.href = self.location.href;

// fenetres pop-ups d'etiquette et de prix
var ff,ff2,ff3;
function WinPop(fname,titre,params) {
  if (ff3==null || ff3.closed)ff3=window.open(fname,titre,params);
  else ff3.focus();
}  
// sans scrollbars avec resize
function WinPopa(fname,w,h) {
  if (ffa==null || ffa.closed) ffa=window.open(fname,'Clenord','resizable=yes,scrollbars=no,width='+w+',height='+h);
  else {
 	ffa.focus();
	ffa.resizeTo(w+12,h+36);
	ffa.location.href=fname;
  }
}
// Generique 
function wPop(fname,larg,haut) {
	h=screen.height;
	if (h<600) h=600;
	h=h-90;
	if (haut > h) haut=h;
  if (ff==null || ff.closed)ff=window.open(fname,"Clenord","scrollbars=yes,resizable=yes,width="+larg+",height="+haut);
  else{
   ff.focus();
   ff.location.href=fname;
  }
}
// Generique avec dimensions par défaut ("Bonjour c'est POP2") ;-)
function wPop2(fname) {
  if (ff==null || ff.closed)ff=window.open(fname,"Clenord","scrollbars=yes,resizable=yes,width=600,height=600");
  else{ff.focus();ff.location.href=fname;}
}
function wPop2lg(fname) {
  if (ff==null || ff.closed)ff=window.open(fname,"Clenord","scrollbars=yes,resizable=yes,width=1400,height=700");
  else{ff.focus();ff.location.href=fname;}
}
function wPop2x(fname) {
  if (ff==null || ff.closed)ff=window.open(fname,"Clenord","scrollbars=yes,resizable=yes,width=950,height=600");
  else{ff.focus();ff.location.href=fname;}
}
//Generique avec resize
function WinPopRs(fname,w,h) {
  if (ff3==null || ff3.closed) ff3=window.open(fname,'Clenord','resizable=yes,scrollbars=yes,width='+w+',height='+h);
  else {
 	ff3.focus();
	ff3.resizeTo(w+12,h+36);
	ff3.location.href=fname;
  }
}
function ferme_popup(){
   if(ff && !ff.closed) ff.close();
   ff=null;
   if(ff2 && !ff2.closed) ff2.close();
   ff2=null;
   if(ff3 && !ff3.closed) ff3.close();
   ff3=null;
}
var ffp=null;
var fullflag=1;
function PanPopfull(fname){
	if (ffp==null || ffp.closed) {
		if( screen.width >1500 ) PanPop(fname,1450,950);
		else fp = window.open(fname,"PhotoPanoramique","scrollbars=yes,fullscreen");
	}
	else{
		ffp.focus();
		ffp.location.href=fname;
	}
}

function PanPop(fname,w,h){
	if (ffp==null || ffp.closed)
		ffp = window.open(fname,"PhotoPanoramique",'resizable=yes,scrollbars=yes,width='+w+',height='+h);
	else{
		ffp.focus();
		ffp.resizeTo(w+16,h+50);
		ffp.location.href=fname;
	}
	fullflag=0;
}


var timerID = null;
var timerOn = false;
var timecount = 500;
var menudown =0;

function showMenu(nummenu){
	stopTim();
	closeMenu();
	menudown=nummenu;
	show1calq('smliens'+menudown);
}
function closeMenu(){
	if (menudown){hide1calq('smliens'+menudown);menudown=0;}
}
function startTim() {if (timerOn == false) {timerID=setTimeout( "closeMenu()" , timecount);timerOn = true;}}
function stopTim() {if (timerOn) {clearTimeout(timerID);timerID = null;timerOn = false;}}
var ffama;
function AmaLeg(fname){if (ffama==null || ffama.closed) ffama=window.open(fname,"","scrollbars=yes,resizable=yes,width=490,height=480");else{ffama.focus();ffama.location.href=fname;}}

function setprof()
{ 
if (navigator.appName == "Netscape" && eval(navigator.appVersion.substring(0,3) ) < 5) document.pge.document.mainpg.document.courrier.prof[1].checked=true;
else document.courrier.prof[1].checked=true;
}

function setActiveStyleSheet(title) {
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
}
var lestyle='v01';
function switchActiveStyleSheet() {
	var newstyle='v01';
	if (lestyle == 'v01') newstyle='v03';
	if (lestyle == 'v03') newstyle='v02';
	lestyle=newstyle;
	setActiveStyleSheet(lestyle);
}

// Charge Flash sans activation ActiveX sous IE
var bg2clear= false;

function embedFlash (width, height, id, align, path, bgcolor, trans, flashvar) {
	/* bg2clear = true; */
	if (trans=="transparent") trans="";
	if (trans=="undefined") trans="window";
	if (flashvar=="undefined") flashvar="";	
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,65,0" width=' + width + ' height=' + height + ' id=' + id + ' align=' + align + '><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value=' + path + ' /><param name="quality" value="high" /><param name="bgcolor" value=' + bgcolor + ' /><param name="wmode" value="'+ trans +'" /><param name="flashvars" value="'+ flashvar +'"  /><param name="menu" value="false" /><embed src="' + path + '" quality="high" bgcolor="' + bgcolor + '" width="' + width + '" height="' + height + '" name="' + id + '" align="' + align + '" wmode="'+ trans + '" FlashVars="'+ flashvar +'"  menu="false" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
}

function embedFlashSecure (width, height, id, align, path, bgcolor, trans, flashvar) {
	if (trans=="undefined") trans="window";
	if (flashvar=="undefined") flashvar="";	
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width=' + width + ' height=' + height + ' id=' + id + ' align=' + align + '><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value=' + path + ' /><param name="quality" value="high" /><param name="bgcolor" value=' + bgcolor + ' /><param name="wmode" value="'+ trans +'" /><param name="flashvars" value="'+ flashvar +'"  /><param name="menu" value="false" /><embed src="' + path + '" quality="high" bgcolor="' + bgcolor + '" width="' + width + '" height="' + height + '" name="' + id + '" align="' + align + '" wmode="'+ trans + '" FlashVars="'+ flashvar +'" menu="false" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" /></object>');
}

function clearingbg (){
	var lenom = "img/pix32blc.gif";
	if (ob=findObj('slidebg')) ob.src=lenom;
}
function StartBg2clear (){
	var imgbck = new Image();
	imgbck.src = "img/pix32blc.gif";
	window.setTimeout("clearingbg()", 5*1000);
}


/* panoramas */
var preld=false;

var slidepath='';
var firstwait = 5 * 1000;
var waitonimages = 3 * 1000;
var current_opacity = 100;
var current_img = 0;
var sens=-5;

function startSlideAnim() {
	window.setTimeout("animation()", firstwait);
}

function get_next_inline(){
	current_img++;
	if (current_img >= slides.length) current_img=0;
	return (slides[current_img]);
}

function changegrandeimg(limage) {
	var ob;
	var lenom = slidepath+get_next_inline()+".jpg";
	if (ob=findObj(limage)) ob.src=lenom;
}


function animation() {

	if (current_opacity == 100) {
		sens = -5;
		/* changer image arrière */
		changegrandeimg('slide1');
	}
	current_opacity += sens;
  setOpacity('pageimg_haut_in2', current_opacity);
	if (current_opacity ==0){
		sens=5;
		/* changer image avant */
		changegrandeimg('slide2');

	}
	if (current_opacity && current_opacity < 100)
		window.setTimeout("animation()", 50);
	else
		window.setTimeout("animation()", waitonimages);
}

function initImage(imageId) {
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageId,0);
}
function fadeIn(objId,opacity) {
  if (document.getElementById) {
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  }
}

function setOpacity(objId, opacity) {
	
	obj = document.getElementById(objId);

  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}
function precharger_img(chemin){slidepath=chemin;for (var i=1;i<slides.length;i++) {eval('var img'+i+'= new Image();');eval('img'+i+'.src = "'+chemin+slides[i]+'.jpg";');}}
var addthis_config = {ui_cobrand: "Clenord"}
function changeimage(id,image) {	if (ob=findObj(id)) ob.src='../../img/'+image+".jpg";}




