// JavaScript Document



// Fonction de preload 
//<![CDATA[
<!-- 
// Vous pouvez changer la vitesse (speed) (1 == tres rapide)
// Vous pouvez changer la qualité de la transition (1 == best)
// Plus la transition est de qualité, plus la rapidité ralenti et doit être augmenté

var speed = 3;

var transition = 7;

// Dimensions du preloader en GIF animé

var GIFpreloadLargeur = 374;

var GIFpreloadHauteur = 107;


var timer= 0;

var opaciT = 100;

function opacity()  {
    opaciT = opaciT - transition;
    var object = document.getElementById("preloader").style;
    object.opacity = (opaciT / 100);
    object.MozOpacity = (opaciT / 100);
    object.KhtmlOpacity = (opaciT / 100);
    object.filter = "alpha(opacity=" + opaciT + ")";
          
     if (opaciT <= 0)
     {
          document.getElementById("preloader").style.visibility="hidden";
          clearInterval(timer);
     }

}
 
function preload()
{
    if (navigator.appName != "Microsoft Internet Explorer") {
         if (document.getElementById)
         {
              document.getElementById("preloadIMG").style.visibility="hidden";
              timer = setInterval("opacity()",speed);
              //timer = setInterval("alert (1)",speed);
         }
         else
         {
              if (document.layers)
              {   
                   document.preloadIMG.visibility = "hidden";
                   timer = setInterval("opacity()",speed);
             }
                 else
              {
                   document.all.preloadIMG.style.visibility = "hidden";
                   timer = setInterval("opacity()",speed);
              }
         }
    }
}

// GÉNÉRER LE CSS POUR LE PRELOADER
var myCSS;
myCSS = "<style type=\"text/css\">";

myCSS += "html, body { height:auto; margin:0px; padding:0px;}";

myCSS += "#preloader {";
myCSS += "position:absolute;";
//myCSS += "background-color:black;";
myCSS += "width:100%;";
myCSS += "height:100%; ";
myCSS += "display:block;";
myCSS += "z-index:1000000;";
myCSS += "}";

myCSS += "#preloadIMG {";
myCSS += "position:absolute;";
myCSS += "left:50%;";
myCSS += "width:" + GIFpreloadLargeur + "px;";
myCSS += "height:" + GIFpreloadHauteur + "px;";
myCSS += "margin-left:-" + (GIFpreloadLargeur / 2) + "px;";
myCSS += "top:150px;";
myCSS += "}";

myCSS += "</style>";

// ÉCRITURE DES CSS
window.document.write(myCSS);

// ÉXÉCUTION
//window.onload = function() { preload(); }

//-->
//]]>



// Fonction show/hide du menu 
//<![CDATA[
<!-- 
function montre(id) {
    var dd_id = document.getElementById('smenu'+id);    
	    for (var i = 1; i<=5; i++) 
	    {
		    if (document.getElementById('smenu'+i)) 
		    {
		        document.getElementById('smenu'+i).style.display='none';
		        var SrcImg=document.getElementById('sImg'+i).src
		        document.getElementById('sImg'+i).src=SrcImg.replace(/-on.png/,"-off.png");
		    }
	    }
    if (dd_id) 
        {
        dd_id.style.display='block';    
        if(document.getElementById("sImg"+id)){
        document.getElementById("sImg"+id).src = document.getElementById("sImg"+id).src.replace(/-off.png/,"-on.png");
        }
        
        if(document.getElementById('hidMenuId')){document.getElementById('hidMenuId').value=id;}
        }
}



//-->
//]]>


// Fonction switch tabs 
//<![CDATA[
<!--
function switchid(id){	
	hideallids();
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3
		document.getElementById(id).style.display = 'none';
		//document.getElementById('fiche-tab0').style.display = 'none';
		//document.getElementById('fiche-tab4').style.display = 'none';

	}
	else {
		if (document.layers) { // NS
			document.id.display = 'none';
		}
		else { // IE
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // NS
			document.id.display = 'block';
		}
		else { // IE
			document.all.id.style.display = 'block';
		}
	}
}

//-->
//]]>



// Fonction switch link color 
//<![CDATA[
<!--
function switchlink(which) {
     if (document.getElementById('tab0-link')) {
        document.getElementById('tab0-link').style.color = '#297acc';
     }
     document.getElementById('tab1-link').style.color = '#297acc';
     document.getElementById('tab2-link').style.color = '#297acc';
     if (document.getElementById('tab3-link')) {
        document.getElementById('tab3-link').style.color = '#297acc';
     }
     document.getElementById(which).style.color = '#5a5a5a';
   }
//-->
//]]>

// Fonction switch link color 
//<![CDATA[
<!--
function switchlinkto(which) {
     document.getElementById('tab4-link').style.color = '#297acc';
     document.getElementById('tab5-link').style.color = '#297acc';
     document.getElementById('tab6-link').style.color = '#297acc';
     document.getElementById(which).style.color = '#5a5a5a';
   }
//-->
//]]>


// Fonction switch tabs
//<![CDATA[
<!--
function switchtabs(which) {
     document.getElementById('conseilshm-sac-tab1').style.display = 'none';
     document.getElementById('conseilshm-sac-tab2').style.display = 'none';
     document.getElementById('conseilshm-sac-tab3').style.display = 'none';
     document.getElementById(which).style.display = 'block';
   }
//-->
//]]>

