function makeRequest(url) {
	var httpRequest;

	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		httpRequest = new XMLHttpRequest();
		if (httpRequest.overrideMimeType) {
			httpRequest.overrideMimeType('text/xml');
			// See note below about this line
		}
	} else if (window.ActiveXObject) { // IE
		try {
			httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!httpRequest) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	httpRequest.onreadystatechange = function() { alertContents(httpRequest); };
	httpRequest.open('GET', url, true);
	httpRequest.send(null);

}

function alertContents(httpRequest) {
	try {
		if (httpRequest.readyState == 4) {
			if (httpRequest.status == 200) {
				var rspText = httpRequest.responseText;
				var oResponseArray = rspText.split("##");
				if (oResponseArray.length != 0){
					if (oResponseArray[0] == 'lock'){
						alert("Account has been locked for "+oResponseArray[1])
					}else if (oResponseArray[0] == 'account'){
						var iTotal
						
						document.getElementById('bsktinfo').style.display = 'block'
						
						sDetail = '<table width="200px" border="0" cellpadding="2" cellspacing="0" class="prodtable">'
						sDetail = sDetail + '<tr><td class="prodheading" width="50%" align="left">Product Code</td><td class="prodheading" width="25%" align="left">Qty</td></tr>'
						iTotal = 0
						oProducts = oResponseArray[2].split("|");
						if (oProducts.length != 0){
							for (i=0;i<oProducts.length;i++){
								oDetail = oProducts[i].split(":");
								sFunction = "makeRequest('/process.asp?id="+oDetail[0]+"&action=sum&amt='+this.value)"
								sDetail = sDetail + '<tr><td class="account-body" valign="bottom">&nbsp;&nbsp;'+oDetail[5]+'</td><td valign="top" class="account-body"><select name="qty" id="qty" style="width: 85%;" onChange="'+sFunction+'">'
								iCount = (oDetail[3]>10) ? 10 : oDetail[3]
								for (j=0;j<=iCount;j++){
										if (j == oDetail[1]){
											sDetail = sDetail + '<option value='+j+' selected>'+j+'</option>'
										}else{
											sDetail = sDetail + '<option value='+j+'>'+j+'</option>'
										}
								}
								sDetail = sDetail + '</select></td></tr>'
								sDetail = sDetail + '<tr><td align="center" colspan="2"><hr size="1" width="100%"></td></tr>'
								iSubTotal = (oDetail[1]*oDetail[4])
								
								iTotal = iTotal + iSubTotal
							}
							
							sTotal = iTotal.toString();
							oAmount = sTotal.split(".");
							if (oAmount.length > 1){
								if (oAmount[1].length == 1){sTotal = sTotal+'0'};
							}else{
								sTotal = sTotal+'.00'
							}
							
							//sDetail = sDetail + '<tr><td class="account-body"><b>Total</b></td><td class="account-body"><b>$&nbsp;'+Math.round(sTotal)+'</b></td></tr>'
							sDetail = sDetail + '<tr><td class="account-body"><b>Total</b></td><td class="account-body"><b>'+oResponseArray[5]+'&nbsp;'+RoundDec((sTotal*oResponseArray[4]),2)+'</b></td></tr>'
						}
						
						sDetail = sDetail + '</table>'
						sDetail = sDetail + '<br style="line-height:10px"><table width="200px" cellpadding="0" cellspacing="0"><tr><td align="middle">'
						sDetail = sDetail + '<input type="button" name="checkout" value="Checkout" class="plainbutton" onClick="fnLoadCheckOut();" style="width:170px;">'
						sDetail = sDetail + '</td></tr></table>'
						
						document.getElementById('bsktaccount').innerHTML = "";
						document.getElementById('bsktaccount').innerHTML = sDetail;
					}else if (oResponseArray[0] == 'product' || oResponseArray[0] == 'volume'){
						oProductArray = oResponseArray[2].split("`");
						for (i=0;i<oProductArray.length;i++){
							if (i==0){
								document.getElementById('prod'+oResponseArray[1]).innerHTML = oProductArray[i]
							}//else{
								//if (oProductArray[i] != ''){
									//document.getElementById('header'+oResponseArray[1]).innerHTML = oProductArray[i]
								//}
							//}
						}
					}else if (oResponseArray[0] == 'rating'){
						document.getElementById('rating'+oResponseArray[1]).innerHTML = oResponseArray[2]
					}else if (oResponseArray[0] == 'assignment'){
						if (oResponseArray[3] == 1){
							window.resizeTo(500,300)
						}else{
							window.resizeTo(500,400)
						}
						document.getElementById('assignment').innerHTML = oResponseArray[2]
					}else if (oResponseArray[0] == 'resetassignment'){
						document.getElementById('assignment').innerHTML = oResponseArray[2]
					}else{
						if (oResponseArray[3] == 0){
							document.location.reload();
						}else{
							sDetail = '<table width="200px" border="0" cellpadding="2" cellspacing="0" class="prodtable">'
							sDetail = sDetail + '<tr><td class="prodheading" width="50%" align="left">Product Code</td><td class="prodheading" width="25%" align="left">Qty</td></tr>'
							iTotal = 0
							oProducts = oResponseArray[2].split("|");
							if (oProducts.length != 0){
								for (i=0;i<oProducts.length;i++){
									oDetail = oProducts[i].split(":");
									sFunction = "makeRequest('/process.asp?id="+oDetail[0]+"&action=sum&amt='+this.value)"
									sDetail = sDetail + '<tr><td class="account-body" valign="absbottom">&nbsp;'+oDetail[5]+'</td><td valign="bottom" class="account-body"><select name="qty" id="qty" style="width: 85%;" onChange="'+sFunction+'">'
									iCount = (oDetail[3]>10) ? 10 : oDetail[3]
									for (j=0;j<=iCount;j++){
											if (j == oDetail[1]){
												sDetail = sDetail + '<option value='+j+' selected>'+j+'</option>'
											}else{
												sDetail = sDetail + '<option value='+j+'>'+j+'</option>'
											}
									}
									sDetail = sDetail + '</select></td></tr>'
									sDetail = sDetail + '<tr><td align="center" colspan="2"><hr size="1" width="100%"></td></tr>'
									iSubTotal = (oDetail[1]*oDetail[4])
									iTotal = iTotal + iSubTotal
								}
								
								sTotal = iTotal.toString();
								oAmount = sTotal.split(".");
								if (oAmount.length > 1){
									if (oAmount[1].length == 1){sTotal = sTotal+'0'};
								}else{
									sTotal = sTotal+'.00'
								}
								
								//sDetail = sDetail + '<tr><td class="account-body"><b>Total</b></td><td class="account-body"><b>$&nbsp;'+Math.round(sTotal)+'</b></td></tr>'
								sDetail = sDetail + '<tr><td class="account-body"><b>Total</b></td><td class="account-body"><b>'+oResponseArray[5]+'&nbsp;'+RoundDec((sTotal*oResponseArray[4]),2)+'</b></td></tr>'
							}
							
							sDetail = sDetail + '</table>'
							sDetail = sDetail + '<br style="line-height:10px"><table width="200px" cellpadding="0" cellspacing="0"><tr><td align="middle">'
							sDetail = sDetail + '<input type="button" name="checkout" value="Checkout" class="plainbutton" onClick="fnLoadCheckOut();" style="width:170px;">'
							sDetail = sDetail + '</td></tr></table>'
							
							document.getElementById('bsktaccount').innerHTML = "";
							document.getElementById('bsktaccount').innerHTML = sDetail;
						}
					}
				}
			} else {
				alert('There was a problem with the request.');
			}
		}
	}
	
	catch( e ) {
		alert('Caught Exception: ' + e.description);
	}
}



