// JavaScript Document
jQuery(function(){

	 jQuery("#explore-nav li a").click(function() {
    
        var curList = jQuery("#explore-nav li.current a").attr("rel");
        var curListHeight = jQuery("#all-list-wrap").height();
        
        jQuery("#all-list-wrap").height(curListHeight);
    
        jQuery("#explore-nav li").removeClass("current");
        jQuery(this).parent().addClass("current");
        
        var listID = jQuery(this).attr("rel");
        
        if (listID != curList) {
            jQuery("#"+curList).fadeOut(300, function() {
    
                jQuery("#"+listID).fadeIn();
                
                var newHeight = jQuery("#"+listID).height();
                
                jQuery("#all-list-wrap").animate({
                    height: newHeight
                });
            
            });
        }        
        
            
        return false;
    });
    
    
            
});

$(function() {		
		
	// initialize scrollable 
	$("div.scrollable").scrollable({
			
		interval: 3000, loop: true, speed: 800,
		

		onBeforeSeek: function() {
			this.getItems().fadeTo(310, 0.2);		
		},
		

		onSeek: function() {
			this.getItems().fadeTo(310, 1);
		}
	});	
	
});

var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline = 0;

$(document).ready(function(){
  headline_count = $("div.headline").size();
  $("div.headline:eq("+current_headline+")").css('top', '5px');
  
  headline_interval = setInterval(headline_rotate,5000); 
  $('#scrollup').hover(function() {
    clearInterval(headline_interval);
  }, function() {
    headline_interval = setInterval(headline_rotate,5000); 
    headline_rotate();
  });
});

function headline_rotate() {
  current_headline = (old_headline + 1) % headline_count; 
  $("div.headline:eq(" + old_headline + ")")
    .animate({top: -205},"slow", function() {
      $(this).css('top', '340px');
    });
  $("div.headline:eq(" + current_headline + ")")
    .animate({top: 5},"slow");  
  old_headline = current_headline;
}

$(document).ready(function(){	
		$("#slider").easySlider({
				auto: true, 
				continuous: true,
				speed: 1000,
				pause: 2000
			});
		});	




$(document).ready(
				function(){
					$('#news').innerfade({
						animationtype: 'slide',
						speed: 750,
						timeout: 2000,
						type: 'random',
						containerheight: '1em'
					});
					
					$('ul#portfolio').innerfade({
						speed: 1000,
						timeout: 5000,
						type: 'sequence',
						containerheight: '220px'
					});
					
					$('.fade').innerfade({
						speed: 1000,
						timeout: 6000,
						type: 'random_start',
						containerheight: '1.5em'
					});
					
					$('.adi').innerfade({
						speed: 'slow',
						timeout: 5000,
						type: 'random',
						containerheight: '150px'
					});

			});



		var theInt = null;
		var $crosslink, $navthumb;
		var curclicked = 0;
		
		theInterval = function(cur){
			clearInterval(theInt);
			
			if( typeof cur != 'undefined' )
				curclicked = cur;
			
			$crosslink.removeClass("active-thumb");
			$navthumb.eq(curclicked).parent().addClass("active-thumb");
				$(".stripNav ul li a").eq(curclicked).trigger('click');
			
			theInt = setInterval(function(){
				$crosslink.removeClass("active-thumb");
				$navthumb.eq(curclicked).parent().addClass("active-thumb");
				$(".stripNav ul li a").eq(curclicked).trigger('click');
				curclicked++;
				if( 6 == curclicked )
					curclicked = 0;
				
			}, 3000);
		};
		
		$(function(){
			
			$("#main-photo-slider").codaSlider();
			
			$navthumb = $(".nav-thumb");
			$crosslink = $(".cross-link");
			
			$navthumb
			.click(function() {
				var $this = $(this);
				theInterval($this.parent().attr('href').slice(1) - 1);
				return false;
			});
			
			theInterval();
		});
		
	$(document).ready(function() {
	$('a.nudge').hover(function() { //mouse in
		$(this).animate({ paddingLeft: '40px' }, 400);
	}, function() { //mouse out
		$(this).animate({ paddingLeft: '20px' }, 400);
	});
});	

$(function()
{
    $('#wysiwyg').wysiwyg();
});