var domains = new Array();
domains[0] = new Object();
domains[0]["url"] = "parkettveredelung.cms.d10.net";
domains[0]["code"] = "ABQIAAAA2M0VigEBut4nNvJw6Zg0CRSmA1t1ne3hCWCQzSsXiaxZWlD3KhSIj8bzBamI3HMCLD3Vp9RyHYUWAQ";

domains[1] = new Object();
domains[1]["url"] = "www.parkettveredelung.com";
domains[1]["code"] = "ABQIAAAA2M0VigEBut4nNvJw6Zg0CRTwo3UcMBFxvBaPlo4PS59Oz4PpjBQSMb95RzD5X1mSg1lamISqgl7otg";

domains[2] = new Object();
domains[2]["url"] = "parkettveredelung.com";
domains[2]["code"] = "ABQIAAAA2M0VigEBut4nNvJw6Zg0CRRzNTY3Tv4Cvaf8OXu7S9EeNtItpBRjkh2-st4PiOYhAd3lWQpUTnKBUw";

domains[3] = new Object();
domains[3]["url"] = "www.parkettveredelung.de";
domains[3]["code"] = "ABQIAAAA2M0VigEBut4nNvJw6Zg0CRSVQaFOTrCTWODuYlUJeKirqeJX3BQonLLPQelzq14YympjwGnB_2niuw";

domains[4] = new Object();
domains[4]["url"] = "parkettveredelung.de";
domains[4]["code"] = "ABQIAAAA2M0VigEBut4nNvJw6Zg0CRRj8-ArAG7IgwRCkTaxgsDNV2HWnxSO37F9csOBboWWXF14qViLF_tMNA";

domains[5] = new Object();
domains[5]["url"] = "parkettveredelung-new.cms.d10.net";
domains[5]["code"] = "ABQIAAAA2M0VigEBut4nNvJw6Zg0CRRUL08ZIl8cmKjEUpR86JCA5H0ZPhT7pljFgsUEhAvjFKgiGMWjvELNlg";

var adresse = window.location.host;

