$(function(){

	$('#contentnavigator').css("visibility", "visible");
	$('#contentnavigator').attr('state', 'on');
	$('#contentnavigator').attr('src', $('#contentnavigator').attr('on'));


        $(function(){
            $('.button').jeegoocontext('ctxmenu', {
                widthOverflowOffset: 0,
                heightOverflowOffset: 1,
                startTopOffset: -1,
                startLeftOffset: 1,
                submenuLeftOffset: -4,
                submenuTopOffset: -2,
                event: 'click',
                openBelowContext: true 
            });
        });
	
	$('#guidewrapper').jeegoocontext('ctxmenu', {
		widthOverflowOffset: 0,
		heightOverflowOffset: 3,
		submenuLeftOffset: -4,
		submenuTopOffset: -5,
		delay: 0,
		fadeIn: 0
	});

	$('#ctxmenu').css("visibility", "visible");

	$('#contentnavigator').click(function () { 
		if ( $(this).attr('state') == 'on' )
		{
			$(this).attr('state', 'off');
			$(this).attr('src', $(this).attr('off'));
			$('#guidewrapper').nojeegoocontext();
			$("#contentnavigator").tooltip({
				position: "top center", 
				offset: [-10, 0], 
				tip: '#tip_guidenav'
			});
		} else {
			$(this).attr('state', 'on');
			$(this).attr('src', $(this).attr('on'));
			$('#guidewrapper').jeegoocontext('ctxmenu', {
				widthOverflowOffset: 0,
				heightOverflowOffset: 3,
				submenuLeftOffset: -4,
				submenuTopOffset: -5,
				delay: 0,
				fadeIn: 0
			});
		}
	});

	$('#contentnavigator').hover(function() {
        var currentImg = $(this).attr('src');
        $(this).attr('src', $(this).attr('hover'));
    }, function() {
        var currentImg = $(this).attr('src');
        $(this).attr('src', $(this).attr( $(this).attr('state')));
    });
	
	$("#contentnavigator").tooltip({
		position: "top center", 
		tip: '#tip_guidenav'
	});

});
