var curPhoto;
var totalPhotos;
var rotateTimer;

$(document).ready(init);

function init(){
	setupCircleNavs();
	galleryRotator();
	fadeIntro();
	sidebarHeight();
	ieStyles();
}

function sidebarHeight(){
	if($("#left-image-top").height() > $("#internal-right-blog").height()){
		var difference = $("#left-image-top").height() - $("#internal-right-blog").height() + 165;
		$("#internal-right-blog").css("padding-bottom", difference);
	}
}

function setupCircleNavs(){
	$("#circle-containers li a").hover(function(){
		$(".circle-on", this).fadeIn(300);
		$(".circle-label", this).addClass("rotate");
		
		var color = $(".circle-label", this).attr("data-color");
		
		$(".circle-label span", this).css("color", color);
		
	}, function(){
		$(".circle-on", this).fadeOut(300);
		$(".circle-label", this).removeClass("rotate");
		$(".circle-label span", this).css("color", "#A0A0A0");
	});
}

function galleryRotator(){
	$('#rotator-gallery').cycle({
		fx		: 	'fade',
		speed	: 	800,
		timeout	:	6000
	});
}

function fadeIntro(){
	if(Modernizr.localstorage && localStorage.sawIntro == null){
	
		localStorage.sawIntro = true;

		$("#image-cover").show();
		$("#circle-containers li").hide();
	
		$("#full-cover").delay(1200).fadeOut(750, fadeImage);
	}else{
		$("#full-cover").hide();
	}
}

function fadeImage(){
	$("#image-cover").delay(500).fadeOut(750, fadeCircles);
}

function fadeCircles(){
	var fadeDelay = 200;
	$("#circle-containers li").each(function(){
		$(this).delay(fadeDelay).fadeIn(500);
		fadeDelay += 200;
	});
}

function ieStyles(){
	if(!Modernizr.rgba){
		$("#main-nav, #header-bottom").css("background", "#000").fadeTo(1, .6);
		$(".circle-label").css("background", "#FFF").fadeTo(1, .9);
	}
}
