Calculate
Voltage
Breaker amps
Power usage W

Difference:

function querystring_calc() { var q = window.location.search.substr(1); if (q.length > 1) { var spl = q.split("&"); for (var x = 0; x < spl.length; x++) { var spl2 = spl[x].split("="); if (spl2.length == 2) { if (spl2[0].length > 0 && spl2[1].length > 0) { if (spl2[0].substr(0,4).toLowerCase() == "res_" || spl2[0].substr(0,4).toLowerCase() == "txt_") { document.getElementById(spl2[0].toLowerCase()).value = spl2[1]; } else { document.getElementById(spl2[0].toLowerCase()).selectedIndex = document.getElementById(spl2[1].toLowerCase()).index; } } } changeType(); } } } function linkToPage() { var pathName = window.location.pathname; var gettype = document.getElementById('calc').options[document.getElementById('calc').selectedIndex].id; var page_url= "http://www.digitalrebellion.com" + pathName; page_url += "?calc=" + gettype; switch (gettype) { case 'diff': page_url += "&country=" + document.getElementById('country').options[document.getElementById('country').selectedIndex].id; page_url += "&txt_breaker=" + document.getElementById('txt_breaker').value; page_url += "&txt_total=" + document.getElementById('txt_total').value; break; case 'breaker': page_url += "&country=" + document.getElementById('country').options[document.getElementById('country').selectedIndex].id; page_url += "&txt_total=" + document.getElementById('txt_total').value; break; case 'voltage': page_url += "&txt_breaker=" + document.getElementById('txt_breaker').value; page_url += "&txt_total=" + document.getElementById('txt_total').value; break; } window.location.href = page_url; } function calculate(gettype, voltage, breaker, power) { voltage = parseFloat(voltage); breaker = parseFloat(breaker); power = parseFloat(power); switch (gettype) { case 'diff': var circuitLimit = breaker * voltage; var recommendedLimit = circuitLimit * 0.8; var load = Math.round(((power / circuitLimit) * 100),2); if (power > circuitLimit) { var vFinal = '' + (circuitLimit - power) + ' W
' + load + '% load
'; } else if (power > recommendedLimit) { var vFinal = '' + (circuitLimit - power) + ' W
' + load + '% load

Within 20% safety margin'; } else { var vFinal = '' + (circuitLimit - power) + ' W
' + load + '% load
'; } document.getElementById('output').innerHTML = "Difference: " + vFinal; // document.getElementById('morestats').innerHTML = "Circuit limit: " + circuitLimit + " W
Recommended limit: " + recommendedLimit + " W"; break; case 'breaker': breaker = power / voltage; var recBreaker = ((power + (power * 0.2)) / voltage); document.getElementById('output').innerHTML = "Minimum breaker size: " + Math.round(breaker) + " A
Recommended breaker size: " + Math.round(recBreaker) + " A"; // document.getElementById('morestats').innerHTML = "Unrounded breaker size: " + breaker + " A
Unrounded recommended breaker size: " + recBreaker + " A"; break; case 'voltage': voltage = power / breaker; document.getElementById('output').innerHTML = "Voltage: " + Math.round(voltage) + " V"; // document.getElementById('morestats').innerHTML = "Unrounded voltage: " + voltage; break; } } function formatNum(nStr) { nStr += ''; x = nStr.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2'); } return x1 + x2; } function recalculate() { var gettype = document.getElementById('calc').options[document.getElementById('calc').selectedIndex].id; var getvoltage = document.getElementById('country').options[document.getElementById('country').selectedIndex].id.substr(1,3); var getbreaker = document.getElementById('txt_breaker').value; var gettotal = document.getElementById('txt_total').value; calculate(gettype, getvoltage, getbreaker, gettotal); } function changeType() { var calc = document.getElementById('calc').options[document.getElementById('calc').selectedIndex].id; switch (calc) { case "diff": document.getElementById('div_voltage').className = 'row'; document.getElementById('div_breaker').className = 'row'; document.getElementById('div_total').className = 'row'; break; case "breaker": document.getElementById('div_voltage').className = 'row'; document.getElementById('div_breaker').className = 'hide'; document.getElementById('div_total').className = 'row'; break; case "voltage": document.getElementById('div_voltage').className = 'hide'; document.getElementById('div_breaker').className = 'row'; document.getElementById('div_total').className = 'row'; break; } recalculate(); } function IsNumeric(sText) { var ValidChars = "0123456789."; var IsNumber=true; var Char; if (sText.length == 0) return false; for (i = 0; i < sText.length && IsNumber == true; i++) { Char = sText.charAt(i); if (ValidChars.indexOf(Char) == -1) { IsNumber = false; } } return IsNumber; } function validate_text(getobj) { var gettext = document.getElementById(getobj).value; if (IsNumeric(gettext) && gettext.length > 0) { resetTextBox(getobj); recalculate(); document.getElementById(getobj).focus(); } else { document.getElementById(getobj).className="textbox_red"; document.getElementById(getobj).focus(); } } function resetTextBox(getobj) { document.getElementById(getobj).className="textbox_black"; document.getElementById(getobj).focus(); }