var ActualLevel, str, bw
ActualLevel = 0

function checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	return this
}
bw=new checkBrowser()

function writestrNS4(str,image,space) {
	document.layers['MenuTree'].document.open();
	if (image == "") {
		document.layers['MenuTree'].document.write(str);
	}
	else
		document.layers['MenuTree'].document.write(str + '<img src=../_admin/images/dummy.gif width=1 height=' + space + ' border=0><br><img src=Images/upload/' + image + '>');
	
	document.layers['MenuTree'].document.close();
}

function writestrNS5(str,space) {
	if (image == "") {
		obj=document.getElementById('MenuTree').innerHTML = str;
	}
	else
		obj=document.getElementById('MenuTree').innerHTML = str + '<img src=../_admin/images/dummy.gif width=1 height=' + space + ' border=0><br><img src=Images/upload/' + image + '>';
}

function writestrIE(str,image,space) {
	document.all.MenuTree.innerHTML = str;
	if (image != "") {
		document.all.MenuTree.innerHTML = str + '<img src=../_admin/images/dummy.gif width=1 height=' + space + ' border=0><br><img src=Images/upload/' + image + '>';
	}
}

function menu_class(MenuName,MenuID,MenuType,id) {
	this.name = MenuName;
	this.menu = MenuID;
	this.ContentType = MenuType;
	this.id = id?id:0;
	this.sub = new Array();
	this.subs = 0;
	this.fold = 1;

	this.addsub = function(MenuName,MenuID,MenuType) {
		this.last = new menu_class(MenuName,MenuID,MenuType,this.id+','+this.subs);
		this.sub[this.subs++] = this.last;
	}
	
	this.getspace = function() {
		par = eval('new Array('+this.id+')');
		for (i=3,j='';i<par.length;i++)
		   j+= Spacer;
		ActualLevel=i;
		return j;
	}

	this.change = function(id) {
		par = eval('new Array('+id+')');
		for (i=1,j='';i<par.length;i++)
		   j+='.sub['+par[i]+']';
		id = eval('this'+j);
		id.fold=id.fold==1?0:1;
		this.draw();
	}


	this.draw = function(id) {
		if (this.id==0) str='';
		this.getspace();
		if (ActualLevel==3) {
			css = 'mainmenu';
		} else
			css = 'menu';
		if (this.ContentType!='None') {
			ThisMenuStr = this.ContentType+'/default.asp?ID='+this.menu;
			if (this.ContentType=='Link') {
				url = 'window.open('+ThisMenuStr+')'
				ThisMenuTarget = '_blank';
			} else
				url = "parent.Content.location.href='"+ThisMenuStr+"'"
				ThisMenuTarget = 'Content';
		} else
			url = 'href="#"'
		if (this.subs > 0) {
			if (this.name) {
				if (this.menu!=1) {
					str += '<tr><td class="td'+css+'">'+this.getspace()
					str += '<a href="javascript:'+url+';menu.change(\''+this.id +'\');" class="'+css+'">';
					if (MenuShow==1)
						(this.fold=='1')?str += SubBeginOff:str += SubBeginOn;
					str += this.name;
					if (MenuShow==1)
						(this.fold=='1')?str += SubEndOff:str += SubEndOn;
					str += '</a></td></tr>'
				}
			}
			if (MenuShow==1) {
				if (this.fold==0 || !this.name)
					for (this.i=0;this.i<this.subs;this.i++)
						this.sub[this.i].draw();
			} else
				for (this.i=0;this.i<this.subs;this.i++)
					this.sub[this.i].draw();
		} else
			str += '<tr><td class="td'+css+'">'+this.getspace()+'<a href="'+ThisMenuStr+'" target="'+ThisMenuTarget+'" class="'+css+'">'+SubBeginOn+this.name+SubEndOn+'</a></td></tr>';
		if (this.id==0) {
			str = '<table width="'+MenuWidth+'" cellspacing="'+MenuSpace+'" cellpadding="0">'+str+'</table>'
			image = FrameMenuBottomPicture
			space = ImageSpace			
			bw.ns4?writestrNS4(str,image,space):bw.ns5?writestrNS5(str,image,space):writestrIE(str,image,space);			
		}
	}
}