var _material;
var _volts;
var _cmas;
var voltage;

function calculate(form){
	
	for (var i=0; i<=form.material.length; i++) 
	{
         if (form.material[i].selected) 
		 {        	
         	_material=eval(form.material[i].value);
         	break	
	     }
     }
	
	for (var i=0; i<=form.volts.length; i++)
	{ 
	    if (form.volts[i].selected) 
		{ 	
         	_volts=eval(form.volts[i].value);
			switch(i) 
			{		
			  case 0:
				voltage=120;
				break;
			  case 1:
				voltage=240;
				break;  
			  case 2:
				voltage=208;
				break;  
			  case 3:
				voltage=120;
				break;  
			  case 4:
				voltage=277;
				break;  
			  case 5:
				voltage=480;
				break;  
			  case 6:
				voltage=277;
				break;  
			  case 7:
				voltage=24;
				break;  
			   case 8:
				voltage=48;
				break; 
			   case 9:
				voltage=12;
				break;    
			}
         break;       	
	   }
     }     
     
	for (var i=0; i<=form.cmas.length; i++) 
	{
         if (form.cmas[i].selected)
		 {         	
         	_cmas=eval(form.cmas[i].value);         	
         	break	
	     }
     }         
     form.circularma.value=_cmas

     if (Math.round((((2*_material*(eval(form.distance.value))*(eval(form.amperes.value)))/_cmas)*_volts)*10)/10<=voltage)
     {
	     form.voltdrop.value=Math.round((((2*_material*(eval(form.distance.value))*(eval(form.amperes.value)))/_cmas)*_volts)*10)/10;
     }
     else 
	 {     
     	form.voltdrop.value=voltage;
     }
     	form.vdpercent.value=(Math.round(((eval(form.voltdrop.value))/voltage)*1000))/10;
        form.voltload.value=voltage-(eval(form.voltdrop.value));
     }     

function _calculate(){
	switch (document.form.lens.options[document.form.lens.selectedIndex].value){
		case'1':Lh=67;Lw=90;break;
		case'2':Lh=55;Lw=74;break;
		case'3':Lh=32;Lw=42;break;
		case'4':Lh=24;Lw=32;break;
		case'5':Lh=17;Lw=22;break;
		case'6':Lh=11;Lw=15;
	}
		distance = document.form.distance.options[document.form.distance.selectedIndex].value;
	if (distance!=0) 
	{
		pi = Math.PI;
		hang=(Lh/2)*(pi/180);
		wang=(Lw/2)*(pi/180);
		height=(Math.round(Math.tan(hang)*distance*2*10))/10;
		width=(Math.round(Math.tan(wang)*distance*2*10))/10;
		document.form.vert.value=height	+ " feet";
		document.form.horiz.value=width  + " feet";
	}
	else
	{
		document.form.vert.value="";
		document.form.horiz.value="";
	}
}