﻿//Autor: Grzegorz Nowacki
//Nazwa pliku: menu.js
//Biblioteka funkcji javascript
	var aktywneMenu = new Array();
	aktywneMenu['podmenu'] = new Array();

	var zmiana = 15;
	var speed = 5;
	
	var zmianaTrans = 0.1;
	var transparentLevel = new Array();
	
	var tOff = new Array();
	var tOn = new Array();
	var time = new Array();
	
	var RGBs = new Array();
	RGBs[0] = 83;
	RGBs[1] = 2;
	RGBs[2] = 0;
	
	var RGBe = new Array();
	RGBe[0] = 241;
	RGBe[1] = 68;
	RGBe[2] = 0;

	var rgb = new Array();

	// nowa funkcja
	function btnDisplayUp(id, img){
		if(time[id]==''){
			var funkcja = "btnDisplayUp('"+id+"', '"+img+"')";
			time[id] = setTimeout(funkcja, 150);
		}else{
			clearTimeout(time[id]);
			window.document.getElementById(id).style.background = "url('elementy/"+img+"')";
			if(aktywneMenu['warstwa'] == id+'_pod'){
				hideMlayerOff();
				aktywneMenu['warstwa'] = '';
			}
		}
	}
	
	// nowa funkcja
	function btnDisplayDown(id, img){
		if(time[id]){
			clearTimeout(time[id]);
		}
		time[id] = '';
		window.document.getElementById(id).style.background = "url('elementy/"+img+"')";
		
		if(aktywneMenu['warstwa']!=(id+'_pod') && aktywneMenu['warstwa']){
			hideMlayerOff();
			aktywneMenu['warstwa'] = '';
		}
	}
	
	// nowa funkcja
	function menuPozycjeShowHide(id){
		var opcja = window.document.getElementById(id).style.display;
		if(opcja=="none"){
			window.document.getElementById(id).style.display = "";
		}else{
			window.document.getElementById(id).style.display = "none";
		}
	}
	
	
	// zmodyfkikowana funkcja
	function displayOff(tlo){
		if(window.document.getElementById(tlo)){
			window.document.getElementById(tlo).className = 'tloUp';
		}
	}
	
	function displayOn(tlo){
		if(window.document.getElementById(tlo)){
			window.document.getElementById(tlo).className = 'tlo';
		}
	}

	// zmodyfkikowana funkcja
	function showM(warstwa){
		
		window.document.getElementById('layerOff').style.width = '100%';
		window.document.getElementById('layerOff').style.height = '100%';
		
		window.document.getElementById(warstwa).style.visibility = 'visible';
		window.document.getElementById(warstwa).style.top = '51px';
					
		if(aktywneMenu['warstwa']!=warstwa && aktywneMenu['warstwa']){
			hideMlayerOff();
			aktywneMenu['warstwa'] = '';
		}
			
		aktywneMenu['warstwa'] = warstwa;
		
		//clearTimeout(time['menuShow'+menu.substr(4,6)]);
	}
	
	function hideMlayerOff(){
		hideM();
		window.document.getElementById('layerOff').style.width = '0px';
		window.document.getElementById('layerOff').style.height = '0px';
	}
	
	// zmodyfkikowana funkcja
	function hideM(){
		window.document.getElementById(aktywneMenu['warstwa']).style.visibility = 'hidden';
		window.document.getElementById(aktywneMenu['warstwa']).style.top = '-300px';
	}
	
	function hideMuse(warstwa, menu){
		var parametr = 'position:absolute; opacity:0; filter:alpha(opacity=0); visibility:hidden;';
		window.document.getElementById(warstwa).style.cssText = parametr;
		
		var kategoria = window.document.getElementById('aktywnaPozycjaMenu').innerHTML;
		var kategoriaPorownanie = window.document.getElementById(menu).innerHTML;
		
		if(menu && kategoriaPorownanie.lastIndexOf(kategoria)<0){
			window.document.getElementById(menu).className = 'kontenerB';
		}

		if(window.document.getElementById(warstwa+"Sep")){
			window.document.getElementById(warstwa+"Sep").className = 'podzial';
		}
	}
	
	function findPos(obj) {
		var nleft = 0;
		var ntop = 0;
		if (obj.offsetParent) {
			nleft = obj.offsetLeft
			ntop = obj.offsetTop
			while (obj = obj.offsetParent) {
				nleft += obj.offsetLeft
				ntop += obj.offsetTop
			}
		}
		return [nleft,ntop];
	}

