
// jQuery is used extensively throughout this website.

var $j = jQuery.noConflict();
	
$j(document).ready(function() {
	
		// Set Captions
		$j("img[longdesc^='caption:'],[longdesc^='Caption:']").each(function() {
			var longdesc = $j.trim($j(this).attr("longdesc").replace(/caption:/i,""));
			var align = $j(this).attr("align");
			$j(this).wrap("<div class='photo " + align + "'><div>");
			$j(this).after("<p>" + longdesc + "</p>");
			$j(this).parent().parent().width($j(this).attr("width") + 2);
		});
		
		// Enable prettyPhoto
		$j("a[rel='colorbox']").colorbox();
		$j(".youtube").colorbox({iframe:true, width:500, height:400});
		
		$j("img.videoIcon").hover(function(){
			$j(this).attr("src","/images/icons/video-watch.png");
		   },function(){
			   $j(this).attr("src","/images/icons/video_12x12.png");
		   }
		)

});



function placeMap(mapId, controls, width, height)
{
	var mapUrl = (("https:" == document.location.protocol) ? "https://" : "http://");
	mapUrl = mapUrl + document.location.hostname + "/maps/default.aspx?mapId=" + mapId + "&amp;controls=" + controls + "&amp;width=" + width + "&amp;height=" + height;
	
	document.write("<i" + "frame class=\"maps\" src=\"" + mapUrl + "\" frameborder=\"0\" width=\"" + width + "\" scrolling=\"no\" height=\"" + height + "\"></i" + "frame>");
}

function toggleGranicusPlayer(videoId) {
	var t = document.getElementById('videoPlayerPreview' + videoId);
	var p = document.getElementById("videoPlayer" + videoId);
		
	if(t.style.display == "none") {
		t.style.display = "block";
		p.style.display = "none";
	} else {
		t.style.display = "none";
		p.style.display = "block";
	}
	p = document.getElementById("MediaPlayer" + videoId);
	p.controls.play();
}

function embedGranicusVideo(videoId, previewImage){
	var videoUrl = 'http://olympia.granicus.com/ASX.php?sn=olympia.granicus.com&publish_id=' + videoId;
	var bgControls = '/images/video-player-320x240-controls.jpg';
	var bgPlayer = '/images/play-button-320x240.png';
	var c = '';
		c += '<div onclick="toggleGranicusPlayer(' + videoId + ')" id="videoPlayerPreview' + videoId + '" style="width:320px;height:305px;background:url(' + bgControls + ') bottom no-repeat;display:block;"><div style="background:url(' + previewImage + ') no-repeat;width=320px;height:240px;"><img src="' + bgPlayer + '" /></div></div>\n';
		c += '<div onclick="toggleGranicusPlayer(' + videoId + ')" id="videoPlayer' + videoId + '" style="display:none">\n';
		c += '<OBJECT ID="MediaPlayer' + videoId + '" WIDTH="320" HEIGHT="305" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">\n';
		c += '<PARAM NAME="URL" VALUE="' + videoUrl + '" />\n';
		c += '<PARAM NAME="FileName" VALUE="' + videoUrl + '" />\n';
		c += '<PARAM NAME="currentPosition" VALUE="0" />\n';
		c += '<PARAM NAME="ShowControls" VALUE="0" />\n';
		c += '<PARAM NAME="ShowDisplay" VALUE="0" />\n';
		c += '<PARAM NAME="uiMode" VALUE="mini" />\n';
		c += '<PARAM NAME="ShowStatusBar" VALUE="0" />\n';
		c += '<PARAM NAME="stretchToFit" VALUE="0" />\n';
		c += '<PARAM NAME="AutoStart" VALUE="0" />\n';
		c += '<PARAM NAME="Banner" VALUE="http://localhost/images/temp-player.jpg" />\n';
		c += '<Embed type="application/x-mplayer2"\n';
		c += 'filename="' + videoUrl + '"\n';
		c += 'src="' + videoUrl + '"\n';
		c += 'width="320"\n';
		c += 'height="305"\n';
		c += 'showcontrols="0"\n';
		c += 'showdisplay="0"\n';
		c += 'showstatusbar="0"\n';
		c += 'autostart="0"\n';
		c += 'currentPosition="0"\n';
		c += 'uiMode="mini"\n';
		c += '</embed>\n';
		c += '</OBJECT>\n';
		c += '</div>';
	
	document.write(c);

}