function checkfittings(fittingsvalue,fittingsobj)  {
if  (  ! isNaN(fittingsvalue)
&&  (fittingsvalue != Number.POSITIVE_INFINITY)
&&  (fittingsvalue != Number.NEGATIVE_INFINITY) ) 
   { return true ;
}
else
{ alert("You have entered 'Text' in the Fittings Field! \r                              |-|-|-|-|-|\rThe system requires that you enter a numeric value.")  ;
fittingsobj.focus()  ;
fittingsobj.value = "" ;
return false ;
}
  // EoIf
}  // EoFn checkfittings

function checkwatts(wattsvalue,wattsobj)  {
if  (  ! isNaN(wattsvalue)
&&  (wattsvalue != Number.POSITIVE_INFINITY)
&&  (wattsvalue != Number.NEGATIVE_INFINITY) )
   { return true ;
}
else
{ alert("You have entered 'Text' in the Watts Field! \r                              |-|-|-|-|-|\rThe system requires that you enter a numeric value.")  ;
wattsobj.focus()  ;
wattsobj.value = ""  ;
return false ;
}     // EoIf
}  // EoFn wattsdesign




 function cdc()  {
fit = eval (document.formamps.fittings.value);
watt = eval (document.formamps.watts.value) ;
ph = eval (document.formamps.phase.value) ;
vo = eval (document.formamps.v.value) ;
lampvolt = eval (document.formamps.voltage.value) ;
vol = eval (1000 / vo) ;
leftover = eval (fit % ph);
workout = fit - leftover
if (lampvolt == 1) {single()} ;
if (lampvolt == 2) {three()} ;
if ((lampvolt == 2) && (ph == 1)) {pup()}
}  // EoFn checkdesign

function pup()  {
document.formamps.dans.value = ""  ;
document.formamps.kva.value = ""  ;
alert("You cannot use 415 volt lamps on a single phase supply.\r Change Phasing back to 3 Phase then alter the voltage.")
} // EoFn clearanswer

function single()  {
if (leftover == 0) {ans = eval(fit * watt / ph * vol / 1000)} ;
if (leftover == 1) {ans = eval(workout * watt / ph * vol / 1000)+(1 * watt  * vol / 1000)} ;
if (leftover == 2) {ans = eval(workout * watt / ph * vol / 1000)+(1 * watt * vol / 1000)} ;
kva1 = fit * watt / 1000 ;
decimal2 (ans) ;
}  // EoFn single

function three()  {
if (leftover == 0) {ans = eval(fit * watt / ph * vol / 1000)} ;
if (leftover == 1) {ans = eval(workout * watt / ph * vol / 1000)+(1 * watt / 2 * vol / 1000)} ;
if (leftover == 2) {ans = eval(workout * watt / ph * vol / 1000)+(1 * watt * vol / 1000)} ;
kva1 = fit * watt / 1000 ;
decimal2 (ans) ;
}  // EoFn three

// something = Math.floor(fit / 3)    returns Integer Number

function firstfocus()   {
document.formamps.fittings.value = "";
document.formamps.fittings.focus();
document.formamps.watts.value = "" ;
document.formamps.phase.value = "3" ;
document.formamps.v.value = "230";
document.formamps.voltage.value = "2" ;
document.formamps.dans.value = "" ;
document.formamps.kva.value = ""  ;
document.formvolt.length.value="" ;
document.formvolt.design.value="";
document.formvolt.type.value="2" ;
document.formvolt.answer1.value="" ;
document.formvolt.answer2.value="" ;
document.formvolt.answer3.value="" ;
document.formvolt.answer4.value="" ;
document.formvolt.answer5.value="" ;
document.formvolt.answer6.value="" ;
document.formvolt.answer7.value="" ;
document.formvolt.answer8.value="" ;
document.formvolt.answer9.value="" ;
document.formvolt.answer10.value="" ;
document.formvolt.answer11.value="" ;
document.formvolt.answer12.value="" ;
document.formvolt.answer13.value="" ;
document.formvolt.answer14.value="" ;
document.formvolt.answer15.value="" ;
document.formvolt.answer16.value="" ;
document.formvolt.answer17.value="" ;
}  // EoFn firstfocus

function resetformamps()   {
document.formamps.fittings.value = "";
document.formamps.fittings.focus();
document.formamps.watts.value = "" ;
document.formamps.phase.value = "3" ;
document.formamps.v.value = "230";
document.formamps.voltage.value = "2" ;
document.formamps.dans.value = "" ;
document.formamps.kva.value = ""  ;
}
// EoFn resetformamps


