function displayCoverFlow () {
	if ($("#repCoverFlow").length > 0)
	{
		$("#sidebar .sbcontain").css('padding',0);
	}
	if ($("div#repCoverFlow").length > 0)
	{
		var flashvars = {};
		var params = {};
		params.scale = "noscale";
		params.salign = "tl";
		params.wmode = "transparent";
		var attributes = {};
		width = $('#sidebar').innerWidth();
		height = 325;
		swfobject.embedSWF("/cover-flow/CoverFlowFX.swf", "repCoverFlow", width, height, "9.0.0", false, flashvars, params, attributes);
		$("#sidebar .sbcontain").append('<p style="text-align: center; font-weight:bold;">click photo for full profile</p>');
	}
}

function map_init() {
	if ($("#googlemap").length > 0) {
		var myLatlng = new google.maps.LatLng(google_lat, google_long);
		var myOptions = {
			zoom: 15,
			center: myLatlng,
			mapTypeId: google.maps.MapTypeId.ROADMAP,
				streetViewControl: true
		}
		var map = new google.maps.Map(document.getElementById("googlemap"), myOptions);
		var marker = new google.maps.Marker({
			position: myLatlng, 
			map: map
		}); 
	}
}

function flash () {
	if ($('#divflash').length == 0)
	{
		$('ul#homeslide').hide().before('<div id="divflash" />');
		$('#divflash').flash(
			{ src: '/images/jsc-intro-movie.swf',
			width: $('#bodygutter').innerWidth(),
			height: $('#bodygutter').innerHeight() },
			{ update: false }
		);
		if ($('.flash-replaced').length == 0) {
			$('ul#homeslide').show().innerfade({
						speed: 1000,
						timeout: 5000,
						type: 'sequence',
				});
			$('#divflash').remove();
		}	
	}	
}

$(document).ready(function () {
	
	flash ();
	
	var po = document.createElement('script'); po.async = true;
	po.src = '/cover-flow/swfobject.js';
	po.onload = displayCoverFlow;
	document.getElementsByTagName('head')[0].appendChild(po);
	
	$(".footlinks").livequery(function() {
		contentheight = $('#bodygutter').innerHeight();
		myfontsize = contentheight/42;
		footlinkheight = (myfontsize * ($(".footlinks p a").length * 3.7))+(myfontsize * 3.3);
		newheight = contentheight-footlinkheight;
		newwidth = ($('#bodygutter').innerWidth() / 2) - (4.8 * myfontsize);
		$('#content').css('overflow','visible');
		$('#content .contain').first().css('overflow','auto').css('height',newheight+'px');
		$(this).css('position','absolute').css('bottom','0').css('width',newwidth+'px');
	});
		
	$("a.opengallery").live('click',function(){
		$('#lightbox1').trigger('click');
		return false;
	});
	
	var script = document.createElement("script");
	script.type = "text/javascript";
	script.src = "//maps.googleapis.com/maps/api/js?sensor=false&callback=map_init";
	document.body.appendChild(script);
	
	$(".lightbox").livequery(function(){
			$('a[rel*=lightbox]').lightBox();
	});		
	
	$.getJSON('/includes/images.php', function(data) {	
	  $.each(data, function(key, val) {
		 $('<img/>')[0].src = val;
	  });	
	});	
});
