var menuAction = "";


function updateBrancheURL(linkObj, a, m, area){
	if(linkObj && linkObj!=null && linkObj.id!='') {
		checkMenuOptions(a);
		//alert(menuAction);
		// BRanchenwechsel bei den Nutzungsoptionen
		if (menuAction != 'marktstatistik' && menuAction != 'ranking' && menuAction != 'anfragen' && menuAction != 'merkliste' && menuAction != 'verzeichnis' && menuAction != 'content_anforderungen' && menuAction !='sonderfunktionen_bestellen' && document.location.href.indexOf("/nutzungsoptionen.htm") >=0 && document.location.href.indexOf("/nutzungsoptionen.htm?a=") < 0){
			if (document.location.href.indexOf("com.benchpark.www")>=0) linkObj.href = '/com.benchpark.www/nutzungsoptionen.htm?a=' + area;
	        else linkObj.href = '/nutzungsoptionen.htm?a=' + area;
			
		}else{
			// Für Breiche, wo keine Branchenauswahl sinnvol ist, wird auf die Seite: Empfohlene Anbieter verlinkt
			if (menuAction=="" && m=='informieren' && (document.location.href.indexOf("agb_")<0 && document.location.href.indexOf("nutzungsoptionen")<0)){
				if (document.location.href.indexOf("com.benchpark.www")>=0) linkObj.href = '/com.benchpark.www/' + linkObj.id;
	        	else linkObj.href = '/' + linkObj.id;
	          	linkObj.href += ".htm";
		
			}else if (a != null && a != "" && a != "null" && menuAction==""){
				// Seiten linken, wo ein Branchenwechsel keinen Sinn macht
				// Vendorseiten
				if (document.location.href.indexOf("/kundenzufriedenheit.htm") >=0 ||
					document.location.href.indexOf("/kiviatgraph_verlauf.htm") >=0 ||
					document.location.href.indexOf("/kommentare.htm") >=0 ||
					document.location.href.indexOf("/statistik.htm") >=0 ||
					document.location.href.indexOf("/informationen.htm") >=0 ||
					document.location.href.indexOf("/profil.htm") >=0 ||
					document.location.href.indexOf("/kontakt.htm") >=0 ||
					document.location.href.indexOf("/showAssessment.htm") >=0 ||
					document.location.href.indexOf("/suchergebnisse.htm") >=0 ){
					if (document.location.href.indexOf("com.benchpark.www")>=0) linkObj.href = '/com.benchpark.www/' + linkObj.id;
	        		else linkObj.href = '/' + linkObj.id;
	        		linkObj.href += ".htm";
				// Tenderseiten
				}else if (document.location.href.indexOf("/anfragen_ausschreibungen_auftraege_suchergebnisse.htm") >=0 ||
							document.location.href.indexOf("/anfragen_ausschreibungen_auftraege_suche/karte.htm") >=0 ||
							document.location.href.indexOf("/beschreibung.htm") >=0 ||
							document.location.href.indexOf("/detailansicht.htm") >=0 ||
							document.location.href.indexOf("/bewerbung.htm") >=0){
					if (document.location.href.indexOf("com.benchpark.www")>=0) linkObj.href = '/com.benchpark.www/' + linkObj.id;
	        		else linkObj.href = '/' + linkObj.id;
	        		linkObj.href += "/anfragen.htm";
	        	// Editorseiten
	        	}else if (document.location.href.indexOf("/editor_einstellungen.htm") >=0 ||
							document.location.href.indexOf("/editor_unternehmensdaten.htm") >=0 ||
							document.location.href.indexOf("/editor_netzwerk.htm") >=0 ||
							document.location.href.indexOf("/editor_informationen.htm") >=0 ||
							document.location.href.indexOf("/editor_kommentare.htm") >=0 ||
							document.location.href.indexOf("/besucherzahlen.htm") >=0 ||
							document.location.href.indexOf("/editor_siegel.htm") >=0 ||
							document.location.href.indexOf("/editor_einladungsservice.htm") >=0){
					if (document.location.href.indexOf("com.benchpark.www")>=0) linkObj.href = '/com.benchpark.www/' + linkObj.id;
	        		else linkObj.href = '/' + linkObj.id;
	        		linkObj.href += ".htm";
	        	// Benutzerkonto
	        	}else if (document.location.href.indexOf("/einstellungen_vollansicht.htm") >=0 ||
							document.location.href.indexOf("/einstellungen_benachrichtigung.htm") >=0 ||
							document.location.href.indexOf("/empfehlungen_und_ausschreibungen.htm") >=0 ||
							document.location.href.indexOf("/bestellhistorie.htm") >=0 ||
							document.location.href.indexOf("/eingegangene_nachrichten.htm") >=0 ||
							document.location.href.indexOf("/gesendete_nachrichten.htm") >=0 ||
							document.location.href.indexOf("/zugewiesene_eintraege.htm") >=0 ){
					if (document.location.href.indexOf("com.benchpark.www")>=0) linkObj.href = '/com.benchpark.www/' + linkObj.id;
	        		else linkObj.href = '/' + linkObj.id;
	        		linkObj.href += ".htm";
	        	// Für Erstbenutzer
	        	}else if (document.location.href.indexOf("/anleitung_anbieter_empfehlen.htm") >=0 ||
							document.location.href.indexOf("/anleitung_anbieter_vergleichen.htm") >=0 ||
							document.location.href.indexOf("/anleitung_bedarf_ausschreiben.htm") >=0 ||
							document.location.href.indexOf("/anleitung_anbieter_positionieren.htm") >=0 ||
							document.location.href.indexOf("/anleitung_medienpartner.htm") >=0 ||
							document.location.href.indexOf("/faq.htm") >=0 ||
							document.location.href.indexOf("/pressearchiv.htm") >=0 ||
							document.location.href.indexOf("/pressekontakt.htm") >=0 ||
							document.location.href.indexOf("/bildarchiv.htm") >=0 ||
							document.location.href.indexOf("/rss.htm") >=0){
					if (document.location.href.indexOf("com.benchpark.www")>=0) linkObj.href = '/com.benchpark.www/' + linkObj.id;
	        		else linkObj.href = '/' + linkObj.id;
	        		linkObj.href += ".htm";
	        	// Empfehlungsseiten
	        	}else if (document.location.href.indexOf("/empfehlen.htm") >=0 || document.location.href.indexOf("/empfehlen_eintragen.htm") >=0 ){
	        		if (document.location.href.indexOf("com.benchpark.www")>=0) linkObj.href = '/com.benchpark.www/' + linkObj.id;
		        	else linkObj.href = '/' + linkObj.id;
		        	
		          	if (document.location.href.indexOf("/empfehlen_eintragen.htm") >=0){
		          		linkObj.href += "/empfehlen_eintragen.htm";
		          	}else{
		          		linkObj.href += ".htm";
		          	}
	        	}else{
					linkObj.href = document.location.href;
					linkObj.href = linkObj.href.replace('awards',linkObj.id);
					linkObj.href = linkObj.href.replace('crm',linkObj.id);
					linkObj.href = linkObj.href.replace('ecm',linkObj.id);
					linkObj.href = linkObj.href.replace('it_und_systemhaeuser',linkObj.id);
					linkObj.href = linkObj.href.replace('erp',linkObj.id);
					linkObj.href = linkObj.href.replace('werbeagenturen',linkObj.id);
					linkObj.href = linkObj.href.replace('e-commerce',linkObj.id);
					linkObj.href = linkObj.href.replace('business-intelligence',linkObj.id);
					linkObj.href = linkObj.href.replace('pr-agenturen',linkObj.id);
					linkObj.href = linkObj.href.replace('dialogmarketing',linkObj.id);
					linkObj.href = linkObj.href.replace('unternehmensberatungen',linkObj.id);
					linkObj.href = linkObj.href.replace('mediaagenturen',linkObj.id);
					linkObj.href = linkObj.href.replace('eventagenturen',linkObj.id);
					linkObj.href = linkObj.href.replace('designagenturen',linkObj.id);
					linkObj.href = linkObj.href.replace('internet_service_provider',linkObj.id);
					linkObj.href = linkObj.href.replace('online_marketing_services',linkObj.id);
					linkObj.href = linkObj.href.replace('personalberatungen',linkObj.id);
					linkObj.href = linkObj.href.replace('wirtschaftsverbaende',linkObj.id);
					linkObj.href = linkObj.href.replace('messen_und_kongresse',linkObj.id);
					linkObj.href = linkObj.href.replace('zertifizierungen',linkObj.id);
					linkObj.href = linkObj.href.replace('zeitarbeitsunternehmen',linkObj.id);
					linkObj.href = linkObj.href.replace('b2b-marktplaetze',linkObj.id);
					linkObj.href = linkObj.href.replace('internetagenturen',linkObj.id);
					linkObj.href = linkObj.href.replace('promotionagenturen',linkObj.id);
				    
			    }
			}else if (menuAction != ""){
			   	if (document.location.href.indexOf("com.benchpark.www")>=0) linkObj.href = '/com.benchpark.www/' + linkObj.id+"/" + menuAction.replace('content_','').replace('_2','')+".htm";
		        else linkObj.href = '/' + linkObj.id +"/" + menuAction.replace('content_','').replace('_2','')+".htm";
				
		        // bei Empfehlen: Singular in URL verwenden fuer Google Optimierung
		        
		        if (menuAction=='ranking') {
		          linkObj.href += "?grp=A";          
		        }
		        
		        linkObj.href = linkObj.href.replace('_dach','');
		
		        if (menuAction=='verzeichnis') linkObj.href = linkObj.href.replace('/verzeichnis.htm','.htm');
	        	
	        	if (menuAction.indexOf("produkt_bestellen")>=0) {
		            var url = 'produkt_bestellen.htm?tage=' + document.getElementById('durationSelector1').value + '&novalidation';
		            linkObj.href  = (document.location.href.indexOf("com.benchpark.www")>=0?'/com.benchpark.www/':'/') + linkObj.id+"/"+url;
		        }
		        else if (menuAction.indexOf("sonderfunktionen_bestellen")>=0) {
		           
		            var su = document.getElementsByName('checkUnternehmen');
		            if (su[0].checked) showUnternehmen = 1;
		            else showUnternehmen = 0;
		            var tage = "";
				   	if (document.getElementById('30').checked){
				   		tage = document.getElementById('30').value;
				   	}
				   	if (document.getElementById('180').checked){
				   		tage = document.getElementById('180').value;
				   	}
				   	/*
				   	if (document.getElementById('360').checked){
				   		tage = document.getElementById('360').value;
				   	}
				   	*/
			        var url = 'sonderfunktionen_bestellen.htm?tage=' + tage + '&novalidation&showUnternehmen='+showUnternehmen;
			        linkObj.href  = (document.location.href.indexOf("com.benchpark.www")>=0?'/com.benchpark.www/':'/') + linkObj.id+"/"+url;
			        
			       
		        }
		        else if (menuAction.indexOf("eigenauskunft_bestellen")>=0) {
		            var url = 'eigenauskunft_bestellen.htm?tage=30&novalidation';
		            linkObj.href  = (document.location.href.indexOf("com.benchpark.www")>=0?'/com.benchpark.www/':'/') + linkObj.id+"/"+url;
		        }
	        	if (menuAction=='merkliste') {
		          linkObj.href = "/"+linkObj.id+"/merkliste/liste.htm";          
		        }
			}else{
				if (document.location.href.indexOf("com.benchpark.www")>=0) linkObj.href = '/com.benchpark.www/' + linkObj.id;
	        	else linkObj.href = '/' + linkObj.id;
				linkObj.href += ".htm";
			}
		
		}
		
	}
}	


