$(function() {
    $('.curvy').corner('10px');

    $('#nav').menu();

    $('.tt').tooltip({
        track: true,
        delay: 0,
        showURL: false,
        showBody: " - ",
        top:5,
        right:-10
    });

	$('.modal').click(function() {
	    if (!$.facebox) {
	        var _aClicked = this;
	        $.getScript('/js/jquery/facebox/facebox.js', function(){
	            $(document).bind('reveal.facebox', function() { $('#facebox .title_text').html($('#facebox').find('h1').html());});
	            $('.modal').facebox();
	            $(_aClicked).click();
	        });
	        return false;
	    }
	    return false;
	});

	$('.pngFix').pngFix();

});

/** Menu **/
(function($) {
    $.fn.menu = function(options)
    {
        options = $.extend({
            hoverClass: 'hover'
        }, options);
        $('ul > li', this).each(function(i) {
            var parent = this;
            var cs = $('> ul', this).size();
            $(this).hover(function() {
                $(this).addClass(options.hoverClass);
                if (cs > 0) {
                    $('> ul > li > ul', parent).hide();
                    $('> ul', this).show();
                }
            }, function() {
                $(this).removeClass(options.hoverClass);
                if (cs > 0) {
                    $('> ul', this).hide();
                }
            });
        });
    };
})(jQuery);
