//<![CDATA[
var active_resultspage = 0;
var max_resultspages = 0;

var enablesearch = 0;

var searchResultBoxClosed = 0;

var loginBoxOpen = 0;

var map;

var myIcon = new GIcon(G_DEFAULT_ICON);
myIcon.image = "templates/images/etf_map_icon.png";
myIcon.iconSize = new GSize(23, 46);
myIcon.shadow = null;
// myIcon.shadow = "templates/images/etf_map_icon_shadow.png";
// myIcon.shadowSize = new GSize(44, 46);
myIcon.iconAnchor = new GPoint(12, 44);
myIcon.infoWindowAnchor = new GPoint(12, 12);
// myIcon.transparent = "";
myIcon.transparent = null;
myIcon.imageMap = [ 4,1, 3,11, 1,13, 1,27, 10,44, 13,44, 22,27, 20,23, 19,1 ];
var markerOptions = { icon:myIcon };

var myIcon_orange = new GIcon(G_DEFAULT_ICON);
myIcon_orange.image = "templates/images/etf_map_icon_orange.png";
myIcon_orange.iconSize = new GSize(23, 46);
myIcon_orange.shadow = null;
// myIcon_orange.shadow = "templates/images/etf_map_icon_shadow.png";
// myIcon_orange.shadowSize = new GSize(44, 46);
myIcon_orange.iconAnchor = new GPoint(12, 44);
myIcon_orange.infoWindowAnchor = new GPoint(12, 12);
// myIcon_orange.transparent = "";
myIcon_orange.transparent = null;
myIcon_orange.imageMap = [ 4,1, 3,11, 1,13, 1,27, 10,44, 13,44, 22,27, 20,23, 19,1 ];
var markerOptions_orange = { icon:myIcon_orange };

var gmarkers = {
	Set : function(etfobj,bar) {this[etfobj] = bar;},
	Get : function(etfobj) {return this[etfobj];}
}

function create_gmarker( id, location, marker, markerType )
{
    var gmarker = new GMarker( location, markerType );
    GEvent.addListener( gmarker, 'click', function( ) {
            gmarker.openInfoWindowHtml( marker );
        }
    );
	gmarkers.Set(id, gmarker);
    return gmarker;
}

function hideshow(divname, action) {
	if (action == "show") {
		document.getElementById(divname).style.display="block";
	}
	if (action == "hide") {
		document.getElementById(divname).style.display="none";
	}
}


function resultsPaging(divid) {
    document.getElementById('page'+divid).style.display="block";
	if ((active_resultspage != "") && (active_resultspage != divid)) { document.getElementById('page'+active_resultspage).style.display="none"; }
	active_resultspage = divid;
	resultsPagingBuildNav(divid);
}

