$(document).ready(function(){
    //Projects page
    $('#video-thumbs').bxSlider({
        mode: 'vertical'
    });
    if($('#accolades-list').length > 0){
		$('#accolades-list').bxSlider({
			mode: 'vertical'
		});
	}
    $('#video-thumbs .box').hover(
        function(){
            $(this).find('.box-title').css({color:'#f47421'});
            $(this).find('.box-desc').css({color:'#f47421'});
        },
        function(){
            $(this).find('.box-title').css({color:'#FFF'});
            $(this).find('.box-desc').css({color:'#FFF'});
        }
    );
    
    $('.bx-next, #contact-more, #profile-more').mousedown(function() {
    	$(this).css({'background-position':'-113px 0'});
		
	});
    $('.bx-next, #contact-more, #profile-more').mouseup(function() {
    	$btn = $(this);
    	setTimeout(function(){$($btn).css({'background-position':'0 0'});},200);
		
	});
		
	$('.bx-next, #contact-more, #profile-more').hover(
		function(){
			$(this).css({'background-position':'-113px 0'});
		},
		function(){
			$(this).css({'background-position':'0 0'});
		}
	);
	
	$('#still-popup-next, #still-popup-back').mousedown(function() {
    	$(this).css({'background-position':'-70px 0'});
		
	});
    $('#still-popup-next, #still-popup-back').mouseup(function() {
    	$btn = $(this);
    	setTimeout(function(){$($btn).css({'background-position':'0 0'});},200);
		
	});
	
	$('#still-popup-next, #still-popup-back').hover(
		function(){
			$(this).css({'background-position':'-70px 0'});
		},
		function(){
			$(this).css({'background-position':'0 0'});
		}
	);
	
	/*$('#accolades-prev, #accolades-pause, #accolades-play, #accolades-next').mousedown(function(){
		if($(this).attr('id') == 'accolades-prev'){
			$(this).css({'background-position':'0 -32px'});
		}
		else if($(this).attr('id') == 'accolades-pause'){	
			$(this).css({'background-position':'-37px -32px'});
		}
		else if($(this).attr('id') == 'accolades-play'){
			$(this).css({'background-position':'-73px -32px'});
		}
		else if($(this).attr('id') == 'accolades-next'){
			$(this).css({'background-position':'-109px -32px'});
		}
	});
	
	$('#accolades-prev, #accolades-pause, #accolades-play, #accolades-next').mouseup(function(){
		$acc_btn = $(this);
		if($(this).attr('id') == 'accolades-prev'){
			setTimeout(function(){$($acc_btn).css({'background-position':'0 0'});},200);
		}
		else if($(this).attr('id') == 'accolades-pause'){	
			setTimeout(function(){$($acc_btn).css({'background-position':'-37px 0'});},200);
		}
		else if($(this).attr('id') == 'accolades-play'){
			setTimeout(function(){$($acc_btn).css({'background-position':'-73px 0'});},200);
		}
		else if($(this).attr('id') == 'accolades-next'){
			setTimeout(function(){$($acc_btn).css({'background-position':'-109px 0'});},200);
		}
	});
	
	$('#accolades-prev, #accolades-pause, #accolades-play, #accolades-next').hover(
		function(){
			if($(this).attr('id') == 'accolades-prev'){
			$(this).css({'background-position':'0 -32px'});
			}
			else if($(this).attr('id') == 'accolades-pause'){	
				$(this).css({'background-position':'-37px -32px'});
			}
			else if($(this).attr('id') == 'accolades-play'){
				$(this).css({'background-position':'-73px -32px'});
			}
			else if($(this).attr('id') == 'accolades-next'){
				$(this).css({'background-position':'-109px -32px'});
			}
		},
		function(){
			if($(this).attr('id') == 'accolades-prev'){
			$(this).css({'background-position':'0 -32px'});
			}
			else if($(this).attr('id') == 'accolades-pause'){	
				$(this).css({'background-position':'-37px 0'});
			}
			else if($(this).attr('id') == 'accolades-play'){
				$(this).css({'background-position':'-73px 0'});
			}
			else if($(this).attr('id') == 'accolades-next'){
				$(this).css({'background-position':'-109px 0'});
			}
		}
	);
	*/
    
    //Profile page
    var profileCurrentStep = 0;
    
    $("#profile-more").click(function() {
       if (profileCurrentStep < 2) {
           profileCurrentStep++;
           $("#profile-scroller").stop(true, false).animate({ marginTop: (profileCurrentStep == 1 ? '-375px' : '-750px') }, "slow");
       }
       else {
           profileCurrentStep = 0;
           $("#profile-scroller").stop(true, false).animate({ marginTop: '0px' }, "slow");
       }
    });
    
    //Accolades page
    $('#accolades-slideshow').cycle({
        fx: 'fade',
        prev:   '#accolades-prev', 
        next:   '#accolades-next',
        pause: true
    });
    
    $("#accolades-play").click(function() {
        $("#accolades-slideshow").cycle("resume");
    });
        
    $("#accolades-pause").click(function() {
        $("#accolades-slideshow").cycle("pause");
    });
    
    //Friends page
    
    //Contact page
    var contactCurrentStep = 0;
    
    $("#contact-more").click(function() {
       if (contactCurrentStep < 1) {
           contactCurrentStep++;
           $("#contact-scroller").stop(true, false).animate({ marginTop: (contactCurrentStep == 1 ? '-380px' : '-760px') }, "slow");
       }
       else {
           contactCurrentStep = 0;
           $("#contact-scroller").stop(true, false).animate({ marginTop: '0px' }, "slow");
       }
    });
    
});
