// Détection du navigateur
var ie4 = (document.all)? true:false;
var ns4 = (document.layers)? true:false;
var ns6 = (document.getElementById)? true:false;
var ns	= (ns4 || ns6);
var dom = (ie4 || ns6);

// systeme d'exploitation
var sys=navigator.platform;

// ----------------------------- fonction permettant de récupere la sélection d'une liste déroulante 
function getDropdownValue(theDropdown) {
	if ( (theDropdown.length!=0) && (theDropdown.selectedIndex!=-1) )
		return theDropdown.options[theDropdown.selectedIndex].value;
	else
		return '';
} // fin fonction 'getDropdownValue()'

// ----------------------------- fonction vérifiant la validité du formatage d'un email 
 function isValidEmail(strEmail) { // vérif validité email par REGEXP
   var reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/
   regObject = new RegExp();
   regObject = reg.exec(strEmail.toLowerCase());
   return (regObject!=null)
}// fin fonction 'isValidEmail()'

// fonction remplacement de chaine
function str_replace(whatStr, byStr, string) {
	while (string.indexOf(whatStr)>-1)
		string=string.replace(whatStr , byStr)
	return string;
}

function basename(path, suffix) {
    var b = path.replace(/^.*[\/\\]/g, '');
    
    if (typeof(suffix) == 'string' && b.substr(b.length-suffix.length) == suffix) {
        b = b.substr(0, b.length-suffix.length);
    }
    return b;
}

//Pop up centered over screen
function popup(adresse,hpop,lpop,scrollbars) {
	var hauteur_popup=hpop;
	var H = (screen.height - hauteur_popup) / 2;
	var largeur_popup=lpop;
	var L = (screen.width - largeur_popup) / 2;
	var pop_name = basename(adresse, '.html');
	pop_name = pop_name.replace(/[^a-z0-9]/g, '');
	
	pop_up = window.open(adresse,pop_name,"status=yes,resizable=no,height="+hauteur_popup+",width="+largeur_popup+",top="+H+",left="+L+",scrollbars="+scrollbars);
}

// fonction de resize pour IE5 et Netscape6
function autoResize() {
	mac = (navigator.appVersion.indexOf("Macintosh")>0)? true:false;

	if(!mac) {
		largeur = document.body.offsetWidth;
		hauteur = document.body.scrollHeight+31;
		if (ns)	largeur = document.body.offsetWidth+6;

		if (hauteur) {
			hauteur = hauteur+19;
			this.resizeTo(largeur, hauteur);
			this.focus();
		}
	}
}
//Switch web Callback, formulaire
function verifheure(){
HeureLocale = new Date();
	if (HeureLocale.getHours() >= 9 && HeureLocale.getHours() < 19 && HeureLocale.getDay() >= 1 && HeureLocale.getDay() < 6){
	showWCB();
	}else{
	popup('/callback-popup.html',530,641,'no');
	}
}