$(document).ready(
	function() {
		// Setup triangle drops
		$(".triangle-drop-contents").hide();
		$(".triangle-drop").each(function(i) {
			if (i == 0) {
				// show correct image for first drop
				$(this).children("h4").css('backgroundImage', 'url(/images/small-down.gif)');
				
				// show contents for first drop
				$(this).children("div.triangle-drop-contents").show();
			}
			
			// set on click
			$(this).children("h4").click(function() {
				if ($(this).parent().children("div.triangle-drop-contents").is(":visible")) {
					$(this).css('backgroundImage', 'url(/images/small-right.gif)');
					$(this).parent().children("div.triangle-drop-contents").slideUp();
				} else {
					$(this).css('backgroundImage', 'url(/images/small-down.gif)');
					$(this).parent().children("div.triangle-drop-contents").slideDown();
				}
			});
		});
		
		// load google if necessary
		//if (typeof($("#map")) != null) {
		//	loadMap();
		//}

	}
);

function reOrder(loc, id, pd_val) {
	if(loc && id && pd_val) {
		document.location.href = loc + '&id=' + id + '&order=' + pd_val;
	}
}

var geocoder;
var map;
var dirObj;

function requestdirections2(mapobj,toaddr,fromaddr)
{
	if( typeof(dirObj) != 'undefined')
	{
		dirObj.clear();
	}
	mapobj.clearOverlays();
	$("#directions").html("");
	dirObj = new GDirections(mapobj,document.getElementById("directions"));
	dirObj.load('from:'+fromaddr+' to: '+toaddr);
	return false;
}

function showAddress(address) {
	map = new GMap2(document.getElementById("map"));
	geocoder = new GClientGeocoder();
	
	geocoder.getLatLng(
		address,
		function(point) {
			if (!point) {
				alert(address + " not found");
			} else {
				map.addControl(new GSmallMapControl());
				map.setCenter(point, 14);
				var marker = new GMarker(point);
				map.addOverlay(marker);
				marker.openInfoWindowHtml("Liberty Museum<br />321 Chestnut St., Philadelphia, PA 19106<br />215-925-2800");
			}
		}
	);
}

function loadMap()
{
	if(GBrowserIsCompatible())
	{
		$("#directions").html("");
		showAddress("321 Chestnut St., Philadelphia, PA 19106");
	}
}


function deleteConfirm()
{
	var confirmation= confirm("Are you sure you want to delete this item?");
	if(confirmation)
		return true;
	else
		return false;
}