var flagopen = new Array();
var nmenu=3;

var vizSelectFlag = 0;
var topOpen;

for(i = 0;i <= 10; i++){
	flagopen[i]=0;
	}

function initall() {
	initMouse();

}
function BrowserCheck() {
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.v = parseInt(navigator.appVersion)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
	this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
	if (this.ie5) this.v = 5
	this.min = (this.ns||this.ie)
}

browserr = new BrowserCheck()
//var flagopen[i]=0;
var xOld,yOld;
xOld=0;yOld=0;
var eldrag=null;



function initMouse() {
	document.onmousedown = mouseDown
	document.onmousemove = mouseMove
	document.onmouseup = mouseUp
	if (browserr.ns) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP)
}

function mouseDown(e) {
	if ((browserr.ns && e.which!=1) || (browserr.ie && event.button!=1)) return true
	var x = (browserr.ns)? e.pageX : event.x+document.body.scrollLeft
	var y = (browserr.ns)? e.pageY : event.y+document.body.scrollTop
	if (browserr.ns && e.target!=document) routeEvent(e)

	return DownMouse(x,y)
}
function mouseMove(e) {
	var x = (browserr.ns)? e.pageX : event.x+document.body.scrollLeft
	var y = (browserr.ns)? e.pageY : event.y+document.body.scrollTop
	if (browserr.ns && e.target!=document) routeEvent(e)
	
	return MoveMouse(x,y)
}
function mouseUp(e) {
	var x = (browserr.ns)? e.pageX : event.x+document.body.scrollLeft
	var y = (browserr.ns)? e.pageY : event.y+document.body.scrollTop
	if (browserr.ns && e.target!=document) routeEvent(e)
	
	 return UpMouse(x,y)
}







function dTopf(divname) {
var fts1;
	if(document.all){
	  if(document.all[divname] != null){		
	    fts1=document.all[divname].style.posTop;
	  }
	}
	if(document.layers){
	  fts1=document.layers[divname].top;
	}

return fts1
}



function dLeftf(divname) {
var fts1;
	if(document.all){
	  if(document.all[divname] != null){
	    fts1=document.all[divname].style.posLeft;
	  }
	}
	if(document.layers){
	fts1=document.layers[divname].left;
	}

return fts1
}






function MoveMouse(x,y) {

return true
}

function DownMouse(x,y) {
	return true

}

function UpMouse(x,y) {

	return true
	
	
}
	 

function showNavMenu(num){

hideNavMenu();
  thisOpen = 'navMenu' + num;

  if(document.all[('navMenu' + num)] != null){
    document.all['navMenu' + num].style.visibility = 'visible';
	hideSelElement("SELECT", thisOpen);	
    document.all['navMenudop0'].style.zIndex = 1;	
    document.all['navMenudop'].style.zIndex = 1;
    document.all['navMenudop2'].style.zIndex = 1;			
  }
 
}

function hideNavMenu(){
    if(document.all[thisOpen] != null){
      document.all[thisOpen].style.visibility = 'hidden';
      if (vizSelectFlag	== 1){	   
		 showElement("SELECT");
      }	  
    }
      document.all['navMenudop0'].style.zIndex = -1; 
      document.all['navMenudop'].style.zIndex = -1; 
      document.all['navMenudop2'].style.zIndex = -1; 	  
    thisOpen = ""; 

	//alert(document.all['navMenudop'].style.height)
}


function hideSelElement(elmID, name)
{

   x = dLeftf(name); y = dTopf(name);
   ToolbarMenu = document.all[name];
		//alert(x + "------" + y);   
	for (i = 0; i < document.all.tags(elmID).length; i++)
	{
				
		obj = document.all.tags(elmID)[i];
		if (! obj || ! obj.offsetParent)
			continue;

		// Find the element's offsetTop and offsetLeft relative to the BODY tag.
		objLeft   = obj.offsetLeft;
		objTop    = obj.offsetTop;
		objParent = obj.offsetParent;
		while (objParent.tagName.toUpperCase() != "BODY")
		{
			objLeft  += objParent.offsetLeft;
			objTop   += objParent.offsetTop;
			objParent = objParent.offsetParent;
		}
		// Adjust the element's offsetTop relative to the dropdown menu


		if (y > (objTop + obj.offsetHeight) || (y + ToolbarMenu.offsetHeight) < objTop){
			;
		}
		else if (x > (objLeft + obj.offsetWidth) || (x + ToolbarMenu.offsetWidth) < objTop) {
			;
		}
		else {
			obj.style.visibility = "hidden";
	        vizSelectFlag = 1;			
		}
	}
}

function showElement(elmID)
{
	
	for (i = 0; i < document.all.tags(elmID).length; i++) {
	  obj = document.all.tags(elmID)[i];
		if (! obj || ! obj.offsetParent){
		  continue;
		}	
 	  obj.style.visibility = "visible";
	}
	vizSelectFlag = 0;
}


function posnavMenu() {

for(i = 0; i < 15; i++){
  
    if(document.all['navMenu' + i] != null){
	  if(document.all['navMenuTr' + i] != null){
	 

	 obj = document.all['navMenuTr' + i];
		// Find the element's offsetTop and offsetLeft relative to the BODY tag.
		objLeft   = obj.offsetLeft;
		objTop    = obj.offsetTop;
		objParent = obj.offsetParent;
		while (objParent.tagName.toUpperCase() != "BODY")
		{
			objLeft  += objParent.offsetLeft;
			objTop   += objParent.offsetTop;
			objParent = objParent.offsetParent;
		}
	  
	   lTop = objTop - 16;
	   
//alert(document.all['navMenuTr3'].offsetTop)
      }
	  document.all['navMenu' + i].style.top = lTop;
	  

	 }
  }

}



window.onerror=null;
function bigFoto(src, w, h, num) {
  var winParam = 'scrollbars=no, width=' + w + ', height=' + h + ', location=no, toolbar=no, directories=no, status=no ,menubar=no, resizable=no, screenX=180,screenY=166, top=166, left=180';    
  var name = 'nm' + num;
  subs=window.open('', name, winParam);
  
  subs.document.write('<html>' + 
'<head>' + 
'<title>Трояна</title>' + 
'</head>' +
'<body bgcolor="#ffffff" marginwidth=0 marginheight=0 topmargin=0 leftmargin=0 link="#00325F" vlink="#00325F" alink="#00325F">' +
'<img src="'  + src + '" border="0"><br>' + 
'</body>' +
'</html>')
		  }
