function findPosX(obj)
{
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj)
{
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}


sfHover = function() {
	var subtrX = parseInt(findPosX(document.getElementById("pageWrapper"))); 
	var sf = document.getElementById("nav");
	if(sf == null)return;

	sfEls	= sf.getElementsByTagName("LI");
	
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className	+=" sfhover";
			if(this.parentNode.id == 'nav'){
				for(var j = 0; j < this.childNodes.length; j++){
					var ul			= this.childNodes[j];
					if(ul.tagName =='UL'){
						ul.style.left	= (findPosX(this) - subtrX)+'px';
						ul.style.top	= (findPosY(this)+21)+'px';
					} 
				}
			}
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			if(this.parentNode.id == 'nav'){
				for(var j = 0; j < this.childNodes.length; j++){
					var ul			= this.childNodes[j];
					if(ul.tagName =='UL'){
						ul.style.left	= '-999em';
					} 
				}
			}
		}
	}
}
if (window.attachEvent) {
	window.attachEvent("onload", sfHover);
	window.attachEvent("onresize", sfHover);
}

