// To make IE quiet and happy
if (typeof console == "undefined" || typeof console.log == "undefined") var console = { log: function(x) {  } };


var active_page = null;
var active_tab = null;

/*
 * Activate  the main navigation entry
 */
function activate_nav( name, path )
{
	if( name != '')
	{
		$("#nav_first ul li." + name + " a").css("background-image","url('" + path + "/Images/nav_button/nav_" + name + "_act.gif')");
	
		if( name != "contact" )
		{
			$("#nav_first ul li." + name + " a").css("width",parseInt($("#nav_first ul li." + name + " a").css("width")) +1 +"px");
			
			var prev_name = $("#nav_first ul li." + name ).next().attr('class');
	
			if( typeof(prev_name) != "undefined" )
			{
				$("#nav_first ul li." + prev_name + " a").css('background-position','-1px 0px');
				$("#nav_first ul li." + prev_name + " a").css('width',parseInt($("#nav_first ul li." + prev_name + " a").css('width')) -1 +"px");
			}
		}
		active_page = name;
	}
}


/*
 * TAB Navigation
 *
 */
 
function activate_tab( me )
{
	if( active_tab != null )
	{
		restore_tab(active_tab);
	}

	var sibling = $(me).parent().next('li');
	sibling.css("background-position","-1px 100%");
	sibling.children("a").css("margin-left","-1px");
	$(me).addClass("active");

	active_tab = me;
}

function restore_tab( me )
{
	var sibling = $(me).parent().next('li');
	sibling.css("background-position","0% 100%");
	sibling.children("a").css("margin-left","0px");
	$(me).removeClass("active");
}


function tab_navigation_set( tab_name )
{
	// Hide all tabs
	$("div#content div.right div.box").hide();
	// Show the first one
	$("div#content div.right div#" + tab_name + ".box").show();
	

	// Same for the left side
	$("div#content div.left div.box").hide();
	// Show the first one
	$("div#content div.left div#" + tab_name + "_left.box").show();

	
	//replaceH1();
	// Sifr replace
	//replaceH2();
	//replaceH3();
	//alert('replace');
	//$("h3").removeClass('noSifr');
	//replaceSubHeadline();
	
	
	$("div#content div.right div.tab_nav li a").removeClass('active');

	var tab = $("div#content div.right div.tab_nav li." + tab_name + " a");

	activate_tab(tab);
}


/*
 * Register the tab navigation within pages
 */
function register_tab_navigation( first_tab )
{
	window.setTimeout(function(){
		// move all boxes after the sIFR replacement back into the page!!
		$("div.right div.box").css("left", "0px");
		$("div#content div.left").css("left", "0px");
		
		tab_navigation_set(first_tab);
		},
		800
	);

	$("div#content div.right div.tab_nav li a").click(function()
	{
		var active_tab = $(this).parent().attr("class");
		tab_navigation_set(  active_tab );

	});
}

