// -------------------------------------------------------------------------
//  Create XMLHttpRequest object 
// -------------------------------------------------------------------------

var req;

// Get an XMLHttpRequest object in a portable way.
function newReq() {
  req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    } 
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }
}

// -------------------------------------------------------------------------

function smsQuery(url) {
  // oper = 'pollSmsAccess';
  oper = 'show';
  newReq();	
  req.open('POST', url, true);
  req.onreadystatechange = processReqChange;
  req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  var encoded ='';
  encoded = 'method=' + escape(oper);
  req.send(encoded);

}


// -------------------------------------------------------------------------


function processReqChange() 
{
     if (req.readyState == 4) {
        if (req.status == 200) {
           response  = req.responseXML.documentElement;
           granted = response.getElementsByTagName('granted')[0].firstChild.data;
           if( granted == 1 ){
              reloadPage( );
           }
       }    
     }
}

// -------------------------------------------------------------------------

function reloadPage( ){
  document.location = document.location;

}

// -------------------------------------------------------------------------
