var SWinW,SWinH,FWinW,FWinH;
var SLdAgnWin;
var FColW,SColW,DColW;
var RLvl=0;
var FrstCreat=1,Ldd=0,Crtd=0,IniFlg;
var FrstCntnr=null,CurOvr=null,CloseTmr=null;
var ImgStr;
var Ztop=100;
var ShwFlg=0;
var M_StrtTp, M_StrtLft;
var StaticPos=0;
var LftXtra=DomNav?LeftPaddng:0;
var TpXtra=DomNav?TopPaddng:0;
var M_Hide=Nav4?'hide':'hidden';
var M_Show=Nav4?'show':'visible';
var Par=window;
var Doc=Par.document;
var Bod=Doc.body;
var Trigger=NavYes?Par:Bod;
var StartTop=0;				
var StartLeft=0;
       			
	

if(Nav4)FontSize++;
function main(top,left,numberOfOptions)
{	
	
	NoOffFirstLineMenus=numberOfOptions;
	M_StrtTp=StartTop=top;	
	M_StrtLft=StartLeft=left;				
	
	
	if(Trigger.onload)Dummy=Trigger.onload;
	if(DomNav&&!Opr)Trigger.addEventListener('load',Go,false);
	else Trigger.onload=Go;
}
function Dummy(){return}

function CnclSlct(){return false}

function Go(){

	//Dummy();
	if(Ldd||!PosStrt)return;
	Crtd=0; Ldd=1;
	status='Building menu';
	if(FrstCreat){
		FWinW=ExpYes?window.document.body.clientWidth:window.innerWidth;
		FWinH=ExpYes?window.document.body.clientHeight:window.innerHeight;
		SWinW=ExpYes?window.document.body.clientWidth:window.innerWidth;
		SWinH=ExpYes?window.document.body.clientHeight:window.innerHeight;
		}
	FColW=Nav4?window.document:window.document.body;
	SColW=Nav4?window.document:window.document.body;
	DColW=Nav4?window.document:window.document.body;
	if(FrstCreat){
		FrstCntnr=CreateMenuStructure("Menu",NoOffFirstLineMenus);
		FrstCreat=0;}
	else CreateMenuStructureAgain("Menu",NoOffFirstLineMenus);
	PosMenu(FrstCntnr,StartTop,StartLeft);
	IniFlg=1;
	Initiate();
	Crtd=1;
	SLdAgnWin=ExpYes?window.document.body:window;
	status='Menu is ready'}


function PosMenu(Ct,Tp,Lt){
	var Ti,Li,Hi;
	var Mb=Ct.FrstMbr;
	var CStl=!Nav4?Ct.style:Ct;
	var MStl=!Nav4?Mb.style:Mb;
	var PadL=Mb.value.indexOf('<')==-1?LftXtra:0;
	var PadT=Mb.value.indexOf('<')==-1?TpXtra:0;
	var MWt=!Nav4?parseInt(MStl.width)+PadL:MStl.clip.width;
	var MHt=!Nav4?parseInt(MStl.height)+PadT:MStl.clip.height;
	var CWt=!Nav4?parseInt(CStl.width):CStl.clip.width;
	var CHt=!Nav4?parseInt(CStl.height):CStl.clip.height;
	var CCw,CCh;
	var STp,SLt;
	RLvl++;
	CStl.top=RLvl==1?Tp:0;
	Ct.OrgTop=Tp;
	CStl.left=RLvl==1?Lt:0;
	Ct.OrgLeft=Lt;
	Hi=Li=0;Ti=CHt-MHt-2*1;

	while(Mb!=null){
		MStl.left=Li+1;
		MStl.top=Ti+1;
		if(Nav4)Mb.CLyr.moveTo(Li+1,Ti+1);
		if(Mb.CCn){
			if(Hi){	STp=Ti+MHt+2*1;
				SLt=Li}
			else{	SLt=Li+(1-ChildOverlap)*MWt+1;
				STp=RLvl==1?Ti:Ti+ChildVerticalOverlap*MHt}
			PosMenu(Mb.CCn,STp,SLt)}
		Mb=Mb.PrvMbr;
		if(Mb){	MStl=!Nav4?Mb.style:Mb;
			PadL=Mb.value.indexOf('<')==-1?LftXtra:0;
			PadT=Mb.value.indexOf('<')==-1?TpXtra:0;
			MWt=!Nav4?parseInt(MStl.width)+PadL:MStl.clip.width;
			MHt=!Nav4?parseInt(MStl.height)+PadT:MStl.clip.height;
			Hi?Li-=BorderBtwnElmnts?(MWt+1):(MWt):Ti-=BorderBtwnElmnts?(MHt+1):MHt}}
	RLvl--}

