$(document).ready(function() {
	// get this to work!!!!!!
	// $.preloadCssImages({ imgDir: 'images' });
//	init();
	var host = (window.location.hostname == 'localhost' || window.location.hostname == '192.168.1.6') 
	    		? window.location.hostname+':4567' 
	    		: 'services.three60.com';
	
	$('#unfurl-viewport').unfurl({
		account: 4,
		baseUrl: 'http://'+host+'/unfurl',
		thumbnailScroller: true,
		thumbnailScrollerHeight: 500,
		albumSelectedIndicator: '*',
		slideshowSpeed: 2,
		onLoaded:function(){
			// $('#unfurl-viewport').fadeIn();
			// $.fn.unfurl.makeScrollable();
		}
	});
	
	$('#unfurl-close-link').click(function(){
		$('#unfurl-viewport').slideUp();
		$('#content').show();
	});
	
	$('#portfolio_link').click(function(){
		$('#content').fadeOut();
		$('#unfurl-viewport').slideDown();
		$.fn.unfurl.makeScrollable();
	});
	
	introSplash();
});

function init() {
	// $('body').css("background-color", "#0D2D40")
	$('#splash_bug').css("display", "none");
	$('#header').css("display", "block");
	$('#content_area').css("display", "block");
	$('#footer').css("display", "block");
	$('#menu').css("display", "block");
	$('#credits').css("display", "block");
	// 
	// $("li.image").hover(function(){
	// 	var image_on = $(this).attr("id").replace('_', '_on_');
	// 	$(this).css("backgroundImage", "url(images/"+image_on+".jpg)");	
	// },function(){
	// 	var image_off = $(this).attr("id").replace('_', '_off_');
	// 	$(this).css("backgroundImage", "url(images/"+image_off+".jpg)");	
	// });
	// 
	// $("li.image").each(function(){
	// 	var image_off = $(this).attr("id").replace('_', '_off_');
	// 	$(this).css("backgroundImage", "url(images/"+image_off+".jpg)");	
	// 	$(this).css("opacity", "0");
	// 	$(this).click(function(){
	// 		// togglePholio();
	// 		$("#pholio").slideDown("fast");
	// 		return false;
	// 	});
	// });
	// 
	// var timer = setInterval(doFades, 300);
	// var num = 0;
	// 
	// function doFades(){
	// 	num++;
	// 	var e = $("li.image");
	// 	var image = $(e[num-1]);
	// 	
	// 	image.animate({opacity:100}, 5000);
	// 
	// 	if(num >= 5){
	// 		clearInterval(timer);
	// 	}
	// }   
}

function introSplash(){
	// $('body').css("background-color", "#0D2D40")
	$('#splash_bug').css("opacity", "0");
	$('#header').css("display", "none");
	$('#content_area').css("display", "none");
	$('#menu').css("display", "none");
	$('#footer').css("display", "none");
	$('#credits').css("display", "none");
	
	$('#splash_bug').animate({opacity:100}, 1000, function(){ 
		$('#splash_bug').animate({opacity:0}, 2000, init);
	});
}
