function Menu(id,parent,name,href,type){
	this.id = id;
	this.parent = parent;
	this.name = name;
	this.href = href;
	this.type = type;
	this.tdObj = null;
	return this;
}
function myDiv(object){
	this.visible = 'false';
	this.id = object.parent;
	this.menuArray = new Array();
	this.menuArray[0] = object;
	this.height = 0;
	this.width = 0;
	this.obj = null;
	this.parent = null;
	this.type = 'left';
	return this;
}

function addDiv(object,mydiv){
	mydiv.menuArray[mydiv.menuArray.length] = object;
}

function getParentDiv(parent){
	i = 0;
	while (menu[i] != null){
		if (menu[i].id == parent) {
			j = 0;
			while (divArray[j] != null){
				if (divArray[j].id == menu[i].parent) {
					return (divArray[j]);
				}
			j++;
			}
		}
		i++;
	}
	return null;
}

function getDivOnId(id){
	i = 0;
	while (divArray[i] != null){
		if (divArray[i].id == id) {
			return (divArray[i]);
		}
		i++;
	}
	return null;
}

function getGlubina(object){
	var count = 0;
	obj = object;
	while (obj.parent){
		obj = obj.parent;
		count++;
	}
	return count;
}

function setZindex(object){
	object.obj.style.zIndex = getGlubina(object);
}
function showDiv(object){
	MainParent = getObjectLeft(getElement("main100002"));
	while (object.obj){
		selftop = getObjectTop(object.obj);
		selfleft = getObjectLeft(object.obj);
		partop =  getObjectTop(getElement('main'+object.id));
		parleft =  getObjectLeft(getElement('main'+object.id));
		if (object.type == 'left'){
		if (!object.parent) {
			object.obj.style.top = partop - 3;
			object.obj.style.left = (parleft - 165) ;
		} else {
			object.obj.style.top = partop -3;
			object.obj.style.left = (parleft - 160) ;
		}
		}
		else {
			if (!object.parent) {
				object.obj.style.top = partop + 20 ;
				object.obj.style.left = parleft - 4;
			}
			else {
				//alert(parleft - MainParent);
				if (parleft - MainParent > 157 || object.parent.id == 100001 || (object.parent.parent && object.parent.parent.id== 100001)) {
					object.obj.style.left = parleft-160;
					object.obj.style.top = partop - 3;
					}
				else {
					object.obj.style.top = partop - 3;
					object.obj.style.left = parleft+154;
				}				
			}
		}
		object.obj.style.visibility = 'visible';
		if (object.parent) object = object.parent;
		else break;
	}
}
function getParentLeft(object){
	left = 0;
	while (object.parent) {
		left  += getObjectLeft(getElement('main'+object.id))
		object = object.parent;
	}
	return left - 152 - getObjectLeft(getElement('main'+object.id));
}
function hideDiv(object){
	i = 0;
	while (divArray[i] != null) {
		object = divArray[i];
		object.obj.style.visibility = 'hidden';
		i++;
	}
	return '';
}
function hideDivWithoutParent(object){
		i = 0;
		currentDiv = getDivOnId(activeLayer);
		while (object.obj){
			object.obj.style.visibility = 'hidden';
			if (object.parent) object = object.parent;
			else break;
		}
		return '';
}