function updateMenuLink(act,targetUrl, linkObj){
		menuAction = act;
		if (document.location.href.indexOf("com.benchpark.www")>=0){
		 linkObj.href = '/com.benchpark.www/'+targetUrl;
		}else{
			linkObj.href = "/"+targetUrl;
		}
		if (act == 'sonderfunktionen_bestellen'){
			 var su = document.getElementsByName('checkUnternehmen');
	         if (su[0].checked) showUnternehmen = 1;
	         else showUnternehmen = 0;
	         var tage = "";
		   	if (document.getElementById('30').checked){
		   		tage = document.getElementById('30').value;
		   	}
		   	if (document.getElementById('180').checked){
		   		tage = document.getElementById('180').value;
		   	}
		   	/*
		   	if (document.getElementById('360').checked){
		   		tage = document.getElementById('360').value;
		   	}
		   	*/
            var url = targetUrl+'?tage=' +tage + '&novalidation&showUnternehmen='+showUnternehmen;
            linkObj.href  = (document.location.href.indexOf("com.benchpark.www")>=0?'/com.benchpark.www/':'/') + url;
		     
		}
		
		if (targetUrl.indexOf("javascript")>=0){
			linkObj.href = targetUrl;
			menuAction = act;
			if (document.getElementById('menu_image')){
				document.getElementById('menu_image').style.display='block';
				document.getElementById('menu_header').style.display='block';
			}
		}
		if (act=='empfehlen') {
          linkObj.href = linkObj.href.replace('internetagenturen','internetagentur');
          linkObj.href = linkObj.href.replace('werbeagenturen','werbeagentur');
          linkObj.href = linkObj.href.replace('pr-agenturen','pr-agentur');
          linkObj.href = linkObj.href.replace('unternehmensberatungen','unternehmensberatung');
          linkObj.href = linkObj.href.replace('mediaagenturen','mediaagentur');
          linkObj.href = linkObj.href.replace('eventagenturen','eventagentur');
          linkObj.href = linkObj.href.replace('designagenturen','designagentur');
          linkObj.href = linkObj.href.replace('promotionagenturen','promotionagentur');
          linkObj.href = linkObj.href.replace('online_marketing_services','online_marketing_service');
          linkObj.href = linkObj.href.replace('personalberatungen','personalberatung');          
        }
        
        if (act=='verzeichnis') linkObj.href = linkObj.href.replace('/verzeichnis.htm','.htm');
}


