/**
 * Tooltip
 */

this.tooltip = function(){	
    /* CONFIG */		
    xOffset = 10;
    yOffset = 20;		
    // these 2 variable determine popup's distance from the cursor
    // you might want to adjust to get the right result		
    /* END CONFIG */		
    $('ul.sublevel li').hover(
        function(e){
            //this.t = this.title;
            //this.title = "";
            $('body').append('<p id="tooltip">'+ $(this).html() +'</p>');
            $("#tooltip")
                .css("top",(e.pageY - xOffset) + "px")
                .css("left",(e.pageX + yOffset) + "px")
                .fadeIn("fast");		
        },
        function(){
            //this.title = this.t;		
            $("#tooltip").remove();
        }
    );	
    
    $("span.anatomieLink a").mousemove(function(e){
    $("#tooltip")
        .css("top",(e.pageY - xOffset) + "px")
        .css("left",(e.pageX + yOffset) + "px");
    });
};


this.addParam = function() {
    var getIt = $('span.anatomieLink a').attr('href');
    var put = getIt+'?request=main';
};


var config = {    
        sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
        interval: 200, // number = milliseconds for onMouseOver polling interval    
        timeout: 500, // number = milliseconds delay before onMouseOut    
    };

$(document).ready(function() {

    $('span.anatomieLink a').attr('href', function() {
       return this+'?request=main';
    });

    $('span.anatomieLink a').fancybox({
        hideOnContentClick: false
    });

    $("a[rel^='lightbox']").fancybox();
    
    tooltip();
    
    
    //xOffset = 10;
    //yOffset = 20;
    /*
    $('ul.sublevel li').hover(
        function() {
            $('div#tab-container').append('<p id="tooltip">'+ $(this).text() +'</p>');
            $("#tooltip")
                .css("top",(pageY - 10) + "px")
                .css("left",(pageX + 20) + "px")
                .fadeIn("fast");
        },
        function() {
            $("#tooltip").remove();
        }
    )
    */
    // anatomie neu
    
    //When page loads...
    //$("div#tab-container").hide(); //Hide all content
    $('div.tab-content').hide();
    
    
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
    $("div.tab-content:first").show(); //Show first tab content
    
       
    //On Click Event
    $("ul.tabs li").click(function(e) {
        
        //e.preventDefault;
        $("ul.tabs li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $("div.tab-content").hide(); //Hide all tab content
        
        var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active ID content
        return false;
    });
    
    
    /**
     * Fighting the Hover Tunnel
     */
    
    
    
    $('#aside-content li.submenu').hoverIntent(
        // mouseover
        function(){
            $(this).find('>ul').fadeIn('fast');
        },
        // mouseout
        function(){
            $(this).find('>ul').fadeOut('fast');
        }
    );

    
    
    // Forms

    if ($('form .callbackToggler input').attr('checked')) {
        //alert('ya');
        $('form .callbackToggler input').change(function() {
            $(this).attr('checked');
        });
    } else {
        //alert('na');
        $('form div.callbackContent').hide("fast");
    }

    $('form .callbackToggler input').change(function() {
        if(!this.checked) {
            $('form div.callbackContent').hide("fast");
            $('form div.callbackContent input').val('');
            if ($('div.callbackContent p.error')) {
                $('div.callbackContent p.error').hide();
            }
        } else {
            $('form div.callbackContent').toggle("fast");
        }
    });

});


