var submenu = $('<div/>').css({'top':0,'left':leftPos}).appendTo(container);
if($.browser.msie) { $(submenu).width('200px'); } // Cuz IE don't support auto width
var subitems = $(item).data('sub').children('li');
$.each(subitems,function(i,subitem){
var subsubitem = $(':eq(0)',subitem).clone().data('sub',$(subitem).children('ul')).appendTo(submenu);
if($(subsubitem).data('sub').length) {
$(subsubitem).addClass('hasChildMenu');
if($.browser.safari){
$(subsubitem).css({'margin-right':'15px'});
}
addWidget(subsubitem);
}
});
}
// Uses canvas, if available, to draw a triangle to denote that item is a parent
function addWidget(item, color){
var triheight = $(item).height();
var canvas = $("<canvas></canvas>").attr({height:triheight,width:10}).addClass('widget').prependTo(item); if(!color){ color = $(canvas).css('color'); }
canvas = $(canvas).get(0);
if(canvas.getContext){
var context = canvas.getContext('2d');
context.fillStyle = color;
context.beginPath();
context.moveTo(3,(triheight/2 - 3));
context.lineTo(10,(triheight/2));
context.lineTo(3,(triheight/2 + 3));
context.fill();
} else {
/**
* Canvas not supported - put something in there anyway that can be
* suppressed later if desired. We're using a decimal character here
* representing a "black right-pointing pointer" in Windows since IE