// JavaScript Document

function loadInquire(CITEMNO)
{
	document.getElementById(CITEMNO+'-InquireBox').style.display = 'none'; 
	document.getElementById(CITEMNO).style.display = 'block'; 
	
}

function closeInquire(CITEMNO)
{
	document.getElementById(CITEMNO+'-InquireBox').style.display = 'block'; 
	document.getElementById(CITEMNO).style.display = 'none'; 
}

function sendInquire(CITEMNO)
{
	closeInquire(CITEMNO);
	
	var InquireMSG = document.getElementById(CITEMNO+'-InquireMSG').value;

	//change spaces into %20
	InquireMSG = InquireMSG.replace(/\n/g, "<br>");
	InquireMSG = InquireMSG.replace(/&/g, "and");
	
	var xmlhttp=false; 
	//Try to create active x object
	try {
		xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); 
		} catch (e) {
		try {
			 xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); 
		} catch (E) {
			 xmlhttp = false;
		}
	 }
	 if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		 xmlhttp = new XMLHttpRequest();
	 }
	
	var page ='pages/save_inquiry.cfm';
	
	var params = '?CITEMNO='+CITEMNO+'&InquireMSG='+encodeURIComponent(InquireMSG);

	var file = page+params;

	//Open the file through GET, and add the page we want to retrieve as a GET variable
	xmlhttp.open('GET',file, true);     

	xmlhttp.onreadystatechange=function() {
	if(xmlhttp.readyState == 1){

	   //Check if it is ready to recieve data 
	   }else if(xmlhttp.readyState==4) { 
	   //Make sure there is something in the content variable
	   var content = xmlhttp.responseText; 
	
		  //The content data which has been retrieved
		  if( content )
		  { 
				//Do somehting after request
		  }
	   }
	}
	//Nullify the XMLHttpRequest
	xmlhttp.send(null);
}