function checkMenuOptions(a){
	if (menuAction=='anfragen' || menuAction=='content_anforderungen' || menuAction=='anforderungen' || menuAction == 'anfragen_ausschreibungen_auftraege'){
		document.getElementById("spezialBranchen").style.display="none";
	}else if (document.getElementById("spezialBranchen")){
		document.getElementById("spezialBranchen").style.display="block";
	}
	if (a==null || a == "" || a == "null"){
		document.getElementById('branchenmenu').style.display='block';
	}
}



function showBranchesMenu(act){
	menuAction = act;
	if (document.getElementById('menu_image')){
		document.getElementById('menu_image').style.display='block';
		document.getElementById('menu_header').style.display='block';
	}
	document.getElementById('branchenmenu').style.display='block';
}

function hideBranchenMenu(){
	if (document.getElementById('menu_image') && document.getElementById('menu_image').style.display == 'block' ){
		document.getElementById('menu_image').style.display='none';
		document.getElementById('menu_header').style.display='none';
	}
	document.getElementById('branchenmenu').style.display='none';
}


function menuCheckBrowser(menuObj){
	if (navigator.appName.indexOf("Explorer") < 0){
		menuObj.style.display='none';
	}

}

function toggleMenu(menuObj){

	if (isMenu){
		isMenu=false;
		menuObj.style.display='none';
	}else{
		isMenu=true;
		menuObj.style.display='block';
	}
}

function displayBranchesMenu(menuObj){
	isMenu=true;
	menuObj.style.display='block';
}

function closeBranchesMenu(menuObj){
	isMenu=false;
	menuObj.style.display='none';
	if (document.getElementById('menu_image') && document.getElementById('menu_image').style.display == 'block' ){
		document.getElementById('menu_image').style.display='none';
		document.getElementById('menu_header').style.display='none';
	}
}
