/*
var panes = new Array();

function setupPanes(containerId, defaultTabId) {
  // go through the DOM, find each tab-container
  // set up the panes array with named panes
  // find the max height, set tab-panes to that height
  panes[containerId] = new Array();
  var maxHeight = 0; var maxWidth = 0;
  var container = document.getElementById(containerId);
  var paneContainer = container.getElementsByTagName("div")[0];
  var paneList = paneContainer.childNodes;
  for (var i=0; i < paneList.length; i++ ) {
    var pane = paneList[i];
    if (pane.nodeType != 1) continue;
    if (pane.offsetHeight > maxHeight) maxHeight = pane.offsetHeight;
    if (pane.offsetWidth  > maxWidth ) maxWidth  = pane.offsetWidth;
    panes[containerId][pane.id] = pane;
    pane.style.display = "none";
  }
    paneContainer.style.height = maxHeight + "px";
    paneContainer.style.width  = maxWidth + "px";
    document.getElementById(defaultTabId).onclick();
}

function showPane(paneId, activeTab) {
  // make tab active class
  // hide other panes (siblings)
  // make pane visible
    for (var con in panes) {
    activeTab.blur();
    activeTab.className = "tab-active";
    if (panes[con][paneId] != null) { // tab and pane are members of this container
      var pane = document.getElementById(paneId);
      pane.style.display = "block";
      var container = document.getElementById(con);
      var tabs = container.getElementsByTagName("ul")[0];
      var tabList = tabs.getElementsByTagName("a")
      for (var i=0; i<tabList.length; i++ ) {
        var tab = tabList[i];
        if (tab != activeTab) tab.className = "tab-disabled";
      }
      for (var i in panes[con]) {
        var pane = panes[con][i];
        if (pane == undefined) continue;
        if (pane.id == paneId) continue;
        pane.style.display = "none"
      }
    }
  }
  // return false;    
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}*/
	
// MEMBERS DROP DOWN //

function callingJQ() {
	  startJQTimer();
	  $('#content').fadeTo( 0, 1);
	}

currentSlide = 1;
timeToDrift = 10000;
prevSlide = currentSlide;

var timerCount = 0;
function startJQTimer() {
  timerCount = window.setInterval('drift()', timeToDrift);
}

$(function() {
  $('.a1').click(function() {
	
	$('.a1').removeClass('s' + prevSlide + 'greyBG');
	
	currentSlide = $(this).attr('name');
	
	prevSlide = currentSlide;
	
	//Clear then Set timer again
	window.clearInterval(timerCount);
	startJQTimer();
	
	$(this).addClass('s' + currentSlide + 'greyBG');
	
	$('#description').find('.desCopy').hide();
	$('#IMGchange').find('.imgPlace').hide();
	$('#captionCopy2').find('span').hide();
	
    $(this).parent().find('.desCopy').clone().show().appendTo('#description');
	$(this).parent().find('.imgCaption').clone().fadeIn().appendTo('#captionCopy2');
    $(this).parent().find('.imgPlace').clone().fadeIn().appendTo('#IMGchange');
	
    return false;
  });
});

$(function() {
  $('.sNext').click(function() {
	
	
	$('#description').find('.desCopy').hide();
	$('#IMGchange').find('.imgPlace').hide();
	$('#captionCopy2').find('span').hide();
	
	//Clear then Set timer again
	window.clearInterval(timerCount);
	startJQTimer();
	
	if(currentSlide > (totalSlideCount - 1)) {
		
		$('.a1').removeClass('s' + prevSlide + 'greyBG');
		$('.s1').addClass('s1greyBG');
		
		$(this).parent().addClass('s' + currentSlide + 'greyBG');
		
		$(this).parent().find('.desCopy').clone().show().appendTo('#description');
		$(this).parent().find('.imgCaption').clone().fadeIn().appendTo('#captionCopy2');
   	 	$(this).parent().find('.imgPlace').clone().fadeIn().appendTo('#IMGchange');
		
		currentSlide = 1;
		prevSlide = currentSlide;
	}
	else {
		currentSlide++
		
		var goUpSlide = ('.s' + currentSlide );
		
		$('.a1').removeClass('s' + prevSlide + 'greyBG');
		
		prevSlide = currentSlide;
		
		$(goUpSlide).addClass('s' + currentSlide + 'greyBG');
		
		$(goUpSlide).parent().find('.desCopy').clone().show().appendTo('#description')
		$(goUpSlide).parent().find('.imgCaption').clone().fadeIn().appendTo('#captionCopy2');
   	 	$(goUpSlide).parent().find('.imgPlace').clone().fadeIn().appendTo('#IMGchange');
		
		return;
	}
	
  });
});

