//*********************************************************
// 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 (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.open("GET",sXml,false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
}

///////////////////////////////////////////////////////
//	General send XML doc functionality
///////////////////////////////////////////////////////
function sendDoc()
{
    if (window.XMLHttpRequest)
      {
      // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlHTTP = new XMLHttpRequest();
        xmlHTTP.open("post", sUrl, false);
        xmlHTTP.send(xmlDoc);
        //alert(xmlHTTP.responseText);
        //document.getElementById("errorSpan").innerHTML = xmlHTTP.responseText;
        return xmlHTTP.responseXML;
      }
    else
      {
      // code for IE6, IE5
        xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
        xmlHttp.open("post", sUrl, false);
        xmlHttp.send(xmlDoc);        
        //alert(xmlHTTP.responseText);
        //document.getElementById("errorSpan").innerHTML = xmlHttp.responseText;
        return xmlHttp.responseXML;
      }
    //xmlhttp.open("GET",sXml,false);
    xmlhttp.send();
    xmlDoc=xmlhttp.responseXML;
} 

/******************************************
    sets values to xml nodes
******************************************/
function setXmlValue(sNode,sValue)
{
    //xmlDoc = loadDocument();
    if (window.XMLHttpRequest)
      {
        //xmlDoc=loadDocument("bible.xml");
        xmlDoc.getElementsByTagName(sNode)[0].firstChild.nodeValue = sValue;
      }
    else
      {// code for IE6, IE5
        xmlDoc.selectSingleNode("//"+sNode).text = sValue;
      }
}

/***********************************************
    returns the value from the xmlNode
***********************************************/
function getXmlValue(sNode)
{
 
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
        return xmlDoc.getElementsByTagName(sNode)[0].firstChild.nodeValue;
      }
    else
      {// code for IE6, IE5
        return xmlDoc.selectSingleNode("//"+sNode).text;
      }    
}
  

////////////////////////////////////////////////////////////////////
// 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);

}
//////////////////////////////////////////////////////////////////
// Fix for firefox bug not alowing for the 4096 characters in XML
//////////////////////////////////////////////////////////////////
function datadif(sNode)
{
	if(!xmlDoc.getElementsByTagName(sNode)[0].firstChild.nodeValue)return'';
	if(typeof(xmlDoc.getElementsByTagName(sNode)[0].textContent) != "undefined")
	{
	    return xmlDoc.getElementsByTagName(sNode)[0].textContent;
	}
	else
	{
	    return xmlDoc.getElementsByTagName(sNode)[0].firstChild.nodeValue;
	}
}	/* test case 
function parseXML()
{
//Parse an XML String
//The following code fragment parses an XML string into an XML DOM object:

    txt="<bookstore><book>";
    txt=txt+"<title>Everyday Italian</title>";
    txt=txt+"<author>Giada De Laurentiis</author>";
    txt=txt+"<year>2005</year>";
    txt=txt+"</book></bookstore>";

    if (window.DOMParser)
      {
      parser=new DOMParser();
      xmlDoc=parser.parseFromString(txt,"text/xml");
      }
    else // Internet Explorer
      {
      xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
      xmlDoc.async="false";
      xmlDoc.loadXML(txt); 
      }  

}
*/
///////////////////////////////////////////////////////////////////////////////
//	General load XML doc functionality
///////////////////////////////////////////////////////////////////////////////
function OldloadDocument() {
	/*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 oldsendDoc(sUrl) {
	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 oldsetXmlValue(sNode,sValue){
    
    if(window.ActiveXObject){
        xmlDoc.selectSingleNode("//"+sNode).text = sValue;
        
    }else if(document.implementation && document.implementation.createDocument){
    
        xmlDoc.getElementsByTagName(sNode)[0].firstChild.nodeValue = sValue;
    }   
}




