///////////////////////////////////////////////////////////////////////////////////////////////////
// 	Menu Copyright CybWarrior; Adapté et modifié pour les besoins de la cause //
///////////////////////////////////////////////////////////////////////////////////////////////////
var IE=document.all ? true : false;
var NS=document.layers ? true : false;
var Panels=new Array();
var Layers=new Array();
var Menus=new Array();
var GrandeurFenetreX=0;
var PosYMenu=0;
var PosXMenu=0;

var MenuPrincipal = new Menu();
	MenuPrincipal.Panel.AddItem("Accueil", "index.asp");
	MenuPrincipal.Panel.AddItem("Participer", "index.asp?lecentre=participer");
	MenuPrincipal.Panel.AddItem("Liste des prix", "index.asp?lecentre=listeprix");
	MenuPrincipal.Panel.AddItem("Commanditaires", "index.asp?lecentre=commanditaires");
	MenuPrincipal.Panel.AddItem("Voir les photos inscrites", "asp/photosinscrites.asp");
	MenuPrincipal.Panel.AddItem("R&egrave;glements", "html/reglements.pdf");
	MenuPrincipal.Panel.AddItem("Nous contacter", "mailto:concoursphoto@chevreuil.net?subject=Concours de photos");
	MenuPrincipal.Panel.AddItem("Cr&eacute;dits", "index.asp?lecentre=credits");
	MenuPrincipal.Build();

MenuPopup = MenuPrincipal;
Positionnement();

window.onresize=function(){Positionnement();}
document.onkeydown=function(){Positionnement();};
document.onmousewheel=function(){Positionnement();};
window.onscroll=function(){Positionnement();};

function Positionnement()
{
	if(IE){GrandeurFenetreX=document.body.clientWidth;}
	else{GrandeurFenetreX=window.innerWidth;}
	
	PosYMenu=document.body.scrollTop + 180;
	PosXMenu=(GrandeurFenetreX-763-document.body.style.marginLeft-document.body.style.marginRight) / 2 +10;
	if(PosXMenu<20){PosXMenu=20;}	
	MenuPopup.Panel.Show();	
}

function Menu()
{
	this.Index=Menus.length;
	Menus[this.Index]=this;
	this.Panel=new Panel(0,0); 
	this.Build=function()
	{
		this.Panel.Build();
	}
}

function Panel(left, top, parent, item){
	this.parent=parent;
	this.Index=Panels.length;
	this.Item=item;
	this.Items=new Array();
	this.Panels=new Array();
	this.left=left;
	this.top=top;
	this.visible=false;
	Panels[this.Index]=this;
	this.AddItem=function(caption, url){
		if(url==undefined){
			var Index=this.Panels.length;
			this.Panels[Index]=new Panel(0, 0, this, this.Items.length);
			this.Items[this.Items.length]=new Array(caption + '&nbsp;<b>&raquo;</b>', 'href=# onMouseOver="Panels[' + this.Panels[Index].Index + '].Show();"');
		}
		else{
			if(url=="asp/photosinscrites.asp")
				this.Items[this.Items.length]=new Array(caption, 'href="' + url + '" target="_blank"')
			else
				this.Items[this.Items.length]=new Array(caption, 'href="' + url + '"')
		}
	}
	this.Build=function(){
		var tag="<table bgcolor='#EEEEEE' cellpadding=1 cellspacing=0 border=1 bordercolor='#663300' b><tr><td><table bgcolor='#EEEEEE' border=0 cellpadding=1 cellspacing=0><tr><td><table bgcolor='#EEEEEE' border=0 cellpadding=1 cellspacing=0>";
		for(var i=0; i < this.Items.length; i++)tag+="<tr><td height=24> <a class=MnuItem " + this.Items[i][1] + " onMouseOver=this.style.backgroundColor='#B6D9EB';this.style.color='#B06021' onMouseOut=this.style.backgroundColor='#EEEEEE';this.style.color='#006699'>" + this.Items[i][0] + "</a></td></tr>";
		tag+="</table></td></tr></table></td></tr></table>";
		this.Layer=new Layer(tag, this.left, this.top);
		this.Layer.Hide();
		for(var i=0; i < this.Panels.length; i++)this.Panels[i].Build();
	}
	this.Show=function(){
		for(var i=0; i < Panels.length; i++)Panels[i].Hide();
		this.Layer.Move(PosXMenu, PosYMenu);
		this.Layer.Show();
		this.visible=this.Layer.visible;
	}
	this.Hide=function(){
		this.Layer.Hide();
		for(var i=0; i < this.Panels.length; i++)this.Panels[i].Hide();
		this.visible=this.Layer.visible;
	}
	this.Width=function()
	{
		return this.Layer.Width();
	}
}

function Layer(tag, left, top){
	this.Index=Layers.length;
	Layers[this.Index]=this;
	this.visible=true;
	this.Show=function(){
		if(IE)this.Object.style.visibility='visible';
		else if(NS)this.Object.visibility='show';
		this.visible=true;
	}
	this.Hide=function(){
		if(IE)this.Object.style.visibility='hidden';
		else if(NS)this.Object.visibility='hide';
		this.visible=false;
	}
	this.Width=function(){
		if(IE)return this.Object.offsetWidth;
		else if(NS)return this.Object.clip.width;
	}
	this.Height=function(){
		if(IE)return this.Object.offsetHeight;
		else if(NS)return this.Object.clip.height;
	}
	this.Top=function(){
		if(IE)return parseInt(this.Object.style.top);
		else if(NS)return this.Object.top;
	}
	this.Left=function(){
		if(IE)return parseInt(this.Object.style.left);
		else if(NS)return this.Object.left;
	}
	this.Move=function(left, top){
		if(IE){this.Object.style.left=left;this.Object.style.top=top;}
		else if(NS){this.Object.left=left;this.Object.top=top;}
	}
	if(IE){
		document.write('<div id=lay' + this.Index + ' style="position:absolute;left:' + left + 'px;top:' + top + 'px;">' + tag + '</div>');
		this.Object=document.all['lay' + this.Index];
	}
	else if(NS){
		document.write('<layer id=lay' + this.Index + ' left=' + left + ' top=' + top + '>' + tag + '</layer>');
		this.Object=document.layers['lay' + this.Index];		
	}
}

///////////////////////////////
// FIN DU CODE DU MENU       //
///////////////////////////////
