/*!
  *  @function:   pre_registration()
  *  @return:     boolean value True or False
  *  @brief:      The Function takes the above parameter and pass them to pre_registration.php file and retrive the appropriate message to display
                  for registration
*/

function  pre_registration()
{
      var username = document.getElementById('name').value;

      var email_id = document.getElementById('email').value;

      //creating the xmlHttp object

      var xmlHttp = getXmlHttpReqObject();

     //if object is not created return

     if( ! xmlHttp)
         return false;

     //on state change do this call back function

     xmlHttp.onreadystatechange=function()
     {
        //if data is recieved

        if(xmlHttp.readyState==4)
        {       // alert(xmlHttp.responseText);
             if(xmlHttp.responseText != '')
             {
                var reply = xmlHttp.responseText;
                var id = 'midPanleft';
                var element = document.getElementById(id);
                element.innerHTML =  reply;
             }
        }
      }
    //create a parameter string

    var qry = "username=" + username + "&email_id=" + email_id;

   //set the file path

   var url = 'pre_registration.php';

   //xmlhttp.open() function to set the connection

   xmlHttp.open('POST', url, true);

   xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

   //send the request

   xmlHttp.send(qry);

   return true;

}

function getXmlHttpReqObject()
{
    var xmlHttp = null;
    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;
            }
        }
    }
    return xmlHttp;
}
