window.addEvent('domready', function() {
	var all_divs = $ES('div');
	var toggle_arrow_divs = all_divs.filterByClass('toggle-arrow');
	
	toggle_arrow_divs.each( function( item, index ) {
		var sindex = index.toString();
		var mySlide = new Fx.Slide('section-'+sindex, {
			duration: 400,
			onComplete: function() {
				if( $('section-'+sindex+'_img').getProperty('src') == mosConfig_live_site+"/images/small-right.gif" )
					$('section-'+sindex+'_img').setProperty('src', mosConfig_live_site+'/images/small-down.gif');
				else
					$('section-'+sindex+'_img').setProperty('src', mosConfig_live_site+'/images/small-right.gif');
			}
		});
		
		mySlide.hide();
		
		$('section-'+sindex).setStyle('padding-bottom', '5px');
		$('section-'+sindex).setStyle('display', 'block');

		$('toggle-arrow-img-'+sindex).addEvent('click', function(e) {
			e = new Event(e);
			mySlide.toggle();
			e.stop();
		});
		$('toggle-arrow-'+sindex).addEvent('click', function(e) {
			e = new Event(e);
			mySlide.toggle();
			e.stop();
		});
	});
});

function camera1()
{
window.open("http://74.95.174.137:5000/ImageViewer?Resolution=320x240","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=yes, width=340, height=275")
}
function camera2()
{
window.open("http://74.95.174.137:5100/ImageViewer?Resolution=320x240","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=yes, width=340, height=275")
}

function coupon(id)
{
window.open(mosConfig_live_site+"/w/coupon/"+id,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=yes, width=546, height=590")
}

var geocoder;
var map;

function requestdirections2(mapobj,toaddr,fromaddr)
{
	dirObj = new GDirections(mapobj,document.getElementById("directions"));
	dirObj.load('from:'+fromaddr+' to: '+toaddr);
	return false;
}

function addAddressToMap(response)
{
	map.clearOverlays();
	if (!response || response.Status.code != 200) {
		alert("Sorry, we were unable to geocode that address");
	}
	else
	{
		place = response.Placemark[0];
		point = new GLatLng(place.Point.coordinates[1],
		place.Point.coordinates[0]);
		
		var baseIcon = new GIcon();
		baseIcon.image = mosConfig_live_site+"/images/daspunt.png";
		baseIcon.shadow = mosConfig_live_site+"/images/theshadow.png";
		baseIcon.iconSize = new GSize(30, 50); // The size of the image
		baseIcon.shadowSize = new GSize(44, 50); // the size of the shadow image
		baseIcon.iconAnchor = new GPoint(9, 44); // the point in relation to the top left corner of the icon where the icon will attach to the map
		baseIcon.infoWindowAnchor = new GPoint(22, 3); // The point where the info window will attach to the icon
		baseIcon.infoShadowAnchor = new GPoint(7, 7); // no idea
		
		markerOptions = { icon:baseIcon };
		var marker = new GMarker(point, markerOptions);
		
		map.addOverlay(marker);
		
		//marker = new GMarker(point);
		map.addOverlay(marker);
		marker.openInfoWindowHtml('<table width=\'380\'><tr><td><img src=\''+mosConfig_live_site+'/images/logo-small.jpg\' /></td><td>Buzzy\'s Bow Wow Meow<br>' + place.address+'<br />610.617.3300</td></tr></table>');
	}
}

function loadMap()
{
	if(DisplayMap == true )
	{
		if (GBrowserIsCompatible())
		{
			var point = new GLatLng(40.005562, -75.261626);
			map = new GMap2(document.getElementById("map"));
			map.addControl(new GSmallMapControl());
			map.setCenter(point, 13);
			
			if( StartAddress == "" ) {
				geocoder = new GClientGeocoder();
				geocoder.getLocations("701 Montgomery Ave, Narberth, PA 19072", addAddressToMap);
			}
		
			requestdirections2(map, "701 Montgomery Ave, Narberth, PA 19072", StartAddress);
		}
	}
}