//Gestion des popup
function PopupCentrer(page,largeur,hauteur,options) {
	var top=(screen.height-hauteur)/2;
	var left=(screen.width-largeur)/2;
	window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}

// GESTION DES GALLERIES - balises select / MAJ des tableaux de bord / ...
function codePostal(cp,type)
{
	new Ajax.Request('ajax.php',
	{
		method: 'post',
		parameters: 'cp='+cp+'&type='+type,
		onSuccess: function(ajax)
		{
			$(type + '_ville').replace(ajax.responseText);
		}
	});
}

function pays(paysVar,type)
{
	if(paysVar != '1') $('divDepartement').style.display = 'none';
	else $('divDepartement').style.display = 'block';
	
	var cp = $(type + '_cp').value;
	
	new Ajax.Request('ajax.php',
	{
		method: 'post',
		parameters: 'paysVar='+paysVar+'&cpBis='+cp+'&type='+type,
		onSuccess: function(ajax)
		{
			$(type + '_cp').replace(ajax.responseText);
		}
	});
}

function verifDept(dept)
{
	if(dept == "") $('dept').addClassName('error');
}


function cp(idpays,idcp,type,classe)
{
	new Ajax.Request('ajax.php',
	{
		method: 'post',
		parameters: 'paysVar='+idpays+'&classe='+classe+'&type='+type,
		onSuccess: function(ajax)
		{
			$(type + '_cp').replace(ajax.responseText);
		}
	});
	
	new Ajax.Request('ajax.php',
	{
		method: 'post',
		parameters: 'paysVille='+idpays+'&classe='+classe+'&type='+type,
		onSuccess: function(ajax)
		{
			$(type + '_ville').replace(ajax.responseText);
		}
	});
	
	
	//pays(idpays,type);
	if(idpays == 1) 
	{ //codePostal(idcp,type);
		new Ajax.Request('ajax.php',
		{
			method: 'post',
			parameters: 'cp='+cp+'&classe='+classe+'&type='+type,
			onSuccess: function(ajax)
			{
				$(type + '_ville').replace(ajax.responseText);
			}
		});
	}
}

//Calibre en fonction de la sous famille
function getCalibre(idcateg)
{
	//alert('arriver');
	new Ajax.Request('ajax.php',
	{
		method: 'post',
		parameters: 'idcateg='+idcateg,
		onSuccess: function(ajax)
		{
			$('sscateg').replace(ajax.responseText);
		}
	});
}

//Modele en fonction de la sous famille
function getModele(ssfam)
{
	new Ajax.Request('ajax.php',
	{
		method: 'post',
		parameters: 'ssfam='+ssfam,
		onSuccess: function(ajax)
		{
			$('modele').replace(ajax.responseText);
		}
	});
}



//recherche avancï¿½e : pays => departement
function dept_rech(rech_pays)
{
	new Ajax.Request('ajax.php',
	{
		method: 'post',
		parameters: 'rech_pays='+rech_pays,
		onSuccess: function(ajax)
		{
			$('dept').replace(ajax.responseText);
		}
	});
}

//Mode paiement : professionnels payent unikement en CHQ
function getPaiement(prof)
{
	if (prof == 'oui')
	{
		$('affich_pro').style.display = 'none';
	}
	else
	{
		$('affich_pro').style.display = 'block';
	}
}

//Ouvrir la pop-up pour l'aperï¿½u d'annonce

function PopupCentrer(page,largeur,hauteur,options) {
	var top=(screen.height-hauteur)/2;
	var left=(screen.width-largeur)/2;
	window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}


function recherche()
{
	new Ajax.Request('ajax.php',
	{
		method: 'post',
		parameters: 'id='+id+'&level='+level+'&destruct='+destruct,
		onSuccess: function(ajax)
		{
			$('recherche').replace(ajax.responseText);
		}
	});
}


/*affichage de bulles*/
function Over(bulle){
   var oDiv = document.getElementById(bulle);
   // apparition de la div :
   oDiv.style.visibility =  "visible";
}

function Out(bulle){
   var oDiv = document.getElementById(bulle);
   
   // disparition de la div :
  oDiv.style.visibility = "hidden";
}


//si une session adhï¿½rent est ouverte
function verifInscrit(session,url)
{	
	if(session == 1 )
	{
		alert('Vous êtes visiteur sur notre site, devenez membre, inscrivez-vous ');
		document.location.href = "/se-logger.html";
	}
	else
	{
		document.location.href = url;
	}
		
}

function suppSession(typeSession)
{
	new Ajax.Request('ajax.php',
	{
		method: 'post',
		parameters: 'typeSession='+typeSession,
		onSuccess: function(ajax)
		{
			//$('recherche').replace(ajax.responseText);
		}
	});
}

function takeFTP(url)
{
	new Ajax.Request('view_ftp.php',
	{
		method: 'post',
		parameters: 'link='+url,
		onSuccess: function(ajax)
		{
                        window.open('ftp://'+constant.FTP_LOGIN+':'+constant.FTP_PASSWORD+'@'+constant.FTP_URL+'/'+url);
                        //$('recherche').replace(ajax.responseText);
		}
	});
}
