// JavaScript Document
<!--
the5Image = new Image(); the5Image.src = "../images/select/5.gif";
the10Image = new Image(); the10Image.src = "../images/select/10.gif";
the15Image = new Image(); the15Image.src = "../images/select/15.gif";
the20Image = new Image(); the20Image.src = "../images/select/20.gif";
the30Image = new Image(); the30Image.src = "../images/select/30.gif";
the40Image = new Image(); the40Image.src = "../images/select/40.gif";
the50Image = new Image(); the50Image.src = "../images/select/50.gif";
the60Image = new Image(); the60Image.src = "../images/select/60.gif";
the80Image = new Image(); the80Image.src = "../images/select/80.gif";
the100Image = new Image(); the100Image.src = "../images/select/100.gif";

var theVolumeA = new Array(30,40,60,80,100,0);
var theVolumeB = new Array(5,10,15,20,30,40);
var theVolumeC = new Array(5,10,20,30,40,50);
var theRates = new Array('A','B','C');
var lastRadioNumber = 0;
var lastRadioRateNumber = 0;
var lastType = 'A';

ron = new Image(); ron.src = "../images/select/radioon.gif";
roff = new Image(); roff.src = "../images/select/radiooff.gif";
wlPic = new Image(); wlPic.src = "../images/select/wall.gif";;
cePic = new Image(); cePic.src = "../images/select/ceiling.gif";;
wdPic = new Image(); wdPic.src = "../images/select/window.gif";;
idPic = new Image(); idPic.src = "../images/select/duct.gif";
rfPic = new Image(); rfPic.src = "../images/select/roof.gif";

function selectApplication() {
	for (var o=0; o<document.fan.airrate.options.length; o++)
		if (document.fan.application.options[document.fan.application.selectedIndex].value == document.fan.airrate.options[o].value) {
			document.fan.airrate.selectedIndex = o;
			clickType(document.fan.airrate.options[o].value);
		}
	
	document.getElementById('airrate_display').innerHTML = document.fan.airrate.options[document.fan.airrate.selectedIndex].text + " <a href='#' onClick='allowChangeAirRate()'>(change)</a>"
}

function allowChangeAirRate() {
	document.getElementById('airrate_select').style.display='inline'; 
	document.getElementById('airrate_display').style.display='none';
}

function radioButton(number){
    if(lastRadioNumber != number){document['radio' + number].src = ron.src;}
    if(lastRadioNumber >= 0 && lastRadioNumber != number){document['radio' + lastRadioNumber].src = roff.src;}
    lastRadioNumber = number;
    document.fan.roomvolume.value = eval('theVolume' + lastType + '[number]');
}

function reloadValues() {
	var vol = document.fan.roomvolume.value;
	updateRoomVolumes();
	theArray = eval('theVolume' + lastType);
	for(i = 0;i<theArray.length;i++)
		if (theArray[i] == vol)
			radioButton(i);
}

function updateRoomVolumes() {
	if (document.fan.airrate.selectedIndex > 0)
		clickType(document.fan.airrate.options[document.fan.airrate.selectedIndex].value);
}

function calculateWindow() {
	var popup = window.open('calculate.html','Calculate_Volume','screenX=200,screenY=200,top=200,left=200,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizeable=0,width=450,height=450');
}

/*
function radioRateButton(number){
    if(lastRadioRateNumber != number){document['radioRate' + number].src = ron.src;}
    if(lastRadioRateNumber >= 0 && lastRadioRateNumber != number){document['radioRate' + lastRadioRateNumber].src = roff.src;}
    lastRadioRateNumber = number;
    clickType(theRates[number]);
    document.fan.airrate.value = theRates[number];
}
*/
function clickType(type){
   theArray = eval('theVolume' + type);
   lastType = type;
   for(i = 0;i<theArray.length;i++){
     if(theArray[i] != 0){
         document['value'+i].src = eval('the' + theArray[i] + 'Image.src');
         document['radio'+i].src = '../images/select/radiooff.gif';
     }
     else{
         document['value'+i].src = '../images/spacer.gif';
         document['radio'+i].src = '../images/spacer.gif';
     }
   }
   document['radio0'].src = '../images/select/radioon.gif';
   document.fan.roomvolume.value = theArray[0];
   lastRadioNumber = 0;
}

function changeMountPic(){
    if (document.fan.mounttype.options[document.fan.mounttype.selectedIndex].value == "") {document.mountpic.src = '../images/preview.gif';}
    else {document.mountpic.src = eval(document.fan.mounttype.options[document.fan.mounttype.selectedIndex].value + 'Pic.src');}
}

function preSubmitForm(){
   if (document.fan.airrate.options[document.fan.airrate.selectedIndex].value == ""){
	  alert("You haven't selected a required Air Rate yet!");
	  return false;
   }
   if 
	  (document.fan.mounttype.options[document.fan.mounttype.selectedIndex].value == ""){ 
   	   alert("You haven't selected a Mounting Arrangement yet!");
       return false;
	}
	
	document.fan.appname.value = document.fan.application.options[document.fan.application.selectedIndex].text;
									
	return true;
}

//-->
