// JavaScript Document
function slideSwitch() {
	var active=$('#slideshow ul li:visible');	
	var nav = $('#larrow ul li');
	
	var active_nav = $('#larrow ul').find('li').filter('[class=active]');
	
	var next = active.next();
	var next_nav = active_nav.next();
	
	if(next.length == 0){
		next = $('#slideshow ul li:first');		
	}
	if(next_nav.length == 0){
		next_nav = $('#larrow ul li:first');		
	}
	active.animate({opacity: 'hide'}, 0);
	active_nav.removeClass("active");
	next.animate({opacity: 'show'}, 2500); 
	next_nav.addClass("active");
}
$(function() {
	$('#slideshow ul li').hide();
	$('#slideshow ul li:first').show();
	$('#larrow ul li:first').addClass("active");
	setInterval( "slideSwitch()", 5000 ); 
	//slide Course
	var divimage = $('div[class=oneimage]');
	divimage.hide();
	divimage.each(function(){
		var thisid = this.id;
		//alert(thisid);
		var thisid_ret = thisid.split("_");
		if(parseInt(thisid_ret[1])<5){
			$(this).show();
		}
		//alert(parseInt(thisid_ret[1]));
	});	
	$('.next').click(function(){
		var thefirst = $('div[class=oneimage]:visible:first'); 
		var thefirstid = thefirst.attr("id");
		var thefirstid_ret = thefirstid.split("_");
		var nextshow = parseInt(thefirstid_ret[1])+4;
		if(nextshow>numbercourse)
			return false;
		else{
			thefirst.hide(); 
			$('div[id=oneimage_'+nextshow+']').show();
		}
	});		
	$('.prev').click(function(){
		var thefirst = $('div[class=oneimage]:visible:last'); 
		var thefirstid = thefirst.attr("id");
		var thefirstid_ret = thefirstid.split("_");
		var nextshow = parseInt(thefirstid_ret[1])-4;
		//alert(nextshow);
		if(nextshow<1)
			return false;
		else{
			thefirst.hide(); 
			$('div[id=oneimage_'+nextshow+']').show(); 
		}
	});		
});      