<!--//---------------------------------+
//  Developed by Roshan Bhattarai 
//  Visit http://roshanbh.com.np for this script and more.
//  This notice MUST stay intact for legal use
// --------------------------------->
$(document).ready(function() {
	var clicked_menu_head;
	var speed = 300;
 
	$('span.menu_head').click(function() {
		clicked_menu_head = $(this);
		if (clicked_menu_head.next().is(':visible')) {
			clicked_menu_head.next().slideUp();
			clicked_menu_head.css({backgroundImage:"url(/SiteCollectionImages/treeview_nolines_plus.gif)", backgroundColor:""});
		}
 
		// if clicked menu head is submenu, check if there are any submenus in it, then hide
		clicked_menu_head.next().find('span.menu_head a'&&'span.menu_head2').each(function () {
			$(this).next().slideUp(speed);
			$(this).css({backgroundImage:"url(/SiteCollectionImages/treeview_nolines_plus.gif)", backgroundColor:""});
		});
 
		parent_menu_head = clicked_menu_head.parents('ul.menu_body').prev(clicked_menu_head.parents('ul.menu_body').size()-1);
 
		if (clicked_menu_head.next('ul.menu_body').is(':visible')) {
		} else clicked_menu_head.css({backgroundImage:"url(/SiteCollectionImages/treeview_nolines_minus.gif)", backgroundColor:"#ededed"}).next('ul.menu_body').slideDown(speed);

		
 
 
		/*$('#firstpane').children('p').siblings('p').each(function() {
			// loop through each main menu, if not equal, hide all sub menu
			if (parent_menu_head.attr('id')) {
				if (parent_menu_head.attr('id') != $(this).attr('id')) {
					$(this).children('div.menu_body').slideUp(speed);
				}
			} else {
				if (clicked_menu_head.attr('id') != $(this).attr('id')) {
					$(this).css({backgroundImage:"url(left.png)"})
					$(this).next().slideUp(speed).find('p.menu_head').each(function() {
						$(this).next().slideUp(speed);
					});
				}
			}
 
		});*/
	});
	
	
		$('span.menu_head2').click(function() {
		clicked_menu_head = $(this);
		if (clicked_menu_head.next().is(':visible')) {
			clicked_menu_head.next().slideUp();
			clicked_menu_head.css({backgroundImage:"url(/SiteCollectionImages/treeview_nolines_plus.gif)", backgroundColor:""});
		}
 
		// if clicked menu head is submenu, check if there are any submenus in it, then hide
		clicked_menu_head.next().find('span.menu_head2').each(function () {
			$(this).next().slideUp(speed);
			$(this).css({backgroundImage:"url(/SiteCollectionImages/treeview_nolines_plus.gif)", backgroundColor:""});
		});
 
		parent_menu_head = clicked_menu_head.parents('ul.menu_body').prev(clicked_menu_head.parents('ul.menu_body').size()-1);
 
		if (clicked_menu_head.next('ul.menu_body').is(':visible')) {
		} else clicked_menu_head.css({backgroundImage:"url(/SiteCollectionImages/treeview_nolines_minus.gif)", backgroundColor:"#f5f5f5"}).next('ul.menu_body').slideDown(speed);


	});
});
