function updateCombos() {
    var tmvApprovalSelector = document.getElementById("tmvApproval");
    var endUseSectorSelector = document.getElementById("endUseSectorDDM");
    var typeOfProductSelector = document.getElementById("typeOfProduct");
    var applicationSelector = document.getElementById("application");
		var url;
    var tmvApprovalSelected = "Show All";
    var endUserSectorSelected = "Show All";
    var typeOfProductSelected = "Show All";
    var applicationSelected = "Show All";
    try {
        tmvApprovalSelected = tmvApprovalSelector.value;
        endUserSectorSelected = endUseSectorSelector.value;
        typeOfProductSelected = typeOfProductSelector.value;
        applicationSelected = applicationSelector.value; 
				
        tmvApprovalOrig = tmvApprovalSelected;
        endUseSectorOrig = endUserSectorSelected;
        typeOfProductOrig = typeOfProductSelected;
        applicationOrig = applicationSelected;
    } catch(Exception) { }
		if (arguments.length){
			args = arguments[0].substring(1).split("|");
			url = "getDropDowns.jsp?";
			for(i=0;i<args.length;i++){
				arg = args[i].split("=");
				url += arg[0] + "="+ escape(arg[1])+"&"; 
				switch(arg[0]) {
					case "tmvApproval" : tmvApprovalOrig = unescape(arg[1]);break;
					case "endUserSector" : endUseSectorOrig = unescape(arg[1]);break;
					case "typeOfProduct" : typeOfProductOrig = unescape(arg[1]);break;
					case "appSelect" : applicationOrig = unescape(arg[1]);break;
					default : "";
				}
			}
		}else {
     url = "getDropDowns.jsp?tmvApproval="+escape(tmvApprovalSelected)+"&endUserSector="+escape(endUserSectorSelected)+"&typeOfProduct="+escape(typeOfProductSelected)+"&appSelect="+escape(applicationSelected)+"&";
    }
		oXmlHttp.open("GET",url,true);
    oXmlHttp.onreadystatechange = handleResponse;  //callback to handleResponse();
    oXmlHttp.send(null);
}