$(function() {
  $('.sPrev').click(function() {
	
	$('#description').find('.desCopy').hide();
	$('#IMGchange').find('.imgPlace').hide();
	$('#captionCopy2').find('span').hide();
	
	//Clear then Set timer again
	window.clearInterval(timerCount);
	startJQTimer();
	
	currentSlide--
	
	if(currentSlide < 1) {
		
		$('.s1').removeClass('s' + prevSlide + 'greyBG');
		$('.s' + totalSlideCount).addClass('s' + totalSlideCount + 'greyBG');
		
		currentSlide = totalSlideCount;
		prevSlide = currentSlide;
		
		var toTop = ('.s' + currentSlide );
		
		$(toTop).parent().find('.desCopy').clone().show().appendTo('#description')
		$(toTop).parent().find('.imgCaption').clone().fadeIn().appendTo('#captionCopy2');
   	 	$(toTop).parent().find('.imgPlace').clone().fadeIn().appendTo('#IMGchange');
		
	}
	else {
		
		var backUpSlide = ('.s' + currentSlide );
		
		$('.a1').removeClass('s' + prevSlide + 'greyBG');
		
		prevSlide = currentSlide;
		
		$(backUpSlide).addClass('s' + currentSlide + 'greyBG');
		
		$(backUpSlide).parent().find('.desCopy').clone().show().appendTo('#description')
		$(backUpSlide).parent().find('.imgCaption').clone().fadeIn().appendTo('#captionCopy2');
   	 	$(backUpSlide).parent().find('.imgPlace').clone().fadeIn().appendTo('#IMGchange');

		return;
	}
	
  });
});
  
  function drift() { 
		
		$('#description').find('.desCopy').hide();
		$('#IMGchange').find('.imgPlace').hide();
		$('#captionCopy2').find('span').hide();
		
		if(currentSlide > (totalSlideCount - 1)) {
		
			$('.a1').removeClass('s' + prevSlide + 'greyBG');
			$('.s1').addClass('s1greyBG');
			
			$(this).parent().addClass('s' + currentSlide + 'greyBG');
			
			$('.s1').parent().find('.desCopy').clone().show().appendTo('#description');
			$('.s1').parent().find('.imgCaption').clone().fadeIn().appendTo('#captionCopy2');
			$('.s1').parent().find('.imgPlace').clone().fadeIn().appendTo('#IMGchange');
			
			currentSlide = 1;
			prevSlide = currentSlide;
		}
		else {
			currentSlide++
			
			var moveOn = ('.s' + currentSlide );
		
			$('.a1').removeClass('s' + prevSlide + 'greyBG');
		
			prevSlide = currentSlide;
		
			$(moveOn).addClass('s' + currentSlide + 'greyBG');

			$(moveOn).parent().find('.desCopy').clone().show().appendTo('#description')
			$(moveOn).parent().find('.imgCaption').clone().fadeIn().appendTo('#captionCopy2');
			$(moveOn).parent().find('.imgPlace').clone().fadeIn().appendTo('#IMGchange');
			
			return false;
		}
		
	}
	

$(document).ready(function() {
	// $('#myselectbox').selectbox({debug: true});
	$('#a1_down').bubbletip($('#tip1_down'), {
		deltaDirection: 'down',
		deltaPosition: 0,
		offsetTop: 4
	});
	
	totalSlideCount = $('#caseSlide2 ul li .a1').size();

	$('.s1').addClass('s1greyBG');
	
});	

