// Initialize the SoundManager component
soundManager.url = '/scripts/';
soundManager.defaultOptions.volume = 66;



// General setup for the detail pages
function detailInit() {
	// Hide the comment form
	$("#comment-form").hide();
	// Setup the button to show the comment form
	$("#add-comment a").click(function() {
		$("#comment-form").slideDown("slow");
		$(this).hide();
        var targetOffset = $("#comment-form").offset().top;
		$('html,body').animate({scrollTop: targetOffset}, 1000);
		return false;
	});

	
	// Set up the audio links to play in place using the SoundManager.
	// If SoundManager doesn't load for some reason, the links will still function as normal.
	soundManager.onload = function() {
		// Cycle through the audio links and load the target of each
		$('a.audioLink').each(function (i) {
			soundManager.createSound({
				id: 'clip'+i,
				url: $(this).attr("href"),
				autoLoad: true,
				volume: 50
			});
			
			// Set up the onClick handler to control SoundManager
			$(this).click(function() {
				if (soundManager.sounds['clip'+i].playState == 1) {
					soundManager.stopAll();
				} else {
					soundManager.sounds['clip'+i].play('clip'+i);		
				}
				$(this).toggleClass('playing');
				return false;
			});
		});		
	};

	// Open links with rel="external" in a new window
	$("a[@rel~='external']").click(function(){
	window.open($(this).attr("href"));
	return false;
	});
};


function createMap(loc_lat, loc_long) {
	// Create point
	var gPoint = new YGeoPoint(loc_lat, loc_long);
	// Create a map object
	var map = new YMap(document.getElementById('map'));
	// Add map type control
	map.addTypeControl();
	// Add map zoom (long) control
	map.addZoomShort();
	// Add the Pan Control
	map.addPanControl();
	map.removeZoomScale();
	// Set map type to either of: YAHOO_MAP_SAT, YAHOO_MAP_HYB, YAHOO_MAP_REG
	map.setMapType(YAHOO_MAP_REG);
	// Display the map centered on a geocoded location
	map.drawZoomAndCenter(gPoint, 6);
    // Add marker for the office
    map.addMarker(gPoint);
}
