app = {

    sizeContentWindow: function() {
            
        var d = $('#deck');
        var c = $('#content').outerHeight();
        var f = $('#footer').outerHeight();
        var w = $(window).height();
                
        if(w > (c+f)) {
            
            d.height(w - f);
            
        }
            
    },
    
    pagingArrowsImage: function() {
    
        var hiddenNext = $('#previousLink a').attr('href');
        var hiddenPrev = $('#nextLink a').attr('href');
        
        if($('#nextLink').children().length > 0) {
            $('#prev').attr('href', hiddenPrev);
        } else {
            $('#prev').addClass('disabled');
        };
        
        if($('#previousLink').children().length > 0) {
            $('#next').attr('href', hiddenNext);
        } else {
            $('#next').addClass('disabled');
        };
        
    },

    init: function() {
        app.sizeContentWindow();
        app.pagingArrowsImage();
    }

}

$(document).ready(function() {

    app.init();
    
    $(window).resize( function() {
        app.init();
    });
    
    $(window).scroll( function() {
        app.init();
    });

});

$(document).ready(function(){	
	$("#slider").easySlider({
		auto: false,
		continuous: true 
	});
});


jQuery.fn.shorten = function(settings) {
  var config = {
    showChars : 300,
    ellipsesText : ". . .",
    moreText : "more",
    lessText : "less"
  };
 
  if (settings) {
    $.extend(config, settings);
  }
 
  $('.morelink').live('click', function() {
    var $this = $(this);
    if ($this.hasClass('less')) {
      $this.removeClass('less');
      $this.html(config.moreText);
    } else {
      $this.addClass('less');
      $this.html(config.lessText);
    }
    $this.parent().prev().toggle();
    $this.prev().toggle();
    return false;
  });
 
  return this.each(function() {
    var $this = $(this);
 
    var content = $this.html();
    if (content.length > config.showChars) {
      var c = content.substr(0, config.showChars);
      var h = content.substr(config.showChars , content.length - config.showChars);
      var html = c + '<span class="moreellipses">' + config.ellipsesText + '&nbsp;</span><span class="morecontent"><span>' + h + '</span>&nbsp;&nbsp;<a href="javascript://nop/" style="display: block; margin-top: 12px;" class="morelink">' + config.moreText + '</a></span>';
      $this.html(html);
      $(".morecontent span").hide();
    }
  });
}

$(document).ready(function() {

	//When page loads...
	$(".tab_section").hide(); //Hide all content
	$(".tabs a:first").addClass("active").show(); //Activate first tab
	$(".tab_section:first").show(); //Show first tab content

	//On Click Event
	$(".tabs a").click(function() {

		$(".tabs a").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_section").hide(); //Hide all tab content

		var activeTab = $(this).attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});
	
	$(".author .right_column p").shorten();

});

