function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}




function setOrder(result)
{
    items = new Array();

    for (i = 0; i < result.length; ++i) {
        items[i] = result[i]['id'] + '|'
                + result[i]['amount'];
    }

    order = items.join('#');
    document.cookie = "order=" + encodeURI(order);

}

function getOrder()
{
    var result = new Array();
    var resultIndex = 0;

    cookies = document.cookie.split(';');

    for (i = 0; i < cookies.length; ++i) {
        tmp = cookies[i].split('=');

        regEmpty = /\s+/;
        cookieName  = tmp[0].replace(regEmpty, '');
        cookieValue = tmp[1];
        if ('order' == cookieName && cookieValue) {

            cookieValue = decodeURI(cookieValue);
            items = cookieValue.split('#');

            for (ii = 0; ii < items.length; ++ii) {
                props = items[ii].split('|');
                if (props.length == 2 && props[0] != '') {

                    result[resultIndex] = new Array();
                    result[resultIndex]['id']       = props[0];
                    result[resultIndex]['amount']   = props[1];
                    ++resultIndex;
                }
            }
        }
    }

    return result;
}
function clearOrder()
{
    order = getOrder();

    for (i = 0; i < order.length; ++i)
      {
        if (document.getElementById('coltovar' + order[i]['id']))
          document.getElementById('coltovar' + order[i]['id']).innerHTML = "0";
      }

    document.cookie = "order=; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
    drawOrder();
}


function removeFromOrder(id)
{
    order = getOrder();
    var j = 0;
    var newOrder = new Array();

    for (i = 0; i < order.length; ++i) {
        if (order[i]['id'] != id) {
            newOrder[j] = order[i];
            ++j;

        }
    }
    
    setOrder(newOrder);

}


function plustovar1(id)
  {
    order = getOrder();
    var j = 0;
    var newOrder = new Array();


    for (i = 0; i < order.length; ++i) {
        if (order[i]['id'] == id)
          order[i]['amount']++;
        newOrder[i] = order[i];
    }
    
    setOrder(newOrder);

    drawOrder();
  }

function minustovar1(id, no)
  {
    order = getOrder();
    var j = 0;
    var newOrder = new Array();

    for (i = 0; i < order.length; ++i) {
        if (order[i]['id'] == id)
          {
            order[i]['amount']--;
            if ((document.getElementById('coltovar' + order[i]['id']))&&(order[i]['amount'] == 0))
              document.getElementById('coltovar' + order[i]['id']).innerHTML = "0";
          }
        if (order[i]['amount'] > 0)
          newOrder[j++] = order[i];
    }


    
    setOrder(newOrder);

    drawOrder();
  }



// uniTip - written by Nathan Ford for Unit Interactive
//
// uniTip is based on qTip:
// qTip - CSS Tool Tips - by Craig Erskine
// http://qrayg.com

var uniTipTag = "a,img"; //Which tag do you want to uniTip-ize? Keep it lowercase. No spaces around commas.//
var uniTipClass = "tip"; //Which classes do you want to uniTip-ize? If you leave this blank, then all the tags designated above will get uniTip-ized. Match case. No spaces around commas.

var uniTipX = -10; // X offset from cursor//
var uniTipY = -7; // Y offset from cursor//

//______________________________________________There's no need to edit anything below this line//

var offsetX = uniTipX, offsetY = uniTipY, elewidth = null, eleheight = null, tipid = null, tiptop = null, tipbot = null, tipcapin=null, tippointin=null, altText=false;

var x=0, y=0, WinWidth=0, WinHeight=0, TipWidth=0, TipHeight=0, CapHeight=0, PointHeight=0;

