/****************************************************************************
 *  header.js
 *
 *  Hier werden alle JavaScript Methoden für den bet2dogs-Header definiert.
 *
 *
 ****************************************************************************/
	browser=0;
	alerted=false;
	if (document.all) browser=1;
	if (document.layers) browser=3;
	else if (navigator.appName=="Netscape") browser=2;


	// DYNAMIC MENU CONTENTS ARRAY
	// Here we store information for each submenu identified by unique ID.
	// This informations are then used by function CHANGE_MENU to generate submenu LAYER contents.
	// Please note that letter "#" in <A HREF="#"> have to be replaced with proper URL address
	
	submenus=new Array();
	
	submenus["wetten"]=new Array();
	submenus["wetten"][0]=4;
	submenus["wetten"][1]='<A HREF="http://' + server + '/wettpunkt/bets/index.jsp" CLASS="na1"><FONT COLOR="#000000"><B>' + txtZuRennen + '</B></FONT></A>';
	submenus["wetten"][2]='<A HREF="http://' + server + '/wettpunkt/sport/konto/funkt/KontoAuszug.jsp" CLASS="na1"><FONT COLOR="#000000"><B>' + txtKontoAuszug + '</B></FONT></A>';
	submenus["wetten"][3]='<A HREF="http://' + server + '/wettpunkt/sport/konto/funkt/WettHistorie.jsp?limit=true" CLASS="na1"><FONT COLOR="#000000"><B>' + txtMeineWetten + '</B></FONT></A>';
	submenus["wetten"][4]='<A HREF="http://' + server + '/wettpunkt/bets/b2dergebnis.jsp" CLASS="na1"><FONT COLOR="#000000"><B>' + txtErgebnisse + '</B></FONT></A>';
	
	submenus["konto"]=new Array();
	submenus["konto"][0]=showSGH ? 6 : 5;
	submenus["konto"][1]='<A HREF="http://' + server + '/wettpunkt/sport/konto/funkt/Einzahlung.jsp" CLASS="na1"><FONT COLOR="#000000"><B>' + txtEinzahlung + '</B></FONT></A>';
	submenus["konto"][2]='<A HREF="http://' + server + '/wettpunkt/sport/konto/funkt/Auszahlung.jsp" CLASS="na1"><FONT COLOR="#000000"><B>' + txtAuszahlung + '</B></FONT></A>';
	submenus["konto"][3]='<A HREF="https://' + server + '/wettpunkt/sport/konto/funkt/StammdatenAenderung.jsp" CLASS="na1"><FONT COLOR="#000000"><B>' + txtStammdaten + '</B></FONT></A>';
	submenus["konto"][4]='<A HREF="https://' + server + '/wettpunkt/sport/konto/funkt/PersLimit.jsp" CLASS="na1"><FONT COLOR="#000000"><B>' + txtPersLimits + '</B></FONT></A>';
	submenus["konto"][5]='<A HREF="http://' + server + '/wettpunkt/sport/konto/funkt/Passwort.jsp" CLASS="na1"><FONT COLOR="#000000"><B>' + txtPwdChange + '</B></FONT></A>';
	if (showSGH) {
	    submenus["konto"][6]='<A HREF="http://' + server + '/wettpunkt/sport/konto/funkt/EmailAenderung.jsp" CLASS="na1"><FONT COLOR="#000000"><B>' + txtStartguthaben + '</B></FONT></A>';
	}


	submenus["service"]=new Array();
	submenus["service"][0]=3;
	submenus["service"][1]='<A HREF="http://' + server + '/wettpunkt/bets/info.jsp" CLASS="na1"><FONT COLOR="#000000"><B>' + txtInfo + '</B></FONT></A>';
	submenus["service"][2]='<A HREF="mailto:' + serverEmail + '" CLASS="na1"><FONT COLOR="#000000"><B>' + txtKontakt + '</B></FONT></A>';
	submenus["service"][3]='<A HREF="http://' + server + '/wettpunkt/bets/faq.jsp" CLASS="na1"><FONT COLOR="#000000"><B>FAQ</B></FONT></A>';
	
	
	// FUNCTION GENERATE_MENU
	// id - unique identificator for each submenu
	// active - we do not need to create anchor for the submenu which is active
	
	function generate_menu(id,active)
	{
		// filling up the menu contents
		
		space=false;
		contents='<FONT CLASS="na"> &nbsp; &nbsp; &nbsp; ';
		
		for(i=1;i<=submenus[id][0];i++)
		{
//			if (i==active) continue;
			
			if (space) contents+='&nbsp;&nbsp;&nbsp;';
			contents+=submenus[id][i];
			space=true;
		}
		
		contents+='</FONT>';
		
		return contents;
	}
	
	
	// FUNCTION CHANGE_MENU
	// id - unique identificator for each submenu
	// active - we do not need to create anchor for the submenu which is active
	
	function change_menu(id,active)
	{
		contents=generate_menu(id,active);
		
		// using proper method to draw the contents on web browser (depending on BROWSER TYPE)
		
		switch (browser)
		{
			case 1: submenu.innerHTML=contents; break;
			case 2: document.getElementById("submenu").innerHTML=contents; break;
			default: browser_error(); break;
		}
	}
	
	function change_language(_lang) {
        
        var urlnew = "";
        var pos = location.href.indexOf("?");
        if (pos != -1) {
            urlnew = location.href.substring(0, pos);
        }
        
        location.href = urlnew + "?" +  "Language=" + _lang + "&Country=" + _lang.toUpperCase();
    }
    
    

	function logout()
	{
		location.href='http://' + server + '/wettpunkt/bets/login.jsp?action=logout';
	}


    function update_kontostand(val) {
		switch (browser)
		{
			case 1: 
			    if (document.all.Kontostand) {
			        document.all.Kontostand.value=val;
			    }
			    break;
			case 2: 
			    if (document.getElementById("Kontostand")) {
			        document.getElementById("Kontostand").value=val; 
			    }
			    break;
			default: 
			    browser_error(); 
			    break;
		}
        
    }
    
	function tv_focus(element)
	{
		switch (browser)
		{
			case 1: eval('tv_'+element+'.src="/wettpunkt/bets/images/button_'+element+'_active.gif";'); break;
			case 2: eval('document.images["tv_'+element+'"].src="/wettpunkt/bets/images/button_'+element+'_active.gif";'); break;
			default: browser_error(); break;
		}
	}
	
	function tv_unfocus(element)
	{
		if (output!=element)
		{
			switch (browser)
			{
				case 1: eval('tv_'+element+'.src="/wettpunkt/bets/images/button_'+element+'.gif";'); break;
				case 2: eval('document.images["tv_'+element+'"].src="/wettpunkt/bets/images/button_'+element+'.gif";'); break;
				default: browser_error(); break;
			}
		}
	}
	
	function tv_set(element)
	{
		output=element;
		
		tv_unfocus('text');
		tv_unfocus('picture');
		tv_unfocus('movie');
		
		tv_focus(element);
	}
    
    
   	function browser_error()
	{
		if (!alerted)
		{
			alerted=true;
			alert(txtBrowser);
		}
	}
