
var NS = (document.layers) ? true : false;
var IE = (document.all && document.getElementById) ? true : false;
var W3C = (document.getElementById && !document.all) ? true : false;
visible = NS ? 'show' : 'visible';
hidden = NS ? 'hide' : 'hidden';
var m1,m2,m3,m4,m5,m6,m7,m8,m9,m10;
var ms1,ms2,ms3,ms4,ms5,ms6,ms7,ms8,ms9,ms10;
var mainBgPicture; //for main menu background picture
var mainBGcolor;  //for main menu background color
var subBgPicture; // for sub menu background picture
var subBGcolor;  // for sub menu back ground color
var menuWidth;  // menu width 
var menuHeight; //for menu height
var menuLeft;  // menu left position in the screen
var menuTop;  // menu top position in the screen
var mainMenuColor;
var subMenuColor;

function layerObj(id,nestedIn,menuslno,total,haschild){
	// check if layer is nested
	
	if(nestedIn && NS){
		if(nestedIn.obj){
			if(NS){
				this.obj = eval('nestedIn.obj.document.'+id)
				this.style = eval('nestedIn.obj.document.'+id)
			}
		} 
	} else {
		if(NS){
			this.obj = document.layers[id];
			this.style = document.layers[id];
		} else if(IE){
			this.obj =	document.all[id];
			this.style = this.obj.style;
		} else if(W3C){
			this.obj =	document.getElementById(id);
			this.style = this.obj.style;
		}
	}
	//-- define overall/CSS properties
	if(NS){
		this.style.left = this.obj.left;
		this.style.top = this.obj.top;
		if(!(this.width=this.obj.document.width)){
			this.width = this.obj.clip.right;
		}
		if(!(this.height=this.obj.document.height)){
			this.height = this.obj.clip.bottom;
		}
	} else if(IE){
		this.style.left = this.obj.offsetLeft
		this.style.top = this.obj.offsetTop
		this.width = this.obj.offsetWidth
		this.height = this.obj.offsetHeight
	} else if(W3C){
		if(nestedIn){
			this.style.left = this.obj.offsetLeft - nestedIn.obj.offsetLeft;
			this.style.top = this.obj.offsetTop - nestedIn.obj.offsetTop;
		} else {
			this.style.left = this.obj.offsetLeft
			this.style.top = this.obj.offsetTop
		}
	 	this.width = this.obj.offsetWidth
		this.height = this.obj.offsetHeight
	}
	this.opened = false;
	
	if(menuslno){this.slno = menuslno;}
	if(total){this.total = total;}
	if(haschild){this.childs=true;}
	else{this.childs=false;}
}
function imageObj(name,nestedIn){
	// check if layer is nested
	if(nestedIn && NS){
		if(nestedIn.obj){
			if(NS){
				obj = nestedIn.obj.document.images[name];
			}
		} 
	} else {
		if(NS){
			obj = document.images[name];
		} else if(IE){
			obj =	document.all[name];
		} else if(W3C){
			obj = document.images[name];
		}
	}
	return obj
}
function formObj(name,formName,nestedIn){
	// check if layer is nested
	if(nestedIn && NS){
		if(nestedIn.obj){
			if(NS){
				obj = eval('nestedIn.obj.document.'+formName+'.elements[name]');
			}
		} 
	} else {
		if(NS){
			obj = eval('document.'+formName+'.elements[name]');
		} else if(IE){
			obj =	document.all[name];
		} else if(W3C){
			obj = eval('document.'+formName+'.elements[name]');
		}
	}
	return obj
}
function activeXEmbedObj(name,nestedIn){
	// check if layer is nested
	if(nestedIn && NS){
		if(nestedIn.obj){
			if(NS){
				obj = nestedIn.obj.document.embeds[name];
			}
		} 
	} else {
		if(NS){
			obj = document.embeds[name];
		} else if(IE){
			obj = document.all[name];
		} else if(W3C){
			obj = document.embeds[name];
		}
	}
	return obj
}
//-- prototype functions -------------------
layerObj.prototype.moveTo = layerObjMoveTo
function layerObjMoveTo(x,y) {
	if (x!=null) {
		if(IE || W3C) x+="px"
		this.style.left = x
	}
	if (y!=null) {
		if(IE || W3C) y+="px"
		this.style.top = y
	}
}
layerObj.prototype.moveBy = layerObjMoveBy
function layerObjMoveBy(x,y) {
	this.moveTo(parseInt(this.style.left)+x,parseInt(this.style.top)+y);
}
layerObj.prototype.clip = layerObjClip
function layerObjClip(t,r,b,l) {
	if(NS){
		this.obj.clip.top = t;
		this.obj.clip.left = l;
		this.obj.clip.right = r;
		this.obj.clip.bottom = b
	} else {
		this.style.clip = 'rect('+t+','+r+','+b+','+l+')'
	}
}
layerObj.prototype.innerHTML = layerObjInnerHTML
function layerObjInnerHTML(str) {
	if(NS){
		this.obj.document.open();
		this.obj.document.write(str);
		this.obj.document.close();
	} else {
		this.obj.innerHTML = str;
	}
}

