var popArgs,  // tableau des argument d'appel (onload body)
	popTabLink;	// tableau des liens <a> des menus

function Pop_init()
// Paramètre d'appel
// P0
// P1
// P2	- si 1, animation lors de l'affichage des menus
// P3	- pour déplacer les sous-menu sur l'axe des Y (en pourcentage de la taille du menu appelant)
// P4   - pour déplacer les sous-menu sur l'axe des X (en pourcentage de la taille du menu appelant)
{ 
 var i,g,tD,tA,tU,pp,lvl,ev,tn=navigator.userAgent.toLowerCase();
 var leftCol,rightCol,centralId,topId,intcolId,contentId,centralHeight,centralWidth,topHeight,infoId;

 	if(window.opera)
	{
	 if(tn.indexOf("opera 5")>-1||tn.indexOf("opera 6")>-1)
	 	{return;}
	}
	else if(!document.getElementById)
		{return;}

 	popArgs=arguments;
	popTabLink=new Array;
	tD=document.getElementById('popMenu');

	if(tD)
	{
		// Récupération des lien <a>
		tA=tD.getElementsByTagName('A');

	 	for(i=0;i<tA.length;i++)
		{
			// tA[i].popMenuIndex : index du menu
			tA[i].popMenuIndex=popTabLink.length;
			popTabLink[popTabLink.length]=tA[i];
			g=tA[i].parentNode.getElementsByTagName("UL");
			
			//tA[i].popSubmenu : contient false si pas de sous-menu ou le sous-menu sinon
			tA[i].popSubmenu=(g&&g[0])?g[0]:false;
			ev=tA[i].getAttribute("onmouseover");
			if(!ev||ev=='undefined')
			{
				tA[i].onmouseover=function()
				{
					// Positionnement du trigger onmouseover
					Pop_Trigger(this);
				};
			}
			ev=tA[i].getAttribute("onfocus");
			if(!ev||ev=='undefined')
			{
				tA[i].onfocus=function()
				{
					// Positionnement du trigger onfocus
					Pop_Trigger(this);
				};
			}
			if(tA[i].popSubmenu)
			{
				pp=tA[i].parentNode;
				lvl=0;
				while(pp)
				{
					if(pp.tagName&&pp.tagName=="UL")
					{
							lvl++;
					}
					pp=pp.parentNode;
				}
			// Level des menu ayant des sous-menus (1 pour les menus principaux)
			tA[i].popMenuLevel=lvl;
			}
		}
		tD.onmouseout=Pop_Close;
		Pop_Open();
	}
	// Validation de la hauteur-min de info
	infoId=document.getElementById('info');
	if (infoId)
	{
		if (infoId.offsetHeight < 500)
		{
			infoId.style.height=500;
		}
	}	

	// Calculs de longueur
	centralId=document.getElementById('centralId');
	if (centralId)
	{
		centralHeight=centralId.offsetHeight;
		centralWidth=centralId.offsetWidth;
		leftCol=document.getElementById('leftcol');
		if (leftCol)
		{
			leftCol.style.height=centralHeight+'px';
			centralWidth+=leftCol.offsetWidth;
		}	
		rightCol=document.getElementById('rightcol');
		if (rightCol)
		{
			rightCol.style.height=centralHeight+'px';
			centralWidth+=rightCol.offsetWidth;
		}	
		topId=document.getElementById('top');
		if (top)
		{
			topHeight=topId.offsetHeight;
			intcolId=document.getElementById('intcolleft');
			if (intcolId)
			{
				intcolId.style.height=(centralHeight-topHeight)+'px';
			}	
			intcolId=document.getElementById('intcolright');
			if (intcolId)
			{
				intcolId.style.height=(centralHeight-topHeight)+'px';
			}	
		}
		contentId=document.getElementById('content');
		if (contentId)
		{
			contentId.style.width=(centralWidth+5)+'px';
		}	
	}
	googleload();
}

function googleload () {
    var latlng = new google.maps.LatLng(48.227550, 7.169750);
    var myOptions = {
      zoom: 15,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.SATELLITE
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);
	var marker = new google.maps.Marker({
      position: latlng, 
      map: map, 
      title:"Eglise de Saint-Pierre sur l'Hâte"
  });           
}