// Fonction switch tabs
//<![CDATA[
<!--
function switchtabsto(which) {
     document.getElementById('conseilshm-hab-tab1').style.display = 'none';
     document.getElementById('conseilshm-hab-tab2').style.display = 'none';
     document.getElementById('conseilshm-hab-tab3').style.display = 'none';
     document.getElementById(which).style.display = 'block';
   }
//-->
//]]>


// Fonction scroll vertical 
//<![CDATA[
<!--
	var Timer;
	var Pas = 3;
	
	function moveLayer(Sens)
	{
	Objet=document.getElementById("Contenu");
    if(parseInt(Objet.style.top) + (Pas*Sens)>0)  {
		clearTimeout(Timer);
	}
	else if(parseInt(Objet.style.top) + (Pas*Sens)<-(Objet.offsetHeight-document.getElementById("Support").offsetHeight)) {
		clearTimeout(Timer);
	}
    else {
        Objet.style.top = (parseInt(Objet.style.top) + (Pas*Sens)) + "px";
	}
	Timer = setTimeout("moveLayer(" + Sens + ");", 30);
	}
//-->
//]]>



// Fonction highlight des liens des onglets
//<![CDATA[
<!-- 
function switchcolor(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}
//-->
//]]>


// Fonction validation du formulaire de contact
//<![CDATA[
//
function valider(){
	var frm=document.EMAIL
	var sError='';
	InitLabelClass();
	if(frm){
	  	  if(frm.emailclient.value=='' || !validateEmail(frm.emailclient.value)){
           sError+= "- Merci d\'entrer une adresse email valide\n";
           oLabel=GetLabelFor('emailclient');
           oLabel.className='Error';
         }
		 if(frm.nom.value==''){
           sError+= "- Merci d\'entrer un nom\n";
           oLabel=GetLabelFor('nom');
           oLabel.className='Error';
		 }
		 if(frm.prenom.value==''){
           sError+= "- Merci d\'entrer un prenom\n";
           oLabel=GetLabelFor('prenom');
           oLabel.className='Error';
		 }
		 if(frm.tel.value==''){
           sError+= "- Merci d\'entrer un numéro de téléphone\n";
           oLabel=GetLabelFor('tel');
           oLabel.className='Error';
		 }
		 if(frm.titreemail.value==''){
           sError+= "- Merci d\'entrer un titre de l'email\n";
           oLabel=GetLabelFor('titreemail');
           oLabel.className='Error';
		 }
		 if(frm.message.value=='' || frm.message.value.length>8000){
           sError+= "- Merci d\'entrer un message. (max 8000 caract.)\n";
           oLabel=GetLabelFor('message');
           oLabel.className='Error';
		 }
		if(sError==''){
           return true;
         }else{
           alert(sError);
           return false;
         } 
	}
}

//-->
//]]>


// Fonction show/hide div
//<![CDATA[
<!--

function toggleLayer( whichLayerToShow)
{
    for (var i = 1; i < arguments.length; i++) {
        hidediv(arguments[i]);
    }
    showdiv(whichLayerToShow)

//  var elem, vis;
//  if( document.getElementById ) // this is the way the standards work
//    elem = document.getElementById( whichLayer );
//  else if( document.all ) // this is the way old msie versions work
//      elem = document.all[whichLayer];
//  else if( document.layers ) // this is the way nn4 works
//    elem = document.layers[whichLayer];
//  vis = elem.style;
//  // if the style.display value is blank we try to figure it out here
//  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
//    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
//  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}



//-->
//]]>



// Ajouter aux favoris
//<![CDATA[

function addToFavorites(anchor){
	if (window.external)
	{
		    window.external.AddFavorite(anchor.getAttribute('href'), anchor.getAttribute('title'));
	}
}
//-->
//]]>

// Onglet info pays
//<![CDATA[
//function showInfoPays(sBloc,  oLI, idPicto, urlPicto){
function showInfoPays(sBloc,  oLI){
    //oImg = document.getElementById(idPicto);
    if(document.getElementById('dvF')) document.getElementById('dvF').style.display='none';
    if(document.getElementById('dvS')) document.getElementById('dvS').style.display='none';
    if(document.getElementById('dvG')) document.getElementById('dvG').style.display='none';
    if(document.getElementById('dvH')) document.getElementById('dvH').style.display='none';
    if(document.getElementById('dvT')) document.getElementById('dvT').style.display='none';
    if(document.getElementById('dvI')) document.getElementById('dvI').style.display='none';
    if(document.getElementById('dvA')) document.getElementById('dvA').style.display='none';
    var listItems = document.getElementsByName("liip");
    for (i=0;i<listItems.length;i++)
        listItems[i].className="ghost";
    oLI.className="current";
    document.getElementById('dv'+sBloc).style.display='block';  
    //if(oImg) oImg.src= urlPicto;
}

//-->
//]]>

// Shw flash
//<![CDATA[
function showFlash() {
    oss = navigator.platform;
    if(oss !="Win32"){
	    oss = "Mac";
    }
    navigateur = navigator.appName;
    if((oss =="Mac")&&(navigateur =="Netscape")) {
	    //Pas fe flash
    }else{
	    var so = new SWFObject("/media/terdav-home.swf","animation",980,569,7);
	    so.addParam("wmode","transparent");
	    so.write("home-animation");
    }
    
}
//-->
//]]>

// Shw flash Carte
//<![CDATA[
function showFlashCarte() {
    var so = new SWFObject("media/terdav-map.swf","map",416,240,7);
	so.write("flashmap");

}
//-->
//]]>
