	
	$(document).ready(function() {
	
		$('#slider').cycle({ 
			fx:     'fade', 
			timeout:  7000,
			speed:700
		});
		
		$('#accordion_hold:eq(0) > div').hide();
				
		$('#accordion_hold:eq(0) > a').click(function() {
			
			if($(this).next().is(":visible")) {
			
				$(this).next().slideUp();
				$(this).removeClass('controlactive');
				
			} else {
							
				$('#accordion_hold:visible > div').slideUp('fast');
				
				$(this).next().slideToggle('fast');
				
				$('.linkcontrol').removeClass('controlactive');
						
				$(this).addClass('controlactive');

			}
			
		});
		
		setInterval(function() {
		    
		  var carbon = $('#carboncounter').html();
		  carbon++;
		  $('#carboncounter').html(PadDigits(carbon,8));
		  		    
		}, 60000);
		
	});

	function scrollToTop(ID) {

	    $('html, body').animate({
	        scrollTop: $(ID).offset().top
	    }, 2000);

	}
	
	function PadDigits(n, totalDigits) { 
	
        n = n.toString(); 
        var pd = ''; 
        
        if (totalDigits > n.length)  { 
        
            for (i=0; i < (totalDigits-n.length); i++) { 
                pd += '0'; 
            }
             
        } 
        
        return pd + n.toString(); 
        
    } 