function resultsPagingBuildNav(activepage) {
	var navigationString = "";
	if (max_resultspages > 1) {

		navigationString = '<a class="results_navigation_pageno';
		if (activepage == 1) { navigationString = navigationString + '_active"'; }
		else { navigationString = navigationString + '" onclick="javascript: document.location.href=\'#pagenavtop\'; document.location.href=\'#sitestart\';" href="javascript: resultsPaging(1)"'; }
		navigationString = navigationString + '>1</a>';


		if (activepage > 3) { navigationString = navigationString + '<a class="results_navigation_nav" href="javascript: resultsPaging(active_resultspage-1)">&lt;</a>'; }
		else {
			navigationString = navigationString + '<a class="results_navigation_pageno';
			if (activepage == 2) { navigationString = navigationString + '_active"'; }
			else { navigationString = navigationString + '" onclick="javascript: document.location.href=\'#pagenavtop\'; document.location.href=\'#sitestart\';" href="javascript: resultsPaging(2);"'; }
			navigationString = navigationString + '>2</a>';
		}


		if (max_resultspages > 2) {
			if (activepage > 3) {
				navigationString = navigationString + '<a class="results_navigation_pageno';
				if (activepage >= (max_resultspages-2)) {
					navigationString = navigationString + '" onclick="javascript: document.location.href=\'#pagenavtop\'; document.location.href=\'#sitestart\';" href="javascript: resultsPaging(' + (max_resultspages-4) + ')">' + (max_resultspages-4) + '</a>';
				}
				else {
					navigationString = navigationString + '" onclick="javascript: document.location.href=\'#pagenavtop\'; document.location.href=\'#sitestart\';" href="javascript: resultsPaging(' + (activepage-1) + ')"';
					navigationString = navigationString + '>' + (activepage-1) + '</a>';
				}
			}
			else {
				navigationString = navigationString + '<a class="results_navigation_pageno';
				if (activepage == 3) { navigationString = navigationString + '_active"'; }
				else { navigationString = navigationString + '" onclick="javascript: document.location.href=\'#pagenavtop\'; document.location.href=\'#sitestart\';" href="javascript: resultsPaging(3)"'; }
				navigationString = navigationString + '>3</a>';
			}
		}


		if (max_resultspages > 3) {
			if (activepage > 3) {
				navigationString = navigationString + '<a class="results_navigation_pageno';
				if (activepage >= (max_resultspages-2)) {
					navigationString = navigationString + '" onclick="javascript: document.location.href=\'#pagenavtop\'; document.location.href=\'#sitestart\';" href="javascript: resultsPaging(' + (max_resultspages-3) + ')">' + (max_resultspages-3) + '</a>';
				}
				else {
					navigationString = navigationString + '_active">' + activepage + '</a>';
				}
			}
			else {
				navigationString = navigationString + '<a class="results_navigation_pageno" onclick="javascript: document.location.href=\'#pagenavtop\'; document.location.href=\'#sitestart\';" href="javascript: resultsPaging(4)">4</a>';
			}
		}


		if (max_resultspages > 4) {
			navigationString = navigationString + '<a class="results_navigation_pageno';
			if (activepage > 3) {
				if (activepage >= (max_resultspages-2)) {
					if (activepage == (max_resultspages-2)) { navigationString = navigationString + '_active"'; }
					else { navigationString = navigationString + '" onclick="javascript: document.location.href=\'#pagenavtop\'; document.location.href=\'#sitestart\';" href="javascript: resultsPaging(' + (max_resultspages-2) + ')"'; }
					navigationString = navigationString + '>' + (max_resultspages-2) + '</a>';
				}
				else {
					navigationString = navigationString + '" onclick="javascript: document.location.href=\'#pagenavtop\'; document.location.href=\'#sitestart\';" href="javascript: resultsPaging(' + (activepage+1) + ')">' + (activepage+1) + '</a>';
				}
			}
			else {
				navigationString = navigationString + '" onclick="javascript: document.location.href=\'#pagenavtop\'; document.location.href=\'#sitestart\';" href="javascript: resultsPaging(5)">5</a>';
			}
		}


		if (max_resultspages > 5) {
			if (activepage < (max_resultspages-2)) { navigationString = navigationString + '<a class="results_navigation_nav" onclick="javascript: document.location.href=\'#pagenavtop\'; document.location.href=\'#sitestart\';" href="javascript: resultsPaging(' + (active_resultspage+1) + ')">&gt;</a>'; }
			else {
				navigationString = navigationString + '<a class="results_navigation_pageno';
				if (activepage == (max_resultspages-1)) { navigationString = navigationString + '_active"'; }
				else { navigationString = navigationString + '" onclick="javascript: document.location.href=\'#pagenavtop\'; document.location.href=\'#sitestart\';" href="javascript: resultsPaging(' + (max_resultspages-1) + ')"'; }
				navigationString = navigationString + '>' + (max_resultspages-1) + '</a>';
			}
		}


		if (max_resultspages > 5) {
			navigationString = navigationString + '<a class="results_navigation_pageno';
			if (activepage == max_resultspages) { navigationString = navigationString + '_active'; }
			navigationString = navigationString + '" onclick="javascript: document.location.href=\'#pagenavtop\'; document.location.href=\'#sitestart\';" href="javascript: resultsPaging(' + max_resultspages + ')">' + max_resultspages + '</a>';
		}

		document.getElementById('results_navigation').innerHTML = navigationString;
	}
}


