function AfficheCarteRegions(url){
    if ( url == "#url#" ) 
        url = "";
    else
        url = url.substring(5,10);
    document.write('<object data=\"'+url+'imgc1/tourisme-france-PF.swf\" type=\"application/x-shockwave-flash\" width=\"150\" height=\"170\">');
	document.write('<param name=\"quality\" value=\"high\" />');
	document.write('<param name=\"loop\" value=\"false\" />');
 	document.write('<param name=\"menu\" value=\"false\" />');
 	document.write('<param name=\"bgcolor\" value=\"#FFFFFF\" />');
	document.write('<param name=\"movie\" value=\"'+url+'imgc1/tourisme-france-PF.swf\"/>');
	document.write('<param name=\"pluginurl\" value=\"http://www.macromedia.com/go/getflashplayer\" />');
	document.write('<!--[if IE]> <EMBED src=\"'+url+'imgc1/tourisme-france-PF.swf\" loop=false menu=false quality=best scale=exactfit bgcolor=#FFFFFF  WIDTH=\"150\" HEIGHT=\"170\" NAME=\"carte-france-PF\" ALIGN=\"\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"> </EMBED> <![endif]-->');
	document.write('</object>');
}

function AfficheFlash(url,x,y){
    document.write('<object data=\"'+url+'\" type=\"application/x-shockwave-flash\" width=\"'+x+'\" height=\"'+y+'\">');
	document.write('<param name=\"movie\" value=\"'+url+'\"/>');
	document.write('<param name=\"pluginurl\" value=\"http://www.macromedia.com/go/getflashplayer\" />');
	document.write('<!--[if IE]> <EMBED src=\"'+url+'\" scale=exactfit WIDTH=\"'+x+'\" HEIGHT=\"'+y+'\" NAME=\"pub\" ALIGN=\"\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"> </EMBED> <![endif]-->');
	document.write('</object>');
}


sfHover = function() {	var sfEls = document.getElementById("xAutresRegions");	if ( sfEls ){
	    sfEls = sfEls.getElementsByTagName("LI");
	    for (var i=0; i<sfEls.length; i++) {	    	sfEls[i].onmouseover=function() {	     		this.className+=" sfhover";	    	}	    	sfEls[i].onmouseout=function() {	      		this.className=this.className.replace(new RegExp(" sfhover\\b"), "");	    	}		}	}}if (window.attachEvent) 
	window.attachEvent("onload", sfHover);

