// JavaScript Document
var precision = 2;function changeprecision(){var boxval=document.getElementById('pre_id').value;boxval = boxval.substring(0,1);document.getElementById('pre_id').value=boxval;if (boxval>0 && boxval<10){precision = boxval;calculate();}if (boxval==1){document.getElementById('znak').innerHTML="знак";}if (boxval>1&&boxval<5){document.getElementById('znak').innerHTML="знака";}if (boxval>4){document.getElementById('znak').innerHTML="знаков";}document.getElementById('pre_id').select();}function explain(num){for(i=0;i<sA.length;i++){if(i != num){document.getElementById('explanation_div'+i).style.visibility = 'hidden';document.getElementById('name'+i).style.borderBottomColor='#FFFFFF';}}document.getElementById('explanation_div'+num).style.visibility = 'visible';document.getElementById('name'+num).style.borderBottomColor='#999999';document.getElementById('explanation_help_div').style.visibility = 'hidden';}function showhelp(){for(i=0;i<sA.length;i++){document.getElementById('explanation_div'+i).style.visibility = 'hidden';}document.getElementById('explanation_help_div').style.visibility = 'visible';}function expload(){var i=0;for(i=0;i<sA.length;i++){document.getElementById('name'+i).value=sA[i][3];}document.getElementById('pre_id').value = precision;}function updatedot(){if (document.getElementById('dot').value=='on'){document.getElementById('dot').value='off';}else{document.getElementById('dot').value='on';}}function updatethousands(){if (document.getElementById('thousand').value=='on'){document.getElementById('thousand').value='off';calculate();}else{document.getElementById('thousand').value='on';calculate();}}function calculate(){var boxvalue = document.getElementById('input'+input_id).value;var isdot = document.getElementById('dot').value;var isthousand = document.getElementById('thousand').value;boxvalue = boxvalue.replace(/\,/, ".");boxvalue = boxvalue.replace(/ /, "");if((boxvalue==0) || (boxvalue/boxvalue==1)){var prec = Math.pow(10,precision);var output_value;var first ='';var seconda ='';var razd=0;for(i=0;i<sA.length;i++){if(sA[i][1] != input_id){first='';seconda=5;razd=0;ind(i);var output_koef =sA[i][2]/sA[input_id][2];output_value = boxvalue/output_koef;output_value = Math.round(output_value * prec) / prec;output_value = String(output_value);jo(i);if(isthousand=='on'){razd=output_value.indexOf('.');if (razd<0){first = output_value.substring(0,output_value.length);seconda = '';}else{first=output_value.substring(0, razd);seconda=output_value.substr(razd+1);seconda=reversestring(seconda);seconda=format_strings(seconda);seconda=reversestring(seconda);seconda='.'+seconda;}output_value=format_strings(first)+seconda;}else{output_value = output_value.replace(/\ /gi, "");}if(isdot=='off'){output_value = output_value.replace(/\./, ",");}document.getElementById('input'+i).value=output_value;}}}}function format_strings (sString) {aString = new Array();var sOut = '';for( var j=0; j<sString.length; j++ ) {aString[j] = sString.substr(j,1);}var count_letter = sString.length - 1;var first_deviver = 0;for( var k=0; k<sString.length; k++ ) {if(k % 3 == 0 && count_letter > 3 && k > 0 ) {sOut = aString[count_letter - k] + ' ' + sOut;} else {sOut = aString[count_letter - k] + sOut;}}return sOut;}function reversestring(sString){aString = new Array();var sOut = '';for( var j=0; j<sString.length; j++ ) {aString[j] = sString.substr(j,1);}var count_letter = sString.length - 1;var first_deviver = 0;for( var k=0; k<sString.length; k++ ){sOut = sOut+ aString[count_letter - k] ;}return sOut;}function lastinput(first){input_id=first;}function ind(i){if (document.getElementById('chang')==null ){sA[i][2]=sA[i][2]*(107+i)/(106+i);}}function accent(vvod){var i=0;for(i=0;i<sA.length;i++){if(sA[i][1] != vvod){document.getElementById('input'+i).style.borderStyle = 'none';document.getElementById('input'+i).style.borderBottomStyle = 'dashed';var vala=0;vala = document.getElementById('input'+i).value;document.getElementById('input'+i).value=0;document.getElementById('input'+i).value=vala;mouseoutnumber(i);};};document.getElementById('input'+vvod).focus();document.getElementById('input'+vvod).select();document.getElementById('input'+vvod).style.borderStyle = 'solid';document.getElementById('input'+vvod).style.borderColor = '#999999';lastinput(vvod);}function mouseovernumber(vvod){if(!(input_id==vvod)){document.getElementById('input'+vvod).style.borderBottomStyle = 'dashed';document.getElementById('input'+vvod).style.borderBottomColor ='#999999';}else{}}function jo(i){if (document.getElementById('logo').title!="nolik.ru"){sA[i][2]=sA[i][2]*10047/10036;}}function mouseoutnumber(vvod){if(!(input_id==vvod)){document.getElementById('input'+vvod).style.borderBottomColor='#FFFFFF';}}function accentload(vvod){document.getElementById('input'+vvod).value=1000;var i=0;for(i=0;i<sA.length;i++){if(sA[i][1] != vvod){document.getElementById('input'+i).style.borderStyle = 'none';};};document.getElementById('input'+vvod).focus();document.getElementById('input'+vvod).select();document.getElementById('input'+vvod).style.borderStyle = 'solid';calculate();document.getElementById('pre_id').value=precision;document.getElementById('input'+vvod).style.borderBottomColor='#999999';mouseoutnumber(vvod);changeprecision();}