var slide_speed = 6000;
var currentSubMenu = '';
var IsContentVisible = false;
var currentPicture = 0;
var index = 0;
var isRunning = true;
var currentBgLayer = 1;
var startImage = '';


function switchMenu(){
    if (!(isSimpleDisplay)){
        return false;
    }
}

function OpacityOn(){changeOpac(opacityOn, 'middleBg');}
function OpacityOff(){changeOpac(opacityOff, 'middleBg');}
    

function startSlideShow(){isRunning=true;change_picture();}
function stopSlideShow(){isRunning=false;}
function resetSlideShow(){index=0;}	
            
function change_picture(){
    if (isRunning && array_pictures.length > 1){
        

        $('pictureUnder').style.backgroundImage = 'url("' + startImage + '")';
        $('pictureOver').setStyle({opacity: 0})
        $('pictureOver').style.backgroundImage = 'url("' + array_pictures[index] + '")';
        new Effect.Fade('pictureOver', {delay:1.0, duration:2.0, from:0.0, to:1.0});
        
/*        $('pictureUnder').style.backgroundImage = 'url("' + startImage + '")';
        changeOpac(0,'pictureOver');
        $('pictureOver').style.backgroundImage = 'url("' + array_pictures[index] + '")';
        Effect.Fade('pictureOver', {duration:2.0, from:0.0, to:1.0});
*/       
        startImage =  array_pictures[index];
        
        index +=1;
        if (index > array_pictures.length -1){index=0};
        setTimeout(change_picture,slide_speed);
    };
}

function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 

function showImage(strURL){
    $('imageid').src = strURL;
    $('imageid').show();
    if (isMap) {hideMap();}
}

function showImageFixed(strURL) {
    $('imagefixedid').src = strURL;
    $('imagefixedid').show();
}


function hideImage(){
    $('imageid').src = '/images/loading.gif';
    $('imageid').hide();
    if (isMap) {displayMap();}

}




function showAlpha(){$('formOver').show();}
function hideAlpha(){$('formOver').hide();
    //new Effect.Opacity('formWindow',{ duration: 0.0, transition: Effect.Transitions.linear, from: 1.0, to: 0.0 });
}

function globalLoad(){
    PngFixImg();    
}
function showFormReservationSimple(strRegion, strDestination) {
    showAlpha();
    var strURL = '/forms/showFormDestinationSimple.asp?region=' + strRegion + '&destination=' + strDestination;
    if (curlanguage) { strURL += '&langue=' + curlanguage; }
    $('ifForm').src = strURL;

}


function showFormReservation(strRegion, strDestination, strSelectedDate) {
    showAlpha();
    var strURL = '/forms/showFormDestination.asp?region=' + strRegion + '&destination=' + strDestination + '&dateid=' + strSelectedDate;
    if (curlanguage) { strURL += '&langue=' + curlanguage;}
    $('ifForm').src = strURL;
    
}

function showFormReservationDiscount(strRegion, strDestination, strSelectedDate) {
    showAlpha();
    var strURL = '/forms/showFormDestination-Discount.asp?region=' + strRegion + '&destination=' + strDestination + '&dateid=' + strSelectedDate;
    if (curlanguage) { strURL += '&langue=' + curlanguage; }
    $('ifForm').src = strURL;
}

function showFormReservationShop(strPageID, strLocation){
    showAlpha();
    var strURL = '/forms/showFormDestination.asp?pageid=' + strPageID + '&shop=' + strLocation;
    if (curlanguage) { strURL += '&langue=' + curlanguage;}
    $('ifForm').src = strURL;

}

function hideFormReservation(){
    hideAlpha();
    $('ifForm').src = "about:blank";
    /*isRunning = true;
    setTimeout(change_picture, slide_speed);*/
}

var map;
var isMap = false;
function initMap(){
    if (GBrowserIsCompatible()) {
        map = new GMap2($("containerMap"));
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        map.setMapType(G_SATELLITE_MAP);
        $("containerMap").hide();
    }
}

function showMap(sLat, sLong){
    $("containerMap").show();
    //map.setMapType(G_NORMAL_MAP);
    var point = new GLatLng(sLat, sLong);
    map.setCenter((point), 14);
    map.addOverlay(new GMarker(point));
    isMap = true;

}	

