	
	
function ShowIt(t){
	
	$(t).addClass("sfhover");
	$(t).find(" > ul")
           /* .css("display","block")*/
            .css("left","auto");

            
            if (Cufon) Cufon.refresh();

            //.fadeIn();

	bum = $(t).find(" > ul").get(0);
	
	if(bum && (findPosX(bum)+bum.offsetWidth >= getWidth()))
	{
		$(t).find(" > ul").css("left","-250px");
		rev = 1
	} 
}

function HideItGo (t) 
	{
                //var isHovering = $(t).is(".sfhover");

                //alert("is hovering over div?: " + isHovering);

                //if (isHovering) return;

		$(t).find(" > ul").css("left","-999em");

                //$(t).find(" > ul").fadeOut(100,null, function () { $(t).css("left","-999em"); });

                $(t).removeClass("sfhover");
	}

function HideIt(t){
	
	/*
	var x;
	var x=t;
	*/
	//HideItGo (t);
	
	setTimeout( function () {
            //console.log($(t).parent());

            /*
            if ($(t).parent().isHovered() || $(t).isHovered())
            {
                console.log("je hover neschovavam");
                HideIt(t);
                return;
            }
            */
            HideItGo (t)

        },300);
	
	
};



function getWidth(){
var myWidth = 0
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  
  return myWidth;
}

function findPosX(obj){
	var curleft = 0;
	
	if (obj)
	{
		
	
		if(obj.offsetParent)
		while(1) 
			{
				curleft += obj.offsetLeft;
					if(!obj.offsetParent)
					break;
					obj = obj.offsetParent;
			}
		else if(obj.x)
			curleft += obj.x;
		return curleft;
	}
	else
	return false;
}