function resetformvolt()  {
document.formvolt.length.value="" ;
document.formvolt.design.value="";
document.formvolt.type.value="2" ;
document.formvolt.answer1.value="" ;
document.formvolt.answer2.value="" ;
document.formvolt.answer3.value="" ;
document.formvolt.answer4.value="" ;
document.formvolt.answer5.value="" ;
document.formvolt.answer6.value="" ;
document.formvolt.answer7.value="" ;
document.formvolt.answer8.value="" ;
document.formvolt.answer9.value="" ;
document.formvolt.answer10.value="" ;
document.formvolt.answer11.value="" ;
document.formvolt.answer12.value="" ;
document.formvolt.answer13.value="" ;
document.formvolt.answer14.value="" ;
document.formvolt.answer15.value="" ;
document.formvolt.answer16.value="" ;
document.formvolt.answer17.value="" ;
}
// EnOf  resetformvolt


//  Round to 2 decimal point function
function decimal2(x)   {
ans = Math.round(x*100)/100 ;
document.formamps.dans.value = ans ;
document.formvolt.design.value= ans;
decimal1 (kva1)
 }// EoFn 

function decimal1(y)   {
kva1 = Math.round(y*100)/100 ;
document.formamps.kva.value = kva1 ;
}




function isempty1(obj)  {
   if (obj.value == "")  {
  alert("Hey, what are you doing? \rGive me something to work out,\rEnter a number in the " + obj.name + " field!") ;
 obj.focus() ;
return false ;  }
return true
} // EoFn isempty


function checkamps(che)  {
if  ( (isempty1(che.fittings) )
&& (checkfittings(che.fittings.value,che.fittings))
&&  (isempty1(che.watts) )
&& (checkwatts(che.watts.value,che.watts))
) // end of test
{  cdc()  ; }
}  // EoFn checkamps(che)






function checklength(lengthvalue,lengthobj)  {
if  (  ! isNaN(lengthvalue)
&&  (lengthvalue != Number.POSITIVE_INFINITY)
&&  (lengthvalue != Number.NEGATIVE_INFINITY) ) 
   { return true ;
}
else
{ alert("You have entered 'Text' in the Cable Length Field! \r                              |-|-|-|-|-|\rThe system requires that you enter a numeric value.")  ;
lengthobj.focus()  ;
lengthobj.value = "" ;
return false ;
}
  // EoIf
}  // EoFn checklength

function checkdesign(designvalue,designobj)  {
if  (  ! isNaN(designvalue)
&&  (designvalue != Number.POSITIVE_INFINITY)
&&  (designvalue != Number.NEGATIVE_INFINITY) )
   { return true ;
}
else
{ alert("You have entered 'Text' in the Design Current Field! \r                              |-|-|-|-|-|\rThe system requires that you enter a numeric value.")  ;
designobj.focus()  ;
designobj.value = ""  ;
return false ;
}     // EoIf
}  // EoFn checkdesign

//  Round to 2 decimal point function
function dec1(x)   {
total1 = Math.round(x*100)/100 ;
if (total1 >spec) {total1 = "Over Spec"} ;
document.formvolt.answer1.value = total1 ;
}// EoFn 

function dec2(x)   {
total2 = Math.round(x*100)/100 ;
if (total2 >spec) {total2 = "Over Spec"} ;
document.formvolt.answer2.value = total2
} // EoFn 

function dec3(x)   {
total3 = Math.round(x*100)/100 ;
if (total3 >spec) {total3 = "Over Spec"} ;
document.formvolt.answer3.value = total3
}// EoFn 

function dec4(x)   {
total4 = Math.round(x*100)/100 ;
if (total4 >spec) {total4 = "Over Spec"} ;
document.formvolt.answer4.value = total4
} // EoFn 

function dec5(x)   {
total5 = Math.round(x*100)/100 ;
if (total5 >spec) {total5 = "Over Spec"} ;
document.formvolt.answer5.value = total5
}// EoFn 

function dec6(x)   {
total6 = Math.round(x*100)/100 ;
if (total6 >spec) {total6 = "Over Spec"} ;
document.formvolt.answer6.value = total6
} // EoFn 

function dec7(x)   {
total7 = Math.round(x*100)/100 ;
if (total7 >spec) {total7 = "Over Spec"} ;
document.formvolt.answer7.value = total7
}// EoFn 