function tabs_switch(button, state) {
	if (button == "ergebnisse") {
		if (state == 1) {
			hideshow('searchbox_wrapper','hide');
			hideshow('searchbox_results_wrapper','show');
			hideshow('searchbox_tab_profisuche','hide');
			hideshow('searchbox_results_content','show');
			hideshow('tabs_searchresults_profi','hide');
			hideshow('tabs_searchresults','show');
		}
	}
	if (button == "search") {
		if (state == 1) {
			hideshow('searchbox_tab_profisuche','hide');
			hideshow('searchbox_results_content','show');
			hideshow('searchbox_results_wrapper','hide');
			hideshow('searchbox_wrapper','show');
		}
	}
	if (button == "profisuche") {
		if (state == 1) {
			hideshow('searchbox_wrapper','hide');
			hideshow('searchbox_results_wrapper','show');
			hideshow('searchbox_results_content','hide');
			hideshow('searchbox_tab_profisuche','show');
			hideshow('tabs_searchresults','hide');
			hideshow('tabs_searchresults_profi','show');
		}
	}
}

var initialSearchboxHidden = 0;

// function to read cookie values
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

// show options for the amount of selected sockets 
function showSockets(amount) {
	if (amount != "") {
		hideshow('captions','show');
		for (i=1;i<=10;i++)
		{
			hideshow(i,'hide');
		}
		for (i=1;i<=amount;i++)
		{
			hideshow(i,'show');
		}
	}
	else {
		for (i=1;i<=10;i++)
		{
			hideshow('captions','hide');
			hideshow(i,'hide');
		}
	}
}

