//Ajax functions to pre-screen the username and password to make sure that the server will not send an error.

/*
function getNewHTTPObject()
{
        var xmlhttp;

        /** Special IE only code ... */
        /*@cc_on
          @if (@_jscript_version >= 5)
              try
              {
                  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
              }
              catch (e)
              {
                  try
                  {
                      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                  }
                  catch (E)
                  {
                      xmlhttp = false;
                  }
             }
          @else
             xmlhttp = false;
        @end @*/

        /** Every other browser on the planet 
        if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
        {
            try
            {
                xmlhttp = new XMLHttpRequest();
            }
            catch (e)
            {
                xmlhttp = false;
            }
        }

        return xmlhttp;
}
*/


/*
 * Returns a new XMLHttpRequest object, or false if this browser
 * doesn't support it
 */
function getNewHTTPObject() {

  var xmlreq = false;

  if (window.XMLHttpRequest) {

    // Create XMLHttpRequest object in non-Microsoft browsers
    xmlreq = new XMLHttpRequest();

  } else if (window.ActiveXObject) {

    // Create XMLHttpRequest via MS ActiveX
    try {
      // Try to create XMLHttpRequest in later versions
      // of Internet Explorer

      xmlreq = new ActiveXObject("Msxml2.XMLHTTP");

    } catch (e1) {

      // Failed to create required ActiveXObject

      try {
        // Try version supported by older versions
        // of Internet Explorer

        xmlreq = new ActiveXObject("Microsoft.XMLHTTP");

      } catch (e2) {

        // Unable to create an XMLHttpRequest with ActiveX
      }
    }
  }

  return xmlreq;
}


var xmlHttp = getNewHTTPObject();


function getDynamicData(toaddress,toname,fromaddress,fromname)
{
	if ((toaddress.length>0)&&(toname.length>0)&&(fromaddress.length>0)&&(fromname.length>0)) {
		  var url = "emailafriend2.asp?toaddress=" + toaddress + "&toname=" + toname + "&fromaddress=" + fromaddress + "&fromname=" + fromname;
		  xmlHttp.open('GET', url, true);
		  xmlHttp.onreadystatechange = callbackFunction;
		  xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		  xmlHttp.setRequestHeader('Content-Length',0);
		  xmlHttp.send(null);
	} else {
		alert('Please enter all the information');
	}
}

function callbackFunction()
{
	
  if (xmlHttp.readyState != 4)
  return;
  var result = xmlHttp.responseText;
	document.getElementById('emailafriend').innerHTML = "Your message was sent to " + result;



}

