/******************************************************************************************************
 *******************************************************************************************************
 Kaskadowe menu.
 (c) 2003, Marcin Korecki, korecki@pnet.pl. Wszystkie prawa zastrzeżone.
 *******************************************************************************************************
 ******************************************************************************************************/
 
 var hl = null;
 var hlS = null;
 var hlIm = null;
 var hlL = null;
 var hlsL = null;
 var ti = null;
 var tiS = null;
 var tiIm = null;
 var doHilite = false;
 var menuL = 0;
 var menuR = 0;
 var menuT = 0;
 var menuB = 0;
 var empl = null;
 var ready = 0;
 var iBannerLeft = 0;
 var iBannerTop = 0

 doHilite = MK_menu_bgcolor_hl != "" && MK_left_hl != "" && MK_right_hl != "";  
 
 MK_preload(MK_menu_images_dir,MK_left,MK_right,MK_left_icon,MK_right_icon,MK_bottom_left,MK_bottom_right,MK_bottom,MK_top_left,MK_top_right,MK_top,MK_pixel,MK_left_icon_hl,MK_right_icon_hl,MK_left_hl,MK_right_hl);
 
 /*---------------  Detekcja przeglądarki ---------------*/
 
function whatBrowser() {
	this.fappVer = parseFloat(navigator.appVersion);
	this.agent = navigator.userAgent.toLowerCase();
  this.opera = (this.agent.indexOf("opera")!=-1);
  this.ns6 = (navigator.vendor == "Netscape" || navigator.product == "Gecko");
  this.DOM = (document.getElementById) ? true : false;
 	this.nn4 = (document.layers) ? true : false;
 	this.all = (document.all) ? true : false;
  this.ok = (this.DOM || this.all || this.nn4);
  this.ie = (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)&&(navigator.userAgent.indexOf('Opera')==-1)&&(navigator.appName != 'Netscape')&&(navigator.userAgent.indexOf('MSIE') > -1)&&(this.fappVer >=4);

  return this;
}

 var browser = new whatBrowser();

