$(document).ready(function() {

    $(".box_one").each(function(){
        	$(".box_one").eq(0).removeClass("small").end().eq(1).removeClass("small").end().eq(2).removeClass("small").end();
        	$(".box_one:gt(4)").hide();
        	$(".box_postit").show();        	
	});


	$('#box_window_toggle').click(function() {
	  	    $(this).slideUp();
   	  	    $('.vertical_navigation').children().children('li').removeClass('active').animate({ marginRight: -30,},0);  	
        	$(".box_one").addClass('small');
        	$(".box_one").eq(0).removeClass("small").end().eq(1).removeClass("small").end().eq(2).removeClass("small").end();
        	$(".box_one").show();
        	$(".box_postit").show();
        	$(".box_one:gt(4)").hide();
            $("#box_window_container").slideDown();        	
	  	    $('#box_groups_container').delay(300).animate({ height: 565 }, {duration: 300,easing: 'easeInOutExpo' }); 
	});

	
	$('#box_window_toggle').hover(
  	function () {
	  	    $(this).children('.default').fadeOut();
  	},
  	function () {
	  	    $(this).children('.default').fadeIn();
    }
	);  
	


    var updateFrequency = 8;
 	var settimmer = 20;
        $(function(){
                window.setInterval(function() {
                    var navCounter = $("#nav_timer").html();
                    var navPosition = $("#nav_position").html();
                    if(navPosition == 6){
                    var navPosition = 0;
                    }
                    var updateTime = eval(navCounter)- eval(1);
                    var updatePosition = eval(navPosition)+ eval(1);
                    $("#nav_timer").html(updateTime);

                    if(updateTime == 0){
                    $('.window_n' + updatePosition).click();
                    $("#nav_position").html(updatePosition);
                    $("#nav_timer").html(updateFrequency);
                    }
                }, 1000);
    });


	$('.box_window').mouseover(function() {
  	  $("#nav_timer").html('5000');
	}
	);  
	
	
	$('.box_window').mouseleave(function() {
		if ($('#play_pause').hasClass('playing')) { 
		    $("#nav_timer").html(updateFrequency);	    
		}
	}
	);       


$('#play_pause').click(function() {
	if (!$(this).hasClass('playing')) { 
  	    $(this).addClass('playing');	
        $("#play_pause").css({backgroundPosition: '-85px 0px'});
        $("#nav_timer").html(updateFrequency);	    
	}
    else {
  	    $(this).removeClass('playing'); 	
  	    $("#play_pause").css({backgroundPosition: '0px 0px'});
        $("#nav_timer").html('5000');	    
    }
});

	$('#play_pause').hover(
  	function () {
		if (!$(this).hasClass('playing')) { 
	        $("#play_pause").css({backgroundPosition: '0px 0px'});
		}
		else {
	        $("#play_pause").css({backgroundPosition: '-85px 0px'});
	    }
  	},
  	function () {
		if (!$(this).hasClass('playing')) { 
	        $("#play_pause").css({backgroundPosition: '-43px 0px'});
		}
		else {
	        $("#play_pause").css({backgroundPosition: '-128px 0px'});
	    }
	}
	); 




	$('.vertical_navigation').children().children('li').hover(
	  	function () {
		  	    $(this).animate({ marginRight: -10,},300);
	  	},
	  	function () {
					if ($(this).hasClass('active')) {
		  			    $(this).animate({ marginRight: -10,},300);
			        } else {
		  			    $(this).animate({ marginRight: -30,},300);
			 
			        }    
		}
	);  



	$('.vertical_navigation').children().children('li').click(
  	function () {
	if (!$(this).hasClass('active')) { 
			$('#box_window_toggle').slideDown();
	  	    $('.vertical_navigation').children().children('li').removeClass('active').animate({ marginRight: -30,},0); 	
		  	var focus_group = $(this).children('a').html();
	  	    $(this).addClass('active').animate({ marginRight: -10,},0);  	
            $("#nav_group").html(focus_group);
        	$(".box_postit").hide();
	  	    $('#box_groups_container').animate({ height: 800 }, {duration: 300,easing: 'easeInOutExpo' });            
            $("#box_window_container").delay(300).slideUp();

            $(".box_one").each(function(){
				if (!$(this).hasClass(focus_group)) {
					$(this).slideUp(0);
		        } else {
		        	$(".box_one." + focus_group).eq(0).removeClass("small").end().eq(1).removeClass("small").end().eq(2).removeClass("small").end();
					$(this).fadeIn();
		        	$(".box_one." + focus_group + ":gt(8)").hide();
		        }
    		});
    			    
	}
    else {
   			$('#box_window_toggle').slideUp();
   	  	    $(this).removeClass('active').animate({ marginRight: -30,},0);  	
        	$(".box_one").addClass('small');
        	$(".box_one").eq(0).removeClass("small").end().eq(1).removeClass("small").end().eq(2).removeClass("small").end();
        	$(".box_one").show();
        	$(".box_postit").show();
        	$(".box_one:gt(4)").hide();
            $("#box_window_container").slideDown();        	
	  	    $('#box_groups_container').delay(200).animate({ height: 565 }, {duration: 300,easing: 'easeInOutExpo' });            
    }
});






	
// This ends .ready function
});
