// fonction random entre 0 et X-1 ex: si limite=5, cela génère un chiffre entre 0 et 4
function get_random(limite){
    var ranNum= Math.floor(Math.random()*limite);
	return ranNum;
}
/*
function Popup(page1,nom1,option1) {
	if(!page1 == ''){
		window.open(page1,nom1,option1);
	}
}
*/

function Popup(page,nom,top,left,largeur,hauteur,resizable,location,menubar,status,scrollbars,menubar) {
  var top=(screen.height-hauteur)/2;
  var left=(screen.width-largeur)/2;

  if(!page == ''){
		window.open(page,nom,"top="+top+",left="+left+",width="+largeur+",height="+hauteur+",resizable="+resizable+",location="+location+",menubar="+menubar+",status="+status+",scrollbars="+scrollbars+",menubar="+menubar);
	}
}

function Popup_centre(page,nom,top,left,largeur,hauteur,resizable,location,menubar,status,scrollbars,menubar) {
  var top=(screen.height-hauteur)/2;
  var left=(screen.width-largeur)/2;

  if(!page == ''){
		window.open(page,nom,"top="+top+",left="+left+",width="+largeur+",height="+hauteur+",resizable="+resizable+",location="+location+",menubar="+menubar+",status="+status+",scrollbars="+scrollbars+",menubar="+menubar);
	}
}

function envoyer(method,formname,formaction){
	document.forms[formname].method = method;
	document.forms[formname].enctype = "multipart/form-data";
	document.forms[formname].action = formaction;
	document.forms[formname].submit();
}

function confirmation(temp_url) {
	if (confirm('Voulez vous vraiment supprimer cet élément ?')) {
		location.href = temp_url;
	}else{
		alert("Vous avez annulé l'action");
	}
}

function GoURL(categoryMenu){
	if(categoryMenu.options[categoryMenu.selectedIndex].value==""){
		alert('Veuillez selectionner une gamme d\'articles dans le menu.');
	}else{
		window.location.href = categoryMenu.options[categoryMenu.selectedIndex].value;
		categoryMenu.selectedIndex=0;
	}
}


// Fonctions date
function disp(txt){
	document.write(txt);
	}

function don_date_maj(){
	var date_maj=new Date(document.lastModified);
	date_maj=don_date_format(date_maj);
	return date_maj;
	}

function don_date_jour(){
	var date_jour=new Date();
	date_jour=don_date_format(date_jour);
	return date_jour;
	}

function don_date_format(d1){
	var m=new Array(13);
	m[1]="Janvier"; m[2]="Février";	m[3]="Mars"; m[4]="Avril"; m[5]="Mai"; m[6]="Juin";
 	m[7]="Juillet";	m[8]="Aout"; m[9]="Septembre"; m[10]="Octobre";	m[11]="Novembre"; m[12]="Décembre";
	var d=new Array(8);
	d[1]="Dimanche"; d[2]="Lundi"; d[3]="Mardi"; d[4]="Mercredi"; d[5]="Jeudi"; d[6]="Vendredi"; d[7]="Samedi";
	var mois=m[d1.getMonth()+1];
	var jour=d[d1.getDay()+1];
	var date=d1.getDate();
	var an=d1.getYear();
	if (an<200) an=1900+an;
	date=jour+" "+date+" "+mois+" "+an;
	return date;
	}
	
// Fonctions heure
function don_heure(){
	var date_jour=new Date();
	var heure=date_jour.getHours();
	var min=date_jour.getMinutes();
	var sec=date_jour.getSeconds();
	if (heure<10) heure="0"+heure;
	if (min<10) min="0"+min;
	if (sec<10) sec="0"+sec;
	heure=heure+":"+min;
	return heure;
	}


// Fonctions menu deroulant
var delay_nav_hori = 600;
var timeout_nav_hori;

