
//Create a generic browser specific XML Http object
function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
    {// Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();}
  catch (e)
    { // Internet Explorer
    try
      {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
    catch (e)
      {xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
    }
  return xmlHttp;
}

//Use the data returned by the changeOB function
//place the XMLHttp results into the innerHTML if a specific table cell
function useData()
{
	if (xmlHttp.readyState==4)
	{
		document.getElementById("dynamic").innerHTML = xmlHttp.responseText;
		var options = { 
	        target:        '#dynamic',   // target element(s) to be updated with server response
	        success:       showResponse  // post-submit callback
    	}; 
	    // bind form using 'ajaxForm' 
	    $('#processForm').ajaxForm(options);
	    
	    $('#processForm').submit(function() { 
        // inside event callbacks 'this' is the DOM element so we first 
        // wrap it in a jQuery object and then invoke ajaxSubmit 
        //$(this).ajaxSubmit(options); 
 
        // !!! Important !!! 
        // always return false to prevent standard browser submit and page navigation 
        return false; 
    }); 
	}
}


//Use the generic XML Http object to get the contents of a URL Using GET method
function changeOB(url)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
  		{
  		alert ("Your browser does not support AJAX!");
  		return;
  		} 
	//var url="test2.html";
	xmlHttp.onreadystatechange=useData;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function postOB(url)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
  		{
  		alert ("Your browser does not support AJAX!");
  		return;
  		} 
	//var url="test2.html";
	xmlHttp.onreadystatechange=useData;
	xmlHttp.open("POST",url,true);
	xmlHttp.send(null);
}

// post-submit callback 
function showResponse(responseText, statusText)  { 
    var options = { 
        target:        '#dynamic',   // target element(s) to be updated with server response
        success:       showResponse  // post-submit callback
	}; 
    // bind form using 'ajaxForm' 
    $('#processForm').ajaxForm(options);
    
 /*   $('#processForm').submit(function() { 
        // inside event callbacks 'this' is the DOM element so we first 
        // wrap it in a jQuery object and then invoke ajaxSubmit 
        $(this).ajaxSubmit(options); 
 
        // !!! Important !!! 
        // always return false to prevent standard browser submit and page navigation 
        return false; 
    }); */
}