function Initiate(){
	if(IniFlg){Init(FrstCntnr);IniFlg=0;if(ShwFlg)AfterCloseAll();ShwFlg=0}}

function Init(CPt){
	var Mb=CPt.FrstMbr;
	var MCSt=Nav4?CPt:CPt.style;
	RLvl++;
	MCSt.visibility=RLvl==1?M_Show:M_Hide;
	while(Mb!=null){
		if(Mb.Hilite){Mb.Hilite=0;LowItem(Mb);}
		if(Mb.CCn) Init(Mb.CCn);
		Mb=Mb.PrvMbr}
	RLvl--}

function ClrAllChlds(Pt){ 
	var PSt;
	while (Pt){	if(Pt.Hilite){Pt.Hilite=0;
			LowItem(Pt);
			if(Pt.CCn){
				PSt=Nav4?Pt.CCn:Pt.CCn.style;
				PSt.visibility=M_Hide;
				ClrAllChlds(Pt.CCn.FrstMbr)}
			break}
		Pt=Pt.PrvMbr}}

function GoTo(){
	if(this.Lnk){
		status='';
		var HP=Nav4?this.LLyr:this;
		LowItem(HP);
		IniFlg=1;Initiate();
		this.Lnk.indexOf('javascript:')!=-1?eval(this.Lnk):window.location.href=this.Lnk}}

function HiliteItem(P){
	if(Nav4){
          if(P.HiB)P.bgColor=P.HiB;
          P.document.write(P.Ovalue);
	  P.document.close()}
	else{	
          if(P.HiB)P.style.backgroundColor=P.HiB;
	  if(P.HiF)P.style.color=P.HiF}
	P.Hilite=1}

function LowItem(P){
	if(Nav4){
          if(P.LwB)P.bgColor=P.LwB;
          P.document.write(P.value);
	  P.document.close()}
	else{	
          if(P.LwB)P.style.backgroundColor=P.LwB;
          if(P.LwF)P.style.color=P.LwF}}

function OpenMenu(){	
	if(!Ldd||!Crtd) return;
	var TS=ExpYes?window.document.body.scrollTop:window.pageYOffset;
	var LS=ExpYes?window.document.body.scrollLeft:window.pageXOffset;
	var CCnt=Nav4?this.LLyr.CCn:this.CCn;
	var THt=Nav4?this.clip.height:parseInt(this.style.height);
	var TWt=Nav4?this.clip.width:parseInt(this.style.width);
	
	var TLt=Nav4?this.Ctnr.left:parseInt(this.Ctnr.style.left);
	var TTp=Nav4?this.Ctnr.top:parseInt(this.Ctnr.style.top);
	
	
	var HP=Nav4?this.LLyr:this;
	CurOvr=this;
	IniFlg=0;
	ClrAllChlds(this.Ctnr.FrstMbr);
	HiliteItem(HP);
	if(CCnt!=null){
		if(!ShwFlg){ShwFlg=1;	BeforeFirstOpen()}
		var CCW=Nav4?this.LLyr.CCn.clip.width:parseInt(this.CCn.style.width);
		var CCH=Nav4?this.LLyr.CCn.clip.height:parseInt(this.CCn.style.height);
		var CCSt=Nav4?this.LLyr.CCn:this.CCn.style;
		var SLt=this.Lvl==1?CCnt.OrgLeft+TLt+LS:CCnt.OrgLeft+TLt;
		var STp=this.Lvl==1?CCnt.OrgTop+TTp:CCnt.OrgTop+TTp;
		if(MenuWrap){
				if(SLt+CCW>SWinW+LS)SLt=this.Lvl==1?SWinW+LS-CCW:SLt-(CCW+(1-2*ChildOverlap)*TWt);
				if(SLt<LS)SLt=LS;
			 	if(STp+CCH>TS+SWinH)STp=this.Lvl==1?STp=TS+SWinH-CCH:STp-CCH+(1-2*ChildVerticalOverlap)*THt;
				if(STp<TS)STp=TS;}
		CCSt.top=STp;CCSt.left=SLt;CCSt.visibility=M_Show}
	status=this.Lnk}

