$(function(){	
			
var showInterval;			
	
	// SLIDESHOW FUNCTION
	//var whatsnewrotate = true;
	SS = {
		currentnum:0,
		showWrapper:'',
		showItems:'',
		showLength:0,
		controls:false,	
	 //setup slideshow - (main container,target tag,add numberlinks,place numberlinks rel to container (before, after, append, prepend))
		setupShow : function(wrpr,itms,plyr,plyrloc) {
			//main container of slideshow
			showWrapper = wrpr;
			//containers within main container that container img info/will be changed
			showItems = showWrapper.children(itms);
			//length of show based on number of showItems above
			showLength = showItems.length;
		  
		  if (plyr) {
			  //write number links for controls if specified
			var nums = '<div id="numberLinks">';
			for(i=0;i<showLength;i++) {
				i==0 ? nums += '<a href="" class="current">' + (i + 1) + '</a> | ' : nums += '<a href="">' + (i + 1) + '</a> | ';
				}
			nums += '<a href="" class="pausebtn">Pause</a></div>';
			//determine where numberLinks goes relative to the showWrapper
			/*var mainCont = $('#features');
			if (plyrloc == "before") {
				mainCont.before(nums)
			} else if (plyrloc == "after") {
				mainCont.after(nums);
			} else if (plyrloc == "append") {
				mainCont.append(nums);
			} else if (plyrloc == "prepend") {
				mainCont.prepend(nums);
			}*/
			$('ul.slideshow_nothumbs').before(nums)
			
			// numbers click function
			$('#numberLinks a').click(function() {
				if ($(this).attr('class') == 'pausebtn') {
					showInterval ?	clearInterval(showInterval) : null;
					$(this).removeClass('pausebtn').addClass('playbtn').text('Play');
				} else if ($(this).attr('class') == 'playbtn') {
					SS.fadeShow();
					showInterval = setInterval("SS.fadeShow()",6000);
					$(this).removeClass('playbtn').addClass('pausebtn').text('Pause');
				} else {
					  
					showInterval ?	clearInterval(showInterval) : null;
					$('#numberLinks a.pausebtn').removeClass('pausebtn').addClass('playbtn').text('Play');
					
					var curnum = (parseInt($(this).siblings('.current').text())) - 1;
					var curli = 'li:eq('+curnum+')';
					var thisnum = (parseInt($(this).text())) - 1;
					var thisli = 'li:eq(' + thisnum + ')';
					 
					 $(this).siblings('.current').removeClass('current').end().addClass('current');
					 $('ul.slideshow_nothumbs').find(curli).removeClass('current').fadeOut('slow');
					 $('ul.slideshow_nothumbs').find(thisli).addClass('current').fadeIn('slow');
				
				}
			
				return false;
			});		
			
			
			/*--- FEATURES TOOLTIPS ---*/
			$('#features').append('<div id="tooltip"><p></p><div class="tooltiparrow"></div></div>');
					
			$('#numberLinks a').hover(function(){
											
				if($(this).text() == 'Play' || $(this).text() == 'Pause') {
					return;
				} else {
				
					thisIndex = (parseInt($(this).text()))-1;
					//get tooltip text from h3 from li number parsed from number of rollover
					$('#features #tooltip p').text($('#features ul li:eq(' + thisIndex + ') h3:eq(0)').text())
					
					var addwidth=0;
					var tipwidth = $('#features #tooltip').width();
					var navoffset = $(this).parent().position({ border: true, padding: true });
					var navnumoffset = $(this).position({ border: true, padding: true });
				
					//find center point to place pop up
					var targetX = navnumoffset.left - (tipwidth/2) + 480;
					//var targetX = $(this).outerWidth()+7;
					var targetY = navoffset.top - $('#features #tooltip').height();
					//tell the dd to display and position
					
					$('#features #tooltip').css('left',targetX).css('top',targetY).show();
					$('#features #tooltip .tooltiparrow').css('width',tipwidth);
				
				}
				
			},function(){
				if($(this).text() == 'Play' || $(this).text() == 'Pause') {
					return;
				} else {
					$('#features #tooltip').hide();
				}
			});
			
			// video thumbnail click function
			$('#features a.myPlayer').click(function() {
				showInterval ?	clearInterval(showInterval) : null;	
				$('#numberLinks a.pausebtn').removeClass('pausebtn').addClass('playbtn').text('Play');
				return true;			   
			 });
			
			//set controls variable to true so fadeShow will change number links
			controls = true;
			}
		},
		fadeShow : function() {
			//get the current image
                var currentItem = $('ul.slideshow_nothumbs li.current');
				
				//if current item is the last li, go back to the first
				if (showItems.eq(showLength-1).attr('class')== "current") {
					
					currentItem.fadeOut(800).removeClass('current');
					showItems.eq(0).fadeIn(1200).addClass('current');
					if (controls) {
						$('#numberLinks').find('a.current').removeClass('current');
						$('#numberLinks').find('a:eq(0)').addClass('current');
					}
				} else {
						/*currentItem.find('h3','p','img').fadeOut(800);
					currentItem.find('h3').text(currentItem.next().find('h3').text());
					currentItem.find('p').text(currentItem.next().find('p').text());
					currentItem.find('img').attr('src',(currentItem.next().find('img').attr('src')));
					currentItem.find('h3','p','img').fadeIn(800);
					currentItem.removeClass('current').next().addClass('current');*/
				currentItem.fadeOut(800).removeClass('current');
					currentItem.next().fadeIn(1200).addClass('current');
					if (controls) {
						thisn = $('#numberLinks').find('a.current');
						thisn.next().addClass('current');
						thisn.removeClass('current'); 
					}
						
				}
		}
	};
		
		
	
	//setup slideshow - (main container,target tag,add numberlinks,place numberlinks rel to container (before, after, append, prepend))	
	SS.setupShow($('ul.slideshow_nothumbs'),'li',true,'append');
	//SETTING SHOWINTERVAL VARIABLE STARTS SLIDESHOW ROTATION	
	var showInterval = setInterval("SS.fadeShow()",6000);
	

});		
	
		
		
		
//uses jquery ajaxify plugin to lazy load main image rotation images and code from index_rotation.cfm
//$(document).ready(function() { //checks if document is loaded before loading images and code
//  $(this).ajaxify({
//		link:'index_rotation.cfm',
//		target: 'ul.slideshow_nothumbs',
//		animateOut:{opacity:'0'},
//		animateOutSpeed:300,
//		animateIn:{opacity:'1'},
//		animateInSpeed:300,
//		loading_txt: "Loading...",
//		loading_img: "/images/spacer.gif",
//		event:false,
//		onSuccess:function(options,data){  //calls main image rotation slideshow once images successfully loaded
//			SS.setupShow($('ul.slideshow_nothumbs'),'li',true,'append'); 
//			showInterval = setInterval("SS.fadeShow()",6000);
//		}
//	});	
//});			   
//	
//		
//		
//		
//		
//		
//	
//				
// 	});	  