for (var i = 0; i <= domains.length-1; i++) {
  if (domains[i]["url"] == adresse) {
    document.write('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key='+domains[i]["code"]+'" type="text/javascript"><\/script>');
    break;
  }
}
              
                    var gmarkers =[];
                    var htmls = [];
                    var to_htmls= [];
                    var from_htmls= [];
                    var gdir="";
                    var reasons=[];
                    
                    // Call this function when the page has been loaded
                    function createMap(latitude,longitude,destination) {
                      jQuery(".map").empty().hide();
                      jQuery(".directions").empty().hide();
                      
                      var map = new google.maps.Map2(document.getElementById('map_'+destination),
                          { size: new GSize(400,320) } );
                      map.addControl(new GLargeMapControl());
                      map.addControl(new GMapTypeControl());
                      
                      var centrePoint = new GLatLng(latitude,longitude);
                      map.setCenter(centrePoint, 14); 
                      
                      //add the marker
                      var marker = createMarker(centrePoint,destination);
                      map.addOverlay(marker);
                      GEvent.trigger(marker,'click'); //Open the bubble over the marker
                      // === create a GDirections Object ===
                    gdir=new GDirections(map, document.getElementById("directions_"+destination));
                 
                      // === Array for decoding the failure codes ===
                      
                      reasons[G_GEO_SUCCESS]            = "Success";
                      reasons[G_GEO_MISSING_ADDRESS]    = "Missing Address: The address was either missing or had no value.";
                      reasons[G_GEO_UNKNOWN_ADDRESS]    = "Unknown Address:  No corresponding geographic location could be found for the specified address.";
                      reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";
                      reasons[G_GEO_BAD_KEY]            = "Bad Key: The API key is either invalid or does not match the domain for which it was given";
                      reasons[G_GEO_TOO_MANY_QUERIES]   = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";
                      reasons[G_GEO_SERVER_ERROR]       = "Server error: The geocoding request could not be successfully processed.";
                      reasons[G_GEO_BAD_REQUEST]        = "A directions request could not be successfully parsed.";
                      reasons[G_GEO_MISSING_QUERY]      = "No query was specified in the input.";
                      reasons[G_GEO_UNKNOWN_DIRECTIONS] = "The GDirections object could not compute directions between the points.";
               
                      // === catch Directions errors ===
                      GEvent.addListener(gdir, "error", function() {
                        var code = gdir.getStatus().code;
                        var reason="Code "+code;
                        if (reasons[code]) {
                          reason = reasons[code]
                        } 
                       alert("Failed to obtain directions, "+reason);
                      });
                      jQuery("#map_"+destination).show();
                    }
                    function createMarker(point, destination) {
                       var marker = new GMarker(point);
                       var html = "";
                       name = $('#name_'+destination).html();
                       address = $('#addr1_'+destination).html() + '<br\/>' +$('#addr2_'+destination).html();
                      // The info window version with the "to here" form open
                      to_htmls[destination] = html + '<b>' + name + '</b> <br />' + address +'<br />'+translationsettings_setting_text_5+'<b>'+translationsettings_setting_text_6+'<\/b> - <a href="javascript:fromhere(' + destination + ')" mce_href="javascript:fromhere(' + destination + ')">'+translationsettings_setting_text_7+'<\/a>' +
                         '<br>'+translationsettings_setting_text_8+'<form action="javascript:getDirections(' + destination + ')">' +
                         '<input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" /><br>' +
                         '<INPUT value="'+translationsettings_setting_text_10+'" TYPE="SUBMIT"><br>' +
                         '<input type="hidden" id="daddr" value="'+name+"@"+ point.lat() + ',' + point.lng() + 
                         '" />';
                      // The info window version with the "from here" form open
                      from_htmls[destination] = html + '<b>' + name + '</b> <br />' + address +'<br />'+translationsettings_setting_text_5+'<a href="javascript:tohere(' + destination + ')" mce_href="javascript:tohere(' + destination + ')">'+translationsettings_setting_text_6+'<\/a> - <b>'+translationsettings_setting_text_7+'<\/b>' +
                         '<br>'+translationsettings_setting_text_9+'<form action="javascript:getDirections(' + destination + ')">' +
                         '<input type="text" SIZE=40 MAXLENGTH=40 name="daddr" id="daddr" value="" /><br>' +
                         '<INPUT value="'+translationsettings_setting_text_10+'" TYPE="SUBMIT"><br>' +
                         '<input type="hidden" id="saddr" value="'+name+"@"+ point.lat() + ',' + point.lng() +
                         '" />';
                      // The inactive version of the direction info
                      html = html + '<b>' + name + '</b> <br />' + address +'<br />'+translationsettings_setting_text_5+'<a href="javascript:tohere(' + destination + ')" mce_href="javascript:tohere(' + destination + ')">'+translationsettings_setting_text_6+'<\/a> - <a href="javascript:fromhere(' + destination + ')" mce_href="javascript:fromhere(' + destination + ')">'+translationsettings_setting_text_7+'<\/a>';
               
                      GEvent.addListener(marker, "click", function() {
                        marker.openInfoWindowHtml(html);
                      });
                      // save the info we need to use later for the side_bar
                      gmarkers[destination]=(marker);
                      htmls[destination] = html;
                      
                    return marker;
                    }
                    // functions that open the directions forms
                    function tohere(i) {
                      gmarkers[i].openInfoWindowHtml(to_htmls[i]);
                      jQuery("#directions_"+i).show();
                      jQuery("#print_"+i).show();
                    }
                    function fromhere(i) {
                      gmarkers[i].openInfoWindowHtml(from_htmls[i]);
                      jQuery("#directions_"+i).show();
                      jQuery("#print_"+i).show();
                    }
                    // ===== request the directions =====
                    function getDirections(i) {
                      // ==== Set up the walk and avoid highways options ====
                      var opts = {};
                      //if (document.getElementById("walk").checked) {
                      //   opts.travelMode = G_TRAVEL_MODE_WALKING;
                      //}
                      //if (document.getElementById("highways").checked) {
                      //   opts.avoidHighways = true;
                      //}
                      // ==== set the start and end locations ====
                      var saddr = document.getElementById("saddr").value
                      var daddr = document.getElementById("daddr").value
                      gdir.load("from: "+saddr+" to: "+daddr, opts);
                      print_html = 'http://maps.google.com/maps?f=d&saddr='+saddr+'&daddr='+daddr+'&f=d&ie=UTF8&layer=c&pw=2&hl='+translationsettings_setting_text_2;
                      jQuery("#print_"+i).attr('href',print_html);
                    }
                    //google.setOnLoadCallback(initialize);

                                        
                    
                     function checkBrandIfExist(brandId,storeId,countryId,showBrand,image){
                      jQuery("#brand_"+brandId+"_"+storeId).attr('src','images/spacer.gif');
                        jQuery.getJSON(
                        'http://storelocator.parkettveredelung.d10.net/webservice/storeLocator.cfc?callback=?',
                        //'http://cf8/akzonobel_storelocator/webservice/storeLocator.cfc?callback=?',
                        {method : 'getStore2BrandExist',
                        store_id:storeId, 
                        brand_id:brandId 
                        },
                        function checkBrand(r){
                          if (r.STOREHASBRAND != 0){
                            $("#brand_"+r.BRAND_ID+"_"+r.STORE_ID).attr('src','/assets/templates/parkettveredelung/images/'+image);
                          }
                        }
                      );
                     }
                     function searchStore(){
                      $('#maincontent').removeAttr('style');
                      jQuery('#NoResultArea').html('<center><img src="assets/templates/parkettveredelung/images/loader.gif" border="0" /></center>');
                      jQuery('#NoResultArea').show();
                      var city = jQuery("#city").val();
                      var zipcode = jQuery('#zipholder').html();

                      if ((zipcode == "") | (zipcode == null) | (zipcode == "&nbsp;"))
                      {
                        zipcode = jQuery("#zipcode").val();
                        jQuery('#zipholder').html(zipcode);
                      }

                      //var province = jQuery("#province").val();
                      var country_id=jQuery("#country_id").val();
                      var brand_id='-1';
                      if(country_id=='7' && zipcode==""  && city == "") {
                     jQuery('#NoResultArea').html('<center><br /><span style="color:#ff0000;">Bitte grenzen Sie Ihre Suche weiter ein, indem Sie eine PLZ oder eine Stadt angeben.</span></center>');
                     jQuery('#NoResultArea').show();    
                      }else{
                      jQuery('#resultStore').empty();
                      jQuery.getJSON(
                        'http://storelocator.parkettveredelung.d10.net/webservice/storeLocator.cfc?callback=?',
                        {method : 'getStore',
                        city :city,
                        zipcode :zipcode,
                        //province:province,
                        country_id:country_id, 
                        brand_id:brand_id
                        },
                        function returnStore(r){
                          myRow="";
                          var result= r;
myRow='<table border="0">';
                          for (var i = 0; i < r.ROWCOUNT; i++) {
                            store_name = r.DATA.STORE_NAME[i];
                            store_address = r.DATA.STORE_ADDRESS[i] + '<br />' + r.DATA.STORE_CITY[i];
                            store_name = store_name.replace(/'/g," ");
                            store_address = store_address.replace(/'/g," ");
                            store_id = r.DATA.STORE_ID[i];
                            store_plz = r.DATA.STORE_ZIPCODE[i].replace('_','');
myRow+='<tr><td width="270px">';
                            myRow+='<div style="margin: 20px 0pt 0pt;" mce_style="margin: 20px 0pt 0pt;">';
                            myRow+='<div class="tahoma_14_bold" id="name_'+r.DATA.STORE_ID[i]+'"><strong>'+r.DATA.STORE_NAME[i]+'</strong></div>';
                            checkBrandIfExist(10,store_id,country_id,0,'colormixer.gif');
                            myRow+='<div><img style="margin-top: -20px; margin-left: 320px; z-index:999;" id="brand_10_'+store_id+'" src="/assets/templates/parkettveredelung/images/spacer.gif" border="0" alt="colormixer" title="colormixer" />&nbsp;</div>';
                            myRow+='<div class="tahoma_11_regular" id="addr1_'+r.DATA.STORE_ID[i]+'">'+r.DATA.STORE_ADDRESS[i]+'</div>';
                            myRow+='<div class="tahoma_11_regular" id="addr2_'+r.DATA.STORE_ID[i]+'">'+store_plz+' '+r.DATA.STORE_CITY[i]+'</div>';

                            
                            if ((r.DATA.STORE_PHONE[i] != "") && (r.DATA.STORE_PHONE[i] != null)) {
                              myRow+='<div class="tahoma_11_regular">'+translationsettings_setting_text_11+' '+r.DATA.STORE_PHONE[i]+'</div>';
                            }
                            
                            if ((r.DATA.STORE_FAX[i] != "") && (r.DATA.STORE_FAX[i] != null)) {
                              myRow+='<div class="tahoma_11_regular">'+translationsettings_setting_text_12+' '+r.DATA.STORE_FAX[i]+'</div>';
                            }

                            if ((r.DATA.STORE_CONTACT_FIRSTNAME[i] != "") && (r.DATA.STORE_CONTACT_FIRSTNAME[i] != null)) {
                              myRow+='<div class="tahoma_11_regular">Zweihorn Kontakt: '+r.DATA.STORE_CONTACT_FIRSTNAME[i]+' '+r.DATA.STORE_CONTACT_LASTNAME[i]+'</div>';
                            }
                            if ((r.DATA.STORE_CONTACT_PHONE[i] != "") && (r.DATA.STORE_CONTACT_PHONE[i] != null)) {
                              myRow+='<div class="tahoma_11_regular">Mobil: '+r.DATA.STORE_CONTACT_PHONE[i]+'</div>';
                            }


                            
                            if ((r.DATA.STORE_WEBSITE[i] != "") && (r.DATA.STORE_WEBSITE[i] != null)) {
                              myRow+='<div class="tahoma_11_regular">'+translationsettings_setting_text_13+' <a href="http://'+r.DATA.STORE_WEBSITE[i]+'" mce_href="http://'+r.DATA.STORE_WEBSITE[i]+'" target="_blank">'+r.DATA.STORE_WEBSITE[i]+'</a></div>';
                            }
                            
                            if ((r.DATA.STORE_EMAIL[i] != "") && (r.DATA.STORE_EMAIL[i] != null)) {
                              myRow+='<div class="tahoma_11_regular">'+translationsettings_setting_text_14+' <a href="mailto:'+r.DATA.STORE_EMAIL[i]+'" mce_href="mailto:'+r.DATA.STORE_EMAIL[i]+'">'+r.DATA.STORE_EMAIL[i]+'</a></div>';
                            }
                            if ((r.DATA.STORE_EXTRA_OPENTIME[i] != "") && (r.DATA.STORE_EXTRA_OPENTIME[i] != null)) {
                              myRow+='<br /><b>Öffnungszeiten:</b><br />';
                              myRow+='<div class="tahoma_11_regular" style="display:inline;">'+r.DATA.STORE_EXTRA_OPENTIME[i].replace(/\r\n/g, '<br />')+'</a></div>';
                            }
myRow+='<br />';
 myRow+="<div class='tahoma_11_regular'><a href=javascript:createMap('"+r.DATA.STORE_LATITUDE[i]+"','"+r.DATA.STORE_LONGITUDE[i]+"','"+r.DATA.STORE_ID[i]+"')>"+translationsettings_setting_text_3+"</a></div>";
                            myRow+='<div id="map_'+r.DATA.STORE_ID[i]+'" class="map" style="display:none;width:400px;height:320px"></div>';
                            myRow+='<div id="directions_'+r.DATA.STORE_ID[i]+'" class="directions" style="display:none;width:400px;"></div>';
                            myRow+='<br />';
                            myRow+='</td></tr>';
                            myRow+='<tr><td colspan="2"><div style="background-color:#bccddd; font-size:0pt; height:1px; width:400px;"></div></td></tr>';
                          }
myRow+='</table>';
                          if (r.ROWCOUNT == 0){
                            zipcode = jQuery('#zipholder').html();
                            oldzipcode = jQuery("#zipcode").val();

                            if (zipcode != oldzipcode.substring(0,1))
                            {
                              var newzipcode = zipcode.substring(0, zipcode.length-1);
                              jQuery('#zipholder').html(newzipcode);
                              searchStore();
                            }
                            else
                            {
                              jQuery("#resultArea").hide();
                              jQuery('#NoResultArea').html('<br /><span style="color:#ff0000"><center>'+translationsettings_setting_text_23+'</center></span>');
                              jQuery("#NoResultArea").show();
                            }
                          }else{
                            jQuery("#NoResultArea").hide();
                            jQuery("#resultStore").html(myRow);
                            jQuery("#resultArea").fadeIn();
                            jQuery("#NoResultArea").hide();
                          }
                        }
                       );} }