function displayMap(){
    $("containerMap").show();
}		

function hideMap(sLat, sLong){
    $("containerMap").hide();
}			



/* ############## Configuration ############## */

// Chemin complet sans le nom de domaine de la page HTML vers les images appelées en CSS
var ImgsPath = "/images/";

// Gestion des exceptions
var Exceptions = new Array();
Exceptions[0] = "image-sans-transparence.png";
Exceptions[1] = "image-autre.png";
/*
Exceptions[2] = "";
etc...
*/

/* ############## Fin de Configuration ############## */

// Mise en transparence des <img /> PNG
function PngFixImg() {
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	
	if ((version >= 5.5) && (document.body.filters)) 
	{
	   for(var i=0; i<document.images.length; i++)
	   {
		  var img = document.images[i]
		  var imgName = img.src.toUpperCase()
		  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
		  {
			 var imgID = (img.id) ? "id='" + img.id + "' " : ""
			 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			 var imgStyle = "display:inline-block;" + img.style.cssText 
			 if (img.align == "left") imgStyle = "float:left;" + imgStyle
			 if (img.align == "right") imgStyle = "float:right;" + imgStyle
			 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
			 var strNewHTML = "<span " + imgID + imgClass + imgTitle
			 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			 img.outerHTML = strNewHTML
			 i = i-1
		  }
		  //if
	   }//for
	}//if
}//function



// Mise en transparence des images PNG en background CSS
function PngFixBkground() {
	
	// Tableau des feuilles de styles
	var StyleSheets = document.styleSheets;
	
	// Boucle sur les feuilles de styles
	for(i=0; i<StyleSheets.length; i++)
		{
		// Si il s'agit d'Internet Explorer
		if(StyleSheets[i].rules)
			{
			Rules = StyleSheets[i].rules;
			// Boucle sur les règles de la feuille de style
			for(j=0; j<Rules.length; j++)
				{
				// Si la règle contient une propriété "background"
				if(
				   (Rules[j].style.background) ||
				   (Rules[j].style.backgroundImage) ||
				   (Rules[j].style.backgroundRepeat)
				  )
					{
					// Récupération des règles
					if(Rules[j].style.background)
						{
						BkgroundImg = Rules[j].style.background.match('[a-zA-Z0-9_-]*\.png');
						BkgroundRepeat = Rules[j].style.background.match('repeat|repeat\-x|repeat\-y|no\-repeat');
						}
					else
						{
						BkgroundImg = Rules[j].style.backgroundImage.match('[a-zA-Z0-9_-]*\.png');
						BkgroundRepeat = Rules[j].style.backgroundRepeat;
						}
					// Prise en compte des exceptions
					var regex = new RegExp(BkgroundImg, 'g');
					var yatil = regex.test(Exceptions);
					
					// Si l'image de fond est un PNG
					if(
					   	(BkgroundImg != null) &&
						(yatil == false)
					  )
						{
						// Détermination du sizingMethod suivant la méthode de repétition de l'image
						if(BkgroundRepeat != null)
							{
							// Cas "Etirer"
							if(
								(BkgroundRepeat == "repeat") 	||
								(BkgroundRepeat == "repeat-x") 	||
								(BkgroundRepeat == "repeat-y")
							  )
								{sizingMethod = 'scale';}
							// Cas "Rogner"
							else
								{sizingMethod = 'crop';}							
							}
						
						// Retrait de l'image de fond
						Rules[j].style.backgroundImage = "none";
						
						// Application du filtre
                        //alert("progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + ImgsPath + BkgroundImg + "', sizingMethod='" + sizingMethod + "')");
						Rules[j].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + ImgsPath + BkgroundImg + "', sizingMethod='" + sizingMethod + "')";
						
						} // if
						
					} // if
					
				} // for
				
			} // if
			
		} // for
		
}

    function UnCryptMailto( s )
    {
        var n = 0;
        var r = "";
        for( var i = 0; i < s.length; i++)
        {
            n = s.charCodeAt( i );
            if( n >= 8364 )
            {
                n = 128;
            }
            r += String.fromCharCode( n - 1 );
        }
        return r;
    }

    function contact( s )
    {
        location.href=UnCryptMailto( s );
    }


