dhtmlXWebMenuObject.prototype._fixTopCornersInIE = function(itemId) {
	if (this.idPull[itemId] == null) { return; }
	var item = this.idPull[itemId];
	//
	item._cornerTR.style.right = - item.offsetWidth % 2 + "px";
	item._cornerBR.style.right = item._cornerTR.style.right;
	item._cornerBR.style.bottom = - item.offsetHeight % 2 + "px";
	item._cornerBL.style.bottom = item._cornerBR.style.bottom;
	item._barR.style.right = item._cornerTR.style.right;
	
	item._barR.style.height = item.offsetHeight - 10+"px";
	item._barL.style.height = item._barR.style.height;
	item._barT.style.width = item.offsetWidth - 10 + "px";
	if (!item._barB._fixed) {
		item._barB.style.width = item.offsetWidth-10+"px";
		item._barB._fixed = true;
	}
	item._barB.style.bottom = item._cornerBL.style.bottom;
	item._barM.style.width = item._barT.style.width;
	item._barM.style.height = item._barL.style.height;
	
}
dhtmlXWebMenuObject.prototype._fixOpenedSublevel = function(itemId, state) {
	itemId = this.idPrefix+itemId;
	if (this.itemPull[itemId] == null) { return; }
	if (this.itemPull[itemId]["parent"] == null) { return; }
	if (this.itemPull[itemId]["parent"] == this.idPrefix+this.topId) {
		var item = this.idPull[itemId];
		if (state == true) {
			if (_isIE) {
				item._barB.style.width = item.offsetWidth+"px";
				item._barB.style.left = "0px";
			} else {
				item._barB.style.left = "0px";
				item._barB.style.right = "0px";
			}
		} else {
			if (_isIE) {
				item._barB.style.width = item.offsetWidth-10+"px";
				item._barB.style.left = "5px";
			} else {
				item._barB.style.left = "5px";
				item._barB.style.right = "5px";
			}
		}
	}
}
dhtmlXWebMenuObject.prototype._fixSubCornersInIE = function(itemId) {
	if (this.idPull[itemId] == null) { return; }
	if ((navigator.appVersion).search(/MSIE\s7/) == -1) {
		if (this.idPull[itemId].offsetWidth % 2 == 0) {
			this.idPull[itemId]._subTR.style.right = "0px";
			this.idPull[itemId]._subTR.style.marginRight = "5px";
		} else {
			this.idPull[itemId]._subTR.style.right = "-1px";
			this.idPull[itemId]._subTR.style.marginRight = "7px";
		}
	}
	this.idPull[itemId]._subBL.style.top = this.idPull[itemId].offsetHeight - 5 + "px";
	this.idPull[itemId]._subBR.style.top = this.idPull[itemId]._subBL.style.top;
	this.idPull[itemId]._subBR.style.right = this.idPull[itemId]._subTR.style.right;
	this.idPull[itemId]._subBR.style.marginRight = this.idPull[itemId]._subTR.style.marginRight;
}

dhtmlXWebMenuObject.prototype._fixPolyCornersInIE = function(itemId) {
	if (this.idPull["polygon_"+this.idPrefix+itemId] == null) { return; }
	var item = this.idPull["polygon_"+this.idPrefix+itemId];
	//
	item._cornerPolyBrdR.style.height = item.offsetHeight - 12 + "px";
	item._cornerPolyBrdL.style.height = item._cornerPolyBrdR.style.height;
	item._cornerPolyBrdB.style.width = item.offsetWidth - 12 + "px";
	item._cornerPolyBrdT.style.width = item._cornerPolyBrdB.style.width;
}

