

	browser_name = navigator.appName;
	browser_version = parseFloat(navigator.appVersion);

	if (browser_name == "Netscape" && browser_version >= 3.0) { roll = 'true'; }
	else if (browser_name == "Microsoft Internet Explorer" && browser_version >= 3.0) { roll = 'true'; }
	else { roll = 'false'; }

	function over(img,ref) { if (roll == 'true') { document.images[img].src = ref; } }
	function out(img,ref)  { if (roll == 'true') { document.images[img].src = ref; } }

	if (roll == 'true')
	{
		a1=new Image;a1.src="interface/item_subtype_117.gif";
		a2=new Image;a2.src="interface/item_subtype_117_over.gif";
		a3=new Image;a2.src="interface/item_subtype_117_selected.gif";

		a4=new Image;a4.src="interface/item_subtype_118.gif";
		a5=new Image;a5.src="interface/item_subtype_118_over.gif";
		a6=new Image;a6.src="interface/item_subtype_118_seleced.gif";
		
		a7=new Image;a7.src="interface/item_subtype_119.gif";
		a8=new Image;a8.src="interface/item_subtype_119_over.gif";
		a9=new Image;a9.src="interface/item_subtype_119_seleced.gif";

		a10=new Image;a10.src="interface/item_subtype_120.gif";
		a11=new Image;a11.src="interface/item_subtype_120_over.gif";
		a12=new Image;a12.src="interface/item_subtype_120_seleced.gif";

		a13=new Image;a13.src="interface/item_subtype_121.gif";
		a14=new Image;a14.src="interface/item_subtype_121_over.gif";
		a15=new Image;a15.src="interface/item_subtype_121_seleced.gif";

		a16=new Image;a16.src="interface/item_subtype_122.gif";
		a17=new Image;a17.src="interface/item_subtype_122_over.gif";
		a18=new Image;a18.src="interface/item_subtype_122_seleced.gif";

		a19=new Image;a19.src="interface/item_subtype_123.gif";
		a20=new Image;a20.src="interface/item_subtype_123_over.gif";
		a21=new Image;a21.src="interface/item_subtype_123_seleced.gif";

		a22=new Image;a22.src="interface/item_subtype_124.gif";
		a23=new Image;a23.src="interface/item_subtype_124_over.gif";
		a24=new Image;a24.src="interface/item_subtype_124_seleced.gif";

		a25=new Image;a25.src="interface/item_subtype_125.gif";
		a26=new Image;a26.src="interface/item_subtype_125_over.gif";
		a27=new Image;a27.src="interface/item_subtype_125_seleced.gif";
	}


