
var nav_timer = 0;
var nav_block = 0;
var active_nav_1 = 0;
var last_active_nav_1 = 0;
var prev_active_nav_1 = 0;
var current_content_param = 0;
var last_content_param = 0;

/*----------------------------------------------------------------------------------------------
	navi aktivierung
----------------------------------------------------------------------------------------------*/
function nav_click(button){
	
	prev_active_nav_1 = last_active_nav_1;
	
	// IE FIX: prevent the second call from a parent of a nested link 
	if(!nav_block){
		nav_block = 1;
		function  nav_unlock(){ nav_block = 0; }
		nav_timer = window.setTimeout(nav_unlock,1);
		
		// get the id of the first layer
		var first = button.id;
		first = first.split("_");
		first = first[0] + '_' + first[1] + '_' + first[2];
		
		active_nav_1 = first;
		
		// unmark the last active button of the first layer
		if(last_active_nav_1){ 
			if($(last_active_nav_1).className.match('link_1_act directory_down'))
				$(last_active_nav_1).className = 'link_1 directory_down';
			else
				$(last_active_nav_1).className = 'link_1';
		}
		// mark the active button of the first layer
		if($(active_nav_1).className.match('link_1 directory_down'))
			$(active_nav_1).className = 'link_1_act directory_down';
		else
			$(active_nav_1).className = 'link_1_act';
			
		last_active_nav_1 = active_nav_1;
		
		/*
		
		switch(button.id){
			
			// home
			case 'nav_btn_1':
				break;
		}	
		*/
		
		button.blur();
	}
	
}

/*-------------------------------------------------------------------------
	den site content per ajax laden
-------------------------------------------------------------------------*/
var nav_block1 = 0;
function load_data(param){
	
	last_content_param = current_content_param;
	
	// IE FIX: prevent the second call from a parent of a nested link 
	if(!nav_block1){
		
		nav_block1 = 1;
		function  nav_unlock(){ nav_block1 = 0; }
		nav_timer = window.setTimeout(nav_unlock,1);
		
		ajax = new Ajax;
		if(!ajax) alert('kein ajax :(');
		ajax.params = 'id=' + param;
		ajax.url = 'inc/get_content.src.php';
		ajax.onSuccess = function(text,xml){
			$('content').innerHTML = text;
			
			title = text.match("<h1>(.*?)</h1>");
			title = title[1];
			
			init_content_scroll(40);
			
			if($('bg_img_path').value)
				$('mainframe').style.backgroundImage = 'url(' + $('bg_img_path').value + ')';	
			
			document.title = 'INDIE JONES - ' + replace_entities(title);
			window.location.hash = active_nav_1.replace("nav_btn_","") + '_' + param + '|' + title;
			
			current_content_param = param;
		
		}
		ajax.doRequest();
		
	}
}

function replace_entities(text){
	text = text.replace('&uuml;','ü');
	text = text.replace('&Uuml;','Ü');
	text = text.replace('&auml;','ä');
	text = text.replace('&Auml;','Ä');
	text = text.replace('&ouml;','ö');
	text = text.replace('&Ouml;','Ö');
	return text;
}