// first, find all the correct elements
init = function () {
	var elementList = uniTipTag.split(",");
	for(var j = 0; j < elementList.length; j++) {	
		var elements = document.getElementsByTagName(elementList[j]);
		
		if(elements) {
			for (var i = 0; i < elements.length; i ++) {
				if (uniTipClass != '') {
				
					var elClass = elements[i].className;
					var elClassList = uniTipClass.split(",");
					
					for (var h=0; h < elClassList.length; h++) { if (elClass.match(elClassList[h])) unitipize(elements[i]); }
					
				} else unitipize(elements[i]);
			}
		}
	}
}

// next, add the tooltip function to those elements
unitipize = function (element) {
	var a = element;
	altText = (a.alt && a.getAttribute("alt") != '' ) ? true : false;
	var sTitle = (altText == true) ? a.getAttribute("alt") : a.getAttribute("title");				
	if(sTitle) {
		a.onmouseover = function() {build(a, sTitle);};
		a.onmouseout = function() {hide(a, sTitle);};
	}
}

// now, we build the tooltip
build = function (a) {
	tipid = a;
	var ii = document.getElementById(tipid);
	
	document.onmousemove = function (evt) {move (evt)};
        ii.style.display = 'block';
}

// now, we track the mouse and make the tooltip follow
move = function (evt) {
	var ii = document.getElementById(tipid);
	
	if (window.event) {
		x = window.event.clientX;
		y = window.event.clientY;
		
		if (document.documentElement.scrollLeft) ii.style.left = (TipWidth >= WinWidth ) ? ((x - offsetX - elewidth) + document.documentElement.scrollLeft) + "px" :  (x + offsetX + document.documentElement.scrollLeft) + "px";
		else ii.style.left = (TipWidth >= WinWidth ) ? ((x - offsetX - elewidth) + document.body.scrollLeft) + "px" :  (x + offsetX + document.body.scrollLeft) + "px";
		
		if (document.documentElement.scrollTop) ii.style.top = (TipHeight >= WinHeight) ? ((y - offsetY - eleheight) + document.documentElement.scrollTop) + "px" : (y + offsetY + document.documentElement.scrollTop) + "px";
		else ii.style.top = (TipHeight >= WinHeight) ? ((y - offsetY - eleheight) + document.body.scrollTop) + "px" : (y + offsetY + document.body.scrollTop) + "px";
		
	} else {
		x = evt.clientX;
		y = evt.clientY;	
		
		ii.style.left = (TipWidth >= WinWidth ) ? ((x - offsetX - elewidth) + window.scrollX) + "px" :  (x + offsetX + window.scrollX) + "px";
		ii.style.top = (TipHeight >= WinHeight) ? ((y - offsetY - eleheight) + window.scrollY) + "px" : (y + offsetY + window.scrollY) + "px";
	}
	
	TipWidth = x + elewidth + 20;
	TipHeight = y + eleheight + 20;
	
}

// lastly, hide the tooltip
hide = function (a) {
        if (a == tipid)
          {
  	    var ii = document.getElementById(tipid);
	    ii.style.display = "none";
	  }
}

// add the event to the page
if (window.addEventListener) window.addEventListener("load", init, false);
if (window.attachEvent) window.attachEvent("onload", init);





function n_GetX(pid)
{
var X = 0;
do { X += pid.offsetLeft } while ((pid = pid.offsetParent) != null);
return X;
}

function n_GetY(pid)//Cлужебная функция, определяет позицию TOP родительского элемента 

{
var Y = 0;
do { Y += pid.offsetTop } while ((pid = pid.offsetParent) != null);
return Y;
}

function build2(a)
  {
    var ii = document.getElementById(a);
    if (ii.style.display != 'block')
      {
        ii.style.display = 'block';
        ii.style.left = n_GetX(ii) - 100;
        ii.style.top = n_GetY(ii) - 170;
      }
  }
function hide2(a)
  {
    var ii = document.getElementById(a);
    if (ii.style.display != 'none')
      {
        ii.style.left = parseInt(n_GetX(ii)) + 100;
        ii.style.top = parseInt(n_GetY(ii)) + 170;
        ii.style.display = 'none';
      }
  }