function dec8(x)   {
total8 = Math.round(x*100)/100 ;
if (total8 >spec) {total8 = "Over Spec"} ;
document.formvolt.answer8.value = total8
} // EoFn 

function dec9(x)   {
total9 = Math.round(x*100)/100 ;
if (total9 >spec) {total9 = "Over Spec"} ;
document.formvolt.answer9.value = total9
}// EoFn 

function dec10(x)   {
total10 = Math.round(x*100)/100 ;
if (total10 >spec) {total10 = "Over Spec"} ;
document.formvolt.answer10.value = total10
} // EoFn 

function dec11(x)   {
total11 = Math.round(x*100)/100 ;
if (total11 >spec) {total11 = "Over Spec"} ;
document.formvolt.answer11.value = total11
}// EoFn 

function dec12(x)   {
total12 = Math.round(x*100)/100 ;
if (total12 >spec) {total12 = "Over Spec"} ;
document.formvolt.answer12.value = total12
} // EoFn 

function dec13(x)   {
total13 = Math.round(x*100)/100 ;
if (total13 >spec) {total13 = "Over Spec"} ;
document.formvolt.answer13.value = total13
}// EoFn 

function dec14(x)   {
total14 = Math.round(x*100)/100 ;
if (total14 >spec) {total14 = "Over Spec"} ;
document.formvolt.answer14.value = total14
} // EoFn 

function dec15(x)   {
total15 = Math.round(x*100)/100 ;
if (total15 >spec) {total15 = "Over Spec"} ;
document.formvolt.answer15.value = total15
}// EoFn 

function dec16(x)   {
total16 = Math.round(x*100)/100 ;
if (total16 >spec) {total16 = "Over Spec"} ;
document.formvolt.answer16.value = total16
} // EoFn

function dec17(x)   {
total17 = Math.round(x*100)/100 ;
if (total17 >spec) {total17 = "Over Spec"} ;
document.formvolt.answer17.value = total17
} // EoFn

function isempty(obj)  {
   if (obj.value == "")  {
  alert("Hey, what are you doing? \rGive me something to work out,\rEnter a number in the " + obj.name + " field!") ;
 obj.focus() ;
return false ;  }
return true
} // EoFn isempty


function checkform(ch)  {
if  ( (isempty(ch.length) )
&& (checklength(ch.length.value,ch.length))
&&  (isempty(ch.design) )
&& (checkdesign(ch.design.value,ch.design))
) // end of test
{   calc()  ; }
}  // EoFn checkform(ch)

// --------------------------------------------------------
// Assign Variables for 2 Core SWA 70 degrees 1.5mm to 400mm  a to q respectively
a = 29, b = 18, c = 11, d = 7.3, e = 4.4, f = 2.8, g = 1.75, h = 1.25, i = .94 
j = .65, k = .50, l = .41, m = .34, n = .29, o = .24, p = .21, q = .185

// a = 29, b = 18, c = 11, d = 7.3, e = 4.4, f = 2.8, g = 1.75, h = 1.25, i = .93     Original  r Specs
// j = .63, k = .47, l = .38, m = .3, n = .25, o = .19, p = .1555, q = .115
                    
// Assign Variables for 3/4 Core SWA 70 degrees 1.5mm to 400mm  a1 to q1 respectively
a1 = 25, b1 = 15, c1= 9.5, d1 = 6.4, e1 = 3.8, f1 = 2.4, g1 = 1.5, h1 = 1.1, i1 = .81 
j1 = .57, k1 = .43, l1= .35, m1 = .29, n1 = .25, o1 = .21, p1 = .185, q1 = .160

// a1 = 25, b1 = 15, c1= 9.5, d1 = 6.4, e1 = 3.8, f1 = 2.4, g1 = 1.5, h1 = 1.1, i1 = .8   Original r Specs
// j1 = .55, k1 = .41, l1= .33, m1 = .26, n1 = .21, o1 = .165, p1 = .135, q1 = .1

// Assign Variables for 2 Core XPLE  90 degrees 1.5mm to 400mm  a2 to q2 respectively
a2 = 31, b2 = 19, c2= 12, d2 = 7.9, e2 = 4.7, f2 = 2.9, g2 = 1.90, h2 = 1.35, i2 = 1 
j2 = .69, k2 = .52, l2= .42, m2 = .35, n2 = .29, o2 = .24, p2 = .21, q2 = .190

