var userplane = {};
userplane.tour = {

	init: function () {
		$(".up-tour ul li").not("ul li ul li").bind("click",userplane.tour.events.onGroupClick);
	
		$(".up-tour ul li ul li").bind("click",userplane.tour.events.onNodeClick);
		
		// check for anchor call and auto-open corresponding element
		var anchor = "";
		var uri = document.location.toString();
		if ( uri.match("#") ) {
			anchor = uri.split("#")[1];
			$(".up-tour").find("."+anchor).click();
		}
		
			
	},
	
	
	events: {
	
		onGroupClick: function (e) {
		
			// check to see if the item that was clicked was already open if not dont perform action
			if ( ! $(this).hasClass("active") ) {
			
				// remove the active class from everyone else 
				$(".up-tour ul li").removeClass("active");
			
				$(this).addClass("active");
			
				// hide all the others
				$(".up-tour ul li ul").hide("slide")
			
				// show the child ul
				$(this).find("ul").show("slide")
			
			}
		
		
		},
		
		onNodeClick: function (e) {
			e.stopPropagation();
	
			var id = $(this).attr('class');
			
			// hide everything else
			$( ".up-tour-feature span" ).hide();
			
			// open the right detail window
			if ( id.length != 0 ) {
				$( "#" + $(this).attr('class') ).toggle();
			}
		}
		
	}
	
	

}
$(document).ready(userplane.tour.init);
