//For all pages other than gbrowse

$(document).ready(function() {
		
		var current_path =  window.location.pathname;  
		var li_id = $("a[href^='"+current_path+"']").parent().attr('id');
		if (current_path.search(/Welcome|Search|Overview/) > 0){
			li_id="home";
		}
		
		if(li_id){
			$('#'+li_id).addClass('active').css('background','url("/css/images/icon-arrow.gif") no-repeat scroll 10px 10px #F3F7FF'); 	    
		}else{
			
			fetch_navbar_mapping(current_path);
		}
            
		//for navigation bar multiple accordion menu
		$(".topnav").accordion({
				accordion:false,
				speed: 0,
				closedSign: '<img src="/images/icons/icon-down.png" alt="[+]" />',
				openedSign: '<img src="/images/icons/icon-up.png" alt="[-]" />'
				
		});
		

		$('a[title]').qtip(
			{
				content: {
					text: $('.title'),
					title: $('.name')
				},
				position: {
					my: 'right center',
					at: 'left center'
				},
				show: {
					event: 'mouseenter'
				},
				style: {
					classes: 'ui-tooltip-shadow ui-tooltip-rounded'
				}
			});
} );

function fetch_navbar_mapping(current_path){
	
	var url = "/webservice/NavbarService/=/model/json_summary/current_path/"+current_path;
	
	$.ajax({
			url: url,
			type: 'GET',
			success: function(pathmap){
				var li_id = pathmap.navbaritem;
				$('#'+li_id).addClass('active').css('background','url("/css/images/icon-arrow.gif") no-repeat scroll 10px 10px #F3F7FF');
				
			}
		});
	
	
}