dhtmlXWebMenuObject.prototype._addTopLeverCorners = function(itemId) {
	//
	if (this.itemPull[itemId] == null || this.idPull[itemId] == null) { return; }
	if (this.itemPull[itemId]["corners"] != null) { return; }
	var item = this.idPull[itemId];
	// corners
	item._cornerTL = document.createElement("DIV");
	item._cornerTL.className = "dhtmlxWebMenuSirop_TopLevel_Item_Corner_TL";
	item.appendChild(item._cornerTL);
	//
	item._cornerTR = document.createElement("DIV");
	item._cornerTR.className = "dhtmlxWebMenuSirop_TopLevel_Item_Corner_TR";
	item.appendChild(item._cornerTR);
	//
	item._cornerBL = document.createElement("DIV");
	item._cornerBL.className = "dhtmlxWebMenuSirop_TopLevel_Item_Corner_BL";
	item.appendChild(item._cornerBL);
	//
	item._cornerBR = document.createElement("DIV");
	item._cornerBR.className = "dhtmlxWebMenuSirop_TopLevel_Item_Corner_BR";
	item.appendChild(item._cornerBR);
	// bars
	item._barT = document.createElement("DIV");
	item._barT.className = "dhtmlxWebMenuSirop_TopLevel_Item_Bar_Top";
	item.appendChild(item._barT);
	//
	item._barR = document.createElement("DIV");
	item._barR.className = "dhtmlxWebMenuSirop_TopLevel_Item_Bar_Right";
	item.appendChild(item._barR);
	//
	item._barB = document.createElement("DIV");
	item._barB.className = "dhtmlxWebMenuSirop_TopLevel_Item_Bar_Bottom";
	item.appendChild(item._barB);
	//
	item._barL = document.createElement("DIV");
	item._barL.className = "dhtmlxWebMenuSirop_TopLevel_Item_Bar_Left";
	item.appendChild(item._barL);
	//
	item._barM = document.createElement("DIV");
	item._barM.className = "dhtmlxWebMenuSirop_TopLevel_Item_Bar_Middle";
	item.appendChild(item._barM);
	//
	if (_isIE && (navigator.appVersion).search(/MSIE\s7/) == -1) {
		var that = this;
		this.idPull[itemId].attachEvent("onmouseover", function(){that._fixTopCornersInIE(itemId);});
		this._fixTopCornersInIE(itemId);
	}
	//
	this.itemPull[itemId]["corners"] = true;
}

dhtmlXWebMenuObject.prototype._addSubLevelCorners = function(subItemId) {
	//
	if (this.idPull[subItemId] == null) { return; }
	if (this.itemPull[subItemId]["corners"] != null) { return; }
	//
	this.idPull[subItemId]._subTL = document.createElement("DIV");
	this.idPull[subItemId]._subTL.className = "dhtmlxWebMenuSirop_SubLevel_Item_Corner_TL";
	this.idPull[subItemId].appendChild(this.idPull[subItemId]._subTL);
	//
	this.idPull[subItemId]._subBL = document.createElement("DIV");
	this.idPull[subItemId]._subBL.className = "dhtmlxWebMenuSirop_SubLevel_Item_Corner_BL";
	if (!_isIE) { this.idPull[subItemId]._subBL.style.bottom = "0px"; }
	this.idPull[subItemId].appendChild(this.idPull[subItemId]._subBL);
	//
	this.idPull[subItemId]._subTR = document.createElement("DIV");
	this.idPull[subItemId]._subTR.className = "dhtmlxWebMenuSirop_SubLevel_Item_Corner_TR";
	this.idPull[subItemId].appendChild(this.idPull[subItemId]._subTR);
	//
	this.idPull[subItemId]._subBR = document.createElement("DIV");
	if (!_isIE) { this.idPull[subItemId]._subBR.style.bottom = "0px"; }
	this.idPull[subItemId]._subBR.className = "dhtmlxWebMenuSirop_SubLevel_Item_Corner_BR";
	this.idPull[subItemId].appendChild(this.idPull[subItemId]._subBR);
	//
	if (_isIE) {
		var that = this;
		this.idPull[subItemId].attachEvent("onmouseover", function(){that._fixSubCornersInIE(subItemId);});
	}
	//
	this.itemPull[subItemId]["corners"] = true;
}

