function showHide(divid,imgSrc) 
{
	try
	{
		var tableid = document.getElementById(divid);
		var imgEl = document.getElementById(imgSrc);
		
		if (tableid) {
			if (tableid.style.display=='none')
			{
				tableid.style.display = 'block';
							
				if (imgSrc.length>0)
					imgEl.src='/images/minus.gif';			
			}
			else
			{
				tableid.style.display = 'none';
				
				if (imgSrc.length>0)
					imgEl.src='/images/plus.gif';
			}
		}
	}
	catch(e)
	{
		alert("showHide: " + e.description);
	}
}

function SelectAll(objListBox, blnSelect,additionalFunction)
{

	var i;
	
	for (i = 0; i < objListBox.length; i++) 
	{
		if(objListBox.options[i].value!=-1)
			{
			objListBox.options[i].selected = blnSelect;
			}
	}
	if (additionalFunction)
		{
		additionalFunction();
		}
	
}	

function submitForm(cDevice,cMode,cStep,cDevicePhase,objName,LoadID)
{
//alert (cDevice+","+cMode+","+cStep+","+cDevicePhase+","+objName+","+LoadID);
	try
	{
		if(cDevice)
		{
			document.ConfigByDevice.cDevice.value=cDevice;
		}
		if(cMode)
		{
			document.ConfigByDevice.cMode.value=cMode;
		}
		
		if(cStep)
		{
			document.ConfigByDevice.cStep.value=cStep;
		}
		if(LoadID)
		{
			document.ConfigByDevice.cLoadID.value=LoadID;
		}
		if(cDevicePhase)
		{
			if(objName)
			{
				//if changing manf or equip in edit mode, need to
				//setcMode to add so it doesn't break everything
				if(document.ConfigByDevice.cMode.value==1)
				{
					document.ConfigByDevice.cMode.value=0;
				}
				//if we are selecting the manufacturer or the manufacturer equipment 
				//and the selected value is unknown output the enter  manufacturer/device other
				if(objName.selectedIndex==1)
				{
					cDevicePhase=3;
				}
			
			}
			document.ConfigByDevice.cDevicePhase.value=cDevicePhase;
		}
		//if the device has been submitted to be added/edited to 
		//the solution validate all the data available
		if(document.ConfigByDevice.cMode.value==3)
			{
			if (ValidateForm())
				{
				document.ConfigByDevice.submit();
				}
			}
		else
			{
			document.ConfigByDevice.submit();
			}
	}
	catch(e)
	{
		alert("submitForm: " + e.description);
	}
}
function submitForm2(cDevice,cMode,cStep,cDevicePhase,objName,LoadID)
{
	if(cDevice)
		{
			document.ConfigByDevice.cDevice.value=cDevice;
		}
		if(cMode)
		{
			document.ConfigByDevice.cMode.value=cMode;
		}
		
		if(cStep)
		{
			document.ConfigByDevice.cStep.value=cStep;
		}
		if(LoadID)
		{
			document.ConfigByDevice.cLoadID.value=LoadID;
		}
		if(cDevicePhase)
		{
			if(objName)
			{
				//if changing manf or equip in edit mode, need to
				//setcMode to add so it doesn't break everything
				if(document.ConfigByDevice.cMode.value==1)
				{
					document.ConfigByDevice.cMode.value=0;
				}
				//if we are selecting the manufacturer or the manufacturer equipment 
				//and the selected value is unknown output the enter  manufacturer/device other
				if(objName.selectedIndex==1)
				{
					cDevicePhase=3;
				}
			
			}
			document.ConfigByDevice.cDevicePhase.value=cDevicePhase;
		}
		//if the device has been submitted to be added/edited to 
		//the solution validate all the data available
		if(document.ConfigByDevice.cMode.value==3)
			{
			//if (ValidateForm())
			if (1==1)
				{
				document.ConfigByDevice.submit();
				}
			}
		else
			{
			document.ConfigByDevice.submit();
			}
}
function ValidateForm()
{
	try
	{
		with(document.ConfigByDevice)
		{
			//the following fields are for server and workstation validation only
			if(cDevice.value==1||cDevice.value==2||cDevice.value==7)
			{
				if(ChassisTypeID.selectedIndex==0)
				{
					alert("Please select the Chassis Type this device");
					ChassisTypeID.focus();
					return (false);
				}
					
				if(MonitorTypeID.selectedIndex==0)
				{
					alert("Please select the Monitor for this device");
					MonitorTypeID.focus();
					return (false);
				}
				if(HardDriveTypeID.selectedIndex==0)
				{
					alert("Please select the Predominant Hard Drive Type for this  device");
					HardDriveTypeID.focus();
					return (false);
				}
				if(ProcessorTypeID.selectedIndex==0)
				{
					alert("Please select the Processor Type for this device");
					ProcessorTypeID.focus();
					return (false);
				}
			}
			if(cDevice.value==2)
			{
				if(VoltID.selectedIndex==0)
				{
					alert("Please select the Voltage for this device");
					VoltID.focus();
					return (false);
				}
				if (UnlistedEquipmentName.value.search(/^\s*$/) != -1)
				{
					alert ("Please enter a Name for this Work Station")
					UnlistedEquipmentName.focus();
					return (false);
				}
			}
			else
			{
				if (CompanyID.selectedIndex==1)
				{
					if(UnlistedCompanyName.value.search(/^\s*$/) != -1)
					{
						alert ("Please enter a Manufacturer for this Device")
						UnlistedCompanyName.focus();
						return (false);
					}
					if(UnlistedEquipmentName.value.search(/^\s*$/) != -1)
					{
						alert ("Please enter a Name for this Device")
						UnlistedEquipmentName.focus();
						return (false);
					}
				}
				else 
				{
					if (FromLoadTemplateID.selectedIndex==1)
					{
						if(UnlistedEquipmentName.value.search(/^\s*$/) != -1)
						{
							alert ("Please enter a Name for this Device")
							UnlistedEquipmentName.focus();
							return (false);
						}
					}
				}
					//ensure we have a value for the wattsVA field
				if(cDevice.value!=1)
				{
					if(cDevice.value!=7)
					{

						if(PowerUsage.value.search(/^((\d+(\.\d*)?)|((\d*\.)?\d+))$/)  ==-1)
						{
						   alert("Please enter a numerical value for the Power  Usage");
						   PowerUsage.focus();
						   return (false);
						}
					}
				}
				for(i=0;i<VoltID.length;i++)
				{
					if(VoltID[i].checked)
					{
					var ok=true;
					}
				}
				if(!ok)
				{
					alert("Please Select the Operating Voltages for this device");
					VoltID[0].focus();
					return (false);
				}
			}
			if(PlugID.selectedIndex==0)
			{
				alert("Please select the Plug for this device");
				PlugID.focus();
				return (false);
			}
			return (true);
		}
	}
	catch(e)
	{
		alert("submitForm: " + e.description);
	}
}

