﻿
function move_lawa(me)
{
	var master=$(me).data("floater")
	var ashift,x_shift,y_shift
	if($(me).parent().parent().hasClass("sub_nav"))
	{
		
		ashift=$(me).parent().parent().position()
		x_shift=ashift.left
		y_shift=ashift.top
		
	}
	else x_shift=y_shift=0
	 $back.each(function() {
                $(this).clearQueue(); })
	var m_off=$(me).position()
	root_floater.animate( {left:m_off.left+x_shift+4,top:m_off.top+6+y_shift,width:$(me).width()+10})
}
function remember_curr(me)
{
	var ashift,x_shift,y_shift
	if($(me).parent().parent().hasClass("sub_nav"))
	{
		
		ashift=$(me).parent().parent().position()
		x_shift=ashift.left
		curr.width=$($("a",$(me).parent().parent().parent())[0]).width()+10
	}
	else
	{
	 	x_shift=y_shift=0
	 	curr.width=$(me).width()+10
	 }
	var m_off=$(me).position()
	curr.x=m_off.left+x_shift+4
	
	//alert(x_shift+" "+curr.x+ " " +curr.width)
}
function move_curr()
{
	 $back.each(function() {
                $(this).clearQueue(); })
				root_floater.animate( {left:curr.x,top:6,width:curr.width})
}
function move_to_lawa_open_page()
{
	var $li=$("a",$me)
	
	$.each($li,function(){
	if($(this).attr("hash")==lawa_open_page)
	{
		remember_curr(this)
		move_curr()
	}
	});
}
function my_lawa(lawa_item)
{

	$me=$(lawa_item)
	 $back = $('<li class=\"float_rollover\"></li>').appendTo($($me[0]))
	 root_floater=$($(lawa_item+"> li.float_rollover")[0])
    
	$me.addClass("my_lawa")
	
	$("a",$me).mouseenter(function()
	{
			move_lawa(this)
	})
	
	$("a",$me).click(function()
	{
			//move_lawa(this)
			remember_curr(this)
	})
	
	$("a",$me).mouseleave(function()
	{
			move_curr()			
	})
	
	
	//curr=4//$("a",$li[0])
	curr=new Object()

	//alert($li.length)

	var i


	root_floater.css("position","absolute")
	//root_floater.css("top","6px")
	//root_floater.css("left","2px")
	
	//alert($(":parent:parent",this).css("width"));
	//var back_width=Math.floor($($li[0]).width()+10)
	lawa_open_page=window.location.hash
	
	//alert(window.location.hash=="")
	if(lawa_open_page=="")lawa_open_page="#Home"
	move_to_lawa_open_page()

	//root_floater.css("width",back_width+"px")
	root_floater.css("z-index","5")
	//$(".float_rollover",this).fadeTo(10,50);

	
	
	
	
}

$(document).ready(function()
{
	my_lawa("#nav ul")
	$(".paneCpntainerwrapped a").click(function(){lawa_open_page=$(this).attr("hash");move_to_lawa_open_page()});
})

