$(document).ready(function() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("mapWrap"));
		map.disableDragging();  
	  	if ((latitude == '') && (longitude == '')) {
			map.setCenter(new GLatLng(40, -100), 3); //set map center default
		} else {
			map.setCenter(new GLatLng(latitude, longitude), 15); //set map center default
		}
    
		// Get Store open/closed status from xml file
		nocache = parseInt(Math.random()*99999999);
		var searchUrl = '/inc/location/google_maps/ajax-search_gen-xml.php?Lat=' + latitude + '&Lon=' + longitude + '&radius=' + 5; //build the url to execute using ajax
	 	var store_open = true;
		GDownloadUrl(searchUrl, function(data) {
	   		var xml = GXml.parse(data); //parse xml document data
	   		var marker = xml.documentElement.getElementsByTagName('marker'); //get each marker xml element
store_open = marker[0].getAttribute('Open');
	   	 	var OurIcon = new GIcon();
			OurIcon.iconSize = new GSize(32, 52); //required
			OurIcon.iconAnchor = new GPoint(16, 26); //required
			OurIcon.transparent = "/inc/location/google_maps/mm_its_arrow-transparent.png"; //required for IE - to keep clickable markers
			
			if (store_open == "yes") {
				OurIcon.image = '/inc/location/google_maps/mm_its_arrow-purple.png'; //required
			} else {
				OurIcon.image = '/inc/location/google_maps/mm_its_arrow-red.png'; //required
			}
			var point = new GLatLng(latitude,longitude);
			var marker = new GMarker(point,OurIcon);
			map.addOverlay(marker);
		});
    }
	/*
	//BEGIN POPUP FOR SENDING STORE LOCATION INFO TO CELL PHONE
	$(document).bind('reveal.facebox', function() {
		$('#smsForm').submit(function() {
			$.post('/sendToMobile.php', {ajax: true, storeInfo: $($('.sms_location_info')[0]).text(), storeAddress: $($('.sms_address_info')[0]).text(), phone: this.phone.value, carrier: this.carrier[this.carrier.selectedIndex].value, other: this.other.value },
				function(data){
					$('#showSMSError').html(data);
					if ($('#error').val() != "true") {
						$('#smsForm').hide();
					}
				},"html");
			return false;
		});
	});
	//END POPUP FOR SENDING STORE LOCATION INFO TO CELL PHONE
	$('.sendToMobile').click(function (e) {
		e.stopPropagation();
		$.get("/sendToMobile.php", {ajax: true}, function(data){
			$.facebox(data);
		});
		return false;
	});*/
});
