/*
##############################################################################################
##############################################################################################
##########                                                                           #########
########## THIS CODE IS COPYRIGHT OF IWOLRD CREATIVE - http://www.iworldcreative.com #########
########## USE OR REPLICATION OF THIS CODE IN WHOLE OR IN PART WITHOUT THE PRIOR     #########
########## WRITTEN PERMISSION OF IWORLD CREATIVE IS STRICTLY FORBIDDEN.              #########
##########                                                                           #########
##############################################################################################
##############################################################################################
*/



function CheckNumeric(TheElement, TheName, TheValue) 
/*-------------------------------------------------------------------------
  Validate whether the value the user has entered is numeric and
  display an appropriate message if it is not numeric.
-----------------------------------------------------------------------*/
{
	if (isNaN(TheValue))
	{
		alert(TheName + " must be numeric. Please enter a number.");
		TheElement.value = "";
		TheElement.focus();
		return false;
	}
	else
	{	
		calculateIT() ;
		return true;
	}
}


function calculateIT() {

var intSection = document.frmDiameter.section.value ;
var  intAspect = document.frmDiameter.aspect.value ;
var     intRim = document.frmDiameter.rim.value ;


var  intSidewallOD = (intSection*intAspect)/100*2 ;
var       intRimOD = (intRim * 25.4)
var     intTotalOD = intSidewallOD + intRimOD; 
var intRollingCirc = intTotalOD * 3.1426

//remove decimal places
 intSidewallOD = parseInt(intSidewallOD, 0) ;
  	  intRimOD = parseInt(intRimOD, 0) ;
    intTotalOD = parseInt(intTotalOD, 0) ;
intRollingCirc = parseInt(intRollingCirc, 0) ;
   
//add values to form
document.frmDiameter.sidewallod.value = intSidewallOD ;
document.frmDiameter.rimod.value = intRimOD ;
document.frmDiameter.totalod.value = intTotalOD ;


document.frmDiameter.rollingcirc.value = intRollingCirc ;
document.frmDiameter.rollingcirccm.value = intRollingCirc / 10 ;
document.frmDiameter.rollingcircm.value = intRollingCirc / 1000 ;

return true ;
}


function FP_swapImg() {//v1.0
 var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
 n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
 elm.$src=elm.src; elm.src=args[n+1]; } }
}

function FP_preloadImgs() {//v1.0
 var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
 for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
}

function FP_getObjectByID(id,o) {//v1.0
 var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
 else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
 if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
 for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
 f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
 for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
 return null;
}
