﻿// Auteur               : Aurélien Debaisieux
// Date de cr&eacute;ation     : 16/11/2006
// Date de modification : 23/11/2006
// Informations : Liste des fonctions utilis&eacute;es par les pages du site

// Retourne un &eacute;l&eacute;ment du DOM
function ReturnElement( id )
{
	if (!document.getElementById)
		return document.id ;
	else
		return document.getElementById(id);
}
// Affiche le d&eacute;tail d'un avis
function ShowDetail( sAnnonce )
{
	window.open("./avis.asp?n=" + sAnnonce, "_new","height=600,width=800,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes" );
	return true;
}
// Affichge le d&eacute;tail d'une attribution
function ShowDetailAttrib( sAnnonce )
{
	window.open("./attrib.asp?n=" + sAnnonce,  "Annonce" + sAnnonce,"height=600,width=800,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes" );
	return true;
}
// Affiche un popup avec la liste des annonces en cours (pour impression)
function PrintList(d)
{
	window.open("./Print_ListeAnnonce.asp?Print=1"  , "_new","height=600,width=800,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes" ) ;
	return true;
}

// Ecrit un contrôle SELECT dans le document
function writeSelect(sId,sName,sClass,sTitle,sSize,sStyle,sOnChange,sOptions)
{
	var sHtml;
	sHtml = "<select"
	if (sId != "")
		sHtml = sHtml + " id=\"" + sId + "\"";
	if (sName != "")
		sHtml = sHtml + " name=\"" + sName + "\"";
	if (sClass != "")
		sHtml = sHtml + " class=\"" + sClass + "\"";
	if (sTitle != "")
		sHtml = sHtml + " title=\"" + sTitle + "\"";
	if (sSize != "")
		sHtml = sHtml + " size=\"" + sSize + "\"";
	if (sStyle != "")
		sHtml = sHtml + " style=\"" + sStyle + "\"";
	if (sOnChange != "")
		sHtml = sHtml + " onchange=\"" + sOnChange + "\"";
	sHtml = sHtml + ">";
	if (sOptions != "")
		sHtml = sHtml + sOptions;
	sHtml = sHtml + "</select>";
	document.write(sHtml);
}

// Ecrit un contrôle IMG dans le document
function writeImg(sId,sName,sSrc,sAlt,sStyle,sClass,sWidth,sHeight,sOnClick)
{
	var sHtml;
	sHtml = "<img";
	if (sId != "")
		sHtml = sHtml + " id=\"" + sId + "\"";
	if (sName != "")
		sHtml = sHtml + " name=\"" + sName + "\"";
	if (sSrc != "")
		sHtml = sHtml + " src=\"" + sSrc + "\"";
	if (sAlt != "")
		sHtml = sHtml + " alt=\"" + sAlt + "\"";
	if (sStyle != "")
		sHtml = sHtml + " style=\"" + sStyle + "\"";
	if (sClass != "")
		sHtml = sHtml + " class=\"" + sClass + "\"";
	if (sWidth != "")
		sHtml = sHtml + " width=\"" + sWidth + "\"";
	if (sHeight != "")
		sHtml = sHtml + " height=\"" + sHeight + "\"";
	if (sOnClick != "")
		sHtml = sHtml + " onclick=\"" + sOnClick + "\"";
	sHtml = sHtml + " />";
	document.write(sHtml);
}

// Ecrit un contrôle BUTTON dans le document
function writeButton(sId,sName,sLibelle,sClass,sTitle,sStyle,sOnClick)
{
	var sHtml;
	sHtml = "<input type=\"button\"";
	if (sId != "")
		sHtml = sHtml + " id=\"" + sId + "\"";
	if (sName != "")
		sHtml = sHtml + " name=\"" + sName + "\"";
	if (sLibelle != "")
		sHtml = sHtml + " value=\"" + sLibelle + "\"";
	if (sClass != "")
		sHtml = sHtml + " class=\"" + sClass + "\"";
	if (sTitle != "")
		sHtml = sHtml + " title=\"" + sTitle + "\"";
	if (sStyle != "")
		sHtml = sHtml + " style=\"" + sStyle + "\"";
	if (sOnClick != "")
		sHtml = sHtml + " onclick=\"" + sOnClick + "\"";
	if(true)
		sHtml = sHtml + " onmouseover=\"window.status=this.title;return true;\" onmouseout=\"window.status='';return true;\""
	sHtml = sHtml + " />";
	document.write(sHtml);
}
// Permet de définir une hauteur max pour un div
// On impose la hauteur si elle dépasse la limite
function setMaxHauteurDiv(Nom,Hauteur)
{
	try {
		if(document.getElementById(Nom).innerHeight > parseInt(Hauteur,10))
		{
			document.getElementById(Nom).style.overflow = "auto";
			document.getElementById(Nom).style.height = Hauteur + "px";
		}
	}
	catch(ex) {
		
	}
	return true;
}
