<!--

var last_selection;
var def_selection;
var dms_timer;
var dms_hide;
function hideMenuDMS(mode){
	clearTimeout(dms_timer);
	if( dms_hide ){
		dms_hide.removeClass("selected");
		dms_hide.children("ul").css("display", "none");
	}
	if( mode && mode == 1&& def_selection){
		def_selection.addClass("selected");
		def_selection.children("ul").css("display", "block");
		last_selection = def_selection.children("ul");
		dms_hide = def_selection;
	}
}
$(function() {
	$("#menutt > li > a").each(function (i) { 
		if( $(this).parent().hasClass("selected") ){
			last_selection = $(this).parent().children("ul");
			def_selection = $(this).parent();
			dms_hide = $(this).parent();
			$(this).parent().children("ul").css("display", "block");	
		}
		$(this).hover(
				function (){
					hideMenuDMS();
					if( last_selection.parent().attr("rel_cnt") != $(this).attr("rel_cnt")  ) {
						last_selection.css("display", "none");
					}
					last_selection = $(this).parent().children("ul");
					$(this).parent().addClass("selected");	
					$(this).parent().children("ul").css("display", "block");	
				
				}, function () {
					dms_hide = $(this).parent();
					clearTimeout(dms_timer);
					dms_timer = setTimeout("hideMenuDMS(1);", 2500);
				}
		);
		$(this).parent().attr("rel_cnt", i).click(function () { 
				document.location.href = $(this).children().attr("href");	
				return false;
		});
	});
	$("#menutt li ul li a").each(function (i) { 
		if( !$(this).parent().hasClass("selected") ){
			$(this).parent().hover(
				function (){
					$(this).addClass("selected");	
					clearTimeout(dms_timer);
				}, function () {
					$(this).removeClass("selected");
					clearTimeout(dms_timer);
					dms_timer = setTimeout("hideMenuDMS(1);", 2500);	
				}
			);
		}
		$(this).parent().css("cursor", "pointer").attr("rel_cnt", i).click(function () { 
				document.location.href = $(this).children().attr("href");	
				return false;
		});
	});	
});

$(function () {
	$("span").each(function (){
		tmp = $(this).attr("title");
		if( tmp ){
			arr = tmp.split("|");
			$(this).attr("title", "");
			$(this).html("<a href='mailto:"+arr[0]+"@"+arr[1]+"' "+arr[2]+">"+arr[3]+(arr[4] ? "@"+arr[4] : "")+"</a>");
		}
	});	
} );

var DmsGallery = new DmsGallery();
function initDms(){
	DmsGallery.init();	
}
window.onload= initDms;


//Menu DMS
function preSelectMenu(id) { selectMenu("menu" + id, id); }
function selectMenu(th, id) {
  th = document.getElementById(th);
  //ukrywam podmenu innych dzialow
  var Nodes = document.getElementsByTagName('div')
  var max = Nodes.length

  for (var i = 0; i < max; i++) {
    var nodeObj = Nodes.item(i);

    if (nodeObj.id.indexOf("pos") != -1) {
      nodeObj.style.display = "none";
    }
  }

  //pokazuje podmenu
  if (document.getElementById("pos" + id)) document.getElementById("pos" + id).style.display = "block";

  //zmieniam style innych butonow dzialow
  var Nodes = document.getElementsByTagName('li')
  var max = Nodes.length

  for (var i = 0; i < max; i++) {
    var nodeObj = Nodes.item(i);

    if (nodeObj.id.indexOf("menu") != -1) {
      nodeObj.className = "menupoz";
    }
  }

  //zmieniam styl wybranego buttony dzialu
  if (th) th.className = "menupoz2";
}
//Menu DMS
//-->