function handleResponse() {
    var tmvApprovalSelector = document.getElementById("tmvApproval");
    var endUseSectorSelector = document.getElementById("endUseSectorDDM");
    var typeOfProductSelector = document.getElementById("typeOfProduct");
    var applicationSelector = document.getElementById("application");
    var tmvApprovalSelected = "Show All";
    var endUserSectorSelected = "Show All";
    var typeOfProductSelected = "Show All";
    var applicationSelected = "Show All";
  	try {
				
        tmvApprovalSelected = tmvApprovalSelector.value;
        endUserSectorSelected = endUseSectorSelector.value;
        typeOfProductSelected = typeOfProductSelector.value;
        applicationSelected = applicationSelector.value; 
				
    } catch(Exception) { }
    
    //  check if ready state is 4 (finished)
    //  and status is 200 (OK)
    //  This should be true only after completely loaded
    tmvApprovalSelector.options[0].selected = true;
    tmvApprovalSelector.options[0].text = "Please Wait...";
    tmvApprovalSelector.disabled = true;

    endUseSectorSelector.options[0].selected = true;
    endUseSectorSelector.options[0].text = "Please Wait...";
    endUseSectorSelector.disabled = true;

    typeOfProductSelector.options[0].selected = true;
    typeOfProductSelector.options[0].text = "Please Wait...";
    typeOfProductSelector.disabled = true;

    applicationSelector.options[0].selected = true;
    applicationSelector.options[0].text = "Please Wait...";
    applicationSelector.disabled = true;

    if (oXmlHttp.readyState == 4 && oXmlHttp.status == 200) {
			
        // Text returned FROM the page
        var response = oXmlHttp.responseText;
        var newoptions = new Array();
        if (response) {
            // if there is any response from the httprequest, Update ajax content
            while (tmvApprovalSelector.childNodes[0]) {
                tmvApprovalSelector.removeChild(tmvApprovalSelector.childNodes[0]);
            }
            while (endUseSectorSelector.childNodes[0]) {
                endUseSectorSelector.removeChild(endUseSectorSelector.childNodes[0]);
            }
            while (typeOfProductSelector.childNodes[0]) {
                typeOfProductSelector.removeChild(typeOfProductSelector.childNodes[0]);
            }
            while (applicationSelector.childNodes[0]) {
                applicationSelector.removeChild(applicationSelector.childNodes[0]);
            }
            var optionArray = response.split("|");
            var tmvArray = ((response.split("^"))[0]).split("|");
            var endUseSectorArray = ((response.split("^"))[1]).split("|");
            var typeOfProductArray = ((response.split("^"))[2]).split("|");
            var applicationArray = ((response.split("^"))[3]).split("|");
            tmvApprovalSelector.options[0] = new Option("Show All","Show All");
            endUseSectorSelector.options[0] = new Option("Show All","Show All");
            typeOfProductSelector.options[0] = new Option("Show All","Show All");
            applicationSelector.options[0] = new Option("Show All","Show All");
            var ddmLabel1 = (tmvArray[0].split("*"))[0];
            var ddmLabel2 = (endUseSectorArray[0].split("*"))[0];
            var ddmLabel3 = (typeOfProductArray[0].split("*"))[0];
            var ddmLabel4 = (applicationArray[0].split("*"))[0];
            if (tmvApprovalOrig == "Show All") {
                for (i=0;i<=tmvArray.length-1;i++) {
                    optname = tmvArray[i];
                    if(optname.indexOf("*")>=0) {
                        optname = (optname.split("*"))[1];
                    }
                    optval = optname;
                    if (optname != "") {
                        tmvApprovalSelector.options[i+1] = new Option(optname,optval);
                    }
                }
            } else {
                tmvApprovalSelector.options[1] = new Option(tmvApprovalOrig,tmvApprovalOrig);
                tmvApprovalSelector.options[1].selected = true;
            }
            if (endUseSectorOrig == "Show All") {
                for (i=0;i<=endUseSectorArray.length-1;i++) {
                    optname = endUseSectorArray[i];
                    if(optname.indexOf("*")>=0) {
                        optname = (optname.split("*"))[1];
                    }
                    optval =  optname;
                    if (optname != "") {
                        endUseSectorSelector.options[i+1] = new Option(optname,optval);
                    }
                }
            } else {
                endUseSectorSelector.options[1] = new Option(endUseSectorOrig,endUseSectorOrig);
                endUseSectorSelector.options[1].selected = true;
            }
            if (typeOfProductOrig == "Show All") {
                for (i=0;i<=typeOfProductArray.length-1;i++) {
                    optname = typeOfProductArray[i];
                    if(optname.indexOf("*")>=0) {
                        optname = (optname.split("*"))[1];
                    }
                    optval =  optname;
                    if (optname != "") {
                        typeOfProductSelector.options[i+1] = new Option(optname,optval);
                    }
                }
            } else {
                typeOfProductSelector.options[1] = new Option(typeOfProductOrig,typeOfProductOrig);
                typeOfProductSelector.options[1].selected = true;
            }
            if (applicationOrig == "Show All") {
                for (i=0;i<=applicationArray.length-1;i++) {
                    optname = applicationArray[i];
                    if(optname.indexOf("*")>=0) {
                        optname = (optname.split("*"))[1];
                    }
                    optval =  optname;
                    if (optname != "") {
                        applicationSelector.options[i+1] = new Option(optname,optval);
                    }
                }
            } else {
                applicationSelector.options[1] = new Option(applicationOrig,applicationOrig);
                applicationSelector.options[1].selected = true;
            }
            tmvApprovalSelector.disabled = false;
            endUseSectorSelector.disabled = false;
            typeOfProductSelector.disabled = false;
            applicationSelector.disabled = false;
            document.getElementById("ddmLabel1").innerHTML = ddmLabel1;
            document.getElementById("ddmLabel2").innerHTML = ddmLabel2;
            document.getElementById("ddmLabel3").innerHTML = ddmLabel3;
            document.getElementById("ddmLabel4").innerHTML = ddmLabel4;
        }
    }
}