var oXmlHttp = zXmlHttp.createRequest();
var tmvApprovalOrig = "Show All";
var endUseSectorOrig = "Show All";
var typeOfProductOrig = "Show All";
var applicationOrig = "Show All";

/* load functions when dom finishes loading, not when images finish loading */

if (/WebKit/i.test(navigator.userAgent)) { // safari
    var _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
            clearInterval(_timer);
						if(window.location.hash) {
            	updateCombos(window.location.hash);
						}
						else {
            	updateCombos();							
						}
						prepareSubmit();
						
            // call the onload handler
        }
    }, 10);
} else if (document.addEventListener) {
		if(window.location.hash.length) {
    	document.addEventListener("DOMContentLoaded", function() {updateCombos(window.location.hash);} , false);
		}
		else {
    	document.addEventListener("DOMContentLoaded", function() {updateCombos();} , false);			
		}
    document.addEventListener("DOMContentLoaded", prepareSubmit, false);
		
} else {
    //ie
    var script = document.getElementById("loadedScript");
    script.onreadystatechange = function() {
        if (this.readyState == "complete") {
						if(window.location.hash) {
            	updateCombos(window.location.hash);
						}
						else {
            	updateCombos();							
						}
						prepareSubmit();
            // call the onload handler
        }
    };

}

function prepareSubmit() {
	document.getElementById('formMixingValves').onsubmit = function () {
		var tmvApprovalValue = document.getElementById("tmvApproval").value;
    var endUseSectorValue = document.getElementById("endUseSectorDDM").value;
    var typeOfProductValue = document.getElementById("typeOfProduct").value;
    var applicationValue = document.getElementById("application").value;
			window.location.hash= "tmvApproval="+escape(tmvApprovalValue)+"|endUserSector="+escape(endUseSectorValue)+"|typeOfProduct="+typeOfProductValue+"|appSelect="+applicationValue ;
			return true;
	}
	
}

