// JQUERY CONFIGURATION FILE 

jQuery(document).ready(function() {
								
	jQuery('#addPanel').hide();
	jQuery('.record_update').hide();

 	cnt = 0;
	navheads = jQuery('div.navhead');
	navheads.each(function(index){
		jQuery(this).attr('id','nav-'+ cnt);
		cnt++;
	});
	
	// set unique ids for all subnavs
	cnt = 0;
	subnavs = jQuery('div.subnav');
	subnavs.each(function(index){
		jQuery(this).attr('id','subnav-'+ cnt);
		cnt++;
	});
 
 //NAVIGATION MENU
  jQuery('div.sidenav> div.subnav').hide();
  
  jQuery('#nav-0').addClass('admin_button');
  jQuery('#nav-0 a').addClass('admin_button');
  jQuery('#nav_login').addClass('admin_button');
  jQuery('#nav_logout').addClass('admin_button');

  
  jQuery('div.sidenav> div.navhead').click(function() {
	
		
	jQuery(this).parent().find("div.subnav").slideUp('normal');
	jQuery(this).parent().find("div.navhead").removeClass("selected");
	jQuery(this).next('div.subnav').slideToggle('slow');
	jQuery(this).toggleClass("selected");
	
	// set cookie with menu id (zero based).
	menuId = jQuery(this).attr('id');
	jQuery.cookie('rxport_nav', "#"+ menuId);
	//alert("set cookie: " + menuId);
	
	
  });
  
  // get cookie and open submenu if cookie exists
  	if(jQuery.cookie('rxport_nav') != "") {
		menuId = jQuery.cookie('rxport_nav');
		jQuery(menuId).next('div.subnav').slideToggle('slow');
		//alert("get cookie: " + menuId);
	}

  	
	
	
	jQuery('#contentPanel').find('.record_update').hide().end().find('.record_buttons').click(function() { 
	
		jQuery(this).hide('slow').next().hide('slow', function() {												   
			jQuery(this).nextAll('.record_update:first').show('slow');													   
		});
	});

	
	jQuery('#add_button').click(function() {
	jQuery('#contentPanel').hide('slow', function() {
	jQuery('#addPanel').show('slow');
	});
	
	
	})
	
	jQuery('#close_button').click(function() {
	jQuery('#updatePanel').hide('slow');
	jQuery('#addPanel').hide('slow');
	jQuery('#contentPanel').show('slow');
	
	})
	
	
									
	
});
