var PriceReq;

function getPrice(item,qty,OPTIONS) { 	
	if (window.XMLHttpRequest) {
		PriceReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		PriceReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
		
	if (document.ItemForm.OPTION_NAMES != null){
		if (document.ItemForm.OPTIONS[0][0] == null){
			document.ItemForm.OPTION_NAMES.value = document.ItemForm.OPTIONS[document.ItemForm.OPTIONS.selectedIndex].text
		} else {
			options = document.ItemForm.OPTIONS[0][document.ItemForm.OPTIONS[0].selectedIndex].text;
			OPTIONS = document.ItemForm.OPTIONS[0].value;
			
			for (x=1; x<document.ItemForm.OPTIONS.length; x++){
				options = options + "," + document.ItemForm.OPTIONS[x][document.ItemForm.OPTIONS[x].selectedIndex].text;
				OPTIONS = OPTIONS + "," + document.ItemForm.OPTIONS[x].value;
			}
			options = options.replace("None,","");
			document.ItemForm.OPTION_NAMES.value = options;
		}	
	} else {
		OPTIONS = "0";
	}
  	var url = "/getPrice.jsp?item=" + item + "&qty=" + qty + "&OPTIONS=" + OPTIONS;  	
  	
  	if (isNaN(qty)){
  		document.getElementById("priceDiv").innerHTML = "Numbers Only Please";    		 	
  	} else if(qty.length == 0){
  		document.getElementById("priceDiv").innerHTML = "Please enter the qty.";  				   
  	} else {
  		PriceReq.onreadystatechange = setPrice;
   		// if PriceReq is privatized then use http_request.onreadystatechange = function() { processZipData(PriceReq); };
   		PriceReq.open("GET", url);
   		PriceReq.send(null);   		
  	}     	  	
}

function setPrice(){
	if (PriceReq.readyState == 4) {
    	if (PriceReq.status == 200) { // 200=success, 404=not found
    		var data = PriceReq.responseText;    
    		document.getElementById("priceDiv").innerHTML = data; 		
    	} else {		
    	}
    }
}