// JavaScript Document by Ray
$(document).ready(function(){
						   
	  
	  
	  
	  $(".first").hover(
		
			function() {
				
				$(this).find('.second').show();
				
			},
			
			function() {
			
				$(this).find('.second').hide();
			
			}
		
		)
		
		menuHover(".second",".third")
		menuHover(".third",".fouth")	
		
		$('.loginFormBox > ul').tabs();
		
})
function menuHover(parentCssName,childCssName) {

	var menuSelected = $(parentCssName).children().children()
	
	menuSelected.hover(
	
		function() {
			
			var index = $(this).parent().parent().children().children().index(this)
			var selfHeight = $(this).parent().parent().children().children().height()
			
			var topHeight = (selfHeight+1) * index
			
			var parentHeight =  $(this).parent().parent().height()
			//alert(parentHeight)
			var childHeight = $(this).find(childCssName).height()
			//alert(childHeight)
			
			$('#traceInfo').html("index"+index)
			$('#traceInfo2').html("parentHeight"+parentHeight)
			$('#traceInfo3').html("topHeight"+topHeight)
			
			if ( parentHeight>childHeight ) {
				
				if (topHeight >= childHeight) {
					var bottomHeight = (parentHeight-topHeight-selfHeight-1)+"px"
					
					$(this).find(childCssName).css("bottom",bottomHeight);
					$(this).find(childCssName).show();
					
					
				} else {
				
					$(this).find(childCssName).css("top","0px")
					$(this).find(childCssName).show();
				}
			} else {
			
				$(this).find(childCssName).css("top","0px")
				$(this).find(childCssName).show();
			
			
			}
			
			
		},
		
		function() {
		
			$(this).find(childCssName).hide();
		
		}
	
	)	


}
