//*********************************************************
// Declare global variables to get location of code
//*********************************************************

var sUrl = "aspx/everyDayAm.aspx";
var sXml = "xml/everyDayAm.xml";
memID = "";

///////////////////////////////////////////////////////////////////////////////
//	General load XML doc functionality
///////////////////////////////////////////////////////////////////////////////
function loadDocument() {
	if(document.implementation && document.implementation.createDocument){
    
        xmlDoc = document.implementation.createDocument("", "doc", null);
        xmlDoc.async = false;
        //xmlDoc.validateOnParse = false;
        xmlDoc.load(sXml);           
    
    }else if(window.ActiveXObject){
    
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.async = false;
        xmlDoc.validateOnParse = false;
        xmlDoc.load(sXml);
        
    }
	
}	

///////////////////////////////////////////////////////
//	General send XML doc functionality
///////////////////////////////////////////////////////
function sendDoc() {

	if(document.implementation && document.implementation.createDocument){
        xmlHTTP = new XMLHttpRequest();
        xmlHTTP.open("post", sUrl, false);
        xmlHTTP.send(xmlDoc);
       // alert(xmlHTTP.responseText);
       // document.getElementById("errorSpan").innerHTML = xmlHTTP.responseText;
        return xmlHTTP.responseXML;
        
    }else if(window.ActiveXObject){
    
        xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
        xmlHttp.open("post", sUrl, false);
        xmlHttp.send(xmlDoc);        
        document.getElementById("errorSpan").innerHTML = xmlHttp.responseText;
        return xmlHttp.responseXML;
        
    }   
	
}

/******************************************
    sets values to xml nodes
******************************************/
function setXmlValue(sNode,sValue){
    
    if(window.ActiveXObject){
        xmlDoc.selectSingleNode("//"+sNode).text = sValue;
        
    }else if(document.implementation && document.implementation.createDocument){
        xmlDoc.getElementsByTagName(sNode)[0].firstChild.nodeValue = sValue;
    }   
}

/***********************************************
    returns the value from the xmlNode
***********************************************/
function getXmlValue(sNode){

    if(window.ActiveXObject){
    
        return xmlDoc.selectSingleNode("//"+sNode).text;
        
    }else if(document.implementation && document.implementation.createDocument){
    
        return xmlDoc.getElementsByTagName(sNode)[0].firstChild.nodeValue;
    }     
    
}

////////////////////////////////////////////////////////////////////
// general validate function
// using regular expressions
////////////////////////////////////////////////////////////////////
function validateField(obj, sRegExp){

    sText = document.getElementById(obj).value;
    sText = sText.toLowerCase();
    oTextField = new RegExp(sRegExp);
    return oTextField.test(sText);

}	