function animateBackground(backgroundPos, half_circlePos){
	$("#headerlogo").stop().animate({
					backgroundPosition: backgroundPos }, {
                    duration: 1500,
                    easing: 'easeOutCubic'
                })
                				
}

function changeImageDisplayBackgroundAnimate(imgSrc, display){
	$("#image_display").css({'background-image' : "url(\""+imgSrc+"\")"});
	$("#image_display").css({'backgroundPosition' : "610px 0px"});
	$("#image_display").stop(true, false).animate({
					backgroundPosition: "0px 0px" }, {
                    duration: 400,
                    easing: 'easeOutCubic'
                })
	$("#image_display").css({'display' : display});
}

function changeImageDisplayBackgroundAnimateOut(imgSrc, display){
	$("#image_display").stop(true, false).animate({backgroundPosition: "610px 0px" }, {duration: 400, easing: 'easeOutCubic'}, displayNone())
function displayNone() { $("#image_display").css({'display' : "none"});}
}


function nextSlide(){
	var next = $("div#stripTransmitter0 a.current").parent().next();
	if(next.length){
		next.find('a').click();
	}else{
		$("div#stripTransmitter0 a.current").parents('ul').find('li:first-child a').click();
	}
}

var sliderInterval;

function resetInterval(){
	deactivateInterval();
	activateInterval();
}

function deactivateInterval(){
	if(sliderInterval)clearInterval(sliderInterval);
}

function activateInterval(){
	sliderInterval = setInterval(nextSlide, 5000);
}

$(document).ready(function(){


// Get start positions from current
var startSettings = $(".header_nav.current").attr('rel').split(',');  
var BackgroundStartPosition = startSettings[0];  
var	half_circleStartPosition = startSettings[1];  

//Place background and half_circle on right position
//	$("#half_circle").css({'margin-left' : +half_circleStartPosition+"px",'display' : "block"});
//	$("#headerBackground").css({'background-position' : BackgroundStartPosition});

//Listen for hovers and start moving stuff
    $(".home_href").hover(
		function(event){
		var image = $(this).attr('rel');
		changeImageDisplayBackgroundAnimate(image, "block")},
		function(event){
		var image = $(this).attr('rel');
		changeImageDisplayBackgroundAnimateOut(image, "block")}
	);
//Listen for hovers and start moving stuff  
    $(".header_nav").hover(
		function(event){
			var settings = $(this).attr('rel').split(',');  
			var backgroundPos = settings[0];  
			var half_circlePos = settings[1];  
		animateBackground(backgroundPos, half_circlePos)},
		function(event){animateBackground(BackgroundStartPosition, half_circleStartPosition)}
	);
//Listen for hovers and start fading background

	$(".portfolio_href").children(".image_holder").stop(false, true).fadeOut(500); // Because only span allowed, this set's them to no display

    $(".portfolio_href").hover(
		function () {
		$(this).children(".image_holder").stop(false, true).fadeIn(500);
		}, 
		function () {
		$(this).children(".image_holder").stop(false, true).fadeOut(500);
		}
	);	

// Appear menu
	function showArchiveMenu() {
			var numberOfItems = $("#home_player_menu ul li").size();
			var menuTotalSize = numberOfItems * 36;
			var menuTweenDuration = numberOfItems * 100;
			$("#home_player_menu").animate({height:menuTotalSize+'px'},{queue:false, duration:menuTweenDuration, easing: 'easeOutCirc'});
		}


    $("#hideArchiveLink").click(
		function () {
				var numberOfItems = $("#home_player_menu ul li").size();
				var menuTweenDuration = numberOfItems * 75;
				$("#home_player_menu").animate({height:'252px'},{queue:false, duration:menuTweenDuration, easing: 'easeOutCirc', complete:showTelevision});
			}
	);	


// FOCUS ON FIELDS

			$('input[type="text"]').addClass("idleField");
       		$('input[type="text"]').focus(function() {
       			$(this).removeClass("idleField").addClass("focusField");
    		});
    		$('input[type="text"]').blur(function() {
    			$(this).removeClass("focusField").addClass("idleField");
    		});
    		
    					$('textarea').addClass("idleField");
       		$('textarea').focus(function() {
       			$(this).removeClass("idleField").addClass("focusField");
    		});
    		$('textarea').blur(function() {
    			$(this).removeClass("focusField").addClass("idleField");
    		});

// Start lightbox

	$("a.iframeLightbox").fancybox({
		'zoomOpacity'			: true,
		'overlayShow'			: false,
		'zoomSpeedIn'			: 500,
		'zoomSpeedOut'			: 500,
		'frameWidth'			: 550,
		'frameHeight'			: 650
	});


// Label over input fields

$('label.over-apply').labelOver('over-apply')

//CLOSE THE DOM
});


