// Fonctions javascripts communes

/****************************/
/*
<Type>	Fonction
<Categorie>
<Nom>	recupereElementsHTML
<NbParam>	1
<param>
	monElement (string) 
</Param>
<Description>
	Permet de recuperer un tableau contenant tous les elements envoyés en parametre de la page.
	Ex : on souhaiterai recuperer tous les DIV de notre page HTML
</Description>
<Date Création>	02/06/2008
<Auteur Création>	STACHOWIAK Jérôme
<Modification>
</Modification> 
*/
/****************************/

function recupereElementsHTML(monElement) {
	if(monElement!= "") {
		var monTableau;
		monTableau=document.getElementsByTagName(monElement);
		return monTableau;
	}
	else
		return false;
}

/****************************/
/*
<Type>	Fonction
<Categorie>
<Nom>	siDivExist
<NbParam>	1
<param>
	monDiv (string) 
</Param>
<Description>
	Permet de tester si un div est bien present dans la page
</Description>
<Date Création>	02/06/2008
<Auteur Création>	STACHOWIAK Jérôme
<Modification>
</Modification> 
*/
/****************************/

function siDivExist(monDiv) {
	if(monDiv!="") {
		monTableau = recupereElementsHTML("DIV");
		//on recherche dans le tableau
		for(i=0;i<monTableau.length;i++) {
			if(monTableau[i].id.length != 0) {
				if(monTableau[i].id == monDiv) {
					return true
				}
			}
		}
	}
	return false;
}

/****************************/
/*
<Type>	Fonction
<Categorie>
<Nom>	cacheDiv
<NbParam>	1
<param>
	maChaine (string) 
</Param>
<Description>
	Permet de cacher un DIV a partir de son ID
</Description>
<Date Création>	02/06/2008
<Auteur Création>	STACHOWIAK Jérôme
<Modification>
</Modification> 
*/
/****************************/

function cacheDiv(maChaine) {
	if(maChaine!="") {
		if(siDivExist(maChaine) == true) {
			document.getElementById(maChaine).style.display = "none";
		}
	}
}

/****************************/
/*
<Type>	Fonction
<Categorie>
<Nom>	montreDiv
<NbParam>	1
<param>
	maChaine (string) 
</Param>
<Description>
	Permet de montrer un DIV a partir de son ID
</Description>
<Date Création>	02/06/2008
<Auteur Création>	STACHOWIAK Jérôme
<Modification>
</Modification> 
*/
/****************************/

function montreDiv(maChaine) {
	if(maChaine!="") {
		//alert(maChaine);
		if(siDivExist(maChaine) == true) {
			//alert("ok");
			document.getElementById(maChaine).style.display = "block";
		}
	}
}

/****************************/
/*
<Type>	Fonction
<Categorie>
<Nom>	cutChaine
<NbParam>	2
<param>
	maChaine (string) 
	nombre (int)
</Param>
<Description>
	Permet de couper une chaine de caractere, on recupere les x caracteres (definit par nombre) du debut de la chaine
</Description>
<Date Création>	02/06/2008
<Auteur Création>	STACHOWIAK Jérôme
<Modification>
</Modification> 
*/
/****************************/
function cutChaine(maChaine, nombre)
{
	if(maChaine!="") {
		if(maChaine.length > nombre) {
			return maChaine.substring(0 , nombre);
		}
		return maChaine;
	}
}

/****************************/
/*
<Type>	Fonction
<Categorie>
<Nom>	menu_webinside
<NbParam>	2
<param>
	monPanneau (string) 
	type (nombre)
</Param>
<Description>
	Permet d'afficher ou cacher le rollover du menu
</Description>
<Date Création>	06/01/2009
<Auteur Création>	STACHOWIAK Jérôme
<Modification>
</Modification> 
*/
/****************************/
function menu_webinside(id, img){
	// On declare les variables
	var div_menu = document.getElementById(id);

	div_menu.src = "http://www.webinside.fr/medias/images/"+ img;
}


/****************************/
/*
<Type>	Fonction
<Categorie>
<Nom>	PopupCentrer
<NbParam>	10
<param>
	page 
	name
	largeur
	hauteur
	toolbar
	menubar
	scrollbars
	resizable
	status
	location
</Param>
<Description>
	Permet d'ouvrir un pop-up centre avec parametres definis
</Description>
<Date Création>	21/01/2009
<Auteur Création>	STACHOWIAK Jérôme
<Modification>
</Modification> 
*/
/****************************/
function PopupCentrer(page,name,largeur,hauteur,toolbar,menubar,scrollbars,resizable,status,location) {
	var top=(screen.height-hauteur)/2;
  	var left=(screen.width-largeur)/2;
  	window.open(page,name,"top="+top+",left="+left+",height="+hauteur+",width="+largeur+",toolbar="+toolbar+",menubar="+menubar+",scrollbars="+scrollbars+",resizable="+resizable+",status="+status+",location="+location);
	return(false);
}



/****************************/
/*
<Type>	Fonction
<Categorie>
<Nom>	fermerFen
<NbParam>	
<Param>
	
</Param>
<Description>
	Ferme la fenetre
</Description>
<Date Création>	25/07/2008
<Auteur Création>	STACHOWIAK Jérôme
<Modification>
</Modification> 
*/
/****************************/
function fermerFen() {
	window.close();
}


/****************************/
/*
<Type>	Fonction
<Categorie>
<Nom>	envoiContenu
<NbParam>	4
<Param>
	momForm
	monText
	expForm
	champ
</Param>
<Description>
	Permet de renvoyer à la page appelante le contenu saisi dans tiny
	Le formulaire qui transmet le contenu porte le nom de parametre momForm
	Le textarea qui transmet le contenu porte le nom de parametre monText
	Le formulaire de la page qui ouvre le pop-up porte le nom expForm
</Description>
<Date Création>	25/07/2008
<Auteur Création>	STACHOWIAK Jérôme
<Modification>
</Modification> 
*/
/****************************/
function envoiContenu(monForm, monText, expForm, champ) {
if (champ!=""){
	var Monarticle="";

	if(champ=="annonce")
		Monarticle = expForm.annonce;
	else
	{
		if(champ=="texte")
			Monarticle = expForm.texte;
		else
			Monarticle = expForm.accroche;
	}
}
monForm.submit();
Monarticle.value = monText;
fermerFen();
}