function getURLParam( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( document.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

// show Tankstellen detailpage when clicking on a map popup "more" link
function showTsDetailPage(tsId) {
	document.location.href="Details.html?tankstellen-id="+tsId+"&currentSearch="+escape(document.getElementById('tankstellensearch').value);
}


//if cookie contains searchphrase set that searchphrase again and submit search
function setPreviousSearch(cookievalue) {
	if (map.isLoaded() == false) {
		window.setTimeout("setPreviousSearch("+cookievalue+")", 2000);		
	
	}
	else {
		document.getElementById('tankstellensearch').value = cookievalue;
	
		if (cookievalue != "") {
			window.setTimeout("sendsearch(0,'nothing')", 2000);
		}
	}
}

//set Cookie with technical e-station data. If user registers more stations in a row this data will be the default values
function setTechDataCookie() {
	document.cookie = "parkplaetzeAuto="+document.getElementById('parkplaetzeAuto').value;+"";
	document.cookie = "parkplaetze2Spurige="+document.getElementById('parkplaetze2Spurige').value;+"";
	document.cookie = "oe_zeiten="+document.getElementById('oe_zeiten').value;+"";
	document.cookie = "zeiten="+document.getElementById('zeiten').value;+"";
	if (document.getElementsByName('mainPageForm.tankstelle.kostenTyp')[0].checked) {
		document.cookie = "kostenTyp=0";
	}
	else {			
		document.cookie = "kostenTyp=1";
	}
	document.cookie = "preis="+document.getElementById('preis').value;+"";
	document.cookie = "eTankstellenTyp="+document.getElementById('eTankstellenTyp').value;+"";
	document.cookie = "eTankstelleZugang="+document.getElementById('eTankstelleZugang').value;+"";
	document.cookie = "geeignetFuer="+document.getElementById('geeignetFuer').value;+"";
	document.cookie = "eTankstellenSteckeranzahl="+document.getElementById('eTankstellenSteckeranzahl').value;+"";
	
	var cnt = 1;
	while (cnt<11) {
		document.cookie = "anschluss"+cnt+"_typ="+document.getElementById('anschluss'+cnt+'_typ').value;+"";
		document.cookie = "anschluss"+cnt+"_spannung="+document.getElementById('anschluss'+cnt+'_spannung').value;+"";
		document.cookie = "anschluss"+cnt+"_leistung="+document.getElementById('anschluss'+cnt+'_leistung').value;+"";
		cnt++;
	}
}

// read cookie values and populate register form fields 
function readTechDataCookies() {

	if (readCookie("parkplaetzeAuto") != null) {
		iterateFormSelect("parkplaetzeAuto",readCookie("parkplaetzeAuto"));
	}
	if (readCookie("parkplaetze2Spurige") != null) {
		iterateFormSelect("parkplaetze2Spurige",readCookie("parkplaetze2Spurige"));
	}
	if (readCookie("oe_zeiten") != null) {
		iterateFormSelect("oe_zeiten",readCookie("oe_zeiten"));
	}
	if (readCookie("zeiten") != null) {
		document.getElementById('zeiten').value = readCookie("zeiten");
	}
	if (readCookie("kostenTyp") != null) {
		if (readCookie("kostenTyp") == "0") {
			document.getElementsByName('mainPageForm.tankstelle.kostenTyp')[0].checked = true;
		}
		else {
			document.getElementsByName('mainPageForm.tankstelle.kostenTyp')[1].checked = true;
		}
	}
	if (readCookie("preis") != null) {
		document.getElementById('preis').value = readCookie("preis");
	}
	
	if (readCookie("eTankstellenTyp") != null) {
		iterateFormSelect("eTankstellenTyp",readCookie("eTankstellenTyp"));
	}
	if (readCookie("eTankstelleZugang") != null) {
		iterateFormSelect("eTankstelleZugang",readCookie("eTankstelleZugang"));
	}
	if (readCookie("geeignetFuer") != null) {
		iterateFormSelect("geeignetFuer",readCookie("geeignetFuer"));
	}
	if (readCookie("eTankstellenSteckeranzahl") != null) {
		iterateFormSelect("eTankstellenSteckeranzahl",readCookie("eTankstellenSteckeranzahl"));
		showSockets(readCookie("eTankstellenSteckeranzahl"));
	}

	var cnt = 1;
	while (cnt<11) {
		iterateFormSelect("anschluss"+cnt+"_typ",readCookie("anschluss"+cnt+"_typ"));
		iterateFormSelect("anschluss"+cnt+"_spannung",readCookie("anschluss"+cnt+"_spannung"));
		iterateFormSelect("anschluss"+cnt+"_leistung",readCookie("anschluss"+cnt+"_leistung"));
		
/*		jQuery("#registerForm #anschluss"+cnt+"_typ").rules("add", "required");
		jQuery("#registerForm #anschluss"+cnt+"_spannung").rules("add", "required");
		jQuery("#registerForm #anschluss"+cnt+"_leistung").rules("add", "required"); */
		
		cnt++;
	}
	
}

function iterateFormSelect(fieldId, fieldValue) {
	for(i=0;i<document.getElementById(fieldId).length;i++) {
		if(document.getElementById(fieldId).options[i].value==fieldValue) {
			document.getElementById(fieldId).selectedIndex=i
		}
	}
}



function resetSearchForm()
{
document.getElementById('profiRadius2').value = "10";
document.getElementById('profiRadius').value = "10";
document.getElementById('profiTyp').value = "alle";
document.getElementById('profiOeffnungszeitenType').value = "3";
document.getElementById('profiKostenTyp').value = "0";
document.getElementById('profiOrgTyp').value = "0";
document.getElementById('profiZugang').value = "0";
document.getElementById('profiGeeignet').value ="0";
document.getElementById('profiSteckerType').value = "alle";
document.getElementById('profiSteckerVolt').value = "alle";
document.getElementById('profiSteckerAmpere').value = "alle";	
}



//Load Search Criteria into search form.
//Argument type can be: "previous" OR "reset"
//"previous": initilializes form with previous search criteria
//"reset": initilializes default values

function loadTheSearch(type)
{
	if (type=="previous") 	//Letzte Suchanfrage aus Cookie ins Formular laden	

	{		
	if (readCookie("searchtype") != null) 
	{
		if (readCookie("searchtype") != "") 
		{	
			if (readCookie("searchtype")==2) 
			{
				if (readCookie("profiRadius") != null) 
				{
					if (readCookie("profiRadius") != "") 
					{						
						document.getElementById('profiRadius').value = readCookie("profiRadius");
						document.getElementById('profiRadius2').value = readCookie("profiRadius");
						
					}
				}


				if (readCookie("profiTyp") != null) 
				{
					if (readCookie("profiTyp") != "") {
						document.getElementById('profiTyp').value = readCookie("profiTyp");
					}
				}

				if (readCookie("profiOeffnungszeitenType") != null) 
				{
					if (readCookie("profiOeffnungszeitenType") != "") {
						document.getElementById('profiOeffnungszeitenType').value = readCookie("profiOeffnungszeitenType");
					}
				}

				if (readCookie("profiKostenTyp") != null) 
				{
					if (readCookie("profiKostenTyp") != "") {
						document.getElementById('profiKostenTyp').value = readCookie("profiKostenTyp");
					}
				}

				if (readCookie("profiOrgTyp") != null) 
				{
					if (readCookie("profiOrgTyp") != "") {
						document.getElementById('profiOrgTyp').value = readCookie("profiOrgTyp");
					}
				}

				if (readCookie("profiZugang") != null) 
				{
					if (readCookie("profiZugang") != "") {
						document.getElementById('profiZugang').value = readCookie("profiZugang");
					}
				}

				if (readCookie("profiGeeignet") != null) 
				{
					if (readCookie("profiGeeignet") != "") {
						document.getElementById('profiGeeignet').value = readCookie("profiGeeignet");
					}
				}

				if (readCookie("profiSteckerType") != null) 
				{
					if (readCookie("profiSteckerType") != "") {
						document.getElementById('profiSteckerType').value = readCookie("profiSteckerType");
					}
				}

				if (readCookie("profiSteckerVolt") != null) 
				{
					if (readCookie("profiSteckerVolt") != "") {
						document.getElementById('profiSteckerVolt').value = readCookie("profiSteckerVolt");
					}
				}

				if (readCookie("profiSteckerAmpere") != null) 
				{
					if (readCookie("profiSteckerAmpere") != "") {
						document.getElementById('profiSteckerAmpere').value = readCookie("profiSteckerAmpere");
					}
				}
				
			/*	hideshow('searchbox_wrapper','hide');
				hideshow('searchbox_results_wrapper','show');
				hideshow('searchbox_results_content','hide');
				hideshow('searchbox_tab_profisuche','show');
				hideshow('tabs_searchresults','hide');
				hideshow('tabs_searchresults_profi','show');*/
			}
			
			//END: profi suche
			
		}
	}
	
	}
	else if (type=="reset")
	{
		resetSearchForm();

	}
}



// Close Searchbox Results function
function searchboxResultsClose() {
	$("#searchbox_results").animate({
		height: "40px"
	}, 1500, function () {
			document.getElementById("searchbox_results_close").style.display="none";
			document.getElementById("searchbox_results_open").style.display="block";
			searchResultBoxClosed = 1;
	});
}

// Open Searchbox Results function
function searchboxResultsOpen() {
	$("#searchbox_results").animate({
		height: "475px"
	}, 1500, function () {
			document.getElementById("searchbox_results_close").style.display="block";
			document.getElementById("searchbox_results_open").style.display="none";
			searchResultBoxClosed = 0;
		} );
}

//Close Searchbox function
function searchboxClose() {
	$("#searchbox_wrapper").animate({
		height: "50px",
		top: "430px"
	}, 1500, function () {
			document.getElementById("searchbox_close").style.display="none";
			searchResultBoxClosed = 1;
	});
}

// Open Searchbox function
function searchboxOpen() {
	$("#searchbox_wrapper").animate({
		height: "475px",
		top: "0px"
	}, 1500, function () {
			document.getElementById("searchbox_close").style.display="block";
			searchResultBoxClosed = 0;
		} );
}

function closeLoginBox() {
//	if ((loginBoxOpen == 0) && (document.getElementById("loginUsernameField").value == "") && (document.getElementById("loginPasswordField").value == "")) {
	$('#loginWindow').animate({ height: 'hide', opacity: 'hide' }, 'slow');
}


function storeLastSearchToCookie()
{
	
	var expdate = new Date ();

	 expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000*365));
	
	// Build the expiration date string:
 
	 
    // Build the set-cookie string:
     var expire_string = "; expires=" + expdate.toGMTString();
     
	 //alert("schreibe daten aus formular ins cookie..." + profi);
	 document.cookie = "searchtype=2" + expire_string;  	
	 //alert(expire_string);
	 document.cookie = "profiRadius="+document.getElementById('profiRadius').value + expire_string;  
	 document.cookie = "profiOeffnungszeitenType="+document.getElementById('profiOeffnungszeitenType').value + expire_string;  
	 document.cookie = "profiKostenTyp="+document.getElementById('profiKostenTyp').value + expire_string;  
	 document.cookie = "profiZugang="+document.getElementById('profiZugang').value + expire_string;
	 document.cookie = "profiOrgTyp="+document.getElementById('profiOrgTyp').value + expire_string;  
	 document.cookie = "profiTyp="+document.getElementById('profiTyp').value+ expire_string;  
	 document.cookie = "profiGeeignet="+document.getElementById('profiGeeignet').value+ expire_string;  
	 document.cookie = "profiSteckerType="+document.getElementById('profiSteckerType').value+ expire_string;  
	 document.cookie = "profiSteckerVolt="+document.getElementById('profiSteckerVolt').value+ expire_string;  
	 document.cookie = "profiSteckerAmpere="+document.getElementById('profiSteckerAmpere').value+ expire_string;  
	 document.getElementById('checkboxUseStoredCookie').disabled = false;
	 document.getElementById('checkboxUseStoredCookie').checked = true;
}

