var menuWidth = 130;
var topCorrection = 0;
var corrFirst = -1;
var corrLast = -10;
var bottonWidth = 50; // 37
var alignRight = true;	  
var rightHideCartCorrect = 0;

var nn4 = (document.layers)? true:false;
var ie4 = (document.getElementById)? true:false;
var msie = (navigator.userAgent.indexOf("MSIE")>=0)? true:false;
var dom = (document.getElementById)? true:false;
var idMenu = "";
var showedCart = false;
var curPath = "";
var prods = new Array;
var curTr;
var curTrBgColorBuff;
var tTrBgColor = "#Efefef";
var showed;
var curProdCount = null;

function showCart(prod_id, prodPrice, obj) {
       var idBotton = 'cartLayer';
       idMenu = idBotton;
       if ((ie4)&&showedCart&&idMenu!=('menu'+ idBotton)) {
          hide(idMenu);
       }
       
	   curProdPrice = prodPrice;
	   curProdID = prod_id;
        if (!curProdCount) {
            curProdCount = 1;
        }

        if(ie4&&document.getElementById(idMenu)!=null) {
            calc(prods[prod_id], "");
            setStatus(document);
            //curTr = obj.parentElement.parentElement;
            curTr = obj.parentNode.parentNode;
            curTrBgColorBuff = curTr.style.backgroundColor;
		 //if(curTr.style.backgroundColor) {
            curTr.style.backgroundColor = tTrBgColor;
            //curTr.setAttribute("bgColor", tTrBgColor);
         //}
            if(idMenu == "menu1") document.getElementById(idMenu).style.left = calculateSumOffset(obj,"offsetLeft") - corrFirst;
            else if(alignRight)
                document.getElementById(idMenu).style.left = calculateSumOffset(obj,"offsetLeft") + obj.offsetWidth - menuWidth + corrLast;
            else
                document.getElementById(idMenu).style.left = calculateSumOffset(obj,"offsetLeft")/* + obj.offsetWidth/2 - menuWidth/2*/;
            document.getElementById(idMenu).style.top = calculateSumOffset(obj,"offsetTop") + obj.offsetHeight + topCorrection;
            document.getElementById(idMenu).style.visibility = "Visible";showedCart = true;
        }
      }

function calculateSumOffset(item, offsetName)
{
	var totalOffset = 0;
	do
	{
		totalOffset += eval('item.'+offsetName);
		item = item.offsetParent;
	} while (item != null);
	return totalOffset;
}

function hideCart(e) {
    evntX = msie?event.clientX:e.clientX;
    evntY = msie?event.clientY:e.clientY;
    
    if(showed||(showedCart&&!cartFrozen)){
      if(dom && document.getElementById(idMenu)!=null&&(evntY + document.body.scrollTop > document.getElementById(idMenu).offsetHeight + document.getElementById(idMenu).offsetTop
        || evntY + document.body.scrollTop + bottonWidth < document.getElementById(idMenu).offsetTop
        || evntX + document.body.scrollLeft > document.getElementById(idMenu).offsetWidth + document.getElementById(idMenu).offsetLeft + rightHideCartCorrect
        || evntX + document.body.scrollLeft < document.getElementById(idMenu).offsetLeft))
          {hide(idMenu); if(showed) showed = false; if(showedCart) showedCart = false;}
      }
}

function hide(id) {
       if(ie4&&document.getElementById(id)!=null) { document.getElementById(id).style.visibility = "hidden";
	    if(curTr!=null&&curTr.style.backgroundColor!=null) curTr.style.backgroundColor = curTrBgColorBuff; }
}

function hideCartOnClick(e) {
// if(cartFrozen) cartFrozen = false;
 hideCart(e);
}

if(nn4||ie4){

document.onclick = hideCartOnClick;
document.onmousemove = hideCart;

}


function initPath(path){if(path!="")curPath = path + "/";}



