
///////////////////////////////
//  Comments Custom AJAX handler
////////////////
var _req_comments;       // holds a XMLHttpRequest for the AJAX call
var _url_comments = '';  // holds incomming url to process
var _target_tag_id_comments ='';

/////////////////////////////////////
/// call this one first from the link somewhere on the page
/////////////////////////
function getCommentsInitial( url, targetTag ){
 // alert('url='+url);
  var rc ;
  _url_comments = url;
  _target_tag_id_comments = targetTag;
  try{ 
    loadXMLDoc_Comments(_url_comments); 
  }catch(err){alert('getCommentsInitial: '+err);}

  return rc;
}

/* Start  ///////////////////////// */


///////////////////////////
function loadXMLDoc_Comments(url) {
  /* branch for native XMLHttpRequest object */
  if (window.XMLHttpRequest) {
    try{ 
      _req_comments = new XMLHttpRequest();
      _req_comments.onreadystatechange = getCommentsProcess;
      _req_comments.open('GET', encodeURI(url), true);
      _req_comments.send(null);
    }catch(err){alert('loadXMLDoc_Comments'+err);}
    /* branch for IE/Windows ActiveX version */
  } else { 
	if (window.ActiveXObject) {
      _req_comments = new ActiveXObject('Microsoft.XMLHTTP');
      if (_req_comments) {
        try{ 
            _req_comments.onreadystatechange = getCommentsProcess;
	        _req_comments.open('GET', encodeURI(url), true);
	        _req_comments.send();
	    }catch(err){alert('loadXMLDoc_Comments'+err);}
      }
    }
  }
}

/////////////////////////////////
//  this code will need to be updated to add new code to read incomming xml
///////
//function getCommentsProcess() {
function getCommentsProcess() {
  // only if req shows complete
   if (_req_comments.readyState == 4) {

     if (_req_comments.status == 200) {
       // ...process incomming xml
	   //alert('hi');
        response  = _req_comments.responseXML.documentElement;
        method = response.getElementsByTagName('method')[0].firstChild.data;
		recno = response.getElementsByTagName('recordno')[0].firstChild.data;
        result = response.getElementsByTagName('result')[0].firstChild.data;
		
       // if(method=='getTimedOut'){ 
	      //document.getElementById('cY').value = response.getElementsByTagName('cY')[0].firstChild.data;
          //document.getElementById('"+getName()+"').src = result;
          //eval(method + '(\\\'\\\', result)');
		  //alert('result ' + result);
          eval(method + '(result)');
	    //}
          
        
         

      } else {
        alert('There was a problem retrieving the XML data:' + _req_comments.statusText);
      }

    }
}
////////////////////
//  show error
//////////////
function show_error_Comments(result){
  setPopUpMessage( _target_tag_id_comments,  result)
} 
/////////////////////
//  Method called by eval(method + '(result)')
///////////
function show_action_new_Comments(result){
  setPopUpMessage( _target_tag_id_comments,  result)
}
function show_action_save_Comments(result){
  setPopUpMessage( _target_tag_id_comments,  result)
}
//function show_action_aditinitiate_Comments(result){
 // alert('edit result: '+result);
//}
/////////////////////////////
//function showTestSession(result){
 // document.getElementById('testsession').innerHTML = result; 

//}