function deleteSearchCookie()
{
	//alert("delete cookie " + profi);
	document.cookie = "searchtype=2; expires="+now.toGMTString();		  
    document.cookie = "profiRadius="+document.getElementById('profiRadius').value + "; expires=" + now.toGMTString();	
    document.cookie = "profiOeffnungszeitenType="+document.getElementById('profiOeffnungszeitenType').value + "; expires=" + now.toGMTString();	
    document.cookie = "profiKostenTyp="+document.getElementById('profiKostenTyp').value + "; expires=" + now.toGMTString();	
    document.cookie = "profiZugang="+document.getElementById('profiZugang').value + "; expires=" + now.toGMTString();	
    document.cookie = "profiOrgTyp="+document.getElementById('profiOrgTyp').value + "; expires=" + now.toGMTString();	
    document.cookie = "profiTyp="+document.getElementById('profiTyp').value + "; expires=" + now.toGMTString();	
    document.cookie = "profiGeeignet="+document.getElementById('profiGeeignet').value + "; expires=" + now.toGMTString();	
    document.cookie = "profiSteckerType="+document.getElementById('profiSteckerType').value + "; expires=" + now.toGMTString();	
    document.cookie = "profiSteckerVolt="+document.getElementById('profiSteckerVolt').value + "; expires=" + now.toGMTString();	
    document.cookie = "profiSteckerAmpere="+document.getElementById('profiSteckerAmpere').value + "; expires=" + now.toGMTString();
  	document.getElementById('checkboxUseStoredCookie').disabled = true;
	document.getElementById('checkboxUseStoredCookie').checked = false;
}