function Pop_Trigger(a)
{
	var b,t;
	
	if(document.popMenuTimer)
	{
	 	clearTimeout(document.popMenuTimer);
	}
	document.popMenuStatus=1;
	b=(a.popSubmenu)?'Pop_Show(':'Pop_HidePrev(';
	t='document.popMenuTimer=setTimeout("'+b+a.popMenuIndex+')",100)';
	// Au déclanchement du timer, appeler:
	//		Pop_Show s'il y a des sous-menus
	//      Pop_HidePrev sinon
	eval (t);
}	

function Pop_Close(evt)
{
	var pp,st,tS,m=true;
	evt=(evt)?evt:((event)?event:null);
	st=document.popMenuStatus;
	if(st!=-1)
	{
		if(evt)
		{
			tS=(evt.relatedTarget)?evt.relatedTarget:evt.toElement;
			if(tS)
			{
				pp=tS.parentNode;
				while(pp)
				{
					if(pp&&pp.id&&pp.id=="popMenu")
					{
						m=false;
						document.popMenuStatus=1;
						break;
					}
					pp=pp.parentNode;
				}
			}
			if(m)
			{
				document.popMenuStatus=-1;
				if(document.popMenuTimer)
				{
					clearTimeout(document.popMenuTimer);
				}
				document.popMenuTimer=setTimeout("Pop_Clear()",360);
			}
		}
	}
}

function Pop_Clear()
{ 
	var i,tU,tUU;
	document.popMenuStatus=-1;
	tU=document.getElementById('popMenu');
	if(tU)
	{
		tUU=tU.getElementsByTagName("UL");
		if(tUU)
		{
			for(i=tUU.length-1;i>-1;i--)
			{
				Pop_Hide(tUU[i]);
			}
		}
	}
}

function Pop_Open()
{ 
	var i,x,tA,op,pp,wH,tA,k=-1,kk=-1,mt=new Array(1,'','');
	
	op=mt[0];
	if(op<1)
		{return;}
	tA=document.getElementById('popMenu').getElementsByTagName("A");
	wH=window.location.href;
	for(i=0;i<tA.length;i++)
	{
		if(tA[i].href)
		{
			if(op>0)
			{
				if(tA[i].href==wH)
				{
					k=i;
					kk=-1;
					break;
				}
			}
			if(op==2)
			{
				if(tA[i].firstChild)
				{
					if(tA[i].firstChild.nodeValue==mt[1])
					{
						kk=i;
					}
				}
			}
			if(op==3 && tA[i].href.indexOf(mt[1])>-1)
			{
				kk=i;
			}
			if(op==4)
			{
				for(x=1;x<mt.length;x+=2)
				{
					if(wH.indexOf(mt[x])>-1)
					{
						if(tA[i].firstChild&&tA[i].firstChild.data)
						{
							if(tA[i].firstChild.data==mt[x+1])
							{
								kk=i;
								break;
							}
						}
					}
				}
			}
		}
	}
	k=(kk>k)?kk:k;
	if(k>-1)
	{
		pp=tA[k].parentNode;
		while(pp)
		{
			if(pp.nodeName=="LI")
			{
				pp.firstChild.className="p7PMmark"+" "+pp.firstChild.className;
			}
			pp=pp.parentNode;
		}
	}
	if(kk>-1)
	{
		document.p7PMad=1;
	}
	P7_PMadma();
	P7_PMadmb();
}

