function roundNumber(num, dec) {
    var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
    return result;
}
jQuery(function ($) {
    if ($(".phone").length > 0) {
        $(".phone").mask("(999) 999-9999");
    }
    if ($('.currency').length > 0) {
        $('.currency').autoNumeric({ aSep: ',', aDec: '.', aSign: '$', vMax: '199.99' })
    }
});

$(document).ready(function () {



    var $dialog = $('<div id="testtesttest"></div>')
                 .html(' ')
                 .dialog({
                     autoOpen: false,
                     modal: true,
                     width: 360,
                     title: 'Basic Dialog'
                 });
    var $dialogLoading = $('<div id="loadindialogdiv"><br><br>Loading....</div>')
                .html('<br><br><div align=center><img src=/content/img/loading.gif /></div>')
                .dialog({
                    autoOpen: false,
                    modal: true,
                    width: 360,
                    title: 'Loading....'
                });

    var $dialogWIDE = $('<div id="testtesttest"></div>')
                 .html(' ')
                 .dialog({
                     autoOpen: false,
                     modal: true,
                     width: 850,
                     title: 'Basic Dialog'
                 });
    var $dialogWIDELoading = $('<div id="loadindialogdiv"><br><br>Loading....</div>')
                .html('<br><br><div align=center><img src=/content/img/loading.gif /></div>')
                .dialog({
                    autoOpen: false,
                    modal: true,
                    width: 850,
                    title: 'Loading....'
                });
    $('.modalLink').click(function () {
        var url = this.href;
        var title = this.title;
        $dialogLoading.dialog('open');
        $dialog.load(url, {}, function (responseText, textStatus, XMLHttpRequest) {
            $dialogLoading.dialog('close');
            $dialog.dialog('open');
            $dialog.dialog({
                title: title
            });
        }
                    );

        // prevent the default action, e.g., following a link
        return false;
    });
    


    



    /*
    * Form Elements
    */
    $("select, input:checkbox, input:text, input:password, input:radio, input:file, textarea").not("#test").not(".nouniform").uniform();



    /*
    * Closable Alert Boxes
    */
    $('span.hide').click(function () {
        $(this).parent().slideUp();
    });



    /*
    * Toolbox
    */
    $('.toolbox-action').click(function () {
        $('.toolbox-content').fadeOut();
        $('.hide').fadeOut();
        $(this).next().fadeIn();

        return false;
    });

    $('.close-toolbox').click(function () {
        $(this).parents('.toolbox-content').fadeOut();
        $('.hide').fadeOut();
        $('#popRecharge').hide();
        $('#popRechargeActions').hide();
    });

    $(".toolbox-content").bind("clickoutside", function (event) {
        $('#qPhoneRecharge').val('');
        $('#qamount').val('');
        $('#txtToPhone').val('');
        //$('#Access1').val('Spanish');
        //$('#Access2').val('English');
        $('#popRecharge').hide();
        $('#popRechargeActions').hide();
        $(this).fadeOut();
    });

   


    /*
    * Closable Content Boxes
    */
    $('.block-border .block-header span').click(function () {
        if ($(this).hasClass('closed')) {
            $(this).removeClass('closed');
        } else {
            $(this).addClass('closed');
        }

        $(this).parent().parent().children('.block-content').slideToggle();
    });



    /*
    * Tooltips
    */
    $('a[rel=tooltip]').tipsy({ fade: true });
    $('a[rel=tooltip-bottom]').tipsy({ fade: true });
    $('a[rel=tooltip-right]').tipsy({ fade: true, gravity: 'w' });
    $('a[rel=tooltip-top]').tipsy({ fade: true, gravity: 's' });
    $('a[rel=tooltip-left]').tipsy({ fade: true, gravity: 'e' });

    $('a[rel=tooltip-html]').tipsy({ fade: true, html: true });

    $('div[rel=tooltip]').tipsy({ fade: true });

    $.ajaxSetup({
        cache: false
    });
});























