$(function(){

	activeLink();
	cycle();

});

function activeLink()
{
	urlStr = window.location;
	urlStr = urlStr.toString();
	urlPart = urlStr.split("/");

	linkOnPath = '';
	for ( i in urlPart)
	{
		if (i > 2 && urlPart[i] != '')
		{
			linkOnPath += '/'+urlPart[i];
			$("a[href="+linkOnPath+"]").addClass('active');
			$("a[href="+linkOnPath+"]").addClass('active').parent().addClass('active');
		}
		if (i == 3 && urlPart[i] == '')
		{
			linkOnPath += '/'+urlPart[i];
			$("a[href="+linkOnPath+"]").addClass('active');
			$("a[href="+linkOnPath+"]").addClass('active').parent().addClass('active');
		}
	}

}

function cycle(){
	$('#news-wide ul li:first').addClass('show').show(0);
	setInterval('rotate()',6000);
}


function rotate() {
	// Current or first one
	var current = ($('#news-wide ul li.show')?  $('#news-wide ul li.show') : $('#news-wide ul li:first'));
	
	// Next or go back to first
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('#news-wide ul li:first') :current.next()) : $('#news-wide li:first'));

	//Set the fade in effect for the next image, the show class has higher z-index
	next.addClass('show').fadeIn(1000);

	//Hide the current image
	current.hide(0).removeClass('show');
};