if (browser.DOM || browser.all) {
	var v = "visible";
 	var h = "hidden";
}
else {
	var v = "show";
  var	h = "hide";
}
 
 /*---------------  Rollover obrazków ---------------*/
 
 var imagesNo = 0;
 
 while (eval("window.MK_rollover_image_" + imagesNo)) {
   
   obj = MK_getParams(eval("window.MK_rollover_image_" + imagesNo));
   if (obj.first != 0) {
     //alert(obj[0]);
     imageSrcOut = MK_rollover_dir + obj.first + "0." +  MK_rollover_ext;
     imageSrcOver = MK_rollover_dir + obj.first + obj.second + "." +  MK_rollover_ext;

     eval("image_" + imagesNo + "_out = new Image()");
     eval("image_" + imagesNo + "_out.src = imageSrcOut");
   
     eval("image_" + imagesNo + "_over = new Image()");
     eval("image_" + imagesNo + "_over.src = imageSrcOver");
   }
   imagesNo++;
 }
 
 function MK_hilite(image) {
 	
   document.images[image].src = eval(image + "_over" + ".src");
   hlIm = image;  
   
   if (MK_show_status && eval("window.MK_image_text" + image.substring(5)))
     MK_statusMesg(eval("window.MK_image_text" + image.substring(5)));
 }
 
 function MK_hiliteOut(image) {
 
 	document.images[image].src = eval(image + "_out" + ".src");
   hlIm = null; 
   
   if(MK_show_status)
     MK_statusMesg("");
   if (tiIm) tiIm = null;
 }
 
 /*---------------  Funkcje ---------------*/
 
 function MK_statusMesg(mesg) {
   if (browser.opera)
     defaultStatus = mesg;
   else
     status = mesg;
   return;
 }
 
 function MK_getParams(paramName) {
   
   var par = new Object();
   var coma = paramName.indexOf(",");
   if (coma != -1) {
     par.first = paramName.substring(0, coma);
     par.second = parseInt(paramName.substring(coma + 1));
   }
   else
     par.first = par.second = 0;
     
   return par;
 }
 
 function MK_parseXY(paramName) {
   
   var coor = new Array(0,0);
   var coma = paramName.indexOf(",");
   if (coma != -1) {
     coor[0] = parseInt(paramName.substring(0, coma));
     coor[1] = parseInt(paramName.substring(coma + 1));
   }
     
   return coor;
 }
 
 function MK_placeImage(imageName, imageSize) {
   
   var im = "<img src=\"" + MK_menu_images_dir + imageName + "\" width=\"" + MK_parseXY(imageSize)[0] + "\" height=\"" + MK_parseXY(imageSize)[1] + "\" border=\"0\" alt=\"\">";
    
   return im;
 }
 
 function MK_findObjectStyle(obj) {
   
   if (browser.DOM) return document.getElementById(obj).style;
   if (browser.all) return document.all[obj].style;
   if (browser.nn4) return document.layers[obj];
   
   return false;
 }
 
 function MK_findObject(obj) {
   
   if (browser.DOM) return document.getElementById(obj);
   if (browser.all) return document.all[obj];
   if (browser.nn4) return document.layers[obj];
   
   return false;
 }
 
 function MK_layerMoveTo(layerID, x, y) {
 	
   MK_findObjectStyle(layerID).left = x;
   MK_findObjectStyle(layerID).top = y;
 }
 
 function MK_getImageX (img) {
   
   var par = document.images[img];
   var x = 0;
   
   if (!browser.nn4) {
     var lastOffset = 0;
 		while(par){
 			if( (par.offsetLeft != lastOffset) && par.offsetLeft ) x += parseInt(par.offsetLeft);
 			if( par.offsetLeft != 0 ) lastOffset = par.offsetLeft;
 			par = par.offsetParent;
 		}
 	}
   else if (img.x >= 0) x = img.x;
 	
   return x;
 }
 
 function MK_getImageY (img) {
 	
   var par = document.images[img];
   var y = 0;
   
   if(!browser.nn4) {
     var lastOffset = 0;
 		while(par){
       if( (par.offsetTop != lastOffset) && par.offsetTop ) y += parseInt(par.offsetTop);
 			if( par.offsetTop != 0 ) lastOffset = par.offsetTop;
       par = par.offsetParent;
     }		
 	}
   else if (img.y >=0 ) y = img.y;
 	
   return y;
 }
 
 function MK_showLayer(no) {
   
   MK_findObjectStyle("menu" + no).visibility = v;
   hl = no;
 }
 
 function MK_showSublayer(no) {
   
   MK_findObjectStyle("submenu" + no).visibility = v;
   hlS = no;
 }
 
 function MK_hideLayer(no) {
   
   MK_findObjectStyle("menu" + no).visibility = h;
   
   if (hlL) MK_hideMenuLink(hlL);  
   hl = null;
 	ti = null;
 }
 
 function MK_hideSublayer(no) {
   
   MK_findObjectStyle("submenu" + no).visibility = h;
   
   if (hlsL) MK_hideSubmenuLink(hlsL);  
   hlS = null;
 	tiS = null;
 }
 
 function MK_showMenuLink(no) {
   
   if (doHilite) {
     MK_findObjectStyle("linklhl" + no).visibility = v;
     MK_findObjectStyle("linkmhl" + no).visibility = v;
     MK_findObjectStyle("linkrhl" + no).visibility = v;
 		//MK_findObjectStyle("rightIconhl" + no).visibility = v;
     
     if (MK_show_status)
       MK_statusMesg(eval("window.MK_menu_text" + no));
     hlL = no;
 	}
 }
 
 function MK_showSubmenuLink(no) {
   //alert(no);
   if (doHilite) {
     MK_findObjectStyle("sublinklhl" + no).visibility = v;
     MK_findObjectStyle("sublinkmhl" + no).visibility = v;
     MK_findObjectStyle("sublinkrhl" + no).visibility = v;
 		//MK_findObjectStyle("rightIconhl" + no).visibility = v;
     
     if (MK_show_status)
       MK_statusMesg(eval("window.MK_menu_text" + no));
     hlsL = no;
 	}
 }
 
 function MK_hideMenuLink(no) {
   
   if (doHilite) {
     MK_findObjectStyle("linklhl" + no).visibility = h;
     MK_findObjectStyle("linkmhl" + no).visibility = h;
     MK_findObjectStyle("linkrhl" + no).visibility = h;
 		//MK_findObjectStyle("rightIconhl" + no).visibility = h;
     
     if (MK_show_status)
       MK_statusMesg("");
     hlL = null;
 	}
 }
 
 function MK_hideSubmenuLink(no) {
   
   if (doHilite) {
     MK_findObjectStyle("sublinklhl" + no).visibility = h;
     MK_findObjectStyle("sublinkmhl" + no).visibility = h;
     MK_findObjectStyle("sublinkrhl" + no).visibility = h;
 		//MK_findObjectStyle("rightIconhl" + no).visibility = h;
     
     if (MK_show_status)
       MK_statusMesg("");
     hlsL = null;
 	}
 }
 
 function MK_hideMenu(no, im) {
   
   ti = setTimeout("MK_hideLayer('" + no + "')", MK_timeout);
   tiIm = setTimeout("MK_hiliteOut('" + im + "')", MK_timeout);
 }
 
 function MK_hideAllMenus() {
   
 	MK_hideMenu(hl, hlIm);
   tiS = setTimeout("MK_hideSublayer('" + hlS + "')", MK_timeout);
 }
 
 function MK_checkTimeout() {
   
   clearTimeout(ti);
   clearTimeout(tiIm);
   ti = tiIm = null;
 }
 
 function MK_clearTimeouts() {
 	MK_checkTimeout();
 	clearTimeout(tiS);
 	tiS = null;
 }
 
 function MK_positionMenus() {
   
   if (imagesNo > 0) {
     menuL = document.images['image_0'].x;
     menuT = document.images['image_0'].y;
     menuR = document.images["image_" + (imagesNo - 1)].x + document.images["image_" + (imagesNo - 1)].width;
     menuB = menuT + document.images['image_0'].height;
   }
   
   for (i = 0; i < imagesNo; i++) {
     if (eval("window.MK_menu_offset_" + i)) {
       var x = MK_getImageX("image_" + i) + MK_parseXY(eval("MK_menu_offset_" + i))[0];
       var y = MK_getImageY("image_" + i) + MK_parseXY(eval("MK_menu_offset_" + i))[1] + MK_rollover_height;
   		 MK_layerMoveTo("menu_" + i, x, y);
     }
   }
   ready = 1;
 }
 
 function MK_goTo(no) {
   
   var target = null;
   var where = null;
   
   if (!(where = eval("window.MK_menu_link" + no)))
     return;
   else {
     if (target = eval("window.MK_menu_window" + no)) {
       if (target == "_self")
         window.location.href = where;
       else
         window.open(where);
     }
     else
       window.location.href = where;
   }
 }
 
 function show(no) {
   
 	if (shown == null) {
   	MK_findObjectStyle("map_mask").visibility = v;
 		MK_findObjectStyle("woj_" + no).visibility = v;
 	}
 	else {
 		MK_findObjectStyle("woj_" + shown).visibility = h;
 		MK_findObjectStyle("woj_" + no).visibility = v;
 	}
 	shown = no;
 }
 
 function contact(region) {
   
 	if (shown) {
 		MK_findObjectStyle(shown).visibility = h;
   	MK_findObjectStyle(region).visibility = v;
 	}
 	else {
 		MK_findObjectStyle(region).visibility = v;
 	}
 	shown = region;
 }
 
 function hide(no) {
   
   if (shown == no) {
 		MK_findObjectStyle("woj_" + no).visibility = h;
 		MK_findObjectStyle("map_mask").visibility = h;
 		shown = null;
 	}
 }
 
 function show_graph(no) {
   
 	if (shown == null) {
   	MK_findObjectStyle("graph_" + no).visibility = v;
 	}
 	else {
 		MK_findObjectStyle("graph_" + shown).visibility = h;
 		MK_findObjectStyle("graph_" + no).visibility = v;
 	}
 	shown = no;
 }
 
 function hide_graph(no) {
   
   if (shown == no) {
 		MK_findObjectStyle("graph_" + no).visibility = h;
 		shown = null;
 	}
 }
 
 function MK_showEmplDesc(no) {
   
 	if (empl == null) {
   	x = MK_getImageX("pracownik_" + no);
 		y = MK_getImageY("pracownik_" + no);
 		MK_layerMoveTo("opis_" + no, x - 55, y - 15);
 		MK_findObjectStyle("opis_" + no).visibility = v;
 	}
 	else {
 		MK_findObjectStyle("opis_" + empl).visibility = h;
 		x = MK_getImageX("pracownik_" + no);
 		y = MK_getImageY("pracownik_" + no);
 		MK_layerMoveTo("opis_" + no, x - 55, y - 15);
 		MK_findObjectStyle("opis_" + no).visibility = v;
 	}
 	empl = no;
 }
 
 function MK_hideEmplDesc(no) {
   
 	MK_findObjectStyle("opis_" + empl).visibility = h;
 	empl = null;
 }
 
 function MK_printWindow(url, WindowName) {
 	parameters = "width=600, height=" + eval(screen.Availheight - 100) + ", toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes,  resizable=yes, left=0, top=0";
 		
 		window.open(url,WindowName,parameters);
 }
 
 function MK_preload() {
   
   var imA = new Array();
   var args = MK_preload.arguments;
   for (var i = 1; i < args.length; i++)
     if (args[i]) {
       imgSrc = "" + args[0] + args[i];
       eval("im" + i + "= new Image()");
       eval("im" + i + ".src = imgSrc");
     }
 }
 
 if (browser.nn4)
   file = "mk_menu_ns4.js";
 else if (browser.ns6)
   file = "mk_menu_ns6.js"
 else
   file = "mk_menu_other.js";
 document.write("<script language=\"JavaScript\" src=\"js/" + file + "\"></script>");
 document.close();
