//*****************************************************************************
// JS StatsHotels de récupération de l'ID, Nom, Mot de passe du compte StatsHotels.
//*****************************************************************************

function IdStatsHotels() {
	return [document.getElementById("IdPms"),
    document.getElementById("IdStat"),
	document.getElementById("NomStat"),
	SHA256(document.getElementById("MdpStat"))]
}

//*****************************************************************************
// Charger une fenetre pop-up.
//*****************************************************************************

function navigation(s,r,w,h) {

    var windowprops = "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars="+s+",resizable="+r+",width="+w+",height="+h+"";
        fen = window.open ("","sticker",windowprops); if( self.focus ) fen.focus();
}
function navigation2(s,r,w,h) {

    var windowprops = "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars="+s+",resizable="+r+",width="+w+",height="+h+"";
        fen = window.open ("","sticker2",windowprops); if( self.focus ) fen.focus();
}
function navigation3(s,r,w,h) {

    var windowprops = "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars="+s+",resizable="+r+",width="+w+",height="+h+"";
        fen = window.open ("","sticker3",windowprops); if( self.focus ) fen.focus();
}
function navigation4(s,r,w,h) {

    var windowprops = "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars="+s+",resizable="+r+",width="+w+",height="+h+"";
        fen = window.open ("","sticker4",windowprops); if( self.focus ) fen.focus();
}
function navigation5(s,r,w,h) {

    var windowprops = "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars="+s+",resizable="+r+",width="+w+",height="+h+"";
        fen = window.open ("","sticker5",windowprops); if( self.focus ) fen.focus();
}
function navigationRSS(s,r,w,h) {

    var windowprops = "toolbar=0,location=1,directories=0,status=1,menubar=0,scrollbars="+s+",resizable="+r+",width="+w+",height="+h+"";
        fen = window.open ("","stickerRSS",windowprops); if( self.focus ) fen.focus();
}

//*****************************************************************************
// Blocage de la saisie automatique des formulaires.
//*****************************************************************************

function autocomplete() {

    if (document.getElementsByTagName) { 
        var inputElements = document.getElementsByTagName("input"); 
        for (i=0; inputElements[i]; i++) { 
            if (inputElements[i].className && (inputElements[i].className.indexOf("logininput") != -1)) { 
            inputElements[i].setAttribute("autocomplete","off"); 
            }
        }
    }
    
}

//*****************************************************************************
// Impression d'une fenetre pop-up.
//*****************************************************************************

function printPage() {

    if (window.print)
        window.print()
    else
        alert("Votre Navigateur ne supporte pas cette fonction Imprimer. Cliquez sur le menu Fichier et Imprimer...");
}

//*****************************************************************************
// Changer la classe des styles CSS en cas de redimensionnement de la fenetre.
//*****************************************************************************

// Redimensionnement des photos de l'accueil.

function photoResize(y) {

    var photosWidth = 420;
    var photosHeight = 68;
    var screenSize = screenDetect();
	if (screenSize == 2) { var photosWidth = 620; var photosHeight = 101; }
	if (screenSize == 3) { var photosWidth = 820; var photosHeight = 134; }
    for (var i = 0; i<y.length; i++) {
      if (y[i]) {
        y[i].width = photosWidth;
        y[i].height = photosHeight;
      }
    }
}

// Changement des Stylesheets

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;
        }

    }

}


// Détection du navigateur Netscape.

var NS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
          parseFloat(navigator.appVersion) >= 4) ? 1 : 0;

// Détection de la taille de la fenetre du navigateur.

function screenDetect() {

	if (NS4) { var screenWidth = window.innerWidth; var screenHeight = window.innerHeight; }
	else { var screenWidth = document.body.clientWidth; var screenHeight = document.body.clientHeight; }

	if (screenWidth < 980) { setActiveStyleSheet("med1");return 1; }
	else if (screenWidth < 1200) { setActiveStyleSheet("med2");return 2; }
	else if (screenWidth < 2600 && screenHeight > 700) { setActiveStyleSheet("med3"); return 3;}
	else { setActiveStyleSheet("med2") ;return 2;}

}

// Détection des objets à redimensionner.

function detectClass() {
    
	var Obj = null;
	
	if (document.getElementsByName) {	// W3C DOM style
        var y = document.getElementsByName("accueil_photos");
        photoResize(y);
	}
	else if (document.all) {	// IE4 style
		var y = document.all[accueil_photos];
		photoResize(y);
	}    
    
	screenDetect();
    
}

// Premier lancement et redimensionnement.

window.onload = detectClass;
window.onresize = detectClass;
