function formatAsMoney(mnt){
    mnt -= 0;
    mnt = (Math.round(mnt * 100)) / 100;
    return (mnt == Math.floor(mnt)) ? mnt + '.00' : ((mnt * 10 == Math.floor(mnt * 10)) ? mnt + '0' : mnt);
}

function updateboxes(rate, days, hours, fixtures){
    var halideRate = rate * days * hours * 365 / 7000 * 465;
    var fiveRate = rate * days * hours * 365 / 7000 * 236;
    var eightRate = rate * days * hours * 365 / 7000 * 190;
    var totalHours = days * hours * 365 / 7;
    $("#Halide").attr({
        value: "$" + formatAsMoney(halideRate)
    });
    $("#TFive").attr({
        value: "$" + formatAsMoney(fiveRate)
    });
    $("#TEight").attr({
        value: "$" + formatAsMoney(eightRate)
    });
    $("#TotalHours").attr({
        value: totalHours
    });
    $("#TFiveSavings").attr({
        value: "$" + formatAsMoney(halideRate - fiveRate)
    });
    $("#TEightSavings").attr({
        value: "$" + formatAsMoney(halideRate - eightRate)
    });
    $("#TFiveSavingsTotal").attr({
        value: "$" + formatAsMoney(fixtures * (halideRate - fiveRate))
    });
    $("#TEightSavingsTotal").attr({
        value: "$" + formatAsMoney(fixtures * (halideRate - eightRate))
    });
    $("#GreenSmartCalculator").submit();
}

$(document).ready(function(){

    var rate = $('#Rate').fieldValue();
    var days = $('#Days').fieldValue();
    var hours = $('#Hours').fieldValue();
    
    // bind 'myForm' and provide a simple callback function 
    $('#GreenSmartCalculator').ajaxForm({
        // target identifies the element(s) to update with the server response 
        target: '#Results',
        
        // success identifies the function to invoke when the server response 
        // has been received; here we apply a fade-in effect to the new content 
        success: function(){
            $('#Results').fadeIn('slow');
        }
    });
    
    
    $('.Banner').cycle({
        fx: 'fade',
        speed: 3000
    });
    
    $("a.Box").fancybox({
		'titleShow'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});
    
    
});
