﻿$(document).ready(function()
{
    // Wrap each puff (that has a link with class pufflink) in a anchor matching the puff's anchor
    $('.puff').each(function() {
        if($(this).find("a.pufflink").size() > 0)
        {
            $(this).wrap('<a href="' + $(this).find("a").attr("href") + '" target="' + $(this).find("a").attr("target") + '" style="text-decoration:none;"></a>');
            $(this).find('a.pufflink').css('text-decoration','none');
        }
    });
    
    
    // Add hover effect to each puff
    $('.puff').hover(function() {
        $(this).addClass('puffHover');
        $(this).find('h3').stop().animate({'color':'#ff00ff'}, 1);
    }, function() {
        $(this).removeClass('puffHover');
        $(this).find('h3').animate({'color':'#e5e5e5'}, 300);
    });





    /* Fetch number of delicious links to footer */
    /* We can't access an unsecure domain when using our own SSL/Https-pages since we get a warning, etc */
    var location = document.location + ' ';
    var locationSplit = location.split(":",1);
    var protocoll = locationSplit[0];
    if(protocoll != "https")
    {
        url = "http://pacemaker.net/";
        $.ajax({ type: "GET",
            dataType: "jsonp",
            url: "http://feeds.delicious.com/v2/json/urlinfo/"+$.md5(url),
            success: function(data){
                if (data.length > 0) {
                    $("#delicious").text(data[0].total_posts);
                }
            }
        });
    }
    else
    {
        $("#delicious").parent().remove();
    }


    /* Init animation of menu */
    $('.menu a:not(.active)').hover(function() {
        $(this).stop().css({'color':'#ff00ff'});
    }, function() {
        $(this).animate({'color':'#999999'}, 300);
    }); 



    /* Make sure the let's mix-animation is actually animated (e.g. animation is not started on second page for FF3) */
    $('#letsmixGif').attr('src','/inc/img/icons/letsmix2.gif');



    initStylingAndEffects();



    /* Replace row-res images with highres versions instead */
    $(document).ready(function() {
        $('.lowres').each(function() {
            $(this).attr('src', $(this).attr('highres'));
        });
    });



    /* Fix for FF2 - remove dropdownbox transparency and rounded corners for buttons */
    if(jQuery.browser.mozilla && jQuery.browser.version < '1.9')
    {
	    $('.button_blackbg').css('-moz-border-radius','0px');
	    $('select').css('background','black');
    }


});



