function GetBrowserID(){
	var browser="None";
	if(navigator.appName.indexOf("Netscape")>=0&&parseFloat(navigator.appVersion)>=4){browser="NS4";version=4;}
	if(document.getElementById){browser="NS6";
		if(navigator.userAgent.indexOf("6.01")!=-1||navigator.userAgent.indexOf("6.0")!=-1){version=6;}else{version=6.1;}}
	if(document.all){if(document.getElementById){version=5;}else{version=4;}browser="IE";}
	if(navigator.userAgent.indexOf("Opera" )!=-1){browser="Opera";
	if(navigator.userAgent.indexOf("7."    )!=-1){version=7;}else{version=6;}}
	if(navigator.userAgent.indexOf("Safari")!=-1){isSafari=true;}else{isSafari=false;}return browser;
};
function GetOSID(){
	var os=navigator.userAgent;
	if(os.indexOf("Mac")!=-1){os="Mac";}else{os="Win";}return os;
};
function GetByLayer(layerName){return(document.getElementById(layerName)!=null);};
function SetVisibility(element,show){
	var vis;if(show){vis="visible";}else{vis="hidden";}
	if(browser=="IE"&&os=="Win"){if(document.all[element]!=null){if(document.all[element].style.visibility!=vis){
		var i;
		var obj=document.all[element].filters;
		if(obj)	{for(i=0;obj[i];i++){obj[i].apply();}document.all[element].style.visibility=vis;
			 for(i=0;obj[i];i++){obj[i].play();}}
		else	{document.all[element].style.visibility=vis;}
	}}}
	if(browser=="IE"&&os=="Mac"){if(document.all[element]!=null){
		if(document.all[element].style.visibility!=vis)document.all[element].style.visibility=vis;
	}}
	if(browser=="NS6"||browser=="Opera"){if(document.getElementById(element)!=null){
		if(document.getElementById(element).style.visibility!=vis)document.getElementById(element).style.visibility=vis;
	}}
};
function SetBgColor(element,bgColor){
	if(browser=="Opera"&&version<7){return;}
	if(GetByLayer(element)){document.getElementById(element).style.background=bgColor;}
};
function SetFgColor(element,fgColor){
	if(browser=="Opera"&&version<7){return;}
	if(GetByLayer(element)){document.getElementById(element).style.color=fgColor;}
};
function SetLeft(element,left)	 {	 document.getElementById(element).style.left=left+'px';};
function SetTop (element,top)	 {	 document.getElementById(element).style.top=top+'px';};
function GetOffsetLeft  (element){return(document.getElementById(element).offsetLeft);};
function GetOffsetTop   (element){return(document.getElementById(element).offsetTop);};
function GetOffsetHeight(element){return(document.getElementById(element).offsetHeight);};
function GetOffsetWidth (element){return(document.getElementById(element).offsetWidth);};
function GetPageWidth(){
	if(browser=="NS6"||browser=="Opera"){return(window.innerWidth+window.pageXOffset-18);}
	if(browser=="IE"){var obj=document.body.parentNode;if(isNaN(obj.clientWidth )||obj.clientWidth==0 ){
			      obj=document.body;}return(obj.scrollLeft+obj.clientWidth);}
};
function GetPageHeight(){
	if(browser=="NS6"||browser=="Opera"){return(window.innerHeight+window.pageYOffset-18);}
	if(browser=="IE"){var obj=document.body.parentNode;if(isNaN(obj.clientHeight)||obj.clientHeight==0){
			      obj=document.body;}return(obj.scrollTop+obj.clientHeight);}
};
function GetPageXOffset(){
	if(browser=="NS6"||browser=="Opera"){return(window.pageXOffset);}
	if(browser=="IE"){var obj=document.body.parentNode;if(isNaN(obj.scrollLeft)||obj.scrollLeft==0){
			      obj=document.body;}return(obj.scrollLeft);}
};
function GetPageYOffset(){
	if(browser=="NS6"||browser=="Opera"){return(window.pageYOffset);}
	if(browser=="IE"){var obj=document.body.parentNode;if(isNaN(obj.scrollTop )||obj.scrollTop==0 ){
			      obj=document.body;}return(obj.scrollTop);}
};
browser=GetBrowserID();
os=GetOSID();
state=new SetState();
function SetState(){
	this.menuActive=false;
	this.submenuArray=new Array(50);
	this.mainmenuArray=new Array(5);
	this.activemenuArray=new Array(10);
	this.timeoutidArray=new Array(50);
	this.imac=0; this.mmcp=0; this.smcp=0; this.mmac=0; this.smac=0; this.amac=0; this.tiac=0;
	this.onclick=false;
	this.hideidArray=null;
	this.mtopoffset=0;
	this.mleftoffset=0;
	this.CreateMenu=false;
	this.LoadMenu=false;
	this.menuReady=false;
	this.menuStatus=1;
	this.position='bottom';
	this.closedelay=500;
	this.hspacing=5;
	this.columns=1;
	this.textalign='left';
	this.offset=0;
	this.width='';
	this.IsRelative=function(str){
		if(str==null)				{return false;}
		if(str=='null')				{return false;}
		if(str=='')				{return false;}
		if(str.search(/^\/+/i)!=-1)		{return false;}
		if(str.search(/^http:/i)!=-1)		{return false;}
		if(str.search(/^javascript:/i)!=-1)	{return false;}
		return true;
	};
	this.ProcUrl=function(str){if(state.IsRelative(str)){return path+str;}else{return str;}};
	this.StaticMenu=function(){for(var i=0;i<state.mmac;i++){
		var menu=state.mainmenuArray[i];
	}};
};
function Menu(menuName){
	this.itemArray=new Array(30);
	this.iac=0;
	this.count=1;
	if(menuName=='0'){
		state.mainmenuArray[state.mmac++]=this;
		this.name=state.mmac;
		this.isMain=true;
		this.staticX=0;
		this.staticY=0;
	}
	else{
		state.submenuArray[state.smac++]=this;
		this.name=state.mmac+'i'+menuName;
		this.isMain=false;
		this.staticX=-500;
		this.staticY=-500;
	}
	this.offset=state.offset;
	this.fontFamily=state.fontFamily;
	this.fontStyle=state.fontStyle;
	this.fontSize=state.fontSize;	this.sfontSize=state.sfontSize;
	this.fontWeight=state.fontWeight;
// main menu
	this.hlayerpadding=state.hlayerpadding;
	this.vlayerpadding=state.vlayerpadding;
	this.cellpadding=state.cellpadding;
	this.bdrsize=state.bdrsize;	this.hbdrsize=state.hbdrsize;	 // border size
	this.bdrcolor=state.bdrcolor;	this.hbdrcolor=state.hbdrcolor;	 // border color
	this.nbgcolor=state.nbgcolor;	this.hbgcolor=state.hbgcolor;	 // background color
	this.nftcolor=state.nftcolor;	this.hftcolor=state.hftcolor;	 // font color
// submenus
	this.shlayerpadding=state.shlayerpadding;
	this.svlayerpadding=state.svlayerpadding;
	this.scellpadding=state.scellpadding;
	this.sbdrsize=state.sbdrsize;	this.shbdrsize=state.shbdrsize;	 // border size
	this.sbdrcolor=state.sbdrcolor;	this.shbdrcolor=state.shbdrcolor;// border color
	this.snbgcolor=state.snbgcolor;	this.shbgcolor=state.shbgcolor;	 // background color
	this.snftcolor=state.snftcolor;	this.shftcolor=state.shftcolor;	 // font color

	this.position=state.position;
	this.hspacing=state.hspacing;
	this.textalign=state.textalign;
	this.item='';
	this.width=state.width;
	this.style='';
	this.BuildMenu=function(){
		if(!this.isMain){document.writeln('<div id="'+this.name+'" align="left" style="position:absolute; ');
				 document.writeln('background-color:'+this.snbgcolor+';z-index:30;visibility:hidden; ');
				 document.writeln('left:'+this.staticX+'px;top:'+this.staticY+'px;" ');
				 document.writeln('onmouseout="state.menuActive=false;" onmouseover="state.menuActive=true;">');}
		document.writeln('<table id="'+this.name+'table" width="'+this.width+'px" border="0px" ');
		document.writeln('onmouseout="state.menuActive=false;" onmouseover="state.menuActive=true;" ');
		if(this.isMain)	{document.writeln('bgcolor="'+this.nbgcolor+'" cellpadding="'+this.cellpadding+'px">')}
		else		{document.writeln('bgcolor="'+this.snbgcolor+'" cellpadding="'+this.scellpadding+'px">');}
		document.writeln(this.item+'</table>');
		if(!this.isMain){document.writeln('</div>');}
	};
	this.AddItem=function(){this.AddMenuItem(true,arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]);};
	this.AddMenuItem=function(){
		var addr,tip;
		var bdr,hbdr,borderNone='';
		var mname=this.name+'itm'+this.count;
		text=arguments[1];
		addr=state.ProcUrl(arguments[2]);
		tip=arguments[5];
		if(tip==null){tip='';}
		this.style ='font-weight:'+this.fontWeight+';text-decoration:'+this.textDecoration+';';
		this.style+='font-family:'+this.fontFamily+';font-style:'+this.fontStyle+'; font-size:';
		if(this.isMain)	{this.style+=this.fontSize+';'} else {this.style+=this.sfontSize+';'};
		if(this.cellspacing==0){
			if(this.count!=this.tdc){borderNone+='border-top: none; ';}
		}
		if(this.tdc==1){this.item+='<tr>';}
		else{if(this.hspacing!=0){
			this.item+='<td width="'+this.hspacing+'px"> <font color="';
			if(this.isMain)	{this.item+=this.nftcolor;} else {this.item+=this.snftcolor;}
			this.item+='" style="'+this.style+'">&nbsp;</font></td>';}
		}
		nbdr=this.hbdrsize +'px solid '+this.nbdrcolor; snbdr=this.snbdrsize+'px solid '+this.snbdrcolor;
		hbdr=this.hbdrsize +'px solid '+this.hbdrcolor; shbdr=this.shbdrsize+'px solid '+this.shbdrcolor;
		if(this.isMain)	{
			arglist0='\''+this.name+'\',\''+this.count+'\',\''+this.hbgcolor +'\',\''+this.hftcolor +'\',\''+state.imac+'\',\''+hbdr +'\'';
			arglist1='\''+this.name+'\',\''+this.count+'\',\''+this.nbgcolor +'\',\''+this.nftcolor +'\',\''+state.imac+'\',\''+nbdr +'\'';}
		else		{
			arglist0='\''+this.name+'\',\''+this.count+'\',\''+this.shbgcolor+'\',\''+this.shftcolor+'\',\''+state.imac+'\',\''+shbdr+'\'';
			arglist1='\''+this.name+'\',\''+this.count+'\',\''+this.snbgcolor+'\',\''+this.snftcolor+'\',\''+state.imac+'\',\''+snbdr+'\'';}
		var s=''; s=addr.toLowerCase();
		if(s.indexOf("javascript:")==0){s=addr.substring(11,addr.length);}
		else{	if(s.indexOf("'")==-1&&s.indexOf('"')==-1){s='location.href = \''+addr+'\'';}else{s='';}}
		this.item+='<td onmouseover="MenuMouseHover('+arglist0+')"';
		this.item+=' onmouseout="CloseMenu('+arglist1+');" valign="middle">';
		this.item+='<div id="'+mname+'clip" style="position:absolute;width:1px;height:1px" align="'+this.textalign+'"></div>';
		this.item+='<div id="'+mname+'" onmouseover="return;"';
		if(this.isMain)
			{this.item+=' style="border:'+ hbdr+';padding:'+this.vlayerpadding +'px '+this.hlayerpadding +'px '+this.vlayerpadding +'px '+this.hlayerpadding +'px ';}
		else	{this.item+=' style="border:'+shbdr+';padding:'+this.svlayerpadding+'px '+this.shlayerpadding+'px '+this.svlayerpadding+'px '+this.shlayerpadding+'px ';}
		this.item+='" align="'+this.textalign+'">';
		var ret_status=(addr==''?'true':'false');
		this.item+='<a href="'+addr+'" title="'+tip+'" style="text-decoration:none" onmouseover="return '+ret_status+';" onclick="return true;"';
		this.item+='><font id="'+this.name+'a'+this.count+'" style="'+this.style+';color:'
		if(this.isMain)	{this.item+=this.nftcolor;} else {this.item+=this.snftcolor;};
		this.item+=';">'+text+'</font></a>';
		this.item+='</div></td>';this.itemArray[this.iac++]=mname;
		if(this.tdc==this.columns){this.item+='</tr>';this.tdc=1;}else{this.tdc++;}this.count++;
	};
