/*---------------Fonction de recuperation de la taille de l'ecran--------------------*/
function getWindowHeight() {
    var h = 0;
    if (typeof(window.innerHeight) == 'number') { // Netscape
        h = window.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
        h = document.documentElement.clientHeight;
    } else if (document.body && document.body.offsetHeight) { //client
        h = document.body.offsetHeight;
    }
    return h;
}

function getWindowWidth() {
    var w = 0;
    if (typeof(window.innerWidth) == 'number') { // Netscape
        w = window.innerWidth;
    } else if (document.documentElement && document.documentElement.clientWidth) {
        w = document.documentElement.clientWidth;
    } else if (document.body && document.body.offsetWidth) { //client
        w = document.body.offsetWidth;
    }
    return w;
}
//--------------------------------------------------------------------------------------
//------------------------parametre de la fenetre------------------------------------------
function fenetre_param(param)
{		
	if(getWindowHeight() - 130 < 521)
	{
		document.getElementById('window').style.height = 520 + 'px';
	}
	else
	{
		document.getElementById('window').style.height = getWindowHeight() - 130 + 'px';
	}
	//div contenant la map
	if(document.getElementById('map'))
	{
		document.getElementById('map').style.height = getWindowHeight() - 105 + "px";
		document.getElementById('map').style.width = getWindowWidth() - 25 + "px";
		if(param == 0)
		{
			initMap();
		}
	}
	//fenetre ctrl gauche
	if(document.getElementById('layerCtrl'))
	{
		document.getElementById('layerCtrl').style.height = getWindowHeight() - 105 + "px";
	}
}

//--------------------------------------------------------------------------------------

// JavaScript Document
function getXMLHTTP(){
	var xhr=null;
	if(window.XMLHttpRequest) // Firefox et autres
		xhr = new XMLHttpRequest();
	else if(window.ActiveXObject){ // Internet Explorer
		try {
			xhr = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e1) {
				xhr = null;
			}
		}
	}
	else { // XMLHttpRequest non supporté par le navigateur
		alert(msg_error_XMLHTTPRequest_js);
	}
	return xhr;
}

//parsage du XML de retour
function traiteXmlSuggestions(xmlDoc) {
	var options = xmlDoc.getElementsByTagName('option');
	var optionsListe = new Array();
	for (var i=0; i < options.length; ++i) {
		optionsListe.push(options[i].firstChild.data);
	}
	return optionsListe;
}



<!--
/**
* @name EstSirenValide
*
* @param Le code SIREN dont on veut vérifier la validité.
*
* @return Un booléen qui vaut 'true' si le code SIREN passé en
* paramètre est valide, false sinon.
*/
function EstSirenValide(siren)
{
	var estValide;
	if ( (siren.length != 9) || (isNaN(siren)) )
	{
		estValide = false;
	}
	else
	{
		// Donc le SIREN est un numérique à 9 chiffres
		var somme = 0;
		var tmp;
		for (var cpt = 0; cpt<siren.length; cpt++)
		{
			if ((cpt % 2) == 1) { // Les positions paires : 2ème, 4ème, 6ème et 8ème chiffre
				tmp = siren.charAt(cpt) * 2; // On le multiplie par 2
				if (tmp > 9)
					tmp -= 9; // Si le résultat est supérieur à 9, on lui soustrait 9
			}
			else
				tmp = siren.charAt(cpt);
			somme += parseInt(tmp);
		}
		if ((somme % 10) == 0)
			estValide = true; // Si la somme est un multiple de 10 alors le SIREN est valide
		else
			estValide = false;
		}
	return estValide;
}

/**
* @name EstSiretValide
*
* @param Le code SIRET dont on veut vérifier la validité.
*
* @return Un booléen qui vaut 'true' si le code SIRET passé en
* paramètre est valide, false sinon.
*/
function EstSiretValide(siret) {
	var estValide;
	if ( (siret.length != 14) || (isNaN(siret)) )
		estValide = false;
	else {
		// Donc le SIRET est un numérique à 14 chiffres
		// Les 9 premiers chiffres sont ceux du SIREN (ou RCS), les 4 suivants
		// correspondent au numéro d'établissement
		// et enfin le dernier chiffre est une clef de LUHN.
		var somme = 0;
		var tmp;
		for (var cpt = 0; cpt<siret.length; cpt++) {
			if ((cpt % 2) == 0) { // Les positions impaires : 1er, 3è, 5è, etc...
				tmp = siret.charAt(cpt) * 2; // On le multiplie par 2
				if (tmp > 9)
					tmp -= 9; // Si le résultat est supérieur à 9, on lui soustrait 9
				}
				else
					tmp = siret.charAt(cpt);
					somme += parseInt(tmp);
			}
			if ((somme % 10) == 0)
			estValide = true; // Si la somme est un multiple de 10 alors le SIRET est valide
			else
				estValide = false;
		}
	return estValide;
}

 
 
 //---------------------------------------------------
 
 /* menu magasin */
function onItemCheck(item, checked){
	typeFichierMag = item.value;        	
	OngletChargeMag.activate('OngletChargeMagasinsFichier');
	winChargeDonneeMag.show();
}
function onItemCheckZDC(item, checked){
	typeFichierZDC = item.value;        	
	OngletChargeZDC.activate('OngletChargeZDCFichier');
	winChargeDonneeZDC.show();
}


 function utf8_encode ( string ) {
    // Encodes an ISO-8859-1 string to UTF-8  
    // 
    // version: 1004.2314
    // discuss at: http://phpjs.org/functions/utf8_encode    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: sowberry
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman    // +   improved by: Yves Sucaet
    // +   bugfixed by: Onno Marsman
    // +   bugfixed by: Ulrich
    // *     example 1: utf8_encode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'    var string = (argString+''); // .replace(/\r\n/g, "\n").replace(/\r/g, "\n");
 
    var utftext = "";
    var start, end;
    var stringl = 0; 
    start = end = 0;
    stringl = string.length;
    for (var n = 0; n < stringl; n++) {
        var c1 = string.charCodeAt(n);        var enc = null;
 
        if (c1 < 128) {
            end++;
        } else if (c1 > 127 && c1 < 2048) {            enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128);
        } else {
            enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128);
        }
        if (enc !== null) {            if (end > start) {
                utftext += string.substring(start, end);
            }
            utftext += enc;
            start = end = n+1;        }
    }
 
    if (end > start) {
        utftext += string.substring(start, string.length);    }
 
    return utftext;
}



