
jQuery.noConflict()
var jquerypopupmenu={arrowpath:'arrow.gif',popupmenuoffsets:[0,0],animspeed:200,showhidedelay:[150,150],startzindex:1000,builtpopupmenuids:[],positionul:function($,$ul,e){var istoplevel=$ul.hasClass('jqpopupmenu')
var docrightedge=$(document).scrollLeft()+$(window).width()-40
var docbottomedge=$(document).scrollTop()+$(window).height()-40
if(istoplevel){var x=e.pageX+this.popupmenuoffsets[0]
var y=e.pageY+this.popupmenuoffsets[1]
x=(x+$ul.data('dimensions').w>docrightedge)?docrightedge-$ul.data('dimensions').w:x
y=(y+$ul.data('dimensions').h>docbottomedge)?docbottomedge-$ul.data('dimensions').h:y}
else{var $parentli=$ul.data('$parentliref')
var parentlioffset=$parentli.offset()
var x=$ul.data('dimensions').parentliw
var y=0
x=(parentlioffset.left+x+$ul.data('dimensions').w>docrightedge)?x-$ul.data('dimensions').parentliw-$ul.data('dimensions').w:x
y=(parentlioffset.top+$ul.data('dimensions').h>docbottomedge)?y-$ul.data('dimensions').h+$ul.data('dimensions').parentlih:y}
$ul.css({left:x,top:y})},showbox:function($,$popupmenu,e){clearTimeout($popupmenu.data('timers').hidetimer)
$popupmenu.data('timers').showtimer=setTimeout(function(){$popupmenu.show(jquerypopupmenu.animspeed)},this.showhidedelay[0])},hidebox:function($,$popupmenu){clearTimeout($popupmenu.data('timers').showtimer)
$popupmenu.data('timers').hidetimer=setTimeout(function(){$popupmenu.hide(100)},this.showhidedelay[1])},buildpopupmenu:function($,$menu,$target){$menu.css({display:'block',visibility:'hidden',zIndex:this.startzindex}).addClass('jqpopupmenu').appendTo(document.body)
$menu.bind('mouseenter',function(){clearTimeout($menu.data('timers').hidetimer)})
$menu.bind('mouseleave',function(){jquerypopupmenu.hidebox($,$menu)})
$menu.data('dimensions',{w:$menu.outerWidth(),h:$menu.outerHeight()})
$menu.data('timers',{})
var $lis=$menu.find("ul").parent()
$lis.each(function(i){var $li=$(this).css({zIndex:1000+i})
var $subul=$li.find('ul:eq(0)').css({display:'block'})
$subul.data('dimensions',{w:$subul.outerWidth(),h:$subul.outerHeight(),parentliw:this.offsetWidth,parentlih:this.offsetHeight})
$subul.data('$parentliref',$li)
$subul.data('timers',{})
$li.data('$subulref',$subul)
$li.children("a:eq(0)").append('<img src="'+jquerypopupmenu.arrowpath+'" class="rightarrowclass" style="border:0;" />')
$li.bind('mouseenter',function(e){var $targetul=$(this).css('zIndex',++jquerypopupmenu.startzindex).addClass("selected").data('$subulref')
if($targetul.queue().length<=1){clearTimeout($targetul.data('timers').hidetimer)
$targetul.data('timers').showtimer=setTimeout(function(){jquerypopupmenu.positionul($,$targetul,e)
$targetul.show(jquerypopupmenu.animspeed)},jquerypopupmenu.showhidedelay[0])}})
$li.bind('mouseleave',function(e){var $targetul=$(this).data('$subulref')
clearTimeout($targetul.data('timers').showtimer)
$targetul.data('timers').hidetimer=setTimeout(function(){$targetul.hide(100).data('$parentliref').removeClass('selected')},jquerypopupmenu.showhidedelay[1])})})
$menu.find('ul').andSelf().css({display:'none',visibility:'visible'})
$menu.data('$targetref',$target)
this.builtpopupmenuids.push($menu.get(0).id)},init:function($,$target,$popupmenu){if(this.builtpopupmenuids.length==0){$(document).bind("click",function(e){if(e.button==0){$('.jqpopupmenu').find('ul').andSelf().hide()}})}
if(jQuery.inArray($popupmenu.get(0).id,this.builtpopupmenuids)==-1)
this.buildpopupmenu($,$popupmenu,$target)
if($target.parents().filter('ul.jqpopupmenu').length>0)
return
$target.bind("mouseenter",function(e){$popupmenu.css('zIndex',++jquerypopupmenu.startzindex)
jquerypopupmenu.positionul($,$popupmenu,e)
jquerypopupmenu.showbox($,$popupmenu,e)})
$target.bind("mouseleave",function(e){jquerypopupmenu.hidebox($,$popupmenu)})}}
jQuery.fn.addpopupmenu=function(popupmenuid){var $=jQuery
return this.each(function(){var $target=$(this)
jquerypopupmenu.init($,$target,$('#'+popupmenuid))})};jQuery(document).ready(function($){var $anchors=$('*[data-popupmenu]')
$anchors.each(function(){$(this).addpopupmenu(this.getAttribute('data-popupmenu'))})})
function ddlistmenu(id,className){var menu=document.createElement('ul')
if(id)
menu.id=id
if(className)
menu.className=className
this.menu=menu}
ddlistmenu.prototype={addItem:function(url,text,target){var li=document.createElement('li')
li.innerHTML='<a href="'+url+'" target="'+target+'">'+text+'</a>'
this.menu.appendChild(li)
this.li=li
return this},addSubMenu:function(){var s=new ddlistmenu(null,null)
this.li.appendChild(s.menu)
return s}}