///////////////////////////////////////////////////////////////
//	CLASSES
//	============================================================
//	COOK MODEL OBJECT
//	COPYRIGHT (c) ARTCULINAIRE.CH 2001.
//	============================================================

function cook(document, name, hours, path, domain)
 {
	//	PROPERTIES
	this.$document = document;
	this.$name = name;
	
	if(hours)this.$expires = new Date((new Date()).getTime() + hours*3600000);
	   else this.$expires = null;
	if(path) this.$path = path; else this.$path = null;
	if(domain) this.$domain = domain; else this.$domain = null;
 }
 
function storeCook()
 {
	var cookval = "";
	
	for(var prop in this)
	 {
		if((prop.charAt(0) == "$") || ((typeof this[prop]) == "function"))
		    continue;
		if(cookval != "") cookval += "&";
		cookval += prop + ":" + escape(this[prop]);
	 }
	
	var str = this.$name + "=" + cookval;
	
	if(this.$expires)
	   str += "; expires=" + this.$expires.toGMTString();
	if(this.$path)
	   str += "; path=" + this.$path;
	if(this.$domain)
	   str += "; domain=" + this.$domain;
	 
	return this.$document.cookie = str;
 }

function loadCook()
 {
	var allCook = this.$document.cookie;
	if(allCook == "") return false;
	
	var start = allCook.indexOf(this.$name + "=");
	if(start == -1) return false;
	start += this.$name.length + 1;
	
	var end = allCook.indexOf(";", start);
	if(end == -1) end = allCook.length;
	
	var cookval = allCook.substring(start, end);
	
	var myCook = cookval.split("&");
	
	for(var i=0;i<myCook.length;i++)
	    myCook[i] = myCook[i].split(":");
	
	for(var i=0;i<myCook.length;i++)
	 {
		this[myCook[i][0]] = unescape(myCook[i][1]);
	 }
	 
	return true;
 }

function removeCook()
 {
	var str;
	str = this.$name + "=";
	
	if(this.$path) str += "; path=" + this.$path;
	if(this.$domain) str += "; domain=" + this.$domain;
	
	str += "; expires=Fri, 02-Jan-1970 00:00:00 GMT";
	
	return this.$document.cookie = cookie;
 }

//	METHODS
new cook();
cook.prototype.store = storeCook;
cook.prototype.load = loadCook;
cook.prototype.remove = removeCook;


///////////////////////////////////////////////////////////////
//	CLASSES
//	============================================================
//	MENU MODEL OBJECT.
//	COPYRIGHT (c) ARTCULINAIRE.CH 2001.
//	============================================================
//	THANKS TO WWW.EDITEURJAVASCRIPT.COM FOR THE INSPIRATION 
//  OF THIS MENU OBJECT.

function menu()
 {
	//	PROPERTIES.
	this.x = 305;
	this.y = 95;
	this.host = (navigator.appName.indexOf("Netscape") != -1) ?
		 document.headerMenu : headerMenu.style;
	this.color = " #999966";
	this.overColor = "#990066";
	this.items = new Array();
	
	//	METHODS.
	this.fillItems = fillItems;
	this.buildMenus = buildMenus;
	this.hideMenus = hideMenus;
 }

