/* Main JavaScript Document
 * Tazzernator.com
 * Andrew Tajsic
 * January 2012
 */

$(function () {
	
bodyload()

//initialise slider
$("div.metro-pivot").metroPivot();
$("span.theme-box").click(theme_Changed);
$("span.accent-box").click(accent_Changed);

//initialise loading spinner for interests
var opts = {
  lines: 12, // The number of lines to draw
  length: 11, // The length of each line
  width: 5, // The line thickness
  radius: 25, // The radius of the inner circle
  color: '#7f7f7f', // #rgb or #rrggbb
  speed: 1, // Rounds per second
  trail: 60, // Afterglow percentage
  shadow: false // Whether to render a shadow
};
var target = document.getElementById('spinner');
var spinner = new Spinner(opts).spin(target);



function bodyload(){
	//hide the javascript warning... 'cause well, using javascript here...
	$('#js_warn').css('display','none');
	
	$('.topheader').animate({ opacity: 0, marginTop: "-=10px"  }, 0).delay(200).animate({ 
			opacity: 1, 
			marginTop: "+=10px" 
	}, 'medium');
	
	
	
	
	
	//animations		
	$('#under_msg').animate({ opacity: 0 }, 0).delay(50).animate({ opacity: 1 }, 'medium');	
						
	$('.metro-pivot').animate({ opacity: 0, paddingTop: "+=10px" }, 0).delay(400).animate({ 
			opacity: 1, 
			paddingTop: "-=10px" 
	}, 'medium');
	
	$('.theme-box').animate({ opacity: 0.7}, 0);
	$('.accent-box').animate({ opacity: 0.7}, 0);
	
	$('.bottom-banner').animate({ opacity: 0, marginBottom: "-=25px" }, 0).delay(800).animate({ 
			opacity: 1, 
			marginBottom: "+=25px" 
	}, 'medium');
	
	$('.bottom_gradient').animate({ opacity: 0, marginBottom: "-=25px" }, 0).delay(800).animate({ 
			opacity: 1, 
			marginBottom: "+=25px" 
	}, 'medium')
	
	$.get("_engine/status.php", function(result){
		$("#under").html(result);
		$('#under').animate({ opacity: 0 }, 0).animate({ 
			opacity: 1, 
	}, 'medium');
	});
	
	$.get("_engine/interests.php", function(result){
			$(".interests").slideUp("medium", function(){
				$(".interests").html(result);
				$('.tile .hover').animate({ opacity: 0}, 0).hide();
				$('.tile img').hover(
					function(){
						$(this).siblings('div.hover').show().animate({marginTop: "+=10px"}, 0).animate({ 
							opacity: 1, 
							marginTop: "-=10px",
							display: "block",
						}, 200);
					},
					function(){
						$(this).siblings('div.hover').animate({ opacity: 0}, 0).hide();
					}
				);
				$(".interests").slideDown("medium");
			});
			
		});
	}
});

function accent_Changed() {
var accent = $(this).attr("accent");
$(document.body).animate({ opacity: 0}, 0).attr("accent", accent).animate({ opacity: 1}, 600);
}
function theme_Changed() {
var theme = $(this).attr("theme");
$(document.body).animate({ opacity: 0}, 0).attr("theme", theme).animate({ opacity: 1}, 600);
}

function pivot_goTo(header) { $("div.metro-pivot").data("controller").goToItemByName(header); }
function pivot_goToIndex(index) { $("div.metro-pivot").data("controller").goToItemByIndex(index); }

function loadfile(file){
$('body,html').animate({
			scrollTop: 0
		}, 350);
$("#guides_content").slideUp("medium", function(){
		$.get(file, function(result){
			$("#guides_content").html(result);
			$("#guides_content").slideDown("medium");
		});
	});
}