function sendsearch(whichsearch, checkit, e, profi) 
{
	
	
	if (profi != "profi")
		profi = "einfach";
	
	if (document.getElementById('countrySelection').value != searchCountry) {		
		searchCountry = document.getElementById('countrySelection').value;
	}	

	if (((whichsearch == 0) || (whichsearch == 3)) && (enablesearch == 1)) {
		var sendit = 1;
		if (checkit == "key") {
			sendit = 0;
			var characterCode

			if(e && e.which) { //if which property of event object is supported (NN4)
				e = e
				characterCode = e.which //character code is contained in NN4's which property
			}
			else {
				e = event
				characterCode = e.keyCode //character code is contained in IE's keyCode property
			}

			if(characterCode == 13) { //if generated character code is equal to ascii 13 (if enter key)
				sendit = 1;
			}
			else {
				return true
			}

		}

		if (sendit == 1) {
			
			
		 	// NORMALE Suche, Gespeichertes Cookie verwenden
			 if (profi=="einfach" && document.getElementById('checkboxUseStoredCookie').checked == true)
			 {
				
				loadTheSearch("previous");			
				storeLastSearchToCookie();	
				getNewTankstellenFilterResultSubmit(1); // calls struts action
			
			 }
			 
			 
			 
			 if (profi=="einfach" && document.getElementById('checkboxUseStoredCookie').checked == false)
			 {
				 
				 loadTheSearch("reset");
				 //document.getElementById('tankstellensearch').value = document.getElementById('searchquery').value;
				 getNewTankstellenFilterResultSubmit(1); // calls struts action
		     }
			 
			 

			 
			 
			 
			if (mapwindowstate == 1) {
				$("#map1div").animate({
					height: "540px"
				}, 1500 );
				mapwindowstate = 2;
				window.setTimeout("hideshow('map_overlay_content_area', 'show')", 2000);
				document.getElementById('contractmap_img').src="templates/images/expand_map_button_up.png";
			}
			hideshow('newsbox', 'hide');
			hideshow('tabs_spacer', 'hide');
			hideshow('tabs_searchwindow', 'show');
			if (profi != 'profi') {
				tabs_switch('ergebnisse','1');
			}

			// sync search fields
			if (profi == 'profi') {
				document.getElementById('tankstellensearch').value = document.getElementById('profiSearch').value;
			} else {
				document.getElementById('profiSearch').value = document.getElementById('tankstellensearch').value;
			}
			
			// if search phrase does not contain a country, add searchCountry variable
			if (document.getElementById('tankstellensearch').value.indexOf(searchCountry) == -1) {				
				document.getElementById('tankstellensearch').value = document.getElementById('tankstellensearch').value + ", " + searchCountry;
			}
			
			if (document.getElementById('profiSearch').value.indexOf(searchCountry) == -1) {				
				document.getElementById('profiSearch').value = document.getElementById('profiSearch').value + ", " + searchCountry;
			}
			
			getNewTankstellenFilterResultSubmit(1); // calls struts action
			
			if (profi != 'profi') {
				
				hideshow('searchbox_wrapper','hide');
				hideshow('searchbox_results_wrapper','show');
			}
	    	
	    	// set cookie with searchphrase and type to be used with browser back button map calls
		//	if (document.getElementById('tankstellensearch').value != "") {
		  //  	document.cookie = "searchphrase="+document.getElementById('tankstellensearch').value+"";
		  //  	document.cookie = "searchtype=1";				
		//	}		

	    	// if Externalview is used minimize searchbox whenever a search is sent.
	    	if (document.location.href.indexOf("ExternalView") != -1) {
	    		searchboxResultsClose();
	    	}
		}
	} else {
		if (enablesearch == 1) {			
			
			if (mapwindowstate == 1) {
				$("#map1div").animate({
					height: "540px"
				}, 1500 );
				mapwindowstate = 2;
				window.setTimeout("hideshow('map_overlay_content_area', 'show')", 2000);
				window.setTimeout("hideshow('searchbox_wrapper','hide')", 2001);
				if (profi == 'profi') {
					window.setTimeout("hideshow('searchbox_results_wrapper','show')", 2002);
				}

				document.getElementById('contractmap_img').src="templates/images/expand_map_button_up.png";
			}
			window.setTimeout("hideshow('newsbox', 'hide')", 2003);
			window.setTimeout("hideshow('tabs_spacer', 'hide')", 2004);
			window.setTimeout("hideshow('tabs_searchwindow', 'show')", 2005);
			if (initialSearchboxHidden == 0) {
				if (profi != 'profi') {
					window.setTimeout("tabs_switch('ergebnisse','1')", 2006);
				}
				window.setTimeout("initialSearchboxHidden = 1", 2007);
			}
			else {
				if (profi != 'profi') {
					tabs_switch('ergebnisse','1');
				}
			}
			
			document.getElementById('tankstellensearch').value = document.getElementById('profiSearch').value;
			
			// if search phrase does not contain a country, add searchCountry variable
			if (document.getElementById('tankstellensearch').value.indexOf(searchCountry) == -1) {				
				document.getElementById('tankstellensearch').value = document.getElementById('tankstellensearch').value + ", " + searchCountry;
			}
			
			document.getElementById('profiSearch').value = document.getElementById('tankstellensearch').value;
			document.getElementById('profiRadius2').selectedIndex = document.getElementById('profiRadius').selectedIndex;

			
			
			
			
			if (profi=="profi" && document.getElementById('checkboxCookie').checked ==  true)
			 {
				 storeLastSearchToCookie();	
				 getNewTankstellenFilterResultSubmit(whichsearch); // calls struts action	
		     }
			 
			 if (profi=="profi" && document.getElementById('checkboxCookie').checked==false)
			 {
				 deleteSearchCookie();
				 getNewTankstellenFilterResultSubmit(whichsearch); // calls struts action
				 loadTheSearch("previous");
		     }
			 
		
			 

		}
	}
}
		
	