this.columns=state.columns;this.tdc=1;
};
function OpenMenu(){
	if(!state.LoadMenu){return;}
	var name,count;
	var left;
	var top;
	var offset=0;
	var nm1;
	var nm2;
	var isMain=false;
	name=arguments[0];count=arguments[1];
	nm1=name+'i'+count;nm2=name+'itm'+count;
	if(nm1.indexOf('i')==nm1.lastIndexOf('i')){isMain=true;}
	var tmp_amac=state.amac;
	for(var i=0;i<tmp_amac;i++){
		if(state.activemenuArray[i]!=name){
			if(nm1.indexOf(state.activemenuArray[i])==-1)	{SetVisibility(state.activemenuArray[i],false);state.amac--;}
		}
	}
	if(GetByLayer(nm1)){
		state.activemenuArray[state.amac++]=nm1;
		var orientation='bottom';
		for(var i=0;i<state.smac;i++){
			if(state.submenuArray[i].name==nm1){orientation=state.submenuArray[i].position;offset=state.submenuArray[i].offset+0.5*GetPageWidth()-437;break;}
		}
		for(var i=0;i<state.mmac;i++){var menu=state.mainmenuArray[i];if(menu.name==name){isMain=true;}}
		if(isMain){
			left=state.mleftoffset;
			if(orientation=='top'||orientation=='bottom')	{left+=GetOffsetLeft(nm2+'clip');}
			top=GetOffsetTop(nm2+'clip')+state.mtopoffset;
			if(orientation=='bottom')			{top+=GetOffsetHeight(nm2);if(browser=="Opera"){top+=2;}}
		}
		else{
			left=state.mleftoffset;
			if(orientation=='top'||orientation=='bottom')	{left+=GetOffsetLeft(name)+GetOffsetLeft(nm2+'clip');}
			top=GetOffsetTop(name)+GetOffsetTop(nm2+'clip')+state.mtopoffset;
			if(browser=="NS6"&&version!=6.1)		{top=GetOffsetTop(nm2+'clip');}
			if(orientation=='bottom')			{top+=GetOffsetHeight(nm2);}
		}
		left+=offset;
	}
	state.menuActive=true;
	if(GetByLayer(nm1)){
		if(!isSafari){SetLeft(nm1,-800);}
		if(left<GetPageXOffset())			{left=GetPageXOffset();}
		if(left+GetOffsetWidth(nm1)>GetPageWidth())	{left=GetPageWidth()-GetOffsetWidth(nm1);}
		if(top<GetPageYOffset())			{top=GetPageYOffset();}
		if(top+GetOffsetHeight(nm1)>GetPageHeight())	{top=GetPageHeight()-GetOffsetHeight(nm1);}
		SetTop(nm1,top);SetLeft(nm1,left);
		SetVisibility(nm1,true);
		setTimeout('SetzIndex("'+nm1+'", 30)',1);
	}
};
function MenuMouseHover(){
	var name;	name=arguments[0];
	var count;	count=arguments[1];
	var bgcolor;	bgcolor=arguments[2];
	var ftcolor;	ftcolor=arguments[3];
	var border;	border=arguments[5];
	for(var i=0;i<state.tiac;i++){clearTimeout(state.timeoutidArray[i]);}
	state.tiac=0;SetBgColor(name+'itm'+count,bgcolor);
	SetFgColor(name+'a'+count,ftcolor);
	SetBorder(name+'itm'+count,border);
	if(!state.onclick){
		OpenMenu(name,count,arguments[6],arguments[7]);
		if(state.hideidArray!=null){for(var i=0;i<state.hideidArray.length;i++){SetVisibility(state.hideidArray[i],false);}}
	}
};
function CloseMenu(){
	var name;	name=arguments[0];
	var count;	count=arguments[1];
	var bgcolor;	bgcolor=arguments[2];
	var ftcolor;	ftcolor=arguments[3];
	var border;	border=arguments[5];
	if(bgcolor!=null&&ftcolor!=null){SetBgColor(name+'itm'+count,bgcolor);SetFgColor(name+'a'+count,ftcolor);SetBorder(name+'itm'+count,border);}
	state.menuActive=false;
	state.timeoutidArray[state.tiac++]=setTimeout("CloseMenus()",state.closedelay);
};
function CloseMenus(){
	if(!state.menuActive){
		for(var i=0;i<state.amac;i++){SetVisibility(state.activemenuArray[i],false);}
		state.amac=0;
		if(state.hideidArray!=null){for(var i=0;i<state.hideidArray.length;i++)SetVisibility(state.hideidArray[i],true);}
	}
};
function DisplayMenu(){
	for(var i=state.mmcp;i<state.mmac;i++){state.mainmenuArray[i].BuildMenu();SetVisibility(state.mainmenuArray[i].name,true);}
	state.mmcp=state.mmac;
};
function CreateMenu(){
	for(var i=state.smcp;i<state.smac;i++){state.submenuArray[i].BuildMenu();}
	state.smcp=state.smac;
	state.CreateMenu=true;
};
function LoadMenu(){
	if(!state.CreateMenu){return;}
	if(os=="Mac"&&browser=="IE"){state.mtopoffset=parseInt(document.body.topMargin);state.mleftoffset=parseInt(document.body.leftMargin);}
	state.LoadMenu=true;
	for(var i=0;i<state.mmac;i++){var menu=state.mainmenuArray[i];}
};
function SetBorder(element,border){
	if(browser=="Opera"&&version<7){return;}
	if(GetByLayer(element)){document.getElementById(element).style.border=border;}
};
function SetzIndex(element,zIndex){
	if(GetByLayer(element)){document.getElementById(element).style.zIndex=zIndex+1;document.getElementById(element).style.zIndex=zIndex;}
};

