$(document).ready(function(){
	
	// Languages Drop Down Fix for IE	
	$('li.languageSelector').hover (
		function() { $('ul', this).css('display', 'block'); },
		function() { $('ul', this).css('display', 'none'); }
	);					
	
	
	//Get rid of the border for the First a elemnt // or make it white
	$("ul#topNav li a:first").css('border-left','1px solid white');						   
	
	
	$("#browsable").scrollable({circular: true}).navigator().autoscroll({interval: 4000	});	
	

	$("#slidesNav").show();
	$("#slidesNav a:first").addClass("active");
	
	var slideWidth = $("#featured").width();
	var numofSlides = $("#slides .slide").size();
	var totalSlidesWidth = slideWidth * numofSlides;
	
	$("#slides").css({'width' : totalSlidesWidth});
	
	
	rotate = function (){
		
		var triggerID = $active.attr ("rel") - 1;
		var slidePosition = triggerID * slideWidth;
		//alert (triggerID);
		$("#slidesNav a").removeClass('active');
		$active.addClass('active');
		$("#slides").animate({left: -slidePosition}, 500);
		
		
	};
	
	rotateSwitch = function(){		
		play = setInterval(function(){ 
			$active = $('#slidesNav a.active').next();
			if ( $active.length === 0) { //If paging reaches the end...
				$active = $('#slidesNav a:first'); //go back to first
			}
			rotate(); //Trigger the paging and slider function
		}, 7000); //Timer speed in milliseconds (3 seconds)
	};
	
	rotateSwitch(); //Run function on launch
	
	
	$("#slides .slide").hover(function() {
		clearInterval(play); 
	}, function() {
		rotateSwitch(); 
	});	
	
	$("#slidesNav a").click(function() {	
		
		$active = $(this); 
		clearInterval(play);
		rotate();
		rotateSwitch(); 
		return false; 
	
	});
	
	//PNG fix
	//$(document).pngFix();
	//$('img[@src$=.png]').ifixpng(); 
});
