
function aff_cache(id)
{
	if(document.getElementById(id).style.display == "none")
		document.getElementById(id).style.display = "";
	else
		document.getElementById(id).style.display = "none";
}

function aff_cache2(id)
{
	if(document.getElementById(id).style.visibility == "hidden")
		document.getElementById(id).style.visibility = "visible";
	else
		document.getElementById(id).style.visibility = "hidden";
}

function aff(id)
{
	if(document.getElementById(id).style.display == "none")
		document.getElementById(id).style.display = "";
}

function cache(id)
{
	if(document.getElementById(id).style.display == "")
		document.getElementById(id).style.display = "none";
}

function aff2(id)
{
	document.getElementById(id).style.visibility = "visible";
}

function cache2(id)
{
	document.getElementById(id).style.visibility = "hidden";
}


function enroule_deroule(objet)
{
	//alert(objet.src);
	if(objet.src == "http://www.vinonis.fr/images/derouler.gif")
		objet.src = "images/enrouler.gif";
	else
		objet.src = "images/derouler.gif";
}


function centrer_div(nom,l,h)
{
	largeur=((document.body.clientWidth)/2)-(l/2);
	hauteur=((document.body.clientHeight)/2)-(h/2);
	document.getElementById(nom).style.top=hauteur;
	document.getElementById(nom).style.left=largeur;
}

function centrer_div2(nom,l)
{
	largeur=((document.body.clientWidth)/2)-(l/2);
	document.getElementById(nom).style.left=largeur;
}

function open_popup(page, largeur, hauteur)
{
	var top=(screen.height-hauteur)/2;
	var left=(screen.width-largeur)/2;
	window.open(page, '', 'scrollbars=yes,width='+largeur+',height='+hauteur+',top='+top+',left='+left);
}

function voirSelect(v){	
	if(!window.Event){
		oSelects = document.getElementsByTagName('SELECT'); 
		for (i = 0; i < oSelects.length; i++) { 
			oSlt = oSelects[i]; 
			oSlt.style.visibility=v;
		}			
	}
}


//tout cocher / tout décocher
function cocher(Action){
	//Recherche de tous les inputs
	var listeInput = document.getElementsByTagName('input');			
	//On parcours la liste de tous les inputs
	for(var i = 0 ; i < listeInput.length ; i++){
		//On vérifie s'il s'agit d'une checkbox , si oui on la coche
		if(listeInput[i].type == "checkbox"){					
			if(Action==1){
				listeInput[i].checked = true;
			}else{
				listeInput[i].checked = false;
			}
		}
	}			
}

function tout_cocher(value){
	if(value)
		cocher(1);
	else
		cocher(0);
}


function reset_check(){
	oSelects = document.getElementsByTagName('INPUT'); 
	for (i = 0; i < oSelects.length; i++) { 
		oSlt = oSelects[i];
		if(oSlt.type == "checkbox") {
			oSlt.checked = false;
		}
	}
}

function add_categorie()
{	
	document.form.categorie.value = "";
	document.getElementById('categorie_label').innerHTML = "";
	
	oSelects = document.getElementsByTagName('INPUT'); 
	for (i = 0; i < oSelects.length; i++) { 
		oSlt = oSelects[i];
		if(oSlt.type == "checkbox" && oSlt.checked) {
			//alert(oSlt.value);
			var letab = Array();
			letab = oSlt.value.split("-");
			
			//alert(letab[0] + " - " + letab[1]);
			if(document.form.categorie.value == "")
			{
				document.form.categorie.value += letab[0];
				document.getElementById('categorie_label').innerHTML += letab[1];
			}
			else
			{
				document.form.categorie.value += "," + letab[0];
				document.getElementById('categorie_label').innerHTML += ", " + letab[1];
			}
		}
	}
}

function change_action(coche){
	if(coche)
		document.rech.action = "entreprise.php";
	else
		document.rech.action = "annonce.php";
}

function change_action2(value){
	if(value == "2")
		document.rech.action = "entreprise.php";
	else
		document.rech.action = "annonce.php";
}

function rech_change_action2(value){
	if(value == "2")
		document.form.action = "entreprise.php";
	else
		document.form.action = "annonce.php";
}

function verifFormComment(){
	a="0";
	
	if (document.commentaire.userCode.value.length == 0) {alert('Vous n\'avez pas saisi le code.'); a="1"; document.commentaire.userCode.focus();}
	else if (document.commentaire.texte.value.length == 0) {alert('Vous n\'avez pas saisi votre commentaire.'); a="1"; document.commentaire.texte.focus();}
	
	if (a == 0)
	{
		document.commentaire.submit();
	}
}
