$(document).ready(function() {
    $.localScroll();

    $("a[rel^='zoom']").prettyPhoto({
       social_tools: ''
      });

    $("a[rel^='map']").prettyPhoto({
        custom_markup: '<div id="map_canvas" style="width:500px; height:450px"></div>',
        changepicturecallback: function(){ initialize(); }
     });

    $("#howdy").howdyDo({
	action	    : 'push',
	effect	    : 'slide',
	easing	    : 'easeInOutExpo',
	duration    :  650,
	keepState   : false,
	closeAnchor : '<img src="graphics/close-16x16.png" border=0 />'
    });


    $("a[rel^='hyatt']").prettyPhoto({
       social_tools: '',
       theme: 'dark_rounded',
       deeplinking: false,
       default_width: 651,
     });

});


function cal_bmi(lbs, ins) {
    h2 = ins * ins;
    bmi = lbs / h2 * 703
    f_bmi = Math.floor(bmi);
    diff = bmi - f_bmi;
    diff = diff * 10;
    diff = Math.round(diff);
    if (diff == 10) {
        // Need to bump up the whole thing instead
        f_bmi += 1;
        diff = 0;
    }
    bmi = f_bmi + "." + diff;
    return bmi;
}

function CheckInt(w) {
    if (isNaN(parseInt(w))) {
        return false;
    } else if (w < 0) {
        return false;
    } else {
        return true;
    }
}

function ShowBMI() {
    SetPositionToCenter("BMICalcHolder", 150, 250);
    $("#BMICalcHolder").fadeIn("normal", function() {
        $("#outerHolder").fadeTo("slow", 0.25);
    });
}

function CloseBMI() {
    $("#BMICalcHolder").fadeOut("normal", function() {
        $("#outerHolder").fadeTo("slow", 1);
    });
}

function ValidateBMIInput() {
    var returnValue = true;
    if(!CheckInt( $("#bmiHeightFeet").val() ))
        returnValue = false;
    if (!CheckInt($("#bmiHeightInches").val()))
        returnValue = false;
    if (!CheckInt($("#bmiWeight").val()))
        returnValue = false;        
    return returnValue;
    
}

function CalculateBMI() {
    if (ValidateBMIInput()) {
        var heightFeet = parseInt($("#bmiHeightFeet").val());
        var heightInches = parseInt($("#bmiHeightInches").val());
        var weight = parseInt($("#bmiWeight").val());
        var inches = (heightFeet * 12) + heightInches;
        var BMI = cal_bmi(weight, inches);
        $('.done').fadeIn('slow');
        $("#bmiTitle").html("Your BMI:");
        $("#bmiResult").html(BMI);
    }
    else {
        alert("Please enter your height and weight.");
    }
}


function ClearField(object, text) {
    if (document.getElementById(object.id).value == text) {
        document.getElementById(object.id).style.color = "black";
        document.getElementById(object.id).value = "";
    }
}

function RestoreField(object, text) {
    if (document.getElementById(object.id).value == "") {
        document.getElementById(object.id).style.color = "gray";
        document.getElementById(object.id).value = text;
    }
}


function ToggleInsurance(paymentID, insuranceID) {
    var value = document.getElementById(paymentID).value;
    if (value.indexOf("Insurance") > -1) {
        $("#insuranceHolder").slideDown("fast");
        ValidatorEnable(document.getElementById(insuranceID), true);
    }
    else {
        $("#insuranceHolder").slideUp("fast");
        ValidatorEnable(document.getElementById(insuranceID), false);
    }
}

function ToggleMarketingOther(value) {
    if (value.indexOf("Other") > -1) {
        $("#marketingOther").slideDown("fast");
    }
    else {
        $("#marketingOther").slideUp("fast");
    }
}


function ToggleSeminarList(IDFormField_Attend_Seminar_0) {
    var checked = $("#" + IDFormField_Attend_Seminar_0).attr("checked");
    if (checked) {
        $("#seminarDropdownHolder").slideDown("normal");
    }
    else {
        $("#seminarDropdownHolder").slideUp("normal");
    }
}

function SetSeminarList(checked) {

    $(document).ready(function() {
        if(checked == "True") {
            $("#seminarDropdownHolder").show();
        }
        else {
            $("#seminarDropdownHolder").hide();
        }
    });
}