function Pop_Show(a,bp)
{
	var u,lv,oft,ofr,uw,uh,pp,aw,ah,adj,mR,mT,wW=0,wH,w1,w2,w3,sct,pw,lc,pwv,xx=0,yy=0,wP=true;

	var iem=(navigator.appVersion.indexOf("MSIE 5")>-1)?true:false,dce=document.documentElement,dby=document.body;
	document.popMenuStatus=1;
	if(!bp)
	{
			Pop_HidePrev(a);
	}
	u=popTabLink[a].popSubmenu;

	if(u.p7pmax==1)
		{return;}
	
	u.p7pmax=1;
	lv=(popArgs[0]==1&&popTabLink[a].popMenuLevel==1)?true:false;
	popTabLink[a].className=popTabLink[a].className.replace("popUndefClass","popColor");
	oft=parseInt(popArgs[3]);
	ofr=parseInt(popArgs[4]);
	uw=u.offsetWidth;
	uh=u.offsetHeight;
	pp=popTabLink[a];
	aw=pp.offsetWidth;
	ah=pp.offsetHeight;
	while(pp)
	{
		xx+=(pp.offsetLeft)?pp.offsetLeft:0;
		yy+=(pp.offsetTop)?pp.offsetTop:0;
		if(window.opera||navigator.userAgent.indexOf("Safari")>-1)
		{
			if(popTabLink[a].popMenuLevel!=1&&pp.nodeName=="BODY")
			{
				yy-=(pp.offsetTop)?pp.offsetTop:0;
			}
		}
		pp=pp.offsetParent;
	}
	if(iem&&navigator.userAgent.indexOf("Mac")>-1)
	{
			yy+=parseInt(dby.currentStyle.marginTop);
	}
	adj=parseInt((aw*ofr)/100);
	mR=(lv)?0:aw-adj;
	adj=parseInt((ah*oft)/100);
	mT=(lv)?0:(ah-adj)*-1;
	w3=dby.parentNode.scrollLeft;
	if(!w3)
		{w3=dby.scrollLeft;}
	w3=(w3)?w3:0;
	if(dce&&dce.clientWidth)
	{
			wW=dce.clientWidth+w3;
	}
	else if(dby)
	{
		wW=dby.clientWidth+w3;
	}
	if(!wW)
	{
		wW=0;
		wP=false;
	}
	wH=window.innerHeight;
	if(!wH)
	{
		wH=dce.clientHeight;
		if(!wH||wH<=0)
		{
			wH=dby.clientHeight;
		}
	}
	sct=dby.parentNode.scrollTop;
	if(!sct)
	{
		sct=dby.scrollTop;
		if(!sct)
		{
			sct=window.scrollY?window.scrollY:0;
		}
	}
	pw=xx+mR+uw;
	if(pw>wW&&wP)
	{
		mR=uw*-1;mR+=10;
		if(lv)
		{
			mR=(wW-xx)-uw;
		}
	}
	lc=xx+mR;
	if(lc<0)
	{
		mR=xx*-1;
	}
	pw=yy+uh+ah+mT-sct;
	pwv=wH-pw;
	if(pwv<0)
	{
		mT+=pwv;
		if(uh>wH)
		{
			mT=(yy+ah-sct)*-1;
		}
	}
	// mR : décalage à gauche des sous-menus
	// mT : décalage vers le bas des sous-menus
	u.style.marginLeft=mR+'px';
	u.style.marginTop=mT+'px';
	if(popArgs[2]==1)
	{
		if(!iem)
		{
			P7_PManim(a,20);
		}
	}
	u.className="popShow";
}


function P7_PManim(a,st)
{
	var g=popTabLink[a].popSubmenu,sp=30,inc=20;
	st=(st>=100)?100:st;
	g.style.fontSize=st+"%";
	if(st<100)
	{
		st+=inc;
		setTimeout("P7_PManim("+a+","+st+")",sp);
	}
}


function Pop_HidePrev(a,b)
{
	var i,u,tA,tU,pp;
	tA=popTabLink[a];
	pp=tA.parentNode;
	// Remonter les tags jusqu'au premier <ul>
	while(pp)
	{
		if(pp.tagName=="UL")
		{
			break;
		}
		pp=pp.parentNode;
	}
	if(pp)
	{
		tU=pp.getElementsByTagName("UL");
		// Pour tous les sous-tags UL  : appeler hide.
		for(i=tU.length-1;i>-1;i--)
		{
			if(b!=1&&tA.popSubmenu==tU[i])
			{
				continue;
			}
			else
			{
				Pop_Hide(tU[i]);
			}
		}
	}
}
	
function Pop_Hide(u)
{ 
	var i,tt,ua;
	u.p7pmax=0;
	u.className="popHide";
	ua=u.parentNode.firstChild;
	ua.className=ua.className.replace("popColor","popUndefClass");
}
	
function P7_PMadma()
{
}	
function P7_PMadmb()
{
}	

