$(document).ready(function(){
	// show and hide navigation layer
	$('nav.mainNav').delegate('ul.listFloatLeft>li', 'hover', function(){
		$(this).addClass("hover ");
		$(this).find('ul:first').show();
	});
	$('nav.mainNav').delegate('ul.listFloatLeft>li', 'mouseleave', function(){
		$(this).removeClass("hover");
		$(this).find('ul:first').hide();
	});
	
	$(".amenu_link a").each(function() {
		urlString = window.location.pathname;
		
		if(urlString.indexOf($(this).attr("href")) > -1) {
			$(this).addClass("selected");
		}
	});

	// replace empty download link labels for filelist
	if($('.csc-default div.resultListing div.csc-upload-file')){
		$('.csc-default div.resultListing div.csc-upload-file .uploadLink ').each(function(){
			console.log($(this).has('.upload-desc'));
			if($(this).has('.upload-desc').length){
				var desc = $(this).find('.upload-desc').each(function(){
					if($(this).text().length == 0){
						$(this).text($(this).next().find('.hidden').text());
					}
				});
			}else{
				$(this).find('.uploads-link').each(function(){
					var newDesc = $('<p class="upload-desc"></div>').text($(this).find('.hidden').text());
					$(this).before(newDesc);
				});
			}
		});
	}
});