function fillItems()
 {
	this.items[0] = new Array();
	this.items[1] = new Array();
	this.items[2] = new Array();
	this.items[3] = new Array();
	
	//	Les recettes
	this.items[0][0] = "<A href=\"http://www.artculinaire.ch/recettes/index.php4\" class=\"mItems\">Le livre des recettes</A>";
	this.items[0][1] = "<A href=\"http://www.artculinaire.ch/dossiers/index.php4\" class=\"mItems\">Les dossiers à thème</A>";
	
	//	Spécialités
	this.items[1][0] = "<A href=\"http://www.artculinaire.ch/voyages/index.php4\" class=\"mItems\">Les Voyages culinaires</A>";
	this.items[1][1] = "<A href=\"http://www.artculinaire.ch/decos/index.php4\" class=\"mItems\">Les idées déco</A>";
	
	//	Bavardages
	this.items[2][0] = "<A href=\"http://www.artculinaire.ch/forum/index.php4\" class=\"mItems\">Le forum</A>";
	//this.items[2][1] = "<A href=\"chat\" class=\"mItems\">Le chat</A>";
	this.items[2][1] = "<A href=\"javascript:showRecoSite()\" class=\"mItems\">Recommandez Artculinaire.ch</A>";
	this.items[2][2] = "<A href=\"http://www.artculinaire.ch/livredor/index.php4\" class=\"mItems\">Le livre d'or</A>";	

	//	Les plus
	this.items[3][0] = "<A href=\"http://www.artculinaire.ch/recherche/index.php4\" class=\"mItems\">Le moteur de recherche</A>";
	this.items[3][1] = "<A href=\"http://www.artculinaire.ch/astuces/index.php4\" class=\"mItems\">Les astuces</A>";
	this.items[3][2] = "<A href=\"http://www.artculinaire.ch/voc/index.php4\" class=\"mItems\">Le vocabulaire culinaire</A>";
	this.items[3][3] = "<A href=\"http://www.artculinaire.ch/articles/index.php4\" class=\"mItems\">Bon à savoir [NOUVEAU]</A>"; 
	this.items[3][4] = "<A href=\"http://www.artculinaire.ch/liens/index.php4\" class=\"mItems\">Les liens</A>"; 
 }

function buildMenus(index, PxFromLeft, PxFromTop)
 {
	var $table1 = "<TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"" + this.overColor + "\" width=\"200px\"><TR><TD>";
	var $table2 = "<TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"100%\">";
	var $table3 = new String();
	var $table4 = "</TABLE></TD></TR></TABLE>";
	
	this.host.visibility = "hidden";
	this.host.left = (this.x + PxFromLeft);
	this.host.top = PxFromTop;
	
	for(var i=0; i<this.items[index].length; i++)
	 {
		$table3 += "<TR><TD height=\"20\" class=\"mItems\" "
				 + "onMouseOver=\"this.style.background='" + this.overColor + "'\" "
				 + "onMouseOut=\"this.style.background='" + this.color + "'\" >"
		         + this.items[index][i] + "</TD></TR>";
	 }
	
	$table1 += $table2 + $table3 + $table4;
	
	if(navigator.appName.indexOf("Netscape") != -1)
	 {
		this.host.document.writeln($table1);
		this.host.document.close();
	 }
	else
		document.all.headerMenu.innerHTML = $table1;
		
	return this.host.visibility = "visible";
 }

function hideMenus()
 {
	return this.host.visibility = "hidden";
 }
 
 
///////////////////////////////////////////////////////////////
//	CLASSES
//	============================================================
//	DYNAMIC SIZER OBJECT
//	COPYRIGHT (c) ARTCULINAIRE.CH 2001.
//	============================================================

function sizer()
 {
	//	PROPERTIES
	this.state = new Boolean(true);

	// METHODS
	this.resize = resizeIndex;
 }

function resizeIndex()
 {	
	if(this.state)
	 {
		document.all.menuControl.title = "Cliquez ici pour afficher l'index des recettes";
		document.all.artNavigator.style.display = "none";
		document.all.main_L.style.width = 5;
		return this.state = false;
	 }
	else
	 {
		document.all.menuControl.title = "Cliquez ici pour masquer l'index des recettes";
	 	document.all.artNavigator.style.display = "";
	 	document.all.main_L.style.width = "";
		return this.state = true;
	 }
 }
 
///////////////////////////////////////////////////////////////
//	FUNCTIONS

function showRecoSite()
{
	javascript:window.open("http://www.artculinaire.ch/recommander/recommander.html","","toolbar=0,status=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,width=500,height=320");
}
