var map;function showCheckStoresMap(){var width=370;var height=450;showMap(width,height);}function showStoreLocatorMap(){var width=510;var height=510;showMap(width,height);}function showMap(width,height){if(document.getElementById("storeMap")){var mapDivElement=document.getElementById("storeMap");mapDivElement.style.width=width+"px";mapDivElement.style.height=height+"px";map=new GMap2(mapDivElement,{size:new GSize(width,height)});map.addControl(new GLargeMapControl());map.addControl(new GMapTypeControl());if(storesArray){if(storeId){map.setCenter(new GLatLng(storesArray[0][2],storesArray[0][1]),15);}else{map.setCenter(new GLatLng(latitude,longitude),13);if(isCreateUserMarker){createUserMarker(new GLatLng(latitude,longitude),"You are here",0);}}map.panBy(new GSize(10,70));var maptext='<div id="maptext">This is static text<img src="/images/checkout.gif" alt="Logo" /></div>';var bounds=new GLatLngBounds();addMarkers(map,bounds);if(storeId){var zoomL=map.getBoundsZoomLevel(bounds);}else{bounds.extend(new GLatLng(latitude,longitude));var zoomL=map.getBoundsZoomLevel(bounds);zoomL=zoomL-1;map.setZoom(zoomL);}displayStoreNameBelowMap(null);}else{if(typeof(selectedStore)!="undefined"){storeId=selectedStore[0][0];showSingleCheckStoreMap(storeId);}else{if(typeof(favoriteStores)!="undefined"&&favoriteStores.length==1){storeId=favoriteStores[0][0];showSingleCheckStoreMap(storeId);}else{map.setCenter(new GLatLng(latitude,longitude),0);map.setZoom(defaultZoom);}}}}}function getMarkers(n){var batch=[];for(var i=start;i<end;++i){var point=new GLatLng(storesArray[i][2],storesArray[i][1]);maptext="<div id=\"maptext\"><b><a class='map' href='"+pagePrefix+"storeLocator/store_details.jsp?storeId="+storesArray[i][0]+"'>"+storesArray[i][3]+"</a></b><br/>"+storesArray[i][4]+"<br/>"+storesArray[i][7]+","+storesArray[i][6]+"<br/><br/><b>"+telephoneText+":</b>"+storesArray[i][5]+"<br/><br/>&nbsp;</div>";if(typeof(showAll)!="undefined"&&showAll){batch.push(new GMarker(point));}else{if(i>=10&&i<20){batch.push(new GMarker(point));}if(i>=20){batch.push(new GMarker(point));}if(i<10){batch.push(new GMarker(point));}}}return batch;}function addMarkers(map,bounds){for(var i=start;i<end;++i){var point=new GLatLng(storesArray[i][2],storesArray[i][1]);bounds.extend(point);maptext="<div id=\"maptext\"><b><a class='map' href='"+pagePrefix+"storeLocator/store_details.jsp?storeId="+storesArray[i][0]+"'>"+storesArray[i][3]+"</a></b><br/>"+storesArray[i][4]+"<br/>"+storesArray[i][7]+","+storesArray[i][6]+"<br/><br/><b>"+telephoneText+":</b>"+storesArray[i][5]+"<br/><br/>&nbsp;</div>";if(typeof(showAll)!="undefined"&&showAll){createMarker(point,maptext,i);}else{if(i>=10&&i<20){createMarker(point,maptext,i-10);}if(i>=20){createMarker(point,maptext,i-20);}if(i<10){createMarker(point,maptext,i);}}}}function showSingleCheckStoreMap(storeId){if(document.getElementById("storeMap")){var storeToShow=getSelectedStoreDetailsFromArray(storeId,storesArray);displayStoreNameBelowMap(storeToShow);var width=370;var height=450;document.getElementById("storeMap").style.width=width+"px";document.getElementById("storeMap").style.height=height+"px";map=new GMap2(document.getElementById("storeMap"),{size:new GSize(width,height)});map.addControl(new GLargeMapControl());map.addControl(new GMapTypeControl());if(storeToShow){map.setCenter(new GLatLng(storeToShow[2],storeToShow[1]),15);map.panBy(new GSize(10,70));var maptext='<div id="maptext">This is static text<img src="/images/checkout.gif" alt="Logo" /></div>';var bounds=new GLatLngBounds();var point=new GLatLng(storeToShow[2],storeToShow[1]);bounds.extend(point);maptext="<div id=\"maptext\"><b><a class='map' href='"+pagePrefix+"storeLocator/store_details.jsp?storeId="+storeToShow[0]+"'>"+storeToShow[3]+"</a></b><br/>"+storeToShow[4]+"<br/>"+storeToShow[7]+","+storeToShow[6]+"<br/><br/><b>Telephone:</b>"+storeToShow[5]+"<br/><br/>&nbsp;</div>";createMarker(point,maptext,storeToShow[8]);var zoomL=map.getBoundsZoomLevel(bounds);}}}function displayStoreNameBelowMap(storeToShow){if(storeToShow!=null){document.getElementById("selectedStoreName").innerHTML=storeToShow[3]+" store";}else{if(document.getElementById("selectedStoreName")){document.getElementById("selectedStoreName").innerHTML="";}}}function getSelectedStoreDetailsFromArray(storeId,storesArray){var storeFound;for(store in storesArray){if(store){if(storesArray[store][0]==storeId){storeFound=storesArray[store];}}}if(storeFound){return storeFound;}if(typeof(selectedStore)!="undefined"){for(store in selectedStore){if(store){if(selectedStore[store][0]==storeId){storeFound=selectedStore[store];}}}if(storeFound){return storeFound;}}if(typeof(favoriteStores)!="undefined"){for(store in favoriteStores){if(store){if(favoriteStores[store][0]==storeId){storeFound=favoriteStores[store];}}}if(storeFound){return storeFound;}}if(typeof(recommendedStores)!="undefined"){for(store in recommendedStores){if(store){if(recommendedStores[store][0]==storeId){storeFound=recommendedStores[store];}}}if(storeFound){return storeFound;}}return storeFound;}function createMarker(point,html,index){var markerIconImage="/images/content/store_locator/store_marker_images/marker"+index+".png";var icon=new GIcon();icon.image=markerIconImage;icon.iconSize=new GSize(20,34);icon.iconAnchor=new GPoint(20,22);icon.infoWindowAnchor=new GPoint(15,6);var marker=new GMarker(point,icon);map.addOverlay(marker);GEvent.addListener(marker,"click",function(){marker.openInfoWindowHtml(html,{noCloseOnClick:true});});GEvent.addListener(marker,"mouseover",function(){marker.openInfoWindowHtml(html,{noCloseOnClick:true});});return marker;}function createUserMarker(point,html,index){var markerIconImage="/images/content/store_locator/store_marker_images/icon"+index+".png";var icon=new GIcon();icon.image=markerIconImage;icon.iconSize=new GSize(20,34);icon.iconAnchor=new GPoint(20,22);icon.infoWindowAnchor=new GPoint(15,6);var marker=new GMarker(point,icon);map.addOverlay(marker);GEvent.addListener(marker,"click",function(){marker.openInfoWindowHtml(html,{noCloseOnClick:true});GEvent.addListener(marker,"mouseover",function(){marker.openInfoWindowHtml(html);});});return marker;}
