/**
 * Koch.cz Fx
 * Author: Mac Duy Hai
 */

$(window).ready(function(){
   if ($("#Home").length) 
   {
           // change top-margin
        var marginTop = 10; //($(window).height()-$("#container").height()-60)/2;
        marginTop = (marginTop > 0) ? marginTop : 0;
        $("#container").css('marginTop', marginTop);
        
        // strip
        $("#strip li a").hover(function()
        {
            $(this).stop().animate(
            {
                "opacity": 1,
                "marginLeft": 15
            });
        }, function()
        {
            $(this).stop().animate(
            {
                "opacity": 0.4,
                "marginLeft": 0
            });
        }).css(
        {
            "opacity": 0.4,
            "marginLeft": 0
        });
        
        
        /* Fancybox showreel */
        $('#showreelLink').fancyZoom();
        
        /* Fancybox strip */
        $('#strip a').fancyZoom();
        
        $("#showreel").pngFix();
    } else {
        $("#smalltitle").pngFix();
    }
    
    /* Print */
    if ($("#Print").length) 
    {
        $.each(['cs','henkel','impulse','phillips','phillips-bb','ariston','jaguar','ferrero','helen','shell','braun'], function() {
            $('#iflow_images img[rel="'+this+'"], a[rel="'+this+'"]').lightBox();
        });
    }
    
    if ($("#Publicity").length)
    {
        $("ul.imagelist a").lightBox();
        $("ul.imagelist a").css({opacity: 0.7, marginLeft: 0}).hover(
            function() {
                $(this).stop().animate({opacity: 1.0, marginLeft: 10});
            },
            function() {
                $(this).stop().animate({opacity: 0.5, marginLeft: 0});
            }
        )
    }
    
    if ($("#CV").length) {
        $("#cv").accordion({autoheight: false, header: 'a.header'});
        
        // shorten lists
        cutoff = 3;
        $(".cvlist").each(function(j, ul) {
            if ($(ul).find("li").length > cutoff + 1)
            $(ul).find("li").each(function(i, el) {
                if (i > cutoff) {
                    $(el).addClass("hide");
                    $(el).hide();
                } else if (i == cutoff) {
                    var more = document.createElement("a");
                    var li = document.createElement("li");
                    $(more).addClass("more").text("...").attr('href','#').click(function(){
                        $(this).parent().parent().find(".hide").show('slow');;
                        $(this).hide();
                    });
                    $(el).after($(li).append(more));
                }
            });
        })
    }


});

