
	$(function(){	
			   
			   
			   
	
	// 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)
			
			$('#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;
			});		
			
			//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');
	//START What's New slideshow rotation	
	var showInterval = setInterval("SS.fadeShow()",6000);
	
	

		
				/*--- 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 addarrow = '<div id="tooltipArrow"><p>';
			//addarrow+= $('#whatsNew ul li:eq(0) a:eq(0)').text();
			//addarrow+= '</p></div>';
			//if tooltipArrow div doesn't exist, add it, otherwise do nothing
		//	if ($(this).next().find(':first').is('div')) {null;} else {$(this).next().prepend(addarrow);}
			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 });
			
			//var addheight=0;
			//for each a after the current, add widths together
			/*for(i=(thisIndex+1);i<$(this).parent().find('a').length;i++) {
				addwidth += $(this).parent().find('a:eq('+i+')').outerWidth();
				//addheight += $(this).parent().find('a:eq('+i+')').outerHeight();
				}*/
				
			//find center point to place pop up
			var targetX = navnumoffset.left - (tipwidth/2) + 12;//((($(this).outerWidth()/2)+addwidth) - (tipwidth/2));
			//var targetX = $(this).outerWidth()+7;
			var targetY = navoffset.top - $('#features #tooltip').height();//0 - $(this).outerHeight() + 255;
			//tell the dd to display and position
			
			
			$('#features #tooltip').css('left',targetX).css('top',targetY).show();
			$('#features #tooltip .tooltiparrow').css('width',tipwidth);
			//$(this).css('background','url(base_images/tip.gif) no-repeat center top');
		}
		//$(this).next().css('display','block').css('left',targetX).css('top', targetY);
	},function(){
		if($(this).text() == 'Play' || $(this).text() == 'Pause') {
			return;
		} else {
			$('#features #tooltip').hide();
		}
	});
		
				
 	});	  