var i;
var mytime;
var myobj;
var cobj;
var pobj;
var cmenu;
var mtotal;
var prevobj;
var prevtot;
var pmenu;
prevobj=0;
function showMenu(menuno,totalno)
{
	mtotal = totalno;
	if(prevobj!=0)	{
		pobj = eval("ms"+prevobj);pmenu=prevobj;
		if(prevobj==menuno){prevobj=0;cobj=null;}
		else{
		parentobj = eval("m"+menuno);
		cobj = eval("ms"+menuno);
		
		cmenu = menuno;
		
		prevobj = menuno;}
		closeMenu();
		return;
		}
	if(prevobj != menuno){
	
		parentobj = eval("m"+menuno);
		cobj = eval("ms"+menuno);
		cmenu = menuno;

		openMenu();
		prevobj = menuno;
		prevtot = totalno;
	}
}


function openMenu(cm,tot)
{
	var sheight;
	sheight = cobj.height;
		mtop = sheight
		for(var j=cmenu+1;j<=mtotal; j++)
		{
			eval("m"+j).moveTo(null,parseInt(eval("m"+j).style.top)+sheight);
		}

		ci= -menuWidth-menuLeft;
		cobj.opened = true;	
		cobj.moveTo(ci,parseInt(eval("m"+cmenu).style.top)+menuHeight);
		cobj.clip(0,cobj.width,cobj.height,0);
		openSub();
}


function openSub()
{
	
		ci=ci+15;
		cobj.moveTo(ci,null);
		mytime1=setTimeout("openSub()",5);
		if(ci >= menuLeft){clearTimeout(mytime1);}

}


function closeSub()
{

		pi=pi-15;
		pobj.moveTo(pi,null);
		
		mytime=setTimeout("closeSub()",5);
		if(pi < -menuWidth){clearTimeout(mytime); setMenuPositions();
				if(cobj){openMenu();}
		}

}



function setMenuPositions()
{
		for(var j=pmenu+1;j<=mtotal; j++)
		{
			eval("m"+j).moveTo(null,parseInt(eval("m"+eval(j-1)).style.top)+menuHeight);
		}
}


function closeMenu()
{
		pi=parseInt(pobj.style.left);	
		pobj.opened = false;
		closeSub();
}



function createMain(num,totnum,text,link,target,hchild){
	str=""
	str+='<div id="mainmenu'+num+'" class="menustyle"><table border=0 cellpadding=0 cellspacing=0 width='+ menuWidth + '><tr><td height='+ menuHeight +' ';
	if(mainBgPicture){str+='background="' + mainBgPicture +'"';}
	if(mainBGcolor){	str += ' bgcolor="' + mainBGcolor + '">';}
	else { str += '>';}
	if(link){ str+='<a href="'+link+'" onclick="this.blur()" ';	}
	else str+='<a href="javascript:;" onclick="showMenu('+num+',' + totnum +'); this.blur();return false"'
	if(target) str+=' target="'+target+'" '
	str+='><font face=verdana size=1 color=' + mainMenuColor + '>'+text+'</font></a></td></tr></table></div>\n'
	
	document.write(str)
	if(num==1){ m1 = new layerObj("mainmenu"+num,null,num,totnum,hchild);m1.moveTo(menuLeft,menuTop);}
	if(num==2) {m2 = new layerObj("mainmenu"+num,null,num,totnum,hchild);m2.moveTo(menuLeft,parseInt(m1.style.top) + menuHeight);}
	if(num==3) {m3 = new layerObj("mainmenu"+num,null,num,totnum,hchild);m3.moveTo(menuLeft,parseInt(m2.style.top) + menuHeight);}
	if(num==4) {m4 = new layerObj("mainmenu"+num,null,num,totnum,hchild);m4.moveTo(menuLeft,parseInt(m3.style.top) + menuHeight);}
	if(num==5) {m5 = new layerObj("mainmenu"+num,null,num,totnum,hchild);m5.moveTo(menuLeft,parseInt(m4.style.top) + menuHeight);}
	if(num==6) {m6 = new layerObj("mainmenu"+num,null,num,totnum,hchild);m6.moveTo(menuLeft,parseInt(m5.style.top) + menuHeight);}
	if(num==7) {m7 = new layerObj("mainmenu"+num,null,num,totnum,hchild);m7.moveTo(menuLeft,parseInt(m6.style.top) + menuHeight);}
	if(num==8) {m8 = new layerObj("mainmenu"+num,null,totnum,hchild);m8.moveTo(menuLeft,parseInt(m7.style.top) + menuHeight);}
	if(num==9) {m9 = new layerObj("mainmenu"+num,null,num,totnum,hchild);m9.moveTo(menuLeft,parseInt(m8.style.top) + menuHeight);}
	if(num==10) {m10 = new layerObj("mainmenu"+num,false,num,totnum,hchild);m10.moveTo(menuLeft,parseInt(m9.style.top) + menuHeight);}
	
}

