$(function() {
	$('#empty').fadeIn(800,function() {
		$('#nav-wilco').fadeIn(1400,function() {
			$('#gnav-wrap .navlist').fadeIn(800,function() {
				if(!ie6) {
					$('div.scrollable').fadeIn(800,initHome);
					}
				else {
					initHome();
					}	
				});
			});
		});
	});	

function initHome() {
	$('#barker').fadeIn();
	
	
	if(!ie6) {
		$("div.scrollable").scrollable({
			size: 8,
			speed: 200,
			items: ".thms"
			});
			
		$(".thms div img").click(function() {
			bkd = $(this).attr("alt");
			swapPhoto(this,bkd);
			});	
		
		// Pre-load large images
		$('.thms div img').each(function() {
			img = "/images/home/" + $(this).attr("alt") + ".jpg";
			$.ajax({ url: img, cache:true, dataType:"text" });						
			});
		}
	

	if(isiphone == 1) {	
		iPhoneCheck();	
		}
	}
	

function swapPhoto(sel,bkd) {
	$('.thms div img').removeClass("on");
	$(sel).addClass("on");
	bkd = "url(/images/home/" +bkd+ ".jpg)";
	$('#container').css({'background-image': bkd});
	}

function iPhoneCheck() {
	$('#ipapp').fadeIn();
	/*
	app = "";
	app = getCookie("ipapp");
	
	if(app == "1") {
		$('#ipapp').fadeIn();
		setCookie("ipapp",1,60);
		}
	*/	
	}	