﻿function srabcb_flash_calculators() {
    // Data for Flash
    var flashvars = {};
    var params = {
        quality: "best",
        scale: "noscale",
        bgcolor: "#eeeeee",
        fullscreen: "true",
        allowfullscreen: "true",
        wmode: "transparent",
        smoothing: "false"
    };

    if (userHasFlashVersion) {
        // Render Flash  
        swfobject.embedSWF("/_ui/srabcbsha08/swf/calculator_bmi.swf", "bodyMassIndexSwf", "100%", "370", flashVersion, false, flashvars, params);
        swfobject.embedSWF("/_ui/srabcbsha08/swf/calculator_cos.swf", "costOfSmokingSwf", "100%", "370", flashVersion, false, flashvars, params);
        swfobject.embedSWF("/_ui/srabcbsha08/swf/calculator_w2h.swf", "waistToHipSwf", "100%", "370", flashVersion, false, flashvars, params);
    }
    else {
        $('#bodyMassIndexSwf, #costOfSmokingSwf, #waistToHipSwf').empty().append(noFlashContent);
    }
}

$(document).ready(function() {
    // Calculators: Page Tabs
    $('#calculatorTabs .tabs .tab').unbind().click(function() {
        $('#calculatorTabs .tabs .tab').removeClass('active');
        var selectedIndex = $(this).addClass('active').prevAll('.tab').length;
        $('#calculatorTabs .content .bgInner .step').removeClass('active').eq(selectedIndex).addClass('active');
        return false;
    });
    $('#calculatorTabs .tabs .tab').hover(function() {
        $(this).addClass('hover');
    }, function() {
        $(this).removeClass('hover');
    });

    // Calculators: Allow linking to a specific tab
    var pos = window.location.href.search(/#/);
    if (pos != -1) {
        var hash = window.location.href.substring(pos + 1);
        if (hash.substring(0, 3) == 'tab') {
            $('#calculatorTabs .tabs .tab:eq(' + (hash.substring(3) - 1) + ')').click();
        }
    }

    // Flash
    srabcb_flash_calculators();
});