function OpenMenuClick(){
	if(!Ldd||!Crtd) return;
	var HP=Nav4?this.LLyr:this;
	CurOvr=this;
	IniFlg=0;
	ClrAllChlds(this.Ctnr.FrstMbr);
	HiliteItem(HP);
	status=this.Lnk}

function CloseMenu(){
	if(!Ldd||!Crtd) return;
	status='';
	if(this==CurOvr){
		IniFlg=1;
		if(CloseTmr)clearTimeout(CloseTmr);
		CloseTmr=setTimeout('Initiate(CurOvr)',DissapearDelay)}}

function CntnrSetUp(W,H,WMu){
	var x=BorderColor;
	this.FrstMbr=null;
	this.OrgLeft=this.OrgTop=0;
	if(Nav4){	if(x)this.bgColor=x;
                        if(RLvl==1)this.bgColor="#ffffff";
		this.visibility='hide';
		this.resizeTo(W,H)}
	else{	if(x&&RLvl!=1)this.style.backgroundColor=x;
                if(RLvl==1)this.style.backgroundColor="#ffffff";
		this.style.width=W;
		this.style.height=H;
		this.style.fontFamily=FontFamily;
		this.style.fontWeight=FontBold?'bold':'normal';
		this.style.fontStyle='normal';
		this.style.fontSize=FontSize+'pt';
		this.style.zIndex=RLvl+Ztop}}

function MbrSetUp(MbC,PrMmbr,WMu,Wd,Ht){
	
	var Tfld=eval(WMu+'[0]');
	var t,T,L,W,H,S;
	var a;
	this.PrvMbr=PrMmbr;
	this.Lvl=RLvl;
	this.Lnk=eval(WMu+'[1]');
	this.Ctnr=MbC;
	this.CCn=null;
	this.Hilite=0;
	this.style.overflow='hidden';
	this.style.cursor=ExpYes&&(this.Lnk||RLvl==1)?'hand':'default';	
	this.value=Tfld;
	this.LwB=LowBgColor;
	this.LwF=FontLowColor;
	this.HiB=HighBgColor;
	this.HiF=FontHighColor;
	this.style.color=this.LwF;
	if(this.LwB)this.style.backgroundColor=this.LwB;
	this.style.textAlign='left';
	if(Tfld.indexOf('<')==-1){
		this.style.width=Wd-LftXtra;
		this.style.height=Ht-TpXtra;
		this.style.paddingLeft=LeftPaddng;
		this.style.paddingTop=TopPaddng}
	else{	this.style.width=Wd;
		this.style.height=Ht}
	if(Tfld.indexOf('<')==-1&&DomYes){
		t=window.document.createTextNode(Tfld);
		this.appendChild(t)}
	else this.innerHTML=Tfld;
	if(ExpYes){this.onselectstart=CnclSlct;
		this.onmouseover=OpenMenu;
		this.onmouseout=CloseMenu;
		this.onclick=GoTo	}
	else{	this.addEventListener('mouseover',OpenMenu,false);
		this.addEventListener('mouseout',CloseMenu,false);
		this.addEventListener('click',GoTo,false);

}}

