$(document).ready(function() {
	$('.contextMenuBackup')
		.hide();
	
	$('.contextMenuList')
		.removeClass('contextMenuList')
		.addClass('contextMenu')
		.appendTo('#contextMenusContainer');

	/*
	 * there is a bug in mozilla that cases context menus fired from links to be unclickable
	 * As a workaround I remove the actual links but leave basic functionality intact.
	 */
	mozilla = 0;
	jQuery.each(jQuery.browser, function(i, val) {
		if ( (i == 'mozilla') && val ) {
			mozilla = 1;
		}
    	});
    	
    	if ( mozilla == 1 ) {
		$('a.slotLink').each(function(i) {
			$(this).after('<span class="fakeLink">' + $(this).html() + '</span>');
			$(this).parent().click(function(e) {			
				window.location.href = $(this).find('a.slotLink').attr('href');
			});
		}).hide();
		
		
	}
	
	/*
	 * We need to get the id's of the context menu's rows to be able to identify the list used as context menu.
	 */
	$('.contextMenuLink').each(function(i) {
		$(this).contextMenu('#contextMenu' + $(this).attr('id'));
	});
});
