// This is called when submitting a form. It will go through the 
// form elements and disable all the buttons, submits and otherwise.
function DisableForm(objForm){
	for (var i = 0 ; i < objForm.elements.length ; i++){
		if (objForm.elements[i].tagName.toLowerCase() == "input"){
			if ((objForm.elements[i].type.toLowerCase() == "button") ||
				(objForm.elements[i].type.toLowerCase() == "submit") ||
				(objForm.elements[i].type.toLowerCase() == "image")
				){
				// Disable the input
				objForm.elements[i].disabled = true;
				
				// Only change the class if it's not an image
				if (objForm.elements[i].type.toLowerCase() != "image"){
					//objForm.elements[i].className = "button-disabled";
				}
			}		
		}
		
		// Disable any events that might trigger a form-submit
		objForm.elements[i].onclick = null;
		objForm.elements[i].onchange = null;
		objForm.elements[i].onfocus = null;
		objForm.elements[i].onblur = null;
		objForm.elements[i].onkeydown = null;
		objForm.elements[i].onkeyup = null;
	}
	
	// Also, since the form has already been submitted, let's have it return false
	// if it tries to submit again. I am worried though that this might stop the
	//previous form submission.
	objForm.onsubmit = new function(){
		return(false);
	}
}


function displayIngredients(id){
	window.open('/ingredients.cfm?id=' + id, 'Ingredients','location=0,status=0,scrollbars=0,height=400,width=600');
}

function displayCVV2(){
	window.open('/cvv.html', 'CVV2','location=0,status=0,scrollbars=0,height=600,width=600');
}


  if(window.attachEvent)
    window.attachEvent("onload",setListeners);

  function setListeners(){
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++){
      inputList[i].attachEvent("onpropertychange",restoreStyles);
      inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("SELECT");
    for(i=0;i<selectList.length;i++){
      selectList[i].attachEvent("onpropertychange",restoreStyles);
      selectList[i].style.backgroundColor = "";
    }
  }

  function restoreStyles(){
    if(event.srcElement.style.backgroundColor != "")
      event.srcElement.style.backgroundColor = "";
  }

