function initUSEACluetips() {
    jQuery('.USEACluetip, .TableLayout_EAPCalculator td[eventcluetip=1], .USEAClueTip').cluetip({     
        splitTitle: '|', 
        showTitle: false,
        cursor: 'pointer'
    });
}

jQuery(document).ready(function() {
    //Cluetips   
    jQuery('.USEACluetip, .TableLayout_EAPCalculator td[eventcluetip=1], .USEAClueTip').cluetip({
        splitTitle: '|',
        showTitle: false,
        cursor: 'pointer'
    });

    //Admin menu
    jQuery("#dnn_menuHalfPayNav_RadMenu1_m14").closest("li").attr('id', 'admin-menu-li');
    var li = jQuery("#admin-menu-li").html();
    jQuery("#admin-menu-li").remove();
    jQuery("#admin-menu-container").html('<ul class="admin-menu-ul"><li></li></ul>');
    jQuery("#admin-menu-container ul li").html(li);
    jQuery("#admin-menu-container .slide ul").append('<li class="item"><a class="link" href="/Registered/HalfPayDealerMgr/"><img class="leftImage" src="/images/icon_users_16px.gif" alt=""><span class="text">Dealer Manager</span></a>');


    //contact us page
    var last_value;
    jQuery(".contact-form input,.contact-form textarea").click(function() {
        var val = jQuery(this).val();
        last_value = val;
        if (val == 'first name' || val == 'last name' || val == 'email' || val == 'Message') {
            jQuery(this).val('');
        }
    }).blur(function() {
        var val = jQuery(this).val();
        if (val == '') jQuery(this).val(last_value);
    });



    //Tabs
    jQuery(".jQueryTabs").tabs({ selected: 0 });

    jQuery(".jQueryTabs #tabs-1 a.green-btn").click(function() {
        jQuery(".jQueryTabs").tabs('select', 1);
        return false;
    });
    jQuery(".jQueryTabs #tabs-2 a.green-btn").click(function() {
        jQuery(".jQueryTabs").tabs('select', 2);
        return false;
    });
    jQuery(".jQueryTabs #tabs-3 a.green-btn").click(function() {
        jQuery(".jQueryTabs").tabs('select', 3);
        return false;
    });
    jQuery(".jQueryTabs #tabs-4 a.green-btn").click(function() {
        jQuery(".jQueryTabs").tabs('select', 4);
        return false;
    });


    jQuery(".banner .slides").cycle({
        fx: 'fade',
        pause: true,
        pager: '.banner .pager',
        timeout: 9000,
        pagerAnchorBuilder: function(idx, slide) {
            idx++;
            var xclass = jQuery("#pgr" + idx).attr('class');
            var content = jQuery("#pgr" + idx).html();

            switch (idx) {
                case 1:
                    color = "#50715C";
                    break;

                case 2:
                    color = "#505C72";
                    break;

                case 3:
                    color = "#AA8E66";
                    break;

                case 4:
                    color = "#734F5B";
                    break;
            }

            return '<a href="' + color + '" class="' + xclass + '" id="pager-' + idx + '"><div class="' + xclass + '">' + content + '</div></a>';
        }
    });

    jQuery(".banner .pager a").hover(function() {
        jQuery(this).addClass('hover');
    }, function() {
        jQuery(this).removeClass('hover');
    });


    jQuery(".banner .pager a").click(function() {

    });



    jQuery(".admintools .relative-container").hover(function() {

        jQuery('.admintools .link-container .slide').fadeIn();

    }, function() {

        jQuery('.admintools .link-container .slide').fadeOut();
    });



    //CALCULATOR
    jQuery(".calculator").append('<div class="calc-error" style="color: #548968; margin-top:10px; font-size:11px">You must enter all numbers.</div>');
    jQuery(".calc-error").hide();

    jQuery(".calculator input[type='submit']").not('.dealerEnrollCustomerButton').click(function() {
        var amount = jQuery(".calculator input[name='principal']").val();
        var interest = jQuery(".calculator input[name='apr']").val();
        var period = jQuery(".calculator input[name='term']").val();

        if (isNaN(amount) || isNaN(interest) || isNaN(period)) {
            jQuery('.calc-error').fadeIn();
        }
        else {
            window.location = "/Loan_Calculator/?amount=" + amount + "&interest=" + interest + "&period=" + period;
        }

        return false;
    });

    jQuery(".calculator input[name='principal']").click(function() {
        var amount = jQuery(this).val();
        if (amount == 'principle amount e.g. $30,000') jQuery(this).val('');
    }).blur(function() {
        var amount = jQuery(this).val();
        if (amount == '') jQuery(this).val('principle amount e.g. $30,000');
    });

    jQuery(".calculator input[name='apr']").click(function() {
        var interest = jQuery(this).val();
        if (interest == 'APR %') jQuery(this).val('');
    }).blur(function() {
        var interest = jQuery(this).val();
        if (interest == '') jQuery(this).val('APR %');
    });

    jQuery(".calculator input[name='term']").click(function() {
        var period = jQuery(this).val();
        if (period == 'term mo.') jQuery(this).val('');
    }).blur(function() {
        var period = jQuery(this).val();
        if (period == '') jQuery(this).val('term mo.');
    });

    jQuery("a[name='517']").remove();







    //content vertical slider
    jQuery(".collapsing-blurb").wrap('<div class="blurb-wrapper">').wrap('<div class="blurb-content">').css({
        "height": "auto",
        "float": "none",
        "left": "0px",
        "top": "0px"
    });

    var initial_height = jQuery(".blurb-content").height();
    var content_height = jQuery(".collapsing-blurb").height();


    if (content_height > initial_height) {
        jQuery(".blurb-wrapper").append('<p class="readmore"><a href="#" class="blurb-expand" onClick="return false">Read more</a></p>');

        jQuery(".blurb-expand").live("click", function() {
            jQuery(this).removeClass("blurb-expand").addClass("blurb-retract").html('Less');

            var height = jQuery(".collapsing-blurb").height();
            height = height + 20;

            jQuery(".blurb-content").stop().animate({
                height: height + 'px'
            }, 500);
        });

        jQuery(".blurb-retract").live("click", function() {
            jQuery(this).removeClass("blurb-retract").addClass("blurb-expand").html('Read more');

            jQuery(".blurb-content").stop().animate({
                height: initial_height + 'px'
            }, 500);
        });
    }




    jQuery("#accordion").accordion({ active: false });


});