function createSub(parent,num,totnum,text,link,target){
	str=""
	if(num==1){	
				//str+='<div id="submenu'+parent+'" style="Z-INDEX: 4;LEFT: 20px; VISIBILITY: visible; WIDTH: 100px;POSITION: absolute;TOP: 20px; HEIGHT: 20px"><table border=0 cellpadding=0 cellspacing=0 width='+ menuWidth + '>';
				str+='<div id="submenu'+parent+'" class="submenustyle"><table border=0 cellpadding=0 cellspacing=0 width='+ menuWidth + '>';
			  }
	str += '<tr><td height=' + menuHeight + ' ';
	if(subBgPicture){str+='background="' + subBgPicture +'"';}
	if(subBGcolor){	str += ' bgcolor="' + subBGcolor + '">';}
	else{str += '>';}
	if(link){ str+='<a href="'+link+'"'	}
	else str+='<a href="Javascript:;" ';
	if(target) str+=' target="'+target+'" '
	str+='><font size=1 face = verdana color='+ subMenuColor +'>  '+text+'</font></a></td></tr> '
	
	if (num == totnum){str += "</table></div>";}

//alert(str);		
	document.write(str)
	if(num==totnum){
		if(parent==1){ ms1 = new layerObj("submenu"+parent);ms1.moveTo(parseInt(m1.style.left),parseInt(m1.style.top)+m1.height-ms1.height);ms1.clip(ms1.height,ms1.width,ms1.height,0);ms1.style.visibility="visible";}
		if(parent==2) {ms2 = new layerObj("submenu"+parent);ms2.moveTo(parseInt(m2.style.left),parseInt(m2.style.top)+m2.height-ms2.height);ms2.clip(ms2.height,ms2.width,ms2.height,0);ms2.style.visibility="visible";}
		if(parent==3) {ms3 = new layerObj("submenu"+parent);ms3.moveTo(parseInt(m3.style.left),parseInt(m3.style.top)+m3.height-ms3.height);ms3.clip(ms3.height,ms3.width,ms3.height,0);ms3.style.visibility="visible";}
		if(parent==4) {ms4 = new layerObj("submenu"+parent);ms4.moveTo(parseInt(m4.style.left),parseInt(m4.style.top)+m4.height-ms4.height);ms4.clip(ms4.height,ms4.width,ms4.height,0);ms4.style.visibility="visible";}
		if(parent==5) {ms5 = new layerObj("submenu"+parent);ms5.moveTo(parseInt(m5.style.left),parseInt(m5.style.top)+m5.height-ms5.height);ms5.clip(ms5.height,ms5.width,ms5.height,0);ms5.style.visibility="visible";}
		if(parent==6) {ms6 = new layerObj("submenu"+parent);ms6.moveTo(parseInt(m6.style.left),parseInt(m6.style.top)+m6.height-ms6.height);ms6.clip(ms6.height,ms6.width,ms6.height,0);ms6.style.visibility="visible";}
		if(parent==7) {ms7 = new layerObj("submenu"+parent);ms7.moveTo(parseInt(m7.style.left),parseInt(m7.style.top)+m7.height-ms7.height);ms7.clip(ms7.height,ms7.width,ms7.height,0);ms7.style.visibility="visible";}
		if(parent==8) {ms8 = new layerObj("submenu"+parent);ms8.moveTo(parseInt(m8.style.left),parseInt(m8.style.top)+m8.height-ms8.height);ms8.clip(ms8.height,ms8.width,ms8.height,0);ms8.style.visibility="visible";}
		if(parent==9) {ms9 = new layerObj("submenu"+parent);ms9.moveTo(parseInt(m9.style.left),parseInt(m9.style.top)+m9.height-ms9.height);ms9.clip(ms9.height,ms9.width,ms9.height,0);ms9.style.visibility="visible";}
		if(parent==10) {ms10 = new layerObj("submenu"+parent);ms10.moveTo(parseInt(m10.style.left),parseInt(m10.style.top)+m10.height-ms10.height);ms10.clip(ms10.height,ms10.width,ms10.height,0);ms10.style.visibility="visible";}
	}	
}
//--------------------------------------------