
if (document.getElementById){
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterdiv").getElementsByTagName("span");
		if(el.style.display != "block"){ 
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") 
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

function moveLyr(lyrObj,x,y) {
	lyrObj.top = y;
	lyrObj.left = x;
}

function mouseMove(e) {
	if (lyr) moveLyr(lyr,event.x + xOs + document.body.scrollLeft,event.y + yOs + document.body.scrollTop);
}

function showTip(which,MPX,MPY) {
	lyr = document.all[which].style;
	moveLyr(lyr,MPX + xOs + document.body.scrollLeft,MPY + yOs + document.body.scrollTop);
	document.onmousemove = mouseMove;
	lyr.visibility = "visible";

}

function hideTip(which) {
	document.all[which].style.visibility = "hidden";
	lyr=null;
}

// JS Tree
function openTree(link, openSub)
{
    ctExposeItem(0,link);
    if (openSub)
        openSubLevel(0,link);
}

function openSubLevel (treeIndex, link)
{
        if (treeIndex < 0 || treeIndex >= _ctTreeList.length)
                return;
        var tree = _ctTreeList[treeIndex];
        var endIndex = tree.endIndex;
        var i;
        for (i = tree.beginIndex; i < endIndex; ++i)
        {
                if (_ctItemList[i].length > 2 &&
                        _ctItemList[i][2] == link)
                {
                    var item = ctGetObject ('ctItemID' + (_ctTreeList[treeIndex].beginIndex + i)).parentNode;
                    if (!item)
                       return null;
                    ctOpenFolder(item);
                    return true;
                }
        }
}

function findElementByID(id, win)
{
	// current window
	var w = (win != null) ? win : window; 
	var field = null;
	
	var isFirst = true;
	do
	{
		if (!isFirst)
		{
			w = w.top.window;
		}
		field = w.document.getElementById(id);
		isFirst = false;
	}
	while (field == null && w != null && w.top.window != null && w != w.top);
	
	// Don't found? Get opener window!
	if (field == null && w != null && w.opener != null)
	{
		field = findElementByID(id, w.opener);
	}
	
	return field;
}


function openGoodsWindow(goods_id, barcode, inline)
{
	if (inline)
	{
	}
}


//////

function getAbsolutePos(el) 
{
	var r = { x: el.offsetLeft, y: el.offsetTop };
	if (el.offsetParent)
		{
		var tmp = getAbsolutePos(el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
		}
	return r;
}

function checkTKDelivery() {
	if (document.getElementById('fldPurchaseType').value=='delivery_tk') 
	{
		document.getElementById('pay_type2').checked=false;
		document.getElementById('pay_type1').checked=true;
		document.getElementById('fldPaymentType').value=1;
	}
}
//////////////

// определение типа браузера
// if ($is.IE) {....} или if ($is.IE>6) {....} или if ($is.Opera<9) {....}
(function(){
var ua = navigator.userAgent, av = navigator.appVersion, v, i;
$is={};
$is.Opera = !!(window.opera && opera.buildNumber);
$is.WebKit = /WebKit/.test(ua);
$is.OldWebKit = $is.WebKit && !window.getSelection().getRangeAt;
$is.IE = !$is.WebKit && !$is.Opera && (/MSIE/gi).test(ua) && (/Explorer/gi).test(navigator.appName);
$is.IE6 = $is.IE && /MSIE [56]/.test(ua);
$is.IE5 = $is.IE && /MSIE [5]/.test(ua);
$is.Gecko = !$is.WebKit && /Gecko/.test(ua);
$is.Mac = ua.indexOf('Mac') != -1;
for (i in $is) if (!$is[i]) $is[i]=NaN;
if (!$is.IE5) v = (ua.toLowerCase().match(new RegExp(".+(?:rv|it|ra|ie)[\\/: ]([\\d.]+)"))||[])[1];
switch (true) {
    case ($is.WebKit): v=parseInt(v, 10);$is.WebKit=v=v>599?4:v>499?3:v>399?2:1;break;
    case ($is.Opera): $is.Opera =v=v||9;break;
    case ($is.Gecko): $is.Gecko =v=v.substr(0,3)||1.8;break;
    case ($is.IE): $is.IE =v= window.XMLHttpRequest ? 7 : (/MSIE [5]/.test(av)) ? (/MSIE 5.5/.test(av))?5.5:5 : 6;
    };
$is.verb = v;
$is.ok = !!($is.Opera>=9 || $is.IE>=6 || $is.Gecko || $is.WebKit>2);
$is.debug = /&debug$/.test(location.search);
})();

