addLoadEvent(function() {
	var navRoot = getObject("productNav");
	if (navRoot) { 
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") { 
				if (node.childNodes.length >= 3) {
					node.childNodes[0].className="menus";
					node.onmouseover=function() {
						this.className="over";
						fixPosition($(this).children("ul"));
					}
					node.onmouseout=function() {
						this.className="";
					}
					node.childNodes[2].onmouseover=function() {
						this.parentNode.childNodes[0].id="on";
					}
					node.childNodes[2].onmouseout=function() {
						this.parentNode.childNodes[0].id="";
					}
					applyRolloverState(node.childNodes[2]);
				}
			}
		}
	}
})

function applyRolloverState(temp) {
	var navRootNew = temp;
	if (navRootNew) { 
		for (var j=0; j<navRootNew.childNodes.length; j++) {
			var nodeNew = navRootNew.childNodes[j];
			if (nodeNew.nodeName=="LI") { 
				if (nodeNew.childNodes.length >= 3) {
					nodeNew.childNodes[0].className="menus";
					nodeNew.onmouseover=function() {
						this.className="over";
						this.childNodes[2].style.display = "block";
						fixPosition(this.childNodes[2]);
						
					}
					nodeNew.onmouseout=function() {
						this.className="";
						this.childNodes[2].style.display = "none";
					}
					nodeNew.childNodes[2].onmouseover=function() {
						this.parentNode.childNodes[0].id="on";
					}
					nodeNew.childNodes[2].onmouseout=function() {
						this.parentNode.childNodes[0].id="";
					}
					applyRolloverState(nodeNew.childNodes[2]);
				}
			}
		}
	}
}

function fixPosition(ul)
{
	ul = $(ul);
	
	var ulHeight = ul.outerHeight();
	var ulOffset = ul.offset();
	var ulOffsetTop =  ulOffset.top - $(window).scrollTop();
	var viewableHeight = $(window).height();
	if((viewableHeight - ulOffsetTop) < ulHeight){
		ul.css('top','auto');
		ul.css('bottom','0px');
	}
	else{
	}

}

