/* Set the UI and funcationality for all navigation buttons */
$(function(){
	$(".nav ul li").add('.stars ul li').each(function(){
		/* Check if the button belongs to the current page (active button) */
		if(location.pathname.indexOf($(this).find('a').attr('href')) >= 0)
		{
			$(this).addClass('ui-state-active').click(function(){return false;});
		    $(this).find('a').attr('style', 'cursor: default'); // Default mouse cursor for the anchor <a> 
		}
		else
		{
	    	var newLocation = $(this).find('a').attr('href');

	    	$(this).addClass('ui-state-default'); // Assign appropriate UI

			/* Change the mouse cursor to indicate that it is clickable */
	    	if (newLocation)
	    	{
				$(this).hover(function(){
						$(this).addClass('ui-state-hover').attr('style', 'cursor: pointer');
					}, 
					function(){
						$(this).removeClass('ui-state-hover').attr('style', 'cursor: default');
					});
	    	}
	    	else
	    	{
			    $(this).attr('style', 'cursor: default'); // Default mouse cursor for the anchor <a> 
	    	}
			
			/* On click, go to the appropriate page */
		    $(this).click(function(){
			    	if (newLocation)
			    	{
			    		location = newLocation;
			    	}
					return false;
		    	});
		}
	});
});

$(function(){
//	$("<span/>").addClass("ui-icon ui-icon-triangle-1-e").prependTo("div.stars li.ui-state-default:has(a)");
//	$("<span/>").addClass("ui-icon ui-icon-triangle-1-s").prependTo("div.stars li.ui-state-active:has(a)");
	$("<span/>").addClass("ui-icon ui-icon-triangle-1-e").prependTo("div.stars li");
	$("div.stars li.ui-state-default").not("div.stars li.ui-state-default:has(a)").addClass('notClickableStars');

});