// JavaScript Document

$(document).ready(function(e) {
    

	var currDiv = $('#menu-button.active');
	var currPosition = currDiv.position();
	var currWidth = currDiv.width();
	
	//alert(currPosition);
	
	$('#menu-cursor').css({left: currPosition.left + 0, width: currWidth - 16});
	$('#menu-triangle').css({left: currPosition.left + 0});
	
	 
	function shapeReset() {
		$('#header-shape').removeClass();
		$('#header-shape-rect').removeClass();
		$('#header-shape-triangle').removeClass();
		$('#header-shape-circle').removeClass();
	}
	
	$('#menu-button.menu-1, #menu-button.menu-2, #menu-button.menu-3, #menu-button.menu-4, #menu-button.menu-8').hover(
			  function () {
				var btnPosition = $(this).position();
				var btnWidth = $(this).width();
				//alert(btnWidth);
				$('#menu-cursor').css({left: btnPosition.left + 0, width: btnWidth - 16});
				$('#menu-triangle').css({left: btnPosition.left + 0});
				$('#header-shape').css({left: btnPosition.left + ((btnWidth / 2))});
			  }, 
			  function () {
				$('#menu-cursor').css({left: currPosition.left + 0, width: currWidth - 16});
				$('#menu-triangle').css({left: currPosition.left + 0});
				$('#header-shape').css({left: currPosition.left + ((currWidth / 2))});
				//currShape();
			  }
	);
	$('#menu-button.tutorial').hover(
		function () {
			shapeReset();
		}, 
		function () { 
		}
	);

});

$(document).ready(function(){	
		
	var site = function() {
		this.navLi = $('#menu-links ul li').children('ul').hide().end();
		this.init();			
	};
	
	
	
	site.prototype = {         	
		init : function() {
			this.setMenu();
		},
		setMenu : function() {         	
		$.each(this.navLi, function() {
			if ( $(this).children('ul')[0] ) {
				$(this).append('<span class="hasChildren" />');
			}
		});         	
			this.navLi.hover(function() {
				$(this).find('> ul').fadeIn(100);
			}, function() {
				$(this).find('> ul').fadeOut(100);
			});         		
		}        
	}
	new site(); 
	
}); 

$(document).ready(function(){	
		
	var site = function() {
		this.navLi = $('#topo #info ul li').children('ul').hide().end();
		this.init();			
	};
	
	
	
	site.prototype = {         	
		init : function() {
			this.setMenu();
		},
		setMenu : function() {         	
		$.each(this.navLi, function() {
			if ( $(this).children('ul')[0] ) {
				$(this).append('<span class="hasChildren" />');
			}
		});         	
			this.navLi.hover(function() {
				$(this).find('> ul').fadeIn(100);
			}, function() {
				$(this).find('> ul').fadeOut(100);
			});         		
		}        
	}
	new site(); 
	
}); 