function NavMbrSetUp(MbC,PrMmbr,WMu,Wd,Ht){
	var a;
	this.value=eval(WMu+'[0]');
	if(LeftPaddng&&this.value.indexOf('<')==-1)this.value='&nbsp\;'+this.value;
	if(FontBold)this.value=this.value.bold();
	this.Ovalue=this.value;
	this.value=this.value.fontcolor(FontLowColor);
	this.Ovalue=this.Ovalue.fontcolor(FontHighColor);
	this.value="<font face='"+FontFamily+"' point-size='"+FontSize+"'>"+this.value;
	this.Ovalue="<font face='"+FontFamily+"' point-size='"+FontSize+"'>"+this.Ovalue;
	this.LwB=LowBgColor;
	this.HiB=HighBgColor;
	this.CCn=null;
	this.PrvMbr=PrMmbr;
	this.Hilite=0;
	this.visibility='inherit';
	if(this.LwB)this.bgColor=this.LwB;
	this.resizeTo(Wd,Ht);
	this.document.write(this.value);
	this.document.close();
	this.CLyr=new Layer(Wd,MbC);
	this.CLyr.Lvl=RLvl;
	this.CLyr.Lnk=eval(WMu+'[1]');
	this.CLyr.visibility='inherit';
	this.CLyr.onmouseover=OpenMenu;
	this.CLyr.onmouseout=CloseMenu;
	this.CLyr.captureEvents(Event.MOUSEUP);
	this.CLyr.onmouseup=GoTo;
	this.CLyr.LLyr=this;
	this.CLyr.resizeTo(Wd,Ht);
	this.CLyr.Ctnr=MbC;}

function CreateMenuStructure(MNm,No){
	RLvl++;
	var i,NOs,Mbr,W=0,H=0;
	var PMb=null;
	var WMnu=MNm+'1';
	var MWd=eval(WMnu+'[4]');
	var MHt=eval(WMnu+'[3]');
	
		for(i=1;i<No+1;i++){
			WMnu=MNm+eval(i);
			H=eval(WMnu+'[3]')?H+eval(WMnu+'[3]'):H+MHt}
		H=BorderBtwnElmnts?H+(No+1)*1:H+2*1;W=MWd+2*1;
	if(DomYes){
		var MbC=window.document.createElement("div");
		MbC.style.position='absolute';
		MbC.style.visibility='hidden';
		window.document.body.appendChild(MbC)}
	else{	if(Nav4) var MbC=new Layer(W,window)
		else{	WMnu+='c';
			window.document.body.insertAdjacentHTML("AfterBegin","<div id='"+WMnu+"' style='visibility:hidden; position:absolute;'><\/div>");
			var MbC=window.document.all[WMnu]}}
	MbC.SetUp=CntnrSetUp;
	MbC.SetUp(W,H,MNm+'1');
	if(Exp4){	MbC.InnerString='';
		for(i=1;i<No+1;i++){
			WMnu=MNm+eval(i);
			MbC.InnerString+="<div id='"+WMnu+"' style='position:absolute;'><\/div>"}
		MbC.innerHTML=MbC.InnerString}
	for(i=1;i<No+1;i++){
		WMnu=MNm+eval(i);
		NOs=eval(WMnu+'[2]');
W=RLvl==1&&0?eval(WMnu+'[4]')?eval(WMnu+'[4]'):MWd:MWd;
H=RLvl==1&&0?MHt:eval(WMnu+'[3]')?eval(WMnu+'[3]'):MHt;

		if(DomYes){
			Mbr=window.document.createElement("div");
			Mbr.style.position='absolute';
			Mbr.style.visibility='inherit';
			MbC.appendChild(Mbr)}
		else Mbr=Nav4?new Layer(W,MbC):window.document.all[WMnu];
		Mbr.SetUp=Nav4?NavMbrSetUp:MbrSetUp;
		Mbr.SetUp(MbC,PMb,WMnu,W,H);
		if(NOs) Mbr.CCn=CreateMenuStructure(WMnu+'_',NOs);
		PMb=Mbr}
	MbC.FrstMbr=Mbr;
	RLvl--;
	return(MbC)}