// a2 = 31, b2 = 19, c2= 12, d2 = 7.9, e2 = 4.7, f2 = 2.9, g2 = 1.85, h2 = 1.35, i2 = .99     Original r Specs
// j2 = .67, k2 = .5, l2= .4, m2 = .32, n2 = .26, o2 = .2, p2 = .16, q2 = .13

// Assign Variables for 3/4 Core XPLE 90 degrees 1.5mm to 400mm  a3 to q3 respectively
a3 = 27, b3 = 16, c3= 10, d3 = 6.8, e3 = 4, f3 = 2.5, g3 = 1.65, h3 = 1.15, i3 = .87
j3 = .60, k3 = .45, l3= .37, m3 = .30, n3 = .26, o3 = .21, p3 = .185, q3 = .165

// a3 = 27, b3 = 16, c3= 10, d3 = 6.8, e3 = 4, f3 = 2.5, g3 = 1.6, h3 = 1.15, i3 = .86     Original r Specs
// j3 = .59, k3 = .43, l3= .34, m3 = .28, n3 = .22, o3 = .175, p3 = .14, q3 = .115

//----------------------------------------------------------

function calc()   {
cablelength = eval (document.formvolt.length.value) ;
amps = eval (document.formvolt.design.value) ;
cabletype = eval (document.formvolt.type.value) ;

phasetype = eval (document.formamps.phase.value) ;
if (phasetype == 1)   {
spec = 6.9 ;
}
else
{
spec = 12 ;
} // EoIf phasetype

if (cabletype == 1)   {
core2() ;
}
if (cabletype == 2)   {
core34() ;
}
if (cabletype == 3)   {
core2x() ;
}
if (cabletype == 4)   {
core34x() ;
}

} //EoFn Calc

