﻿function addOnloadEvent(){
  if ( typeof window.addEventListener != "undefined" ) {
    window.addEventListener( "load", initUl, false );
  }
  else if ( typeof window.attachEvent != "undefined" ) {
    window.attachEvent( "onload", initUl );
  }
  else {
    if ( window.onload != null ) {
      var oldOnload = window.onload;
      window.onload = function ( e ) {
        oldOnload( e );
        window[initUl]();
      };
    }
    else {
      window.onload = initUl;
	}
}
}

// init LI labels

function initUl() {
	if(document.getElementById("floormenu")) {
		var divli = document.getElementById("floormenu").getElementsByTagName("li");
		var akt=1;
		
		for(var i=0; i<divli.length; i++) {
			divli.item(i).data_id = i+1; 
			divli.item(i).onclick = function() {
				var id = this.data_id;
				if(document.getElementById('floorplan_'+id)) {
					this.parentNode.className = "fpm" + id;
					document.getElementById('floorplan_'+akt).style.display = 'none';
					document.getElementById('floorplan_'+id).style.display = '';
					document.getElementById('floorsdiv' + akt).style.display = 'none';
					document.getElementById('floorsdiv' + id).style.display = '';
					//document.getElementById('floors').src = 'images/floors/floor_' + id + '.png';
					akt=id;	
				};
			};
		};
	}
}

//
addOnloadEvent();