function showHide(id, id2){
    try{
	el = document.getElementById(id);
        el.style.display = el.style.display == "none" ? "block" : "none";

	el2 = document.getElementById(id2);
        el2.className = el2.className== "filter_btn expanded" ? "filter_btn collapsed" : "filter_btn expanded";

    }
    catch (error){
        alert(error.message);
    }
    finally{
        /* Это чтоб страница не дёргалась - отменяем стандартное поведение ссылки с href="#" */
        return false;
    }
}


	function onFilterClick(id) {
		el = document.getElementById(id);
		alert(el.style.Height);
		if (el.style.display=='none'){
			el.style.display='block';
		} else {
            el.style.display=='none';
		}
		return null;
	}


  function checkParentTable(src)  {      
	alert(1);

	alert(src.className);
	while ("table" != src.tagName) {     
	  if ("table" == src.tagName) {
			alert(1)
			return src;
	  }
	  src = src.parentElement;           
	}                                    
	return null;                         
	alert(2)
  }                                      


	function closeAllQWindow() {
       for (var intLoop = 0; intLoop < document.all.length; intLoop++) {
            el = document.all[intLoop];
			if (el.tagName=="DIV" && el.style.position=="absolute") {
				el.style.display='none';
			}
          }
	}


	function showQWindow(id) {
		closeAllQWindow();
		el=document.all[id];
		if (el.style.display=='none'){
			el.style.display='block';
			el.style.pixelTop = document.body.scrollTop+Math.random()*50+100;
			el.style.pixelLeft = document.body.scrollLeft+Math.random()*50+100;
		}
		toFrontQWindow(el);
	}


	function closeQWindow(id) {
		document.all[id].style.display='none';
	}


	function toFrontQWindow(el) {
	  if (typeof(maxZIndex)=="undefined") {
		maxZIndex=0;
	  }
		maxZIndex++;
		el.style.zIndex=maxZIndex;
	}


       function findQWindow(elCheck) {
          while (elCheck != null) {
             if (null != elCheck.getAttribute("QWindow")) {
                return elCheck;
			 }
             elCheck = elCheck.parentElement;
          }      
          return null;
       }


       function checkDrag(elCheck) {
          while (elCheck != null) {
             if (null != elCheck.getAttribute("dragEnabled")) {
                return elCheck;
			 }
             elCheck = elCheck.parentElement;
          }      
          return null;
       }



       function doMouseDown() {
/*          el = checkDrag(event.srcElement);
          elQWindow=findQWindow(event.srcElement);
          if (null != el) {
            elCurrent=findQWindow(el);
			  dxnX=event.clientX-elCurrent.style.pixelLeft+document.body.scrollLeft;
			  dxnY=event.clientY-elCurrent.style.pixelTop+document.body.scrollTop;
			  toFrontQWindow(elCurrent);
          } else if (elQWindow!=null) {
			  toFrontQWindow(elQWindow);
          }*/
       }

      function doMouseMove() {
	  if (typeof(elCurrent)!="undefined") {
        if (elCurrent!=null) {
/*           var intTop = event.clientY + document.body.scrollTop;
           var intLeft = event.clientX + document.body.scrollLeft;
           var intLessTop  = 0;
           var intLessLeft = 0;
           var el = elCurrent.offsetParent;
           while (el.offsetParent != null) {
              intLessTop += el.offsetTop;
              intLessLeft += el.offsetLeft;
              el = el.offsetParent;
           }
           elCurrent.style.pixelTop = intTop  - intLessTop-dxnY;
           elCurrent.style.pixelLeft = intLeft - intLessLeft-dxnX;
*/
           elCurrent.style.pixelTop = event.clientY +document.body.scrollTop-dxnY;
           elCurrent.style.pixelLeft = event.clientX+document.body.scrollLeft-dxnX;
           event.returnValue = true;
        }
	  }

      }


      function doMouseUp() {
        elCurrent=null;
      }


       function doSelectTest() {
         return (null == findQWindow(event.srcElement));
	   }

	function goToCase(window) {
		window.opener.location.assign("case_full.phtml");
		window.close();
		window.opener.focus();
	}

	 function openCase() {
		if (typeof(window.opener.opener)=="undefined")
		{
			window.opener.location.assign("case_full.phtml"); window.opener.focus(); window.close();
			window.opener.focus();
		} else {
			window.opener.opener.location.assign("case_full.phtml"); window.opener.focus(); window.close();
			window.opener.opener.focus();
		}
	 }

	 function linkMaterial(position, item_id, m_type_id, prod_id) {
		if (window.showModalDialog("/mod_linkmaterial.phtml?frame=true&action=new&item_id="+item_id+"&m_type_id="+m_type_id+"&position="+position+"&prod_id="+prod_id+"&nc="+Math.random()*100000, "", "status:0; border:thin; dialogWidth:600pt; help=no")==1) {
            document.location.reload(false);
        }
	 }

	 function materialPreview(item_id) {
		window.open("/material_preview.phtml?item_id="+item_id+"&nc="+Math.random()*100000, "", "status:0; border:thin; dialogWidth:600pt; help=no");
	 }

      function addToOrder(order_id) {  //Функция вызывает модальное окно для создания нового
		  if (window.showModalDialog("mod_edit_elements.phtml?frame=true&order_id="+order_id+"&nc="+Math.random()*100000, "", "status:0; border:thin;  dialogWidth:1020px; dialogHeight:760px;help=no")==1) {
						document.location.reload(false);  
          }

      }





function getCoordinates(event) {
    var scrollX = 0, scrollY = 0;
    if (document.body && typeof document.body.scrollTop != undefined) {
        scrollX += document.body.scrollLeft;
        scrollY += document.body.scrollTop;
        if (document.body.parentNode && typeof document.body.parentNode.scrollTop != undefined) {
            scrollX += document.body.parentNode.scrollLeft;
            scrollY += document.body.parentNode.scrollTop;
        }
    } else if (typeof window.pageXOffset != undefined) {
        scrollX += window.pageXOffset;
        scrollY += window.pageYOffset;
    }

    var x = event.pageX != undefined ? event.pageX : event.x;
    var y = event.pageY != undefined ? event.pageY : event.y;

    x = document.body.clientWidth - (event.clientX + scrollX) - 150;
    y = event.clientY + scrollY - 50;

    if (x < 0) {
        x = 0;
    }

    if (x > document.body.clientWidth) {
        x = document.body.clientWidth;
    }

    return {x: x, y: y};
}




// ------------------------------ TIMERS --------------------------------
var timers = new Object(); //timer [accessKey: timerVariable] global map, do not remove

function addOrOverwriteTimer(key, timeOut, functionality) {
    if (timers[key] != null)
        clearTimeout(timers[key]);

    timers[key] = setTimeout(functionality, timeOut);
}




function refreshCase () {
	window.opener.xajax_doAddItemToCase(0, 0, 0);
}



	 document.onmousedown = doMouseDown;
     document.onmousemove = doMouseMove;
     document.onmouseup = doMouseUp;
     document.onselectstart = doSelectTest;