// check key input when user enters keyword into News Search box
function newssearch(type,e) {
	var characterCode
	var send = 0;

	if (!isNewsSearchInputFieldEmpty()) {
		// type 2 = Keyboard Entry
		if (type == "2") {
			if(e && e.which) { //if which property of event object is supported (NN4)
				e = e
				characterCode = e.which //character code is contained in NN4's which property
			}
			else {
				e = event
				characterCode = e.keyCode //character code is contained in IE's keyCode property
			}

			if(characterCode == 13) { //if generated character code is equal to ascii 13 (if enter key)
				send = 1;
			}
			else {
				return true
			}
		}
		else {
			// type 1 = user clicked arrow button
			send = 1;
		}
		if (send == 1) {
		 	// document.location.hash='sitestart';
			showNewsByTagCloud(getNewsSearchInputField());
			showDisplayAllNews();
		}
	}
}

function showDisplayAllNews() {
	$('#news_searchbox_img_all_news').show("slide", { direction: "down" });
}

function hideDisplayAllNews() {
	$('#news_searchbox_img_all_news').hide("slide", { direction: "down" });
}

// hide the "alle News anzeigen" button
function showallnews() {
	hideDisplayAllNews();
	setNewsSearchInputField("Newsarchiv durchsuchen");
	triggerDeleteNewsFilter();
}

