﻿
function getBMI(form) {
    var vw = document.forms[0].weight.value;
    var vhf = document.forms[0].HeightFeet.value;
    var vhi = document.forms[0].HeightInches.value;

    if (vw != "" && vhf != "0") {
        var w = vw * 1;
        var HeightFeetInt = vhf * 1;
        var HeightInchesInt = vhi * 1;
        HeightFeetConvert = HeightFeetInt * 12;
        h = HeightFeetConvert + HeightInchesInt;
        var displaybmi = 0;
        displaybmi = (Math.round((w * 703) / (h * h)));
        if (isNaN(displaybmi) == false) {
            document.forms[0].BMI.value = displaybmi;
        }
        else {
            document.forms[0].BMI.value = "";

        }

    }

}

function CommaFormatted(amt) {
    var amount = amt;
    var delimiter = ","; // replace comma if desired
    var a = amount.split('.', 2)
    var d = a[1];
    var i = parseInt(a[0]);
    if (isNaN(i)) { return ''; }
    var minus = '';
    if (i < 0) { minus = '-'; }
    i = Math.abs(i);
    var n = new String(i);
    var a = [];
    while (n.length > 3) {
        var nn = n.substr(n.length - 3);
        a.unshift(nn);
        n = n.substr(0, n.length - 3);
    }
    if (n.length > 0) { a.unshift(n); }
    n = a.join(delimiter);
    if (d.length < 1) { amount = n; }
    else { amount = n + '.' + d; }
    amount = minus + amount;
    return amount;
}

function findSavings() {
    exp = $("#foodexpenses").attr("value");
    $("#expense").html(exp);
    exp = (exp * 60) * .50;
    $("#amountSaved").html("$" + exp);

    $("#savings").show();
}
$(document).ready(function () {

    //$("#savings").hide();

    //Click event on Chat Panel + Alert Panel	
    $(".alertpanel a").click(function () { //If clicked on the first link of #chatpanel and #alertpanel...

        if ($(this).next(".subpanel").is(':visible')) { //If subpanel is already active...
            $(this).next(".subpanel").hide(); //Hide active subpanel
            $("#footpanel li a").removeClass('active'); //Remove active class on the subpanel trigger

        }
        else { //if subpanel is not active...
            $(".subpanel").hide(); //Hide all subpanels
            $(this).next(".subpanel").toggle(); //Toggle the subpanel to make active
            $("#footpanel li a").removeClass('active'); //Remove active class on all subpanel trigger
            $(this).toggleClass('active'); //Toggle the active class on the subpanel trigger
        }
        return false; //Prevent browser jump to link anchor
    });

    //Click event outside of subpanel
    $(document).click(function () { //Click anywhere and...
        //		$(".subpanel").hide(); //hide subpanel
        //		$("#footpanel li a").removeClass('active'); //remove active class on subpanel trigger
    });
    $('.subpanel ul').click(function (e) {
        e.stopPropagation(); //Prevents the subpanel ul from closing on click
    });
    $('.alertpanel #closeControl').click(function () {
        $(".subpanel").hide(); //hide subpanel
        $("#footpanel li a").removeClass('active'); //remove active class on subpanel trigger
    });


    //Delete icons on Alert Panel
    $(".alertpanel li").hover(function () {
        $(this).find("a.delete").css({ 'visibility': 'visible' }); //Show delete icon on hover
    }, function () {
        $(this).find("a.delete").css({ 'visibility': 'hidden' }); //Hide delete icon on hover out
    });






});

function display_div(divid) {
    var id = document.getElementById(divid);
    alert(id.style.display);
    if (id.style.display == "none") {

    }
    else {


    }

}
