/* --------------- */
/* Menu interactif */
/* --------------- */

var debugwin=null;
var DEBUG_ENABLED=false;

function mouseover_handler(ev) 
{
    if (this.className == "menu_item_over") this.className="menu_item";
    else this.className="menu_item_over";
    
}

function mouse_click_handler(ev) 
{
    // récupération du lien href de la balise <a> contenue dans le <div> menuitem courant
    var href=this.childNodes[0].href;
    // redirection
    if (href) window.location.href=href;
    debug(href);
    
}


function hookevents()
{
	
var gt = document.getElementById("menu_content"), els;
if (gt && (els=gt.childNodes))
{
	var il=els.length;
	
	for(var i=1; i<il; i++)
	{
		
		debug(els[i].className);
		if(els[i].className!="menu_item") break;
		els[i].onmouseover = els[i].onmouseout = mouseover_handler;
		els[i].onclick=mouse_click_handler;
	}
}


}


function debug(exp)
{
	if (DEBUG_ENABLED)
	{
	
	if (!debugwin) 
	{ 
		debugwin=window.open("","DEBUG","menubar=no,toolbar=no,width=400,height=400");
		debugwin.document.writeln("<b>START DEBUG</b><br/>");
   		debugwin.document.writeln(exp);
   		debugwin.document.writeln("<BR/>");
   	}
   	else { debugwin.document.writeln(exp); debugwin.document.writeln("<BR/>"); }
   	
   	}
   	
}

function resize2()
{
}

/* ------------------- */
/* Préchargement image */
/* ------------------- */

function preloadImage(arg) 
{
		rslt = new Image();
		rslt.src = arg;
		return rslt;
}

// popup
    function popup(page,nom,option)
    {
     window.open(page,nom,option);
    }
//copyleft 2001 Jean-Michel Blondeau jmb@voir.net
function popup2(adresse,fenetre,x,y,redim,ascen,menu,outil,secteur,adres,etat,cadre) {
posX=screen.availWidth-80;posY=screen.availHeight-80;
var arg = "";
 ha = 0;  la = 0;
	arg = arg + "width=" +x;
	arg = arg + ",height=" + y;
	arg = arg + ",resizable=" + redim;
	arg = arg + ",scrollbars=" + ascen;
	arg = arg + ",menubar=" + menu;
	arg = arg + ",toolbar=" + outil;
	arg = arg + ",locectories=" + secteur;
	arg = arg + ",location=" + adres;
	arg = arg + ",status=" + etat;
var loc=cadre;
if (loc=="bg") {ha=posY-y; la = 0}
else if (loc=="bc") {ha=posY-y; la = (posX-x)/2}
else if (loc=="bd") {ha=posY-y; la= posX-x}
else if (loc=="mg") {ha= (posY-y)/2; la = 0}
else if (loc=="mc") {ha= (posY-y)/2; la = (posX-x)/2}
else if (loc=="md") {ha= (posY-y)/2; la= posX-x}
else if (loc=="hg") {ha=0; la = 0}
else if (loc=="hc") {ha=0; la = (posX-x)/2}
else if (loc=="hd") {ha=0; la= posX-x}
	arg += ",screenX=" + la + ",left=" + la;
	arg += ",screenY=" +ha + ",top=" + ha;

window.open(adresse,fenetre,arg);
}

           function image(img)
           {
               preview=open("",'image','width=400,height=400,toolbar=no,scrollbars=no,resizable=yes');	
               preview.document.write("<HTML><HEAD></HEAD>");
               preview.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+40,document.images[0].height+130); window.focus();} else { setTimeout('checksize()',250) } }</"+"SCRIPT>");
               preview.document.write("<BODY style='background:#555555;' onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><CENTER><BR/><IMG src=http://www.buscalorchidees.com/"+img+" border=0><P/><input onclick='javascript:window.close()' type='button' class='button' style='width:150px;' value='Fermer'/></CENTER>");
               preview.document.write("");
               preview.document.write("</BODY></HTML>");
               preview.document.close();           
           }

function update_qte(id, val) {
	quantite = document.form1[id].value;
	quantite = 	parseInt(quantite) + parseInt(val);
	if (quantite < 1) { quantite = 1; }
	if (quantite > 99) { quantite = 99; }
	document.form1[id].value = quantite;
}


