<!-- Hide from old browsers

// *****************************************************
// Format a number with 0 digits after the .
function format0Digit(amount) {
var txt = "";
var w = amount + 0.001;
txt = w + "";
if(txt.indexOf('.')>=0) { txt = txt + "00"; } else { txt = txt + ".00"; }
txt = txt.substring(0,txt.indexOf('.'));
return txt;
}

// *****************************************************
// Format a number with 1 digits after the .
function format1Digit(amount) {
var txt = "";
var w = amount + 0.001;
txt = w + "";
if(txt.indexOf('.')>=0) { txt = txt + "00"; } else { txt = txt + ".00"; }
txt = txt.substring(0,txt.indexOf('.')+2);
return txt;
}

// *****************************************************
// Replace characters in a string with another character
function replaceCharacters(conversionString,inChar,outChar) {
var convertedString = conversionString.split(inChar);
convertedString = convertedString.join(outChar);
return convertedString;
}

// *****************************************************
// Convert a string into a number. Accept k for 1000 and M for 1000'000
function convertToNumber(conversionString) {
var result = conversionString;
result = replaceCharacters(result,"%","");
result = replaceCharacters(result,String.fromCharCode(39),"");
result = replaceCharacters(result,"k","000");
result = replaceCharacters(result,"M","000000");
return result;
}

// *****************************************************
// Reformat a number using k or Mio
function reformatNumber(conversionString) {
var result = conversionString;
if (result > 1000000)
{ result = format1Digit(result / 1000000)+"Mio"; } else
{ if (result > 10000) result = format0Digit(result / 1000)+"k"; } ;
return result;
}

// *****************************************************
// Show a DIV object
function showDiv(objDivID) {
document.getElementById(objDivID).className = 'show';
}

// *****************************************************
// Hide a DIV object
function hideDiv(objDivID) {
document.getElementById(objDivID).className = 'hide';
}

function check_entries() {
var amount = 0;
var total_cost = 0;
var txt = "";

var revenue = 0;
var subscribers = 0;
var revenue_per_subscriber = 0;
var churn_rate = 0;
var churners = 0;
var churn_events_costs = 0;
var churn_replace_costs = 0;
var churn_costs = 0;
var churn_cost_perc = 0;

revenue            = convertToNumber(document.cost_calculator.num_revenue.value);
subscribers        = convertToNumber(document.cost_calculator.num_subscribers.value);
churn_rate         = convertToNumber(document.cost_calculator.num_churn_rate.value);
cost_churn_event   = convertToNumber(document.cost_calculator.num_cost_churn_event.value);
cost_churn_replace = convertToNumber(document.cost_calculator.num_cost_replace_churner.value);

revenue_per_subscriber = revenue / subscribers;
document.cost_calculator.how_much_revenue_per_subscriber.value = reformatNumber(revenue_per_subscriber);

churners = subscribers * churn_rate / 100 * 12;
document.cost_calculator.total_churners.value = reformatNumber(churners);

churn_events_costs = churners * cost_churn_event;
document.cost_calculator.total_churn_events_costs.value = reformatNumber(churn_events_costs);

churn_replace_costs = churners * cost_churn_replace;
document.cost_calculator.total_churn_replace_costs.value = reformatNumber(churn_replace_costs);

churn_costs = churn_events_costs + churn_replace_costs;
document.cost_calculator.total_churn_costs.value = reformatNumber(churn_costs);

total_churn_cost = churn_costs;
document.cost_results.result_total_churn_cost.value = reformatNumber(total_churn_cost);
total_savings = total_churn_cost * 0.05;
document.cost_results.total_savings.value = reformatNumber(total_savings);

if(total_churn_cost == 0) { hideDiv('next_step') } else { showDiv('next_step') } ;
if(total_churn_cost == 0) { showDiv('calculate_first') } else { hideDiv('calculate_first') } ;


churn_costs_perc = churn_costs / revenue * 100;
churn_costs_perc = format1Digit(churn_costs_perc);
document.cost_calculator.total_churn_costs_perc.value = reformatNumber(churn_costs_perc) + "%";


return false;
}



// Unhide -->
