var map1 = null; var boxList =[]; var j = 0; function initialize() { var mapOptions = { center: new google.maps.LatLng(51.10, 10.25), zoom: 6 }; map1 = new google.maps.Map(document.getElementById("map12"), mapOptions); globalAdress = 0; geocoder = new google.maps.Geocoder(); setQuestion(); // Create our "tiny" marker icon showStart('Deutschland', 6); showAll(); } google.maps.event.addDomListener(window, 'load', initialize); function GetXmlHttpObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } function requestDataFilialen(params){ //Action Filialen xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Your browser does not support XMLHTTP!"); return; } var url = 'ajax-request.php?action=getFilialen&'+params; xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4) { response = xmlhttp.responseText; document.getElementById('filialenContent').innerHTML = response; } } xmlhttp.open("GET",url,true); xmlhttp.send(null); /* new Ajax.Request('ajax-request.php?action=getFilialen&'+params, { method:'get', onSuccess: function(transport){ }, onFailure: function(){ alert('Something went wrong...') } }); */ } function addCoords(aplz,aort,aaddress, ahnr, atype){ var address = aplz; if (geocoder) { geocoder.getLatLng ( address, function(point) { if (!point) { } else{ var params = "xpos="+point.lat()+"&ypos="+point.lng()+"&type="+atype+"&nr="+ahnr; ajaxRequestPos(params); } } ); } } function ajaxRequestMail(params){ //Action Filialen xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Your browser does not support XMLHTTP!"); return; } var url = 'ajax-request.php?action=sendMessage&'+params; xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4) { response = xmlhttp.responseText; alert(response); if( response.search(/erfolgreich.+/)){ document.getElementById('resetForm').click(); setQuestion(); } } } xmlhttp.open("GET",url,true); xmlhttp.send(null); /* new Ajax.Request('ajax-request.php?action=sendMessage&'+params, { method:'get', onSuccess: function(transport){ response = transport.responseText || "no response text"; alert(response); if( response.search(/erfolgreich.+/)){ document.getElementById('resetForm').click(); } }, onFailure: function(){ alert('Something went wrong...') } }); */ } function ajaxRequestPos(params){ //Action Filialen xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Your browser does not support XMLHTTP!"); return; } var url = 'ajax-request.php?action=addPos&'+params; xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4) { response = transport.responseText || "no response text"; } } xmlhttp.open("GET",url,true); xmlhttp.send(null); /* new Ajax.Request('ajax-request.php?action=addPos&'+params, { method:'get', onSuccess: function(transport){ response = transport.responseText || "no response text"; }, onFailure: function(){ alert('Something went wrong...') } }); */ } function showStart(address, wideness) { map1.setCenter(new google.maps.LatLng(51.10, 10.25)); map1.setZoom(6); } function setTraderData(){ var response = requestDataFilialen("fNr="+globalF+"&type="+globalType+"&hNr="+globalH); } function setTrader(fId, hType, hId, hName, hAdress, hMail, hpartner){ globalAdress = 0; globalSend = 0; globalMail = ''; globalF = fId; globalH = hId; globalType = hType; if(hAdress){ globalAdress = hAdress; } if(hName){ globalName = hName; } if(hMail){ globalMail = hMail; } if(hpartner){ globalPartner = hpartner; } document.getElementById('kontaktFirma').innerHTML = hName; document.getElementById('routeFirma').innerHTML = hAdress; } function showRoute(){ //globalAdress closeAll(); map1.overlayMapTypes.setAt( 0, null); var routeAdress = 0; if(globalAdress){ routeAdress = globalAdress; } var startAdress = document.getElementById('startAdress').value; var startOrt = document.getElementById('startOrt').value; var startPlz = document.getElementById('startPlz').value; var message = ''; var bolError = 0; if(!startAdress){ message = "* Ihre Adresse \n"; bolError = 1; } if(!startOrt){ message += "* Ihr Ort \n"; bolError = 1; } if(!startPlz || isNaN(startPlz)){ message += "* Ihre Postleitzahl \n"; bolError = 1; } if(!routeAdress){ message += "* Ihr Zielort \n"; bolError = 1; } var start = startPlz+" "+startOrt+" routeAdress"; if(!bolError || startOrt){ document.getElementById('routeInformation').innerHTML = ''; if ( typeof directionsDisplay != 'undefined' ){ directionsDisplay.setMap(null); } var directionsService = new google.maps.DirectionsService(); directionsDisplay = new google.maps.DirectionsRenderer(); directionsDisplay.setMap(map1); directionsDisplay.setPanel(document.getElementById('routeInformation')); var request = { origin:start, destination:routeAdress, travelMode: google.maps.TravelMode.DRIVING }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); } }); if(document.getElementById('routeInformation').innerHTML == ''){ // alert("Keine Routeninformationen zu dieser Adresse verfügbar. Prüfen Sie noch einmal ihre Eingaben!"); } } else{ alert('Folgende Felder wurden nicht korrekt ausgefüllt: \n'+ message); } window.location= '#standort'; } function handleErrors() { alert('Die Adresse konnte nicht gefunden werden. Vermeiden Sie Hausnummerangaben die einen Buchstaben enthalten. Verwenden Sie stattdessen nur den Ziffernwert.'); /* if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS) alert("Unknown Adress"); else if (gdir.getStatus().code == G_GEO_SERVER_ERROR) alert("A geocoding or directions request could not be successfully"); else if (gdir.getStatus().code == G_GEO_MISSING_QUERY) alert("The HTTP q parameter was either missing or had no value."); else if (gdir.getStatus().code == G_GEO_BAD_KEY) alert("The given key is either invalid or does not match the domain" + gdir.getStatus().code); else if (gdir.getStatus().code == G_GEO_BAD_REQUEST) alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code); else alert("An unknown error occurred on Map."+G_GEO_UNKNOWN_ADDRESS); */ } function setQuestion(){ var a = Math.ceil(Math.random() * 10); var b = Math.ceil(Math.random() * 10); globalAnswer = a + b; var question = "Wieviel ist "+ a + " + " + b +"? "; document.getElementById("codeQuestion").innerHTML = question; } function sendMessage(){ var kontaktName = document.getElementById('kontaktName').value; var kontaktTel = document.getElementById('kontaktTel').value; var kontaktMail = document.getElementById('kontaktMail').value; var kontaktMessage = document.getElementById('kontaktMessage').value; var kontaktCode = document.getElementById('kontaktCode').value; var rTel = document.getElementById('rTel').checked; var rFax = document.getElementById('rFax').checked; var rMail = document.getElementById('rMail').checked var answerType = ''; var adressMail = globalMail; //var adressMail = "simon.pickert@gmx.de"; var message = ""; var bolError = 0; if(!kontaktName){ bolError = 1; message += '* Ihre Name \n'; } if(!kontaktMail){ bolError = 1; message += '* Ihre E-Mail Adresse \n'; } if(!kontaktMessage){ bolError = 1; message += '* Ihre Nachricht \n'; } if(!rTel && !rFax && !rMail){ bolError = 1; message += '* Ihre Antwortvariante \n'; } else { if(rTel){ answerType = 'Telefon'; } if(rFax){ answerType = 'Fax'; } if(rMail){ answerType = 'E-Mail'; } } if(kontaktCode != globalAnswer){ bolError = 1; message += '* Ihr Sicherheitscode \n'; setQuestion(); } if(!bolError){ if(kontaktTel){ var answerTel = "&tel="+kontaktTel; } if(globalSend != 'send'){ ajaxRequestMail("name="+kontaktName+"&mail="+kontaktMail+"&hpartner="+globalPartner+"&message="+kontaktMessage+"&answer="+answerType+"&hname="+globalName+"&globalH="+globalH+"&adressMail="+adressMail+answerTel); globalSend = 'send'; } else{ alert("Sie haben bereits eine Nachricht an diesen Händler gesendet."); } } else{ alert("Folgende Felder müssen noch richtig ausgefüllt werden: \n"+message); } } function setMarker(address, wideness, arrData, show) { var htmlString = "
"; if(arrData[2]){ var boxClass = "firma-premium"; } else { var boxClass = "firma-standard"; } switch(arrData[6]){ case "D": var country = "Deutschland"; break; case "CH": var country = "Schweiz"; break; case "A": var country = "Österreich"; break; default: country = arrData[6]; } htmlString += "
"+arrData[0]+"
"+ "
"+arrData[4]+"
"+arrData[5]+"
"+country+"
"; if(arrData[7]){ htmlString += "Telefon "+arrData[7]+"
"; } if(arrData[8]){ htmlString += "Telefax "+arrData[8]+"
"; } else { htmlString += "
"; } if(arrData[3] == 0){ var amount = 'keine'; } else { var amount = arrData[3]; } htmlString += amount+" Angebote online "; htmlString += "
››› Kontakt   "; htmlString += "
"; if(arrData[2]){ htmlString += "
"; } htmlString += "
"; htmlString += "
"; if (geocoder) { //setTrader(arrData[13], arrData[14], arrData[15], arrData[0], arrData[16], arrData[11], arrData[17]); var point = new google.maps.LatLng(arrData[19], arrData[18]); var blueIcon = { image: '', size: '' }; var text = ""; for(i=0;i< arrData.length;i++){ text += i+arrData[i]+"\n"; } var point = new google.maps.LatLng(arrData[18],arrData[19]); var image = ''; if(arrData[2] && arrData[3]){ image = "/google-maps/angebote-premium-m.gif"; } else if(arrData[2]){ image = "/google-maps/premium-m.gif"; } else if(arrData[3]){ image = "/google-maps/angebote-m.gif"; } else{ image = "/google-maps/haendler.gif"; } blueIcon.size = new google.maps.Size(21, 44); var marker = new google.maps.Marker({ position: point, map: map1, icon: image }); var boxText = document.createElement("div"); boxText.style.cssText = ""; boxText.innerHTML = htmlString; var myOptions = { content: boxText ,disableAutoPan: false ,maxWidth: 0 ,pixelOffset: new google.maps.Size(-282, -335) ,zIndex: null ,boxStyle: { background: null ,opacity: 1 ,width: "396px" ,height: "198px" } ,closeBoxMargin: "10px 2px 2px 2px" ,closeBoxURL: "" ,infoBoxClearance: new google.maps.Size(1, 1) ,isHidden: false ,pane: "floatPane" ,enableEventPropagation: false }; var ib = new InfoBox(myOptions); boxList.push(ib); if(show == 1){ closeAll(); setTrader(arrData[13], arrData[14], arrData[15], arrData[0], arrData[16], arrData[9], arrData[17]); boxList[boxList.length-1].open(map1, marker); map1.setCenter(point); map1.setZoom(13); setTraderData(); } google.maps.event.addListener(marker,'click',(function(marker, j) { return function() { closeAll(); setTrader(arrData[13], arrData[14], arrData[15], arrData[0], arrData[16], arrData[9], arrData[17]); openedInfoWindow = boxList[j].open(map1, this); } })(marker, j)); } else{ alert("fehler"); } j++; return false; } function closeWindow(h) { boxList[h].close(); } function closeAll() { for(var m = 0; m<=j; m++){ if(boxList[m] != null){ boxList[m].close(); } } }