﻿// May 2009 - initial common JS contains ajaxProcess for AJAX calls to rProcess.asp
// as in: ajaxProcess('ajax2', '{SiteLinkName}', 'Panel170')  
// where 
//				field = the on form field that receives text output (status, progress, etc)
//				ID = the record ID of the current record
//				site = Owner ID (celebritycruisedestinations, gaytraveldestinations, etc)
//				type = import reference type ID (Promotion, PromoOffer, etc)
//				typeID = import reference ID

// since we're updating a form field instead of a div, use .value instead of .innerHTML for responseText
// and make the call wait until complete by calling .open with ,,false


function ajaxProcess(field, ID, site, type, typeID)
  {
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.getElementById(field).value=xmlHttp.responseText;
      }
    }          
  var page = "http://www.globaltraveltech.com/cim2/rProcess.asp?ID=" + ID + "&Site=" + site + "&Type=" + type + "&TypeID=" + typeID
  // alert ('Launching call to ' + page);    
  xmlHttp.open("GET",page,false);
  xmlHttp.send(null);
  if ((xmlHttp.responseText.indexOf("Failed")!=-1) || (xmlHttp.responseText.indexOf("error")!=-1))
    {return false;}	//result contains "Failed" or "Error"
  else
    {return true;}	//result does not contain "Failed" or "Error"
  }
  
  function test(x,a,b)
    {
    	if (x==true) 	{return true;}
    	if (x==false)	{return false;}
    }