dhtmlXWebMenuObject.prototype._addPolyCorners = function(itemId, isFirst) {
	if (this.idPull["polygon_"+itemId] == null) { return; }
	//
	this.idPull["polygon_"+itemId]._cornerPolyTL = document.createElement("DIV");
	this.idPull["polygon_"+itemId]._cornerPolyTL.className = "dhtmlxWebMenuSirop_SubLevelArea_Polygon_Corner_TL"+(isFirst?"":"2");
	this.idPull["polygon_"+itemId].appendChild(this.idPull["polygon_"+itemId]._cornerPolyTL);
	//
	this.idPull["polygon_"+itemId]._cornerPolyTR = document.createElement("DIV");
	this.idPull["polygon_"+itemId]._cornerPolyTR.className = "dhtmlxWebMenuSirop_SubLevelArea_Polygon_Corner_TR";
	this.idPull["polygon_"+itemId].appendChild(this.idPull["polygon_"+itemId]._cornerPolyTR);
	//
	this.idPull["polygon_"+itemId]._cornerPolyBL = document.createElement("DIV");
	this.idPull["polygon_"+itemId]._cornerPolyBL.className = "dhtmlxWebMenuSirop_SubLevelArea_Polygon_Corner_BL";
	this.idPull["polygon_"+itemId].appendChild(this.idPull["polygon_"+itemId]._cornerPolyBL);
	//
	this.idPull["polygon_"+itemId]._cornerPolyBR = document.createElement("DIV");
	this.idPull["polygon_"+itemId]._cornerPolyBR.className = "dhtmlxWebMenuSirop_SubLevelArea_Polygon_Corner_BR";
	this.idPull["polygon_"+itemId].appendChild(this.idPull["polygon_"+itemId]._cornerPolyBR);
	//
	this.idPull["polygon_"+itemId]._cornerPolyBrdR = document.createElement("DIV");
	this.idPull["polygon_"+itemId]._cornerPolyBrdR.className = "dhtmlxWebMenuSirop_SubLevelArea_Polygon_Corner_BrdR";
	this.idPull["polygon_"+itemId].appendChild(this.idPull["polygon_"+itemId]._cornerPolyBrdR);
	//
	this.idPull["polygon_"+itemId]._cornerPolyBrdL = document.createElement("DIV");
	this.idPull["polygon_"+itemId]._cornerPolyBrdL.className = "dhtmlxWebMenuSirop_SubLevelArea_Polygon_Corner_BrdL";
	this.idPull["polygon_"+itemId].appendChild(this.idPull["polygon_"+itemId]._cornerPolyBrdL);
	//
	this.idPull["polygon_"+itemId]._cornerPolyBrdT = document.createElement("DIV");
	this.idPull["polygon_"+itemId]._cornerPolyBrdT.className = "dhtmlxWebMenuSirop_SubLevelArea_Polygon_Corner_BrdT";
	this.idPull["polygon_"+itemId].appendChild(this.idPull["polygon_"+itemId]._cornerPolyBrdT);
	//
	this.idPull["polygon_"+itemId]._cornerPolyBrdB = document.createElement("DIV");
	this.idPull["polygon_"+itemId]._cornerPolyBrdB.className = "dhtmlxWebMenuSirop_SubLevelArea_Polygon_Corner_BrdB";
	this.idPull["polygon_"+itemId].appendChild(this.idPull["polygon_"+itemId]._cornerPolyBrdB);
}

dhtmlXWebMenuObject.prototype._parseSubLevel = function(itemId) {
	if (this.idPull["polygon_"+itemId] == null) { return; }
	var isFirst = (this.itemPull[itemId]["parent"]==this.idPrefix+this.topId)
	this._addPolyCorners(itemId, isFirst);
	for (var q=0; q<this.idPull["polygon_"+itemId].childNodes.length; q++) {
		this._addSubLevelCorners(this.idPull["polygon_"+itemId].childNodes[q].id);
	}
}



dhtmlXWebMenuObject.prototype.init = function() {
	this._initTopLevelMenu();
	for (var a in this.itemPull) {
		if (this.itemPull[a]["parent"] == this.idPrefix+this.topId && this.itemPull[a]["corners"] == null) { this._addTopLeverCorners(a); }
		if (this.itemPull[a]["complex"] == true && a != this.idPrefix+this.topId) { this._parseSubLevel(a); }
	}
	// inner level ie fixes
	if (_isIE) {
		if ((navigator.appVersion).search(/MSIE\s7/) == -1) { // ie6
			document.styleSheets[document.styleSheets.length-1].addRule(".dhtmlxWebMenuSirop_SubLevel_Item_Corner_TL", " left:-8px!important;");
			document.styleSheets[document.styleSheets.length-1].addRule(".dhtmlxWebMenuSirop_SubLevel_Item_Corner_BL", " left:-8px!important;");
		} else { // ie7
			//prefs=rule_name
			//ssModifier = " propname:value";
			//document.styleSheets[document.styleSheets.length-1].addRule(prefs, ssModifier);
			// document.styleSheets[document.styleSheets.length-1].insertRule(prefs+" { "+ssModifier+" } ", 0);
		}
	}
	var that = this;
	if (_isIE) { this.attachEvent("_onPolyShow", function(itemId){that._fixPolyCornersInIE(itemId);}); }
	this.attachEvent("_onPolyShow", function(itemId){that._fixOpenedSublevel(itemId, true);});
	this.attachEvent("_onPolyHide", function(itemId){that._fixOpenedSublevel(itemId, false);});
	
	this._redistribTopLevelPositions();
}
dhtmlXWebMenuObject.prototype._redistribTopLevelPositions = function() {
	var w = 0;
	for (var q=0; q<this.base.childNodes.length; q++) {
		if (this.base.childNodes[q].tagName == "DIV") {
			this.base.childNodes[q].style.left = w + "px";
			w += this.base.childNodes[q].offsetWidth+10;
		}
	}
}