function affiche_nav_hori(id){
	arrete_masque_nav_hori();
	for (var i = 1; i<=26; i++){
		var id2 = "nav_hori_smenu"+i;
		if(id != id2){
			if (document.getElementById(id2)){
				document.getElementById(id2).style.display='none';
			}
		}
	}
	if (navigator.appName == "Microsoft Internet Explorer") 	
	{
		// Pour ie suppression de l'iframe qui a été ajouté pour que le menu passe sur les tag select 
		if (document.getElementById("iframeSelect") != null)
		{
			document.getElementById("iframeSelect").removeNode(true);
		}
	}
	if (document.getElementById(id)){
		document.getElementById(id).style.display='block';
		
		
		
		// Pour passer sur les champs select Pour ie
		if (navigator.appName == "Microsoft Internet Explorer") 	
		{
		iframe =document.createElement('iframe');
		iframe.id = "iframeSelect";
		iframe.frameBorder="0";
		iframe.style.position='absolute';
		iframe.scrolling="no";
						
		nav_bas= document.getElementById(id);
		nav_bas.parentNode.insertBefore(iframe, nav_bas );
		
		iframe.style.top=document.getElementById(id).offsetTop;
		iframe.style.width=document.getElementById(id).offsetWidth;
		iframe.style.height=document.getElementById(id).offsetHeight;
		iframe.style.left=document.getElementById(id).offsetLeft;
		
		}	
		
		
	}
}

function masque_nav_hori(){
	for (var i = 1; i<=26; i++){
		if (document.getElementById('nav_hori_smenu'+i)){
			document.getElementById('nav_hori_smenu'+i).style.display='none';
		}
	}
	if (navigator.appName == "Microsoft Internet Explorer") 	
	{		
	// Pour ie suppression de l'iframe qui a été ajouté pour que le menu passe sur les tag select 
	if (document.getElementById("iframeSelect") != null)
	{
		document.getElementById("iframeSelect").removeNode(true);
	}
	}    
}

function lance_masque_nav_hori(){
	timeout_nav_hori = setTimeout('masque_nav_hori()', delay_nav_hori);
}
function arrete_masque_nav_hori(){
	if(timeout_nav_hori)
		clearTimeout(timeout_nav_hori);
}


function AfficheBlock(baliseId){
	for(var i=1; i<10; i++){
		var HideBlock = "contenu" + i ;
		if (document.getElementById && document.getElementById(HideBlock) != null){
		document.getElementById(HideBlock).style.visibility='hidden';
    	document.getElementById(HideBlock).style.display='none';
		}
	}
	
	if (document.getElementById && document.getElementById(baliseId) != null){
    	document.getElementById(baliseId).style.visibility='visible';
    	document.getElementById(baliseId).style.display='block';
	}
}



function popuprnp(){
  var win2 = window.open("http://www.receiveandpay.com/wallet/customer/popup3x.php?logo=3769" ,'popup','height=956,width=616,status=yes,scrollbars=yes,menubar=no,resizable=yes');
}


// FONCTIONS POUR LA CARTE DES REVENDEURS


function liste_nom_departements(numero){
var liste_nom_departements;

liste_nom_departements = tmp_tab_departement_name[numero];
return liste_nom_departements;
}

function liste_textes_departements(numero){
var liste_textes_departements;

liste_textes_departements = tmp_tab_departement_texte[numero];
return liste_textes_departements;
}

decal_x = 0;
decal_y = +20;



function pop_infubulle(departement){
tmp_nomdepartement = departement+"-"+liste_nom_departements(departement);
tmp_textes_departement = liste_textes_departements(departement);

document.getElementById("bulle").innerHTML = "<table style='background-color:#E8F3F9'  cellpadding='0' cellspacing='0'><tr><td><img src='http://www.prosoud.com/site/graphisme/produits-de-soudure-2.gif'></td></tr><tr><td style='padding:5px;border-left: 1px solid #000000;border-right: 1px solid #000000'><font style='font-color:#1E40B2;font-family:Arial;font-size:12px'><strong>"+tmp_nomdepartement+"</strong></br>"+tmp_textes_departement+"</font></td></tr><tr><td><img src='http://www.prosoud.com/site/graphisme/produits-de-soudure.jpg'></td></tr></table>";

}

function suivre_souris0(e){
if (navigator.appName=="Microsoft Internet Explorer"){
	var x = event.x + document.body.scrollLeft;
	var y = event.y + document.body.scrollTop;
}else{
	var x =  e.pageX;
	var y =  e.pageY;
}
document.getElementById("bulle").style.left = x + decal_x;
document.getElementById("bulle").style.top  = y + decal_y;
}

function disparaitre0()
{
document.getElementById("bulle").innerHTML = '';
}

document.onmousemove = suivre_souris0;