//---------------------------------------------------2 Core SWA
function core2()  { 
   {
data1 = eval (cablelength * amps * a /1000) ;
dec1(data1) ;
}
  {
data2 = eval (cablelength * amps * b /1000) ;
dec2(data2) ;
}
  {
data3 = eval (cablelength * amps * c /1000) ;
dec3(data3) ;
}
{
data4 = eval (cablelength * amps * d /1000) ;
dec4(data4) ;
}
  {
data5 = eval (cablelength * amps * e /1000) ;
dec5(data5) ;
}
   {
data6 = eval (cablelength * amps * f /1000) ;
dec6(data6) ;
}
  {
data7 = eval (cablelength * amps * g /1000) ;
dec7(data7) ;
}
   {
data8 = eval (cablelength * amps * h /1000) ;
dec8(data8) ;
}
   {
data9 = eval (cablelength * amps * i /1000) ;
dec9(data9) ;
}
  {
data10 = eval (cablelength * amps * j /1000) ;
dec10(data10) ;
}
   {
data11 = eval (cablelength * amps * k /1000) ;
dec11(data11) ;
}
   {
data12 = eval (cablelength * amps * l /1000) ;
dec12(data12) ;
}
 {
data13 = eval (cablelength * amps * m /1000) ;
dec13(data13) ;
}
   {
data14 = eval (cablelength * amps * n /1000) ;
dec14(data14) ;
}
  {
data15 = eval (cablelength * amps * o /1000) ;
dec15(data15) ;
}
  {
data16 = eval (cablelength * amps * p /1000) ;
dec16(data16) ;
}
  {
data17 = eval (cablelength * amps * q /1000) ;
dec17(data17) ;
}

} //EoFn 2c SWA
//----------------------------------------------------3/4 Core SWA
function core34()   {

   {
data1 = eval (cablelength * amps * a1 /1000) ;
dec1(data1) ;
}
  {
data2 = eval (cablelength * amps * b1 /1000) ;
dec2(data2) ;
}
  {
data3 = eval (cablelength * amps * c1 /1000) ;
dec3(data3) ;
}
{
data4 = eval (cablelength * amps * d1 /1000) ;
dec4(data4) ;
}
  {
data5 = eval (cablelength * amps * e1 /1000) ;
dec5(data5) ;
}
   {
data6 = eval (cablelength * amps * f1 /1000) ;
dec6(data6) ;
}
  {
data7 = eval (cablelength * amps * g1 /1000) ;
dec7(data7) ;
}
   {
data8 = eval (cablelength * amps * h1 /1000) ;
dec8(data8) ;
}
   {
data9 = eval (cablelength * amps * i1 /1000) ;
dec9(data9) ;
}
  {
data10 = eval (cablelength * amps * j1 /1000) ;
dec10(data10) ;
}
   {
data11 = eval (cablelength * amps * k1 /1000) ;
dec11(data11) ;
}
   {
data12 = eval (cablelength * amps * l1 /1000) ;
dec12(data12) ;
}
 {
data13 = eval (cablelength * amps * m1 /1000) ;
dec13(data13) ;
}
   {
data14 = eval (cablelength * amps * n1 /1000) ;
dec14(data14) ;
}
  {
data15 = eval (cablelength * amps * o1 /1000) ;
dec15(data15) ;
}
  {
data16 = eval (cablelength * amps * p1 /1000) ;
dec16(data16) ;
}
  {
data17 = eval (cablelength * amps * q1 /1000) ;
dec17(data17) ;
}


} //EoFn
//-------------------------------------------------------------2 Core XPLE
function core2x()   {


{
data1 = eval (cablelength * amps * a2 /1000) ;
dec1(data1) ;
}
  {
data2 = eval (cablelength * amps * b2 /1000) ;
dec2(data2) ;
}
  {
data3 = eval (cablelength * amps * c2 /1000) ;
dec3(data3) ;
}
{
data4 = eval (cablelength * amps * d2 /1000) ;
dec4(data4) ;
}
  {
data5 = eval (cablelength * amps * e2 /1000) ;
dec5(data5) ;
}
   {
data6 = eval (cablelength * amps * f2 /1000) ;
dec6(data6) ;
}
  {
data7 = eval (cablelength * amps * g2 /1000) ;
dec7(data7) ;
}
   {
data8 = eval (cablelength * amps * h2 /1000) ;
dec8(data8) ;
}
   {
data9 = eval (cablelength * amps * i2 /1000) ;
dec9(data9) ;
}
  {
data10 = eval (cablelength * amps * j2 /1000) ;
dec10(data10) ;
}
   {
data11 = eval (cablelength * amps * k2 /1000) ;
dec11(data11) ;
}
   {
data12 = eval (cablelength * amps * l2 /1000) ;
dec12(data12) ;
}
 {
data13 = eval (cablelength * amps * m2 /1000) ;
dec13(data13) ;
}
   {
data14 = eval (cablelength * amps * n2 /1000) ;
dec14(data14) ;
}
  {
data15 = eval (cablelength * amps * o2 /1000) ;
dec15(data15) ;
}
  {
data16 = eval (cablelength * amps * p2 /1000) ;
dec16(data16) ;
}
  {
data17 = eval (cablelength * amps * q2 /1000) ;
dec17(data17) ;
}

} //EoFn
//------------------------------------------------------------------------3/4 Core XPLE
function core34x()   {


{
data1 = eval (cablelength * amps * a3 /1000) ;
dec1(data1) ;
}
  {
data2 = eval (cablelength * amps * b3 /1000) ;
dec2(data2) ;
}
  {
data3 = eval (cablelength * amps * c3 /1000) ;
dec3(data3) ;
}
{
data4 = eval (cablelength * amps * d3 /1000) ;
dec4(data4) ;
}
  {
data5 = eval (cablelength * amps * e3 /1000) ;
dec5(data5) ;
}
   {
data6 = eval (cablelength * amps * f3 /1000) ;
dec6(data6) ;
}
  {
data7 = eval (cablelength * amps * g3 /1000) ;
dec7(data7) ;
}
   {
data8 = eval (cablelength * amps * h3 /1000) ;
dec8(data8) ;
}
   {
data9 = eval (cablelength * amps * i3 /1000) ;
dec9(data9) ;
}
  {
data10 = eval (cablelength * amps * j3 /1000) ;
dec10(data10) ;
}
   {
data11 = eval (cablelength * amps * k3 /1000) ;
dec11(data11) ;
}
   {
data12 = eval (cablelength * amps * l3 /1000) ;
dec12(data12) ;
}
 {
data13 = eval (cablelength * amps * m3 /1000) ;
dec13(data13) ;
}
   {
data14 = eval (cablelength * amps * n3 /1000) ;
dec14(data14) ;
}
  {
data15 = eval (cablelength * amps * o3 /1000) ;
dec15(data15) ;
}
  {
data16 = eval (cablelength * amps * p3 /1000) ;
dec16(data16) ;
}
  {
data17 = eval (cablelength * amps * q3/1000) ;
dec17(data17) ;
}

} //EoFn


