/*
Title:      Main JavaScript	

*/
var timeshow = 10000;

NeHost = { };

// ------[ Feature, for the featured items on the home ]------------------------------------------------- //	
NeHost.Feature = {
	currentPage: 0,
	
	Init : function() {
		$('#feature .items li:gt(0)').hide();
		
		// Build the paging
		toInject = "";
		$('#feature .items li').each(function(i){
			toInject += "<li><a href='#' onclick='NeHost.Feature.GoToPage("+i+");return false;'>"+(i+1)+"</a></li>";
		});
		
		$('#feature .paging').html(toInject);
		$('#feature .paging li:first').addClass('selected');
		
		$('#feature').hover(function(e){
			clearTimeout(slideshow);
			},
			function(){
				NeHost.Feature.SetTimer();
		});
		
		NeHost.Feature.SetTimer();
	},
	
	GoToPage : function(pageToShow,callback){
		clearTimeout(slideshow);
		
		// Fade out the current page
		$('#feature .items li:eq('+NeHost.Feature.currentPage+')').fadeTo('normal',0,function(){
			$(this).hide();
			
			$('#feature .items li:eq('+pageToShow+')').css('opacity',0).show().fadeTo('normal',1);
		});
		
		// Select the correct paging item
		$('#feature .paging li.selected').removeClass('selected');
		$('#feature .paging li:eq('+pageToShow+')').addClass('selected');
		
		NeHost.Feature.currentPage = pageToShow;
		
		if(callback) callback();
	},
	
	SetTimer : function(){
		slideshow = setTimeout(function(){
			nextPage = NeHost.Feature.currentPage+1;
			if(nextPage == $('#feature .paging li').size()){
				nextPage = 0;
			}
			
			NeHost.Feature.GoToPage(nextPage,function(){ NeHost.Feature.SetTimer(); });
		},timeshow);
	}
};


