AtoLoad = new Array();
AtoUnLoad = new Array();
AtoBeforeUnLoad = new Array();
ie = (document.all) ? true : false;

/**
* Execute au demarrage charge les differentes librairies
*/
function init() {
	for(j=0;j<AtoLoad.length;j++) {
		Flib = AtoLoad[j]+"()";
		eval(Flib);
	}
}
/**
 * Exécuté avant la destruction
 */
function beforeDestruct() {
	for(j=0;j<AtoBeforeUnLoad.length;j++) {
		Flib = AtoBeforeUnLoad[j]+"()";
		eval(Flib);
	}
}
/**
 * Executé lorsque l'on quitte la page
 */
function destruct() {
	for(j=0;j<AtoUnLoad.length;j++) {
		Flib = AtoUnLoad[j]+"()";
		eval(Flib);
	}
}
/**
 * Navigation dans l'historique
 */
function historique(url) {
	document.location.href=url;
	return false;
}
/**
 * Affiche ou masque la fenâtre de détail
 */
function showStatus(noresize) {
	if(!noresize) {
		frmset = parent.document.getElementById('framesetBase');
		frmset.rows = "30,*,50";
	}
}
function hideStatus() {
	frmset = parent.document.getElementById('framesetBase');
	frmset.rows = "30,*,0"
	document.location.href="status.php";
}
/**
 * Aggrandis ou réduis la fenêtre de détail
 */
maximized = false;
function maximize(obj) {
	el = parent.document.getElementById('framesetBase');
	if(el.rows == "30,0,*" || el.rows == "30,*,50") el.rows = "30,*,500";
	else el.rows = "30,0,*";
	return false;
}
function minimize () {
	el = parent.document.getElementById('framesetBase');
	el.rows = "30,*,500";
}
function openW(theUrl) {
	theFeatures	= "center:yes;status:no;resizable:yes;dialogWidth:450px;help:no;dialogHeight:300px";
	window.showModalDialog(theUrl,"",theFeatures);
	return false;
}
function openwindow(url) {

}
function openW2(theUrl) {
	theFeatures	= "center:yes;status:no;resizable:yes;dialogWidth:600px;help:no;dialogHeight:300px";
	window.showModalDialog(theUrl,"",theFeatures);
	return false;
}
/**
 * Execute une commande système
 */
function execute(prg) {
	var wsh = new ActiveXObject("WScript.Shell");
	var res = wsh.Run(prg);
}
/**
 * Gère les erreurs javascript
 */
function handleError(msg, url, ln) {
	ln--;
	msg+= "\nUrl..... : "+url;
	msg+= "\nLigne.. : "+ln;
	msg+= "\n------------------------------------------------------------------------------------------------------\n";
	el = document.getElementsByTagName("HTML");
	el = el[0];
	ct = el.innerHTML
	ar = ct.split("\n");
	leng = 4
	start = (ln>leng) ? (ln-leng) : ln;
	end   = (ln>(ar.length-(leng*2))) ? ar.length : ln+leng;
	for(i=start; i < end; i++) 	{
		if(i != ln) msg+= i+" | "+ar[i]+"\n";
		else msg+= i+">>>>"+ar[i]+"\n";
	}
	msg+= "------------------------------------------------------------------------------------------------------\n";
	alert(msg);
	return true;
}
window.onerror = handleError;
window.onload = init;
window.onbeforeunload = beforeDestruct;
window.onunload = destruct;
