var $j = jQuery.noConflict();



$j('.slider .arrow.right').click(function(e) {
	//console.log('going right');
	//move all slides 90px to the right
	
	var slides = $j('.slider a.slide');
	
	//get the width of the slide in pixels
	var slideWidth = $j('.slider').css('width');
	slideWidth = parseInt(slideWidth.substring(0, slideWidth.length - 2));
	
	//iterate through all slides and move them to right
	slides.each(function(index, value) {
	
		
		$j(value).animate({"left": "+=90px"}, "slow", function() {
		
			//after animation check if slide is outside of view
			var left = $j(this).css('left');
			left = parseInt(left.substring(0, left.length - 2));	
			
			if (left > slideWidth)
			{
				//remove slide from DOM
				var tmp = $j(this).remove();
				
				//find location of first slide in list
				var first = $j('.slider .slides a.slide:first');
				
				var firstLeft = first.css('left');
				firstLeft = parseInt(firstLeft.substring(0, firstLeft.length - 2));
				
				//add our removed slide 90px to the left
				$j('.slider .slides').prepend(tmp);
				tmp.css('left', firstLeft - 90 + 'px');			
			
			}		
		});	
	});
});


//move all slides to the  left	
$j('.slider .arrow.left').click(function(e) {

	
	var slides = $j('.slider a.slide');	
	
	//iterate through all slides and move them to right
	slides.each(function(index, value) {
	
		
		$j(value).animate({"left": "-=90px"}, "slow", function() {
		
			//after animation check if slide is outside of view
			var left = $j(this).css('left');
			left = parseInt(left.substring(0, left.length - 2));	
			
			var id = $j(this).attr('id');
			
			//console.log('#' + id + ' left = ' + left);
			
			
			if (left + 90 < 0)
			{
				//console.log('it is hidden');
				
				//remove slide from DOM
				var tmp = $j(this).remove();
				
				//find location of first slide in list
				var last = $j('.slider .slides a.slide:last');
				
				var lastLeft = last.css('left');
				lastLeft = parseInt(lastLeft.substring(0, lastLeft.length - 2));
				
				//add our removed slide 90px to the right
				$j('.slider .slides').append(tmp);
				tmp.css('left', lastLeft + 90 + 'px');					
			}		
			
		});	
	});
});





/* top nav hover links */ 
$j(document).ready(function() {
	

	var scrollX = 0, scrollY = 0;
	var scrollingLabelsTimer;
	
	//go through each slide and set the initial positions
	$j('.slider a.slide').each(function(index, value) {
	
		$j(value).css({
			'position': 'absolute',
			'top': scrollY + 'px',
			'left': scrollX +'px',
			'display': 'block'
		});
		scrollX += 90;	
	});
	
});	






$j(document).ready(function(e) {




});
