/*****************************************
(C) http://www.calculator.net all right reserved.  
*****************************************/
function showquickobjmsg(A,B,C){if(B){A="<font color=red>"+A+"</font>"}gObj(C).innerHTML=A}function calcarithmetic(A){YV=trimAll(gObj("afirstnumber").value+"");Ff=trimAll(gObj("afactor").value+"");jg=trimAll(gObj("athenumber").value+"");if(!isNumber(YV)){showquickobjmsg("the first number need to be numeric",true,A);return }else{if(!isNumber(Ff)){showquickobjmsg("common difference need to be numeric",true,A);return }else{if(!isNumber(jg)){showquickobjmsg("the number to obtain need to be numeric",true,A);return }}}YV=parseFloat(YV);Ff=parseFloat(Ff);jg=parseInt(jg);if(jg<1){showquickobjmsg("the number to obtain need to be positive",true,A);return }mv="sequence: "+YV+", ";for(Wj=2;Wj<10;Wj++){Hi=YV+Ff*(Wj-1);mv+=Hi+", "}IR=YV+Ff*(jg-1);kr=jg*(YV*2+(jg-1)*Ff)/2;mv+=" ...<br>"+jg+"<sup>th</sup> value: <font color=green><b>"+IR+"</b></font>";mv+="<br>the sum of all numbers until the "+jg+"<sup>th</sup>: <font color=green><b>"+kr+"</b></font>";showquickobjmsg(mv,false,A)}function calcgeometric(A){nv=trimAll(gObj("gfirstnumber").value+"");gJ=trimAll(gObj("gfactor").value+"");bQ=trimAll(gObj("gthenumber").value+"");if(!isNumber(nv)){showquickobjmsg("the first number need to be numeric",true,A);return }else{if(!isNumber(gJ)){showquickobjmsg("ommon ratio need to be numeric",true,A);return }else{if(!isNumber(bQ)){showquickobjmsg("the number to obtain need to be numeric",true,A);return }}}nv=parseFloat(nv);gJ=parseFloat(gJ);bQ=parseInt(bQ);if(bQ<1){showquickobjmsg("the number to obtain need to be positive",true,A);return }mv="sequence: "+nv+", ";for(Wj=2;Wj<10;Wj++){Hi=nv*Math.pow(gJ,(Wj-1));mv+=Hi+", "}IR=nv*Math.pow(gJ,(bQ-1));kr=0;if(gJ==1){kr=nv*bQ}else{kr=nv*(Math.pow(gJ,(bQ))-1)/(gJ-1)}mv+=" ...<br>"+bQ+"<sup>th</sup> value: <font color=green><b>"+IR+"</b></font>";mv+="<br>the sum of all numbers until the "+bQ+"<sup>th</sup>: <font color=green><b>"+kr+"</b></font>";if((gJ<1)&&(gJ>-1)){mv+="<br>the sum of this infinite geometric series: <font color=green><b>"+(nv/(1-gJ))+"</b></font>"}showquickobjmsg(mv,false,A)}function calcfibonacci(A){wn=trimAll(gObj("fthenumber").value+"");if(!isNumber(wn)){showquickobjmsg("the number to obtain need to be numeric",true,A);return }wn=parseInt(wn);if(wn<1){showquickobjmsg("the number to obtain need to be positive",true,A);return }lM=1;mS=1;IR=0;kr=2;if(wn==1){IR=1;kr=1}else{if(wn==2){IR=1;kr=2}else{for(Wj=3;Wj<=wn;Wj++){IR=lM+mS;kr+=IR;lM=mS;mS=IR}}}mv="sequence: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...";mv+="<br>"+wn+"<sup>th</sup> value: <font color=green><b>"+IR+"</b></font>";mv+="<br>the sum of all numbers until the "+wn+"<sup>th</sup>: <font color=green><b>"+kr+"</b></font>";showquickobjmsg(mv,false,A)};