function getNewsSearchInputField() {
	return document.getElementById('news_searchbox_inputfield').value;
}

function isNewsSearchInputFieldEmpty() {
	return (getNewsSearchInputField() == "Newsarchiv durchsuchen");
}

function setNewsSearchInputField(searchTerm) {
	document.getElementById('news_searchbox_inputfield').value = (searchTerm) ? searchTerm : "Newsarchiv durchsuchen" ;
}

function showetfmarker(etfmarker) {
	map.setCenter(new GLatLng(etfmarker.getPoint().lat(),etfmarker.getPoint().lng()), 15);
	GEvent.trigger(etfmarker, 'click')
}

function checkInputLength(divname, maxlength) {
	if (document.getElementById(divname).value.length > maxlength) {
		document.getElementById(divname).value = document.getElementById(divname).value.slice(0,maxlength);
		// alert("Es duerfen maximal nur "+maxlength+" Zeichen eingegeben werden!");
	}
}

function checkFieldInputLength(divname, infoname, maxlength) {
	if (document.getElementById(divname).value.length > maxlength) {
		document.getElementById(divname).value = document.getElementById(divname).value.slice(0,maxlength);
	}
	document.getElementById(infoname).value = maxlength-document.getElementById(divname).value.length;
}

function jumpTop() {
	var hashorig = document.location.hash;
	document.location.hash="#sitestart";
	if (hashorig != "") {
		document.location.hash=hashorig;
	}
}

// Drop Down Menus

var dropDownInUse = 0;
var activeInterval = window.setInterval("closeDropDown()", 1000);
var activeDropdown = "mainMenuDropdownServices";

function closeDropDown() {
	if ((dropDownInUse == 0) && (activeDropdown != "")) {
		hideshow(activeDropdown, 'hide');
		activeDropdown = "mainMenuDropdownServices";
	}
}

// round corners with js
/* IE only */
DD_roundies.addRule('.TB_window', '12px');


//]]>