// JavaScript Document

// DropDownMenu by Miha Hribar
// http://hribar.info

function prepareMenu() {
    // first lets make sure the browser understands the DOM methods we will be using
  	if (!document.getElementsByTagName) return false;
  	if (!document.getElementById) return false;
  	
  	// lets make sure the element exists
  	if (!document.getElementById("menu")) return false;
  	var menu = document.getElementById("menu");
  	
  	// for each of the li on the root level check if the element has any children
  	// if so append a function that makes the element appear when hovered over
  	var root_li = menu.getElementsByTagName("li");
  	for (var i = 0; i < root_li.length; i++) {
  	    var li = root_li[i];
  	    // search for children
  	    var child_ul = li.getElementsByTagName("ul");
  	    if (child_ul.length >= 1) {
  	        // we have children - append hover function to the parent
  	        li.onmouseover = function () {
  	            if (!this.getElementsByTagName("ul")) return false;
  	            var ul = this.getElementsByTagName("ul");
  	            ul[0].style.display = "block";
  	            return true;
  	        }
  	        li.onmouseout = function () {
  	            if (!this.getElementsByTagName("ul")) return false;
  	            var ul = this.getElementsByTagName("ul");
  	            ul[0].style.display = "none";
  	            return true;
  	        }
  	    }
  	}
  	
  	return true;
}

addEvent(window, 'load', function() {prepareMenu();});

//addLoadEvent(prepareMenu);

function menu() {
	document.writeln("<td>");
	document.writeln("<a href=\"index.html\">ACCUEIL</a>");
	document.writeln("</td>");
	document.writeln("<td>");
	document.writeln("<a href=\"formules.html\">FORMULES</a>");
	document.writeln("</td>");
	document.writeln("<td>");
	document.writeln("<a href=\"promotion.html\">PROMOTIONS</a>");
	document.writeln("</td>");
	document.writeln("<td>");
	document.writeln("<a href=\"cadeau.html\">IDEES CADEAUX</a>");
	document.writeln("</td>");
	document.writeln("<td>");
	document.writeln("<a href=\"nouveautes.html\">NOUVEAUTES</a>");
	document.writeln("</td>");
	document.writeln("<td style='border: 0px;'>");
	document.writeln("<a href=\"contact.html\">CONTACTEZ-NOUS</a>");
	document.writeln("</td>");
}

function suite(w, mx) {
	var s= document.location.href;
	var re= new RegExp(w + "(.*)\.html")
	var m= re.exec(s);
	var idx; 

	if(m.length==2) {
		idx= m[1];
		if(idx=="")
			idx= 2;
		else
			idx= parseInt(idx)+1;
		if(idx>mx)
			idx= "";
		else
			idx= ""+idx;
		s= w + idx + ".html";
		document.location.href= s;
	}
}
