$(function() {
    /* Navigation initialisieren */
    $(".hlist > ul > li").hover(
      function () {
        $(this).find('ul').css({
            display: 'block',
            opacity: 0
        }).animate({
            opacity: 1
        }, {
            queue: false, duration: 250
        });
      },
      function () {
        $(this).find('ul').animate({
            opacity: 0
        }, {
            queue: false, duration: 250, complete : function() {
                $(this).css({ display: 'none' });
                
            }
        });
      }
    );

    /* Scrollables initialisieren */
    var coverflow = $("#coverflow").scrollable({
        items: '.scrollitems',
        keyboard: false,
        loop: true,
        size: 1
    }).autoscroll({
        interval: 10000
    }).circular();

    var sponsorflow = $("#sponsorflow").scrollable({
        clickable: false,
        items: '.scrollitems',
        keyboard: false,
        loop: true,
        size: 2
    }).autoscroll({
        interval: 4000
    }).circular();

    /* Formular initialisieren */
    $("#participation #occupation").change(function () {
        occupation = $(this).val();

        $("#ismlocation, #lodging, #university, #employer, #miscoccupation").parent().hide();

        switch (occupation) {
            case "0":
                $("#ismlocation, #lodging").parent().show();
                break;
            case "1":
                $("#university").parent().show();
                break;
            case "2":
                $("#employer").parent().show();
                break;
            case "3":
                $("#miscoccupation").parent().show();
                break;
        }
    }).change();

    $("#participation #referralselect").change(function () {
        referral = $(this).val();

        $("#referralmisc").parent().hide();

        if (referral == 7) {
            $("#referralmisc").parent().show();
        }
    }).change();

    $("#participation #dinner").change(function () {
        //alert($("#price").val());
        
        price = parseFloat($("#price").val());
        
        if ($(this).attr('checked')) {
            price = price + 7;
        }

        $("#finalprice").val(price + " Euro");
    }).change();
    
    /* Gallerie initialisieren */
    var gallery = $("div.gallery a");

    if (gallery.length > 0) {
        $("div.gallery a").overlay({
            target: '#overlay',
            expose: '#f1f1f1'
        }).gallery({
            speed: 500,
            template: '<strong>${title}</strong> <span>Bild ${index} von ${total}</span>'
        });
    }
    
    /* Links initialisieren */
    $("a[rel='external']").click(function() {
        this.target = '_blank';
    });

    /* Programmheft initialisieren */
    $("#programmview").flashembed("/download/ism_symposium_broschuere_2010_web.swf");
});