/* Create a new XMLHttpRequest object to talk to the Web server */
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
@end @*/

if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}


function callServerBC( evt ) {	
	    evt = (evt) ? evt : ((window.event) ? window.event : "")
    if (evt) {
        var frm = (evt.target) ? evt.target : evt.srcElement
    }
  // Get value from the web form
  for(z=0; z< errArray.length; z=z+3){
			if(frm.id == errArray[z]) {wasErr = validate(errArray[z]+errArray[z+1]);}
  }
	var val;
	var nome;
	nome = "?" + frm.id
	
	  if (frm.type == "checkbox"){frm.checked?val=frm.value:val="";}
	  else val = frm.value;
	  var url = "storeSession.asp" + nome + "=" + escape(val); 

  // Only go on if there are values for both fields
  if (url == null) return;
   saveW =MM_findObj("saveM");
   saveW.className="errM";

  // Open a connection to the server
  xmlHttp.open("GET", url, true);

  // Setup a function for the server to run when it's done
  xmlHttp.onreadystatechange = updatePage;

  // Send the request
  xmlHttp.send(null);
}

function callServerB( evt ) {	
	    evt = (evt) ? evt : ((window.event) ? window.event : "")
    if (evt) {
        var frm = (evt.target) ? evt.target : evt.srcElement
    }
  // Get value from the web form
	var val;
	var nome;
	nome = "?" + frm.id
	
	  if (frm.type == "checkbox"){frm.checked?val=frm.value:val="";}
	  else val = frm.value;
	  var url = "storeSession.asp" + nome + "=" + escape(val); 
  // Only go on if there are values for both fields
  if (url == null) return;
   saveW =MM_findObj("saveM");
   saveW.className="errM";
  // Open a connection to the server
  xmlHttp.open("GET", url, true);
  // Setup a function for the server to run when it's done
  xmlHttp.onreadystatechange = updatePage;
  // Send the request
  xmlHttp.send(null);
}
function callServer( frm ) {
  // Get value from the web form
    var val;
	var nome;
	nome = "?" + frm.id	
	  if (frm.type == "checkbox"){frm.checked?val=frm.value:val="";}
	  else val = frm.value;
	  var url = "storeSession.asp" + nome + "=" + escape(val); 
  // Only go on if there are values for both fields
  if (url == null) return;
   saveW =MM_findObj("saveM");
   saveW.className="errM";
  // Open a connection to the server
  xmlHttp.open("GET", url, true);
  // Setup a function for the server to run when it's done
  xmlHttp.onreadystatechange = updatePage;
  // Send the request
  xmlHttp.send(null);
}



function bind(frm){
frmO =MM_findObj(frm);
frmE = frmO.elements;
lFrm=frmE.length
	for (i=0; i<lFrm; i++){
		
		pass='';
		for(z=0; z< errArray.length; z=z+3)if(frmE[i].id == errArray[z])pass=frmE[i].id;
		
		if(pass!='')frmE[i].onblur = callServerBC;	
		else {
			if(frmE[i].tagName.toUpperCase()=="INPUT" || frmE[i].tagName.toUpperCase()=="SELECT"){
				if(frmE[i].type.toLowerCase() != "submit" && frmE[i].type.toLowerCase() != "submit" && frmE[i].type.toLowerCase() != "reset")frmE[i].onblur = callServerB;
			}
		}
	}
}




function callSetFormServer( frm ) {
  // Get value from the web form
var str="";
radios = new Array;
lRad=0;
frmO =MM_findObj(frm);
frmE = frmO.elements;
lFrm=frmE.length
for (i=0; i<lFrm; i++){
		notIn=true;
		for (x=0; x<radios.length;x++){
			if (radios[x]==	frmE[i].id) notIn=false;
		}
		if (notIn) {
			radios[radios.length]=frmE[i].id;
			str=str + frmE[i].id;
			if (i<(lFrm-1))str=str+"&";
		}
	}
  // Only go on if there are values for both fields
  if (str == null) return false;
  // Build the URL to connect to
  var url = "getSessionForm.asp?" + str;
  // Open a connection to the server
  xmlHttp.open("POST", url, true);
  // Setup a function for the server to run when it's done
  xmlHttp.onreadystatechange = fillFormFromSession;
  // Send the request
  xmlHttp.send(str);
  
  return true;
}

function callSummaryFirst() { 
  // Build the URL to connect to
  var url = "setSummaryFirst.asp";
  // Open a connection to the server
  xmlHttp.open("GET", url, true);
  // Setup a function for the server to run when it's done
  xmlHttp.onreadystatechange = updateSumary;
  // Send the request
  xmlHttp.send();
  return url

}
function updateSumary() {
  if (xmlHttp.readyState == 4) {
   var response = xmlHttp.responseText;
   document.getElementById("sumary").innerHTML = response;
   saveW =MM_findObj("saveM");
   saveW.className="err";
   
 }
}
function updatePage() {
  if (xmlHttp.readyState == 4) {
   var response = xmlHttp.responseText;
   document.getElementById("sumary").innerHTML = response;
   saveW =MM_findObj("saveM");
   saveW.className="err";
   
 }
}
