trim = function(str, ch) {
    return (str.replace(new RegExp('^' + ch + '*|' + ch + '*$', "g"), ''))
};
var flatShow = [];
$("li > a[name='flat']").each(function(){
    var parent = $(this), id = trim(this.id, 'nav_'), childID = 'nav_wrapper_'+id;
	var child = $("#"+childID);
	child.mouseover(function(){showFlatNav(child, parent);}).mouseout(function(){hidFlatNav(child, parent)});
	parent.mouseover(function(){showFlatNav(child, parent)}).mouseout(function(){hidFlatNav(child, parent)});
});
function showFlatNav(c,p){
	var pos = p.getPosition(), x=pos.x, y=pos.y+25;
	c.data('show',1);
	//$('#subnav').append(c);
	c.css('display', 'block').css('left', x+'px').css('top', y+'px');
	p.addClass('hover');
}
function hidFlatNav(c,p){
	c.removeData('show');
	setTimeout(function(){if(!c.data('show')){c.css('display', 'none');p.removeClass('hover');}},80);
}