sfHover2 = function() {	if ( document.getElementById("iAutresRegions") ){
		var sfEls = document.getElementById("iAutresRegions").getElementsByTagName("LI");		for (var i=0; i<sfEls.length; i++) {			sfEls[i].onmouseover=function() {				this.className+=" sfhover";	        }			sfEls[i].onmouseout=function() {				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");			}		}
	}}if (window.attachEvent) 
	window.attachEvent("onload", sfHover2);

function SwitchObj(obj){    if(document.getElementById(obj)){        var el = document.getElementById(obj);
        if(el.style.display == "none"){            el.style.display = "block";        }else{            el.style.display = "none";        }    }}

// déplacement de la pub de droite !
var hauteur=138; // hauteur de la marge haute de la fenêtre
var marge=820; // marge haut+bas + hauteur pub (pour limiter la descente )
var temps=50;var max=30;

function Start(obj){
    var el = document.getElementById('xPubExterne');
    if ( el ){
        var tailleH = document.documentElement.scrollHeight ;
        var wintop = document.documentElement.scrollTop - hauteur;
        if ( wintop < 0 ) 
        	wintop = 0;   
        var actuel = parseInt(el.style.margin, 10);
        var calcul = actuel + Math.ceil(( wintop-actuel)/2);
        if ( calcul > (tailleH-marge) )
            calcul = tailleH-marge;
        el.style.margin = calcul+ "px 0 0 0";
        setTimeout("Start('xPubExterne')",temps);
    }
}

function MM_openBrWindow(theURL,winName,features) { 
    window.open(theURL,winName,features);
}

function affichage_popup(nom_de_la_page, nom_interne_de_la_fenetre,w,h){	window.open (nom_de_la_page, nom_interne_de_la_fenetre, config='height='+w+', width='+h+', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no')}


function CheckIcard2(form){	
    if (!ValidTexte( form.from_name.value,2 )){
        alert("Merci de saisir votre nom.");
        return false;
    }	
    if ( !ValidEmail( form.from_mail.value ) ){
        alert("Merci de corriger votre email.");
        return false;
    }	
    if (!ValidTexte( form.to_name.value,2 )){
        alert("Merci de saisir le nom du destinataire.");
        return false;
    }	
    if ( !ValidEmail( form.to_mail.value ) ){
        alert("Merci de corriger le mail du destinataire.");
        return false;
    }	
    if ( !ValidTexte( form.message.value,3 ) || form.message.value == "Message : " ){
        alert("merci de saisir un message");
        return false;  
    }
    return true; // pas d'erreur, on valide
}

function CheckSend2(form){	
    if (!ValidTexte( form.nom.value,2 )){
        alert("Merci de saisir votre nom.");
        return false;
    }	
    if ( !ValidEmail( form.mail.value ) ){
        alert("merci de corriger votre email.");
        return false;  
    }
    return true; // pas d'erreur, on valide
}

function CheckContactT(form){	
    if (!ValidTexte( form.nom.value,2 )){
        alert("Merci de saisir votre nom.");
        return false;
    }	
    if ( !ValidEmail( form.mail.value ) ){
        alert("merci de corriger votre email.");
        return false;  
    }
    if ( !ValidTexte( form.message.value,5 ) ){
        alert("merci de saisir votre message.");
        return false;  
    }
    return true; // pas d'erreur, on valide
}

        
function ValidEmail( mail ){
    if (mail.length < 3 || mail.indexOf ('@',0) == -1 || mail.indexOf ('.',0) == -1)
       return false;
    else
       return true;
}

function ValidTexte( texte, minlong ){
    if ( texte.length < minlong )
       return false;
    else
       return true;
}


//----------------------------------------- Compteur de caractère pour textarea
function Compteur( Textarea, Max, IDAffiche){
    txt = Textarea.value; 
    nb = txt.length;
    var nbaff=0;
    if ( nb>Max ){
        alert ( "Pas plus de "+Max+" caractères dans ce champ" );
        Textarea.value=txt.substring(0,Max);
        nb = Max;
    }
    nbaff = Max-nb;
    document.getElementById(IDAffiche).innerHTML = nbaff;
}

function Bookmark(url, site){	if( navigator.appVersion.lastIndexOf("Mac") !=-1 || navigator.appVersion.lastIndexOf("X11")!=-1 ) {		alert("Cette option ne fonctionne pas sur Macintosh. \n \nVeuillez taper :   D");	}else{		window.external.AddFavorite( url , site  );
	}}

function Desactive( id ){
    var div = document.getElementById( id );
    if( div ){
        // var inps = div.getElementsByTagName( 'input' );
        // for ( i=0;i<inps.length;i++)
        //     inps[i].disabled='false';
        // var inps = div.getElementsByTagName( 'select' );
        // for ( i=0;i<inps.length;i++)
        //     inps[i].disabled='false';
       
        var cache = document.getElementById( 'Cache'+id );
        if ( cache ){
            cache.style.width= div.offsetWidth+'px';
            cache.style.height= (div.offsetHeight-25)+'px';    
        }
    }    
}



function JSPopupInput( Titre, Champ, Dest ){
    var Centre = document.getElementById( 'Centre' );  // récup l'id du centre pour rajouter le bloc popup
    
    var modal= document.createElement( 'DIV' ); // Créé le div général
    var a=document.createAttribute( 'id' );
    a.nodeValue='PopupModal';
    modal.setAttributeNode( a );
    
    modal.innerHTML = "<div id='Popup'><h1>Votre administration</h1><form method='post' action='"+Dest+"'><p>"+Titre+"</p><br/><input type='text' name='"+Champ+"' /><br /><input type='submit' value='Valider' /></form></div>";
    
    Centre.appendChild( modal );
}

function JSPass(){
    JSPopupInput( 'Merci de saisir votre mot de passe','pass','adminv2.php' );
}
