//MAP GOOGLE
function montre_map() {
	load();
    document.getElementById('Layer_map').style.display='block';
	document.getElementById('Layer_contact').style.display='none';
} 

// ----------------------------- 

function cache_map() { 
	document.getElementById('Layer_map').style.display='none';
	document.getElementById('Layer_contact').style.display='block';
}
	  
//mot passe
function montre_pass() { 
    if (navigator.appName=='Microsoft Internet Explorer') 
    { 
           document.all.Layer_pass.style.visibility='visible'; 
                   
    } 
    else 
    { 
           document.getElementById('Layer_pass').style.visibility='visible';
     
    } 
      ;} 

// ----------------------------- 

function cache_pass() { 
    if (navigator.appName=='Microsoft Internet Explorer') 
    { 
           document.all.Layer_pass.style.visibility='hidden'; 
                   
    } 
    else 
    { 
           document.getElementById('Layer_pass').style.visibility='hidden';
     
    } 
      ;}

//contact
function montre_contact() { 
    if (navigator.appName=='Microsoft Internet Explorer') 
    { 
           document.all.Layer_contact.style.visibility='visible'; 
                   
    } 
    else 
    { 
           document.getElementById('Layer_contact').style.visibility='visible';
     
    } 
      ;} 

// ----------------------------- 

function cache_contact() { 
    if (navigator.appName=='Microsoft Internet Explorer') 
    { 
           document.all.Layer_contact.style.visibility='hidden'; 
                   
    } 
    else 
    { 
           document.getElementById('Layer_contact').style.visibility='hidden';
     
    } 
      ;}

function affich_menu(div , img , img2, img3){
	if(document.getElementById(div).style.display=='none'){
		new Effect.BlindDown(div, { duration: 0.8 });
		if(img!=''){
			document.getElementById(img).src='/charte/maquette/moins_rouge.gif';
		}
		if(img2!=''){
			document.getElementById(img2).src='/charte/maquette/moins.gif';
		}
		if(img3){
			document.getElementById(img3).src='/charte/maquette/moins_rouge.gif';
		}
	}else{	
		new Effect.BlindUp(div, { duration: 0.8 });
		if(img!=''){
			document.getElementById(img).src='/charte/maquette/plus_rouge.gif';
		}
		if(img2!=''){
			document.getElementById(img2).src='/charte/maquette/plus.gif';
		}
		if(img3){
			document.getElementById(img3).src='/charte/maquette/plus_rouge.gif';
		}
	}
}

function affich_menu_simple(div){
	if(document.getElementById(div).style.display=='none'){
		new Effect.BlindDown(div, { duration: 0.8 });
	}else{	
		new Effect.BlindUp(div, { duration: 0.8 });
	}
}

function afficheDivCatalogue(idFournisseur, div, idArticle) {
	new Ajax.Updater(div, '/catalogue-pompier/ajax/affiche_contactcatalogue.php?fournisseur='+idFournisseur+'&article='+idArticle, {method:'get', onComplete:insertDiv()});
}

function afficheDivAmicale(div,idArticle) {
	new Ajax.Updater(div, '/annuaire-pompier/ajax/affiche_contactamicale.php?id='+idArticle, {method:'get', onComplete:insertDiv()});
}
function afficheDivCds(div,idArticle) {
	new Ajax.Updater(div, '/annuaire-pompier/ajax/affiche_contactcds.php?id='+idArticle, {method:'get', onComplete:insertDiv()});
}

function afficheDivUnion(div,idArticle) {
	new Ajax.Updater(div, '/annuaire-pompier/ajax/affiche_contactunion.php?id='+idArticle, {method:'get', onComplete:insertDiv()});
}

