// Show/Hide archive et date (si nouvelle (hide), si communique (show))
// Sylvie - egzakt.com
// Param	obj		: groupe d'objets
//			etat	: enum('block','none','inline) - valeur du diplay en css
//

function ch_etat_id (obj,etat) {
	if (document.getElementById(obj)) {
		document.getElementById(obj).style.display = etat;
	} 
}

// Fonction d'ouverture de fenetre popup centree
// Simon - egzakt.com
// 2004-10-28
//
function egz_openwindow(lien,cible,w,h) {
	var _win;
	_win = window.open(lien,cible,'width=' + w + ',height=' + h + ',top=' + (screen.height - 400)/2 + 'left='+ (screen.width - 400)/2);
	_win.moveTo((screen.width - w)/2,(screen.height - h)/2);
	_win.focus();

	return _win;
}

// Fonction d'ouverture de fenetre popup centree
// Simon - egzakt.com
// 2004-10-28
//
function egz_openwindow_param(lien,cible,w,h,param) {
	var _win;
	_win = window.open(lien,cible,param);
	_win.moveTo((screen.width - w)/2,(screen.height - h)/2);
	_win.focus();

	return _win;
}

function update_total(f,i,n,s) {
	var total=0;
	var sg="";
	var sd="";

	if (position == "d") {
		sd = s;
	} else {
		sg = s;
	}
	if (s == "$") s = "\\" + s;
	
	eval("total = parseInt(f.qua_"+i+".value) * parseFloat(f.pri_"+i+".value);");
	if(isNaN(parseFloat(total))){
		total=0;
		eval("f.qua_"+i+".value = 0;");
	}
	eval("f.tot_"+i+".value = sg + format(total, 2) + sd;");
	total=0;

	var arrinput = f.getElementsByTagName("INPUT");
	var reg = new RegExp("tot_", "i");
	
	for (var i=0; i<arrinput.length; i++)
		if (arrinput[i].name.match(reg)) {
			eval("total+=parseFloat(f."+arrinput[i].name+".value.replace(/"+s+"/g,''));"); }
	
	if(isNaN(total))
		total=0;
	
	f.subtotal.value = sg + format(total, 2) + sd;
}

function format(expr,decplaces) 
{
	var str=""+Math.round(eval(expr)*Math.pow(10,decplaces)); 
	while(str.length<=decplaces)
		str="0"+str;
	
	var decpoint=str.length-decplaces;
	return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
}

function update_fdx(f,o) {
	var t=0;
	var sg="";
	var sd="";
	
	if (position == "d") {
		sd = s;
	} else {
		sg = s;
	}
	f.fdx_prix.value=sg+format(parseFloat(o.options[o.selectedIndex].value),2)+sd;
	t=parseFloat(f.sous_total.value)+parseFloat(o.options[o.selectedIndex].value);
	f.total.value=sg+format(t,2)+sd;
}

// Fonction d'ouverture et fermeture de divs
// emilie - egzakt.com
// 2005-06-20
//
function showhide(objet) {
	if (document.getElementById(objet).style.display == 'block') {
		document.getElementById(objet).style.display = 'none'
		document.getElementById(objet).style.visibility = 'hidden'
	}
	else {
		document.getElementById(objet).style.display = 'block'
		document.getElementById(objet).style.visibility = 'visible'
	}
}
