// JavaScript Document
// $Header: /var/lib/cvs/aumiot/web/js/functions.js,v 1.5.2.1 2009-07-02 10:14:38 fmarin Exp $

var aumiot_ajp;
var aumiot_tempo = 150;
var aumiot_white_frequency = 6; // Rafraichissement des articles en vitrine (homefix) en secondes


var custom_init = function() {
	var white;
	if($("homeflash")) {
		 $("homeflash").innerHTML = Flash.getHTML("aumiot.swf", 304, 142, {
			loop:"false",
			wmode:"opaque"
		 });
	}

	if($("homefix")) {
		if(!$("white"))
			aumiot_create_white();

		aumiot_ajp = new Ajax.PeriodicalUpdater(
			"homefix",
			"dyn.php?a=homefix", {
				frequency:aumiot_white_frequency,
				onCreate: function() {
					$("white").style.display = "";
				},
				onSuccess: function(transport) {
					new Effect.Fade("white");
				}
			}
		);
	}

	if($("marquee")) {
		var msg = $("marquee").value;
		var longueur = 500;
		$("marquee").value = "";
		while ($("marquee").value.length < longueur)
			$("marquee").value += msg + "               ";
		timer=setTimeout("aumiot_marquee ()",aumiot_tempo);
	}

}

var aumiot_create_white = function() {
	white = document.createElement("div");
	white.id = "white";
	white.style.width = ($("homefix").offsetWidth - 2) + "px";
	if(navigator.appName == "Netscape" && navigator.userAgent.toLowerCase().indexOf("firefox/3") == -1 || navigator.appName == "Opera")
		white.style.marginTop = "10px";
	$("c2").insertBefore(white, $("homefix").parentNode.parentNode.parentNode);
}

var aumiot_marquee = function () {
	$("marquee").value = $("marquee").value.substring(1) + $("marquee").value.charAt(0);
	timer = setTimeout("aumiot_marquee ()", aumiot_tempo);
}

var montre = function(id) {
	var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
	if (d) {d.style.display='block';}
}

var changebg  = function(id,a) {
	if (a == '') {
		document.getElementById(id).style.backgroundColor='';
		document.getElementById(id).style.color='';
		document.getElementById(id).style.border='0';
		document.getElementById(id).style.margin='0';
		document.getElementById('l'+id).style.color= '';
		
	}
	else {
		var e = document.getElementById(id);
		e.style.backgroundColor='#ffffff';
		document.getElementById('l'+id).style.color= '#000000';
		e.style.borderLeft='1px solid gray';
		e.style.borderRight='1px solid gray';
		e.style.marginRight='-2px';
	}
}