function afficheDiv(id, div, dpt) {
	switch(div){
		case 'div_contact_generalites':
			new Ajax.Updater(div, '/annuaire-pompier/ajax/affiche_contact_generalites.php?target='+id+'&dpt='+dpt, {method:'get', onComplete:insertDiv()});
		break;
		case 'div_contactfournisseur':
			new Ajax.Updater(div, '/annuaire-pompier/ajax/affiche_contact_fournisseur.php?id='+id, {method:'get', onComplete:insertDiv()});
		break;
		case 'div_contact':
			new Ajax.Updater(div, '/annuaire-pompier/ajax/affiche_contact.php?id='+id+'&dpt='+dpt, {method:'get', onComplete:insertDiv()});
		break;
		case 'div_modifgroup2':
			document.getElementById('div_groupements').innerHTML='';
			new Ajax.Updater(div, '/espace-sdis/ajax/modif_groupement.php?id='+id, {method:'get', onComplete:insertDiv()});
		break;
		case 'div_modifgroup3':
			document.getElementById('div_groupements').innerHTML='';
			new Ajax.Updater(div, '/espace-sdis/ajax/modif_groupement2.php?id='+id, {method:'get', onComplete:insertDiv()});
		break;
		case 'div_modifproduit':
			new Ajax.Updater(div, '/espace-fournisseur/ajax/modif_produit.php?id='+id, {method:'get', onComplete:insertDiv()});
		break;
		case 'div_modifreportage':
			new Ajax.Updater(div, '/espace-fournisseur/ajax/modif_reportage.php?id='+id, {method:'get', onComplete:insertDiv()});
		break;
		case 'div_modifservice':
			document.getElementById('div_services').innerHTML='';
			new Ajax.Updater(div, '/espace-sdis/ajax/modif_services.php?id='+id, {method:'get', onComplete:insertDiv()});
		break;
		case 'div_modifcontact':
			document.getElementById('div_ajoutcontact').innerHTML='';
			document.getElementById('div_contacts').innerHTML='';
			new Ajax.Updater(div, '/espace-sdis/ajax/modif_contact.php?id='+id, {method:'get', onComplete:insertDiv()});
		break;
		case 'div_modiforga':
			document.getElementById('div_organismes').innerHTML='';
			new Ajax.Updater(div, '/espace-sdis/ajax/modif_autresorganisme.php?id='+id, {method:'get', onComplete:insertDiv()});
		break;
		case 'div_generalites':
			document.getElementById('selectacacher').style.display='none';
			document.getElementById('selectacacher2').style.display='none';
			document.getElementById('selectacacher3').style.display='none';
			document.getElementById('selectacacher4').style.display='none';
			new Ajax.Updater(div, '/espace-sdis/ajax/affiche_generalites.php?id='+id, {method:'get', onComplete:insertDiv()});
		break;
		case 'div_organismes':
			document.getElementById('div_modiforga').innerHTML='';
			new Ajax.Updater(div, '/espace-sdis/ajax/affiche_organismes.php?id='+id, {method:'get', onComplete:insertDiv()});
		break;
		case 'div_groupements':
			document.getElementById('div_modifgroup2').innerHTML='';
			new Ajax.Updater(div, '/espace-sdis/ajax/affiche_groupements.php?id='+id, {method:'get', onComplete:insertDiv()});
		break;
		case 'div_services':
			document.getElementById('div_modifservice').innerHTML='';
			new Ajax.Updater(div, '/espace-sdis/ajax/affiche_services.php?id='+id, {method:'get', onComplete:insertDiv()});
		break;
		case 'div_contacts':
			document.getElementById('div_ajoutcontact').innerHTML='';
			document.getElementById('div_modifcontact').innerHTML='';
			new Ajax.Updater(div, '/espace-sdis/ajax/affiche_contacts.php?id='+id, {method:'get', onComplete:insertDiv()});
		break;
		case 'div_ajoutcontact':
			document.getElementById('div_modifcontact').innerHTML='';
			document.getElementById('div_contacts').innerHTML='';
			new Ajax.Updater(div, '/espace-sdis/ajax/ajout_contact.php?id='+id, {method:'get', onComplete:insertDiv()});
		break;
		case 'div_ajoutorganisme':
			document.getElementById('div_organismes').innerHTML='';
			document.getElementById('div_modiforga').innerHTML='';
			new Ajax.Updater(div, '/espace-sdis/ajax/ajout_organisme.php?id='+id, {method:'get', onComplete:insertDiv()});
		break;
	}
}

function insertDiv() {
    document.getElementById('div_ajax').style.display='block';
}

function cacheDiv(){
	if(document.getElementById('selectacacher')){
		document.getElementById('selectacacher').style.display='block';
		document.getElementById('selectacacher2').style.display='block';
		document.getElementById('selectacacher3').style.display='block';
		document.getElementById('selectacacher4').style.display='block';
	}
	document.getElementById('div_ajax').style.display='none';
}

