var CHECK_HASH_REGEX = /^.*#([^#]+).*$/;

document.observe('dom:loaded', function() {
	// hide vitablock
	$('vitablock').setStyle({display: 'none'});
	
	// hash (open lightbox on hash)
	var hashlink = document.location.href.replace(CHECK_HASH_REGEX, "$1");
	
	// define counter
	var counter = 0;
	
	// IE does not have the array on dom ready -> wait until the GLOBAL_LAYER_CONTROLLER array is filled 
	new PeriodicalExecuter(function(pe) {
		
		// increment counter
		counter += 1;
		
		// stop after 5 repeats
		if (counter >= 5) {
			pe.stop();
		}

		// iterate the object
    	$H(GLOBAL_LAYER_CONTROLLER).each(function(item){
    		
    		// check, if there is an object in the array which contains the hashlink
    		if (item[0].indexOf(hashlink) != -1) {
    			// toggle layer
    			GLOBAL_LAYER_CONTROLLER[item[0]].toggle();
    			// stop the periodical updater
    			pe.stop();
    		}
    	}.bind(pe));
	}, 0.5);

    // render sIFR in lighbox (fireSifrHandler() is called in lightbox script automatically)
	registerSifrHandler('div.vita-text div.sifr-h1 h4','#333333');

});