var ajaxAlert = "Your browser does not support the enhanced functionality of this website, and therefore you will have an experience that differs from the intended one.\n";
//var googleAtxt = "Google-Anzeigen";
var formpart1 = "/firmen-suche/plz-";		// pt TARILE care AU cod postal
//formpart1 = "/firmen-suche"; 	//pt TARILE care NU AU cod postal
var formpart2 = "ort";
var formpart3 = "suche";
//for map.js file
var eTxt = "wurde nicht gefunden!";
var eTxt1 = "Zieladresse";
var eTxt2 = "Startadresse";
var eTxt3 = "Los !";
var eTxt4 = "Bitte geben sie erst eine Adresse an !";
var eTxt5 = "Google-Anzeigen";

 var map = null;
 var geocoder = null;
 var stat = 0;
 var marker = null;
 var infoHTML;
 var vonHTML;
 var nachHTML;
 var mymap;
 
function showSp_DL(geoX,geoY,myDiv,zoom) 
{
    if(geoX != "" && geoY !="" && geoX != 'NF' && geoY != 'NF')
	{ 		  
	 if (GBrowserIsCompatible()) 
		{	   
		map = new GMap2(document.getElementById(myDiv));
		point = new GLatLng(geoY, geoX, true);
	    if (!point) 
	    {
	        /*
			mymap = document.getElementById(myDiv);
			mymap.innerHTML = "<h1  style='color:#F00; margin-top: 5em';><b>" + address + " no fue encontrado! </b><h1>";*/
	    }
	    else
	    {
		    map.setCenter(point, zoom);			
		}
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());     
		map.addControl(new GOverviewMapControl());   
		GMap2.prototype.wheelZoom = function(event)
											{ 
											if((event.detail || -event.wheelDelta) < 0)
											   { map.zoomIn();}
											else
											   { map.zoomOut();}
											return false;
											}
		GEvent.addDomListener(document.getElementById(myDiv), "DOMMouseScroll", map.wheelZoom);
		GEvent.addDomListener(document.getElementById(myDiv), "mousewheel", map.wheelZoom);
		//showLocation();        
		}
	}
}

function showmap_new(land,firmnam,gaddr,bubadress,gtel,gurl,weblkz,vonhier,nachhier,geo,firmanr,logo) 
{
	if(firmnam){	 
		if (GBrowserIsCompatible()) {
			if(!mymap){
				mymap = document.getElementById("map");  
			}
			if(stat==3){
				map = new GMap2(mymap);
			}
			 if(!map){		
				map = new GMap2(mymap);
			}
			var address;
			if (geo != "" && geo != "," && geo != "NF,NF")
			{
				address = geo;
				geoplus = "@" + geo;
				sg = geo.split(",");
				geoY = sg[0];
				geoX = sg[1];
			}
			else{
				address = gaddr + "," + land;				
				geoplus = "";
				
				geocoder = null;
				mymap.innerHTML = "<h1  style='color:#F00; margin-top: 5em';><b>" + address + " " + eTxt + " </b><h1>";
				stat=3;
			}
				point = new GLatLng(geoY, geoX, true);
	            if (!point)
	            {	              
					//  alert(address + " wurde nicht gefunden !");				
					 mymap.innerHTML = "<h1  style='color:#F00; margin-top: 5em';><b>" + address + " " + eTxt + " </b><h1>";
					 stat=3;				 
	            } 
				else {
		            if (stat == 1){
						map.panTo(point); 
		            }
					else{
						map.setCenter(point, 15);
						stat = 1;
					}
					if (marker) {
						map.removeOverlay(marker);
					}
					marker = new GMarker(point); 
					map.addOverlay(marker);
					if (gtel){
						gtel = "Tel.:" + gtel;
					}
					if (logo == "1"){
						logoHtml = "<img src='/image.asp?firma="+ firmanr +"' height='40'><br>";
					}
					else{
						logoHtml = "";
					}				  
					infoHTML = "<div id='blase'><h4>" + logoHtml + firmnam + "</h4><address>" + bubadress+ "<br />" + gtel + "<br /><a href='" + gurl + "'>" + 
				              gurl + "</a>" + "</address>" + "<h5><a href='javascript:routnach();'>" + nachhier + "</a>" + " - " + 
							  "<a href='javascript:routvon()'>" + vonhier + "</a></h5></div>";
				  
					vonHTML = "<div id='blase'><h4>" + logoHtml + firmnam + "</h4><address>" + bubadress+ "<br />" + gtel + "<br /><a href='" + gurl + "'>" + 
				              gurl + "</a>" + "</address>" + "<h5><a href='javascript:routnach();'>" + nachhier + "</a>" + " - "  
							   + vonhier + "</h5><br>" + 
							   "<form action='http://maps.google." + weblkz + "/maps'>" + 
		                       "<input type='hidden' size='40' name='saddr' value='" + address + "(" + firmnam + ") " + geoplus + "'/>" +
	                           eTxt1 + ":<br/>" +
							   "<input type='text' id='daddr' name='daddr' value='' />" +
		                       "<input type='submit' value='" + eTxt3 + "'/>" +
		                       "</form>" +
							   "</div>";
				    nachHTML = "<div id='blase'><h4>" + logoHtml + firmnam + "</h4><address>" + bubadress+ "<br />" + gtel + "<br /><a href='" + gurl + "'>" + 
				              gurl + "</a>" + "</address>" + "<h5>" + nachhier  + " - <a href='javascript:routvon();'>" + 
							   vonhier + "</a></h5><br>" + 
							   "<form action='http://maps.google." + weblkz + "/maps'>" + 
		                       "<input type='hidden' size='40' name='daddr' value='" + address + "(" + firmnam + ") " + geoplus + "'/>" +
	                           eTxt2 + ":<br/>" +
							   "<input type='text' id='saddr' name='saddr' value='' />" +
		                       "<input type='submit' value='" + eTxt3 + "'/>" +
		                       "</form>" +
							   "</div>";			   
				  
				  //			     

					marker.openInfoWindowHtml(infoHTML);
					map.addControl(new GLargeMapControl());
					map.addControl(new GMapTypeControl());     
					map.addControl(new GOverviewMapControl());   
	            
				}			
       //showLocation();        
		}
	}
}

function showSp_new(geoX,geoY,myDiv,zoom)
{
    if(geoX != "" && geoY !="" && geoX != 'NF' && geoY != 'NF')
	{ 		  
        if (GBrowserIsCompatible()) 
	    {	   
		    map = new GMap2(document.getElementById(myDiv));
			point = new GLatLng(geoY, geoX, true);
	        if (!point) 
	        {	            
				/*mymap = document.getElementById(myDiv);
				mymap.innerHTML = "<h1  style='color:#F00; margin-top: 5em';><b>" + address + " no fue encontrado! </b><h1>";*/
	        } 
	        else 
	        {
				map.setCenter(point, zoom);			
			}
			map.addControl(new GLargeMapControl());
			map.addControl(new GMapTypeControl());     
			map.addControl(new GOverviewMapControl());   
			GMap2.prototype.wheelZoom = function(event)
											{ 
											if((event.detail || -event.wheelDelta) < 0)
											   { map.zoomIn();}
											else
											   { map.zoomOut();}
											return false;
											}
			GEvent.addDomListener(document.getElementById(myDiv), "DOMMouseScroll", map.wheelZoom);
			GEvent.addDomListener(document.getElementById(myDiv), "mousewheel", map.wheelZoom); 
		    //showLocation();        
		}
	}
}

function showStrasse(land,ort,geoX,geoY,myDiv,zoom)
{
        if (GBrowserIsCompatible()) 
        {
            if(!mymap) 
            {
		        mymap = document.getElementById(myDiv);  
		    }
		    map = new GMap2(document.getElementById(myDiv));
		    if (geoX == '' || geoY == '' || geoX == 'NF' || geoY == 'NF')
		    {
		        mymap.innerHTML = "<h1  style='color:#F00; margin-top:5em; text-align:center;'><b>" + ort + " - " + land + " " + eTxt + " </b><h1>";		        
		    }
		    else
		    {
                point = new GLatLng(geoY, geoX, true);
                if (!point)
                {
                    mymap.innerHTML = "<h1  style='color:#F00; margin-top:5em; text-align:center;'><b>" + ort + " - " + land + " " + eTxt + " </b><h1>";
			        stat=3;
			    } else 
			    {
			        map.setCenter(point, zoom);			    
			    }
	            map.addControl(new GLargeMapControl());
                map.addControl(new GMapTypeControl());     
                map.addControl(new GOverviewMapControl());   
		        GMap2.prototype.wheelZoom = function(event)
                                      { if((event.detail || -event.wheelDelta) < 0)
                                        { map.zoomIn();}
                                      else
                                        { map.zoomOut();}
                                      return false;
                                      }
                GEvent.addDomListener(document.getElementById(myDiv), "DOMMouseScroll", map.wheelZoom);
                GEvent.addDomListener(document.getElementById(myDiv), "mousewheel", map.wheelZoom);
            }
        }
}

function showsearch(land, weblkz, vonhier, nachhier)
{
    var straddr = document.getElementById("Strasse").value.toLowerCase();
    var myort = document.getElementById("MyOrt").value.toLowerCase();
    if (Trim(straddr)) 
    {
        if (GBrowserIsCompatible())
        {
            if (!map)
            {
                map = new GMap2(document.getElementById("map"));
            }
            geocoder = new GClientGeocoder;
            var address = straddr + "," + myort + "," + land;
            if (geocoder)
            {
                geocoder.getLatLng(address, function (point) {if (!point) {
				//alert(address + " wurde nicht gefunden !");
				} else {if (stat == 1) {map.panTo(point);} else {map.setCenter(point, 16);}if (marker) {map.removeOverlay(marker);}marker = new GMarker(point);map.addOverlay(marker);marker.openInfoWindowHtml("<div id='blase'><h4>" + unescape(straddr.toUpperCase()) + ", " + unescape(myort.toUpperCase()) + "</h2></div>" + "<h4><a href=http://maps.google." + weblkz + "/maps?daddr=" + escape(address) + ">" + nachhier + "</a>" + " - " + "<a href=http://maps.google." + weblkz + "/maps?saddr=" + escape(address) + ">" + vonhier + "</a></h4>");map.addControl(new GLargeMapControl);map.addControl(new GMapTypeControl);map.addControl(new GOverviewMapControl);stat = 1;}});
            }
        }
    } 
    else
    {
        alert(eTxt4);
    }
}

function Filternt()
{
    Name = escape(Trim(document.getElementById("TWert").value.toLowerCase()));
    Name=Name.replace('\n',''); 
    Stadt = escape(Trim(document.getElementById("TOrt").value.toLowerCase())); 
    Stadt=Stadt.replace('\n','');
    
    var myregexp = /[a-z]/i;
    var match = new RegExp(myregexp);
    if(match.test(Name)==true || Name == "") 
    {
        location.replace("http://www.cylex-telefonbuch.de/suche/deutschland/bundesland-/stadt-"+Stadt+"/l-0049-plz--strasse-_name-"+Name+"-s1_filter-0.html");
    }
    else
    {
        var nummer = unescape(Name).replace(/[^\d]/g,'');// replace all non numeric characters
        location.replace("http://www.cylex-telefonbuch.de/invers/" + nummer + "/s1.html");
    }
}
 
function Trim(TRIM_VALUE)
{
	if(TRIM_VALUE.length < 1)
	{
		return "";
	}	
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);	
	if(TRIM_VALUE=="")
	{
		return "";
	}
	else
	{
		return TRIM_VALUE;
	}
}

function RTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0)
	{
		return "";
	}
	var iTemp = v_length -1;

	while(iTemp > -1)
	{
		if(VALUE.charAt(iTemp) == w_space){}
		else
		{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;
	} //End While
	return strTemp;

} //End Function

function LTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	if(v_length < 1)
	{
		return "";
	}
		
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length)
	{
		if(VALUE.charAt(iTemp) == w_space){}
		else
		{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function

//--------------------------------------------------------
function routnach()
{
     //divblase= document.getElementById("blase");
     //divblase.outerHTML = "Test";
     //alert("nach");
     marker.openInfoWindowHtml(nachHTML);
}
function routvon()
{
     //divblase= document.getElementById("blase");
     //divblase.outerHTML = vonHTML;
     marker.openInfoWindowHtml(vonHTML);
     //alert("von");
}
function clear(value)
{
    value = value.replace("'"," ");	
    return value 
}


function google_ad_request_done(google_ads) 
{
	if (google_ads.length < 1 )
		return;
	//var oben = 4;
	//var ad1 = '';
	var ad2 = '';
	/*if (oben > google_ads.length)
		oben = google_ads.length;*/
	var s = '';
	s += '<h2>';
	if (google_info.feedback_url) 
		s += '<a href="' + google_info.feedback_url + '">' + googleAtxt +'</a>';
	else 
		s += googleAtxt;
	s += '</h2>';
	if (google_ads[0].type == 'text') 
	{
		/*for(i = 0; i < oben; ++i) 
		{
			ad1 += '<div>' +
			'<h3><a onclick="javascript:top.location.href=\'' + google_ads[i].url + '\'" onmouseover="window.status=\'gehe zu ' + google_ads[i].visible_url + '\'" onmouseout="window.status=\'\'">' +
			google_ads[i].line1 + '</a></h3>' +
			'<p style="color:#F1F1F1;">' + google_ads[i].line2 + '&nbsp;' + google_ads[i].line3 + '<br/>' + '<a style="cursor:pointer;cursor:hand;text-decoration:none" onclick="javascript:top.location.href=\'' + google_ads[i].url + '\'" onmouseover="window.status=\'gehe zu ' + google_ads[i].visible_url + '\'" onmouseout="window.status=\'\'">'  + google_ads[i].visible_url +
			'</a></p></div>';
		}
		*/
		for(i = 0; i < google_ads.length; ++i) 
		{
			ad2 += '<dt>' +
			'<a onclick="javascript:top.location.href=\'' + google_ads[i].url + '\'" onmouseover="window.status=\'gehe zu ' + google_ads[i].visible_url + '\'" onmouseout="window.status=\'\'">' +
			'<strong>' + google_ads[i].line1 + '</strong></a></dt>' +
			'<dd>' + google_ads[i].line2 + '&nbsp;' + google_ads[i].line3 + '<br/>' + '<a onclick="javascript:top.location.href=\'' + google_ads[i].url + '\'" onmouseover="window.status=\'gehe zu ' + google_ads[i].visible_url + '\'" onmouseout="window.status=\'\'">'  + google_ads[i].visible_url +
			'</a></dd>';
		}
	}
	//ads1 = '<div id="google_stadtplan">' + s +  ad1 +  '</div><br style="clear:both" />';
	ads2 = s + '<dl>' + ad2 + '</dl>';
	//document.getElementById("header").innerHTML = ads1;
   document.write(ads2);
   return;
 }