function effacer(id, page, type)
{
	var a = false;
	switch(type){
		case 'groupement' :
			a = confirm("Vous avez choisi d'effacer un GROUPEMENT.\r\nS'il y a d'autres groupements dans votre SDIS, vous devrez les supprimer pour pouvoir visualiser les centres du GROUPEMENT que vous allez supprimer.");
		break;
		case 'organisme' :
			a = confirm("Vous avez choisi d'effacer un ORGANISME.\r\nEtes-vous certain de vouloir effacer cet ORGANISME ?");
		break;
		case 'contact' :
			a = confirm("Vous avez choisi d'effacer un CONTACT.\r\nEtes-vous certain de vouloir effacer ce CONTACT ?");
		break;
		case 'compagnie' :
			a = confirm("Vous avez choisi d'effacer une COMPAGNIE.\r\nCette action va entrainer la suppression de tous les titres ou centres qui lui sont affectés.\r\n\r\nEtes-vous sûr de vouloir supprimer cette COMPAGNIE ?");
		break;
		case 'titre' :
			a = confirm("Vous avez choisi d'effacer un TITRE.\r\nCette action va entrainer la suppression de tous les centres qui lui sont affectés.\r\n\r\nEtes-vous sûr de vouloir supprimer ce TITRE ?");
		break;
		case 'centre' :
			a = confirm("Vous avez choisi d'effacer un CENTRE.\r\n\r\nEtes-vous sûr de vouloir supprimer ce CENTRE ?");
		break;
		case 'service' :
			a = confirm("Vous avez choisi d'effacer une DIRECTION DE SERVICE.\r\n\r\nEtes-vous sûr de vouloir supprimer cette DIRECTION DE SERVICE ?");
		break;
		case 'sousservice' :
			a = confirm("Vous avez choisi d'effacer un SERVICE.\r\n\r\nEtes-vous sûr de vouloir supprimer ce SERVICE ?");
		break;
		case 'gestionprod' :
			a = confirm("Vous avez choisi d'effacer un produit de votre catalogue.\r\n\r\nEtes-vous sûr de vouloir supprimer ce produit ?");
		break;
		case 'gestionreportage' :
			a = confirm("Vous avez choisi d'effacer un publireportage.\r\n\r\nEtes-vous sûr de vouloir supprimer ce produit ?");
		break;
	}
	if(a){
		switch(page){
			case 'groupement' :
				document.location.href="/espace-sdis/fiche_sdis_territoire.php?page=groupements&action=supprgroup&id="+id;
			break;
			case 'service' :
				document.location.href="/espace-sdis/fiche_sdis_groupement.php?page=services&action=suppr&id="+id;
			break;
			case 'contact' :
				document.location.href="/espace-sdis/fiche_sdis_contact.php?action=suppr&id="+id;
			break;
			case 'organisme' :
				document.location.href="/espace-sdis/fiche_sdis_autres.php?action=suppr&id="+id;
			break;
			case 'gestionprod' :
				document.location.href="/espace-fournisseur/fiche_fournisseur_gestionproduit.php?action=suppr&id="+id;
			break;
			case 'gestionreportage' :
				document.location.href="/espace-fournisseur/fiche_fournisseur_gestionpublireportage.php?action=suppr&id="+id;
			break;
		}
	}
}

function setBlindDownDisplay(id , type){
		setTimeout("new Effect.BlindDown('"+id+"', { duration: 0.4 });",200);
		setTimeout("document.getElementById('"+id+"').style.display='"+type+"';",700);
}

function chercheType(id){
	if(id==30){
		if(document.getElementById('selectNomContact').style.display=='none'){
			new Ajax.Updater('selectNomContact', '/espace-sdis/ajax/form_contact_nom.php', {method:'get', onComplete:setBlindDownDisplay('selectNomContact','block')});
		}
	} else {
		if(document.getElementById('selectNomContact').style.display=='block'){
			new Effect.BlindUp('selectNomContact', { duration: 0.4 });
		}
	}
}

function getScrollY() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    scrOfY = window.pageYOffset;
  } else if( document.body && document.body.scrollTop) {
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && document.documentElement.scrollTop) {
    scrOfY = document.documentElement.scrollTop;
  }
  return scrOfY;
}

function scrolling()
{
 var scrollY=getScrollY();
  //document.getElementById("div_ajax").style.top=parseInt(scrollY)+'px';
  document.getElementById("div_fond_transparent").style.top=parseInt(scrollY)+'px';
  document.getElementById("div_generalites").style.top=-parseInt(scrollY)+'px';
  document.getElementById("div_groupements").style.top=-parseInt(scrollY)+'px';
  document.getElementById("div_services").style.top=-parseInt(scrollY)+'px';
  document.getElementById("div_contacts").style.top=-parseInt(scrollY)+'px';
  document.getElementById("div_organismes").style.top=-parseInt(scrollY)+'px';
  document.getElementById("div_modifproduit").style.top=-parseInt(scrollY)+'px';
  document.getElementById("div_modifreportage").style.top=-parseInt(scrollY)+'px';
}