$(document).ready(function(){
   augmentstyles();
});

function augmentstyles() {
   $('ul#navigation li:last').css({'borderRight': 'none'});
   $('body.interior').find('div#intro ul.subnavigation').height($('body.interior').find('div#intro').height()-50);
/*
   setTimeout( function () {
      $('body').append('<div class="lowerbar">&nbsp;</div>');
      howfardownisthefooter = $('#footer').position().top;
      $('.lowerbar').css({'height': '50px', 'backgroundColor': '#0075bf', 'position': 'absolute', 'width': '100%', 'top': howfardownisthefooter});
   }, 300 );
*/
} //augmentstyles


jQuery(function(){
	jQuery("div.csw").prepend("<p class='loading'>Loading...<br /></p>");
});
var j = 0;
jQuery.fn.codaSlider = function(settings) {
	 settings = jQuery.extend({
     easeFunc: "expoout",
     easeTime: 1000,
     toolTip: false
  }, settings);
	return this.each(function(){
		var container = jQuery(this);
		// Remove the preloader gif...
		container.find("p.loading").remove();
		// Self-explanatory...
		container.removeClass("csw").addClass("stripViewer");
		jQuery(this).parent().parent("#slider").removeClass("prejs");
		// panelCount gives us a count of the panels in the container...
		var panelCount = container.find("li.panel").size();
		cPanel = 0;
      $('.panel:eq('+cPanel+')').css({'display': 'block'});
		// Create appropriate nav
		
			// Create the Left and Right arrows
			jQuery(this).after("<div class='stripNavR' id='stripNavR" + j + "'><a>Next Project</a><\/div>");
			jQuery(this).after("<div class='stripNavL' id='stripNavL" + j + "'><a>Previous</a><\/div>");
			jQuery(this).after("<div class='stripNav' id='stripNav" + j + "'><ul></ul></div>")

			// Create the Tabs
			jQuery(this).find("li.panel").each(function(n) {
               jQuery("div#stripNav" + j + " ul").append("<li class='tab" + (n+1) + "'><a href='#a" + (n+1) + "'><span>" + $('.panel'+(n+1)).find('h2').text() + "<\/span><\/a><\/li>");
         });



      $('.stripNav ul li a:eq('+cPanel+')').addClass('active');

function movemeleft() {
   if (cPanel == 0) {
      $('.stripNav').children('ul').animate({'left': '-800px'}, 500);
      cPanel=7;
      $('.panel:eq(0)').css({'display': 'none'});
      $('.panel:eq('+cPanel+')').css({'display': 'block'});
      $('a.active').removeClass('active').parent('li').siblings().eq(6).children('a').addClass('active');
   } else {
      cPanel-=1;

   if (cPanel == 3) {
      $('.stripNav').children('ul').animate({'left': '0px'}, 500);
   }

      $('.panel:eq('+cPanel+')').next('.panel').css({'display': 'none'});
      $('.panel:eq('+cPanel+')').css({'display': 'block'});
      $('a.active').removeClass('active').parent('li').prev().children('a').addClass('active');
   } //ifcPanel
} //movemeleft

function movemeright() {
   if (cPanel == 7) {
      $('.stripNav').children('ul').animate({'left': '0px'}, 500);
      cPanel=0;
      $('.panel:eq(7)').css({'display': 'none'});
      $('.panel:eq('+cPanel+')').css({'display': 'block'});
      $('a.active').removeClass('active').parent('li').siblings().eq(0).children('a').addClass('active');
   } else {
      cPanel+=1;
   if (cPanel == 4) {
      $('.stripNav').children('ul').animate({'left': '-800px'}, 500);
   }
      $('.panel:eq('+cPanel+')').prev('.panel').css({'display': 'none'});
      $('.panel:eq('+cPanel+')').css({'display': 'block'});
      $('a.active').removeClass('active').parent('li').next().children('a').addClass('active');
   } //ifcPanel
} //movemeright

function movemecustom(that) {
   whichwasclicked = $('.stripNav').children('ul').children('li').index($(that).parent('li'));
   $('.panel:eq('+cPanel+')').css({'display': 'none'});
   cPanel = whichwasclicked;
   $('.panel:eq('+cPanel+')').css({'display': 'block'});
   $('a.active').removeClass('active').parent('li').parent('ul').children('li:eq('+cPanel+')').children('a').addClass('active');
} //movemecustom


			
			// Left nav
			jQuery("div#stripNavL" + j + " a").click(function (){
            movemeleft();
            return false;
			});
			
			// Right nav
			jQuery("div#stripNavR" + j + " a").click(function (){
            movemeright();
            return false;
			});

			// Tab click
			$('div.stripNav').children('ul').children('li').children('a').click(function (){
   			movemecustom(this);
            return false;
			});

		j++;
  });
};
