function changeImage(el, src) {
    $(el).attr('src', src);
}

jQuery.preloadImages = function() {
    for (var i = 0; i < arguments.length; i++) {
        jQuery("<img>").attr("src", arguments[i]);
    }
}

$(document).ready(function() {
    $("a[rel^='prettyPhoto']").prettyPhoto({
        animationSpeed: 'normal',
        padding: 40,
        opacity: 0.35,
        showTitle: false,
        allowresize: true,
        theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
        hideflash: false
    });

    if ($("#customerLogin")) {
        $("#customerLogin").mouseover(function() { changeImage(this, "images/btn_customerlogin_over.png"); });
        $("#customerLogin").mouseout(function() { changeImage(this, "images/btn_customerlogin.png"); });
        $("#customerLogin").mousedown(function() { changeImage(this, "images/btn_customerlogin_on.png"); });
    }

    if ($("#signup")) {
        $("#signup").mouseover(function() { changeImage(this, "images/btn_signup_over.png"); });
        $("#signup").mouseout(function() { changeImage(this, "images/btn_signup.png"); });
        $("#signup").mousedown(function() { changeImage(this, "images/btn_signup_on.png"); });
    }

    $.preloadImages("images/btn_customerlogin_on.png", "images/btn_customerlogin_over.png",
        "images/btn_signup_on.png", "images/btn_signup_over.png"
    );
    
    var loc = location.pathname;
    if ((loc.indexOf("personal") != -1) || (loc.indexOf("result") != -1) || (loc.indexOf("business") != -1)) {
        $('div.features li a').cluetip({
            cluetipClass: 'rounded',
            dropShadow: false, // set to false if you don't want the drop-shadow effect on the clueTip
            sticky: true,
            ajaxCache: false,
            local: false, // Whether to use content from the same page for the clueTip's body
            arrows: true, // if true, displays arrow on appropriate side of clueTip.
            splitTitle: '|' // A character used to split the title attribute into the clueTip title and divs
        });
    }
});