//Proper Address for all locations
var address= new Array();
address["Forsyth"]= ["410 Peachtree Parkway Suite 122","Cumming, GA","30041","Cheeky Forsyth"];
address["Suwanee"]= ["1039 Peachtree Industrial Blvd Suite A 122","Suwanee, Georgia","30024","Cheeky Suwanee"];
address["East Cobb"]= ["4475 Roswell Rd #1510","Marietta, Georgia","30062","Cheeky East Cobb"];
var currentInfoWindow;


//Making array for every location for Taco Mac
function markerArray(map1) {
	var image = 'http://cheeky.tacomac.com/wp-content/themes/FactoryWP/images/loc/cheekyicon.png';
	var markers1 = [];
	var position = [["Forsyth",34.154023,-84.176184],["Suwanee",34.05129,-84.090284],["East Cobb",33.987629,-84.421853]];

	var len = position.length;
	
	for (var i=0; i<len; i++) {
		var myLatLng = new google.maps.LatLng(position[i][1],position[i][2]);
		var marker = new google.maps.Marker({
			position: myLatLng,
			map: map1,
			icon: image,
			title: position[i][0]
		});	
		
		addMarkerListenersInfo(marker, map1);
		
		markers1.push(marker);
	}
	
	return markers1;
	
}

//Adding links and infowindows for every marker
function addMarkerListenersInfo(marker3, map2) {

	google.maps.event.addListener(marker3, 'click', function() {
		var urllink = marker3.getTitle()+"/";
		location.href=urllink;
		});
	
	var currentaddr = address[marker3.getTitle()];
	var contentString='<div class="info_content">'+
				'<h5 class="info_header">'+currentaddr[3]+'</h5>'+
				'<p class="info_address">'+currentaddr[0]+'<br/>'+currentaddr[1]+' '+currentaddr[2]+
				'<br/>'+
				'<a target="_blank" href="http://maps.google.com/maps?daddr='+currentaddr[0]+' '+currentaddr[1]+' '+currentaddr[2]+'">view directions</a>'+'</p>'+
				'</div>';
				
	var infowindow = new google.maps.InfoWindow({
    content: contentString
	});
	
	google.maps.event.addListener(marker3, 'mouseover', function() {
		if (currentInfoWindow != null) {
			currentInfoWindow.close();
		}
		infowindow.open(map2,marker3);
		currentInfoWindow = infowindow;
	});
	
}

