// JavaScript Document


function MM_preloadImages() { //v3.0
  var d=document; if(d.images)
  		{ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}





/***********************************************
 QueryString = "/addresses/location[entity='" + strx + "']/city"
  QueryString = "/addresses/location[entity='Partners Home Care']/city"
***********************************************/



			
var xmldoc;
var Output;
var Output1;
var Output2;
var mXHR;
var strx;
var nodes;
var QueryString;
var result;
var mylocs;
var m;
var locout;
var qstring;
var cnode;
var x;


// BEGIN loadXMLDoc returns xml document object based on browser
function loadXMLDoc(dname)
{
if (window.ActiveXObject) 
	{
		xmldoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
		xmldoc.async = false;
		xmldoc.load(dname);
	}
	else if (document.implementation && document.implementation.createDocument)
		{
			mXHR = new XMLHttpRequest();
			mXHR.open("GET",dname, false);
			mXHR.send(null);
			xmldoc = mXHR.responseXML;
		}
	return xmldoc;
}
//--------------------------------
//END loadXMLDoc



//BEGIN loadOutput --generic code for returning xPath results to HTML element
function loadOutput(OutString,locout)
{
	
		Output = document.all? document.all[locout]  : document.getElementById?
						document.getElementById(locout) : "";
					
		Output.innerHTML = OutString;	
}
//--------------------------------
//END loadOutput 





//BEGIN Get_Phone --retrieves the phone number of a location
function Get_Phone(strx, locout)
{

   qstring = "/addresses/location[linknav='" + strx + "']" 

   loadXMLDoc("xmldata/addresses.xml")

	if (window.ActiveXObject) 
	{
		x = xmldoc.selectSingleNode(qstring)
		cnode = x.childNodes		
		OutString = "";	
		OutString += cnode(8).text  + "<br />";
	}
	else if (document.implementation && document.implementation.createDocument)
	{
		x = xmldoc.evaluate(qstring,xmldoc,null,XPathResult.ANY_TYPE,null);
		cnode = x.iterateNext();
		OutString = "";	
			
  while (cnode) {   

		OutString += cnode.getElementsByTagName('phone')[0].textContent  + "<br />";
		cnode = x.iterateNext(); 
			} 
	}
	
	loadOutput(OutString,locout)
}
//--------------------------------
//END Get_Phone





//BEGIN Get_Address--retrieves the address of a location and formats with line breaks
function Get_Address(strx,locout)
{

	qstring = "/addresses/location[linknav='" + strx + "']" 

	loadXMLDoc("xmldata/addresses.xml")


	if (window.ActiveXObject) 
	{
	
		x = xmldoc.selectSingleNode(qstring)
		cnode = x.childNodes
		OutString = "";	

		//the attribute is the company mame-- 'PHH'-- same for all addresses 
		OutString += x.attributes.getNamedItem("company").nodeValue + "<br />";
		//for addresses.xml, node 0 is the Entity e.g. Home Care, Hospice, etc
		OutString +=  cnode(0).text + "<br />";
		
		/* node 2 is the Building, but not every Building element is populated
		so use if-then to check for empty string  */
		if (cnode(2).text.length > 0) {
			 OutString += cnode(2).text  + "<br />";
				} else {
				}			

		/* node 3 is the first Address line */
		OutString += cnode(3).text  + "<br />";
		
		/* node 2 is the second Address line, but this element is optionally populated
		so use if-then to check for empty string  */
		if (cnode(4).text.length > 0) {
			 OutString += cnode(4).text  + "<br />";
				} else {
				}	
		
		//node 5 is City, node 6 is state, node 7 is Zip
		OutString += cnode(5).text  +  " " + cnode(6).text + ", "  + cnode(7).text  + "<br />";
		
		//node 8 is Phone number
		if (cnode(8).text.length > 0) {
			 OutString += cnode(8).text  + "<br />";
				} else {
				};
				
							

	}
		else if (document.implementation && document.implementation.createDocument)
		{
			x = xmldoc.evaluate(qstring,xmldoc,null,XPathResult.ANY_TYPE,null);
			cnode = x.iterateNext();
			OutString = "";	
	

  			while (cnode) {   

				
					//the attribute is the company mame-- 'PHH'-- same for all addresses 
					OutString  +=  cnode.getAttribute("company") + "<br />";
					
					// Entity e.g. Home Care, Hospice, etc
					OutString += cnode.getElementsByTagName('entity')[0].textContent  + "<br />";
		
					/*  not every Building element is populated
					so use if-then to check for empty string  */
							if (cnode.getElementsByTagName('building')[0].textContent != " ") {
						OutString += cnode.getElementsByTagName('building')[0].textContent + "<br />";
							} else {
							}	

					OutString += cnode.getElementsByTagName('address1')[0].textContent  + "<br />";
					
					/*  not every Address2 element is populated
					so use if-then to check for empty string  */
					if (cnode.getElementsByTagName('address2')[0].textContent != " ") {
						 OutString += cnode.getElementsByTagName('address2')[0].textContent + "<br />";
							} else {
							}	

					// City, State, Zip all wrap on same line
					OutString += cnode.getElementsByTagName('city')[0].textContent  +  " " +
					cnode.getElementsByTagName('state')[0].textContent  + ", "  +
					cnode.getElementsByTagName('zip')[0].textContent  + "<br />";
					
					OutString += cnode.getElementsByTagName('phone')[0].textContent  + "<br />";
					
					cnode = x.iterateNext(); 
							}
  
			} 

		loadOutput(OutString,locout)

						

}
//--------------------------------
//END Get_Address





//BEGIN Get_LocationsList
function Get_LocationsList(strx,locout)
{
		

 QueryString = "/addresses/location[entity='" + strx + "']/linknav" 
 ystring = "/addresses/location[entity='" + strx + "']/city"


    loadXMLDoc("xmldata/addresses.xml")

    cssclass = "LinkItems"

	if (window.ActiveXObject) 
	{
	  
	  	nodes = xmldoc.selectNodes(QueryString);
		dnode =  xmldoc.selectNodes(ystring);		
		OutString = "";
		
		OutString += "<ul class='" + cssclass + "'>";
		
		for (i=0;i<nodes.length && i<dnode.length;i++)
		
			
						
			  {	
			 OutString  += "<li><a href=" +  nodes[i].childNodes[0].nodeValue + ".htm>" +
			 dnode[i].childNodes[0].nodeValue + "</a></li>";
			  }
			  OutString += "</ul>";
	}
		else if (document.implementation && document.implementation.createDocument)
		{
			
			nodes = xmldoc.evaluate(QueryString,xmldoc,null,XPathResult.ANY_TYPE,null);
			dnode = xmldoc.evaluate(ystring,xmldoc,null,XPathResult.ANY_TYPE,null);
			result=nodes.iterateNext();
			yresult = dnode.iterateNext();
			OutString = "";
			OutString += "<ul class='" + cssclass + "'>";
			
			while (result && yresult)
			{
		
				OutString  += "<li><a href=" +  result.childNodes[0].nodeValue + ".htm>" +
				 yresult.childNodes[0].nodeValue + "</a></li>";

				  result=nodes.iterateNext();
				  yresult = dnode.iterateNext(); 

				  }
				OutString += "</ul>";
			} 

			loadOutput(OutString,locout)
	
}
//--------------------------------
//END Get_LocationsList



	
 









/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* passed JSLINT  scan -- http://www.jslint.com,  9/2/10 */ 

/*global window: false */ 


var ie;
var ns6;
var offsetxpoint;
var offsetypoint;
var enabletip;
var tipobj;



offsetxpoint=-60; //Customize x offset of tooltip;
offsetypoint=20; //Customize y offset of tooltip;
ie=document.all;
ns6=document.getElementById && !document.all;
enabletip=false;


function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}


function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
tipobj=document.all? document.all.dhtmltooltip : document.getElementById? document.getElementById("dhtmltooltip") : "";
if (typeof thewidth!="undefined")
	{tipobj.style.width=thewidth+"px";}
if (typeof thecolor!=="undefined" && thecolor!=="") 
	{tipobj.style.backgroundColor=thecolor;}
tipobj.innerHTML=thetext;
enabletip=true;
return false;
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20;
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20;

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000;

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
{
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px";}
else if (curX<leftedge)
	{tipobj.style.left="5px";}
else
//position the horizontal position of the menu where the mouse is positioned
	{tipobj.style.left=curX+offsetxpoint+"px";}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
{
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px";
}
else
{tipobj.style.top=curY+offsetypoint+"px";
tipobj.style.visibility="visible";}
}
}

function hideddrivetip(){
if (ns6||ie){
tipobj=document.all? document.all.dhtmltooltip : document.getElementById? document.getElementById("dhtmltooltip") : "";
enabletip=false;
tipobj.style.visibility="hidden";
tipobj.style.left="-1000px";
tipobj.style.backgroundColor='';
tipobj.style.width='';
}
}

document.onmousemove=positiontip;




//--------------------------------
//BEGIN DONATE.ASP PAGE SCRIPT

function showStuff(workingVar) 
{
	if (workingVar == 'Monthly gift')
	{
		document.getElementById("giftDurationtitle").innerHTML = "Select a Gift Duration:";
		document.getElementById("giftDurationFld").innerHTML = "<select name=giftDuration><option value='Forever'>Forever</option><option value='2 months'>2 months</option><option value='3 months'>3 months</option><option value='4 months'>4 months</option><option value='5 months'>5 months</option><option value='6 months'>6 months</option><option value='7 months'>7 months</option><option value='8 months'>8 months</option><option value='9 months'>9 months</option><option value='10 months>10 months</option><option value='11 months'>11 months</option><option value='12 months'>12 months</option></select>";
	}
	else 
	{
		document.getElementById("giftDurationtitle").innerHTML = "";
		document.getElementById("giftDurationFld").innerHTML = "";
	}
}


// Required fields error checking

function errorCheck()
{

// Create some variables for our script
var requiredFieldsErrorMessage = "";
var firstNameEntered = "";
var lastNameEntered = "";

var AddressEntered = "";
var CityEntered = "";
var StateEntered = "";
var ExpDateEntered = "";
var ExpM = "";
var ExpY = "";

var CardNumberEntered = "";
var AmountEntered = "";
var Amount2Entered = "";
var emailEntered = "";
var DayPhone1Entered = "";
var DayPhone2Entered = "";
var DayPhone3Entered = "";
var zipCodeEntered = "";
var AddressCityEntered = "";
var GiftEntered = "";
var DescEntered = "";
var TitleEntered = "";



var pullDownErrorMessage = "";
var emailErrorMessage = "";
var areaCodeErrorMessage = "";
var zipCodeErrorMessage = "";
var DayPhoneErrorMessage = "";
var AmountErrorMessage = "";
var CreditCardErrorMessage = "";
var ExpErrorMessage = "";
var firstNameErrorMessage = "";
var lastNameErrorMessage = "";
var CityErrorMessage = "";
var AddressCityErrorMessage = "";
var OtherErrorMessage = "";
var TitleErrorMessage = "";



//use below for Credit Card Expiration test
var now = new Date();
//Javascript returns month as 0-11 add 1 to make 1-12
var m = now.getMonth() + 1;
//adds leading zero to months 1-9
var thisMonth = (m < 10) ? '0' + m : m;             

var thisYear = now.getFullYear();                     

firstNameEntered = document.donate.FirstName.value;
lastNameEntered = document.donate.LastName.value;
emailEntered = document.donate.Email.value;
AddressEntered = document.donate.Add1.value;
CityEntered = document.donate.City.value;
StateEntered = document.donate.State.value;
zipCodeEntered = document.donate.Zip.value;
DayPhone1Entered = document.donate.DayPhone1.value;
DayPhone2Entered = document.donate.DayPhone2.value;
DayPhone3Entered = document.donate.DayPhone3.value;
AmountEntered = document.donate.Amount.value;
Amount2Entered = document.donate.Amount2.value;
CardNumberEntered = document.donate.CreditCardNumber.value;
ExpDateEntered = document.donate.ExpY.value;
AddressCityEntered = document.donate.AddressCity.value;


if ((!firstNameEntered) || (!lastNameEntered) || (!AddressEntered)  || (!CityEntered)  || (!StateEntered) || (!zipCodeEntered) ||(!AmountEntered) || (!CardNumberEntered) ||(!emailEntered) || (!Amount2Entered) || (!DayPhone1Entered))
{


	if (!firstNameEntered)
	{
		requiredFieldsErrorMessage = requiredFieldsErrorMessage + "- your first name is missing\r";
	}
	if (!lastNameEntered)
	{
		requiredFieldsErrorMessage = requiredFieldsErrorMessage + "- your last name is missing\r";
	}
	if (!emailEntered)
	{
		requiredFieldsErrorMessage = requiredFieldsErrorMessage + "- your E-mail Address is missing\r";
	}
	if (!AddressEntered)
	{
		requiredFieldsErrorMessage = requiredFieldsErrorMessage + "- your Address is missing\r";
	}
	if (!CityEntered)
	{
		requiredFieldsErrorMessage = requiredFieldsErrorMessage + "- your City is missing\r";
	}
	
	if (!zipCodeEntered)
	{
		requiredFieldsErrorMessage = requiredFieldsErrorMessage + "- your Zip Code is missing\r";
	}
	if (!DayPhone1Entered)
	{
		requiredFieldsErrorMessage = requiredFieldsErrorMessage + "- your Telephone Area Code is missing\r";
	}

	if (document.donate.dropAmount.value == 0)
	{
		if (!AmountEntered)
		{
			requiredFieldsErrorMessage = requiredFieldsErrorMessage + "- your Donation Amount is missing\r";
		}

		if (!Amount2Entered)
		{
			requiredFieldsErrorMessage = requiredFieldsErrorMessage + "- your Donation Amount (cents) is missing\r";
		}
	}

	if (!CardNumberEntered)
	{
		requiredFieldsErrorMessage = requiredFieldsErrorMessage + "- your Card Number is missing\r";
	}
	
}


//more than a dollar

	AmountEntered = document.donate.Amount.value
	


//numbers in Amount  

	AmountEntered = document.donate.Amount.value
	Amount2Entered = document.donate.Amount2.value
	
	if (AmountEntered)
{
	AmountIsNaN = isNaN(AmountEntered)
	
	if (AmountIsNaN == 1)
	{		
		AmountErrorMessage = "- donation amount must consist of numbers only\r";
	}
}
	if (Amount2Entered)
{	
	Amount2NaN = isNaN(Amount2Entered)
	if (Amount2NaN == 1)
	{
		AmountErrorMessage = "- donation amount must consist of numbers only\r";

	}
}

//numbers in Credit

	CardNumberEntered = document.donate.CreditCardNumber.value
	
	if (CardNumberEntered)
{
	AmountIsNaN = isNaN(CardNumberEntered)
	if (AmountIsNaN == 1)
	{		
		CreditCardErrorMessage = "- your Credit Card Number has non-numbers in it\r";
	}


}


//numbers in Phone

	DayPhone1Entered = document.donate.DayPhone1.value
	DayPhone2Entered = document.donate.DayPhone2.value
	DayPhone3Entered = document.donate.DayPhone3.value
	
	if (DayPhone1Entered)
{
	AmountIsNaN = isNaN(DayPhone1Entered)
	if (AmountIsNaN == 1)
	{		
		DayPhoneErrorMessage = "- your Day Phone Number Area Code has non-numbers in it\r";
	}


}
	if (DayPhone2Entered)
{
	AmountIsNaN = isNaN(DayPhone2Entered)
	if (AmountIsNaN == 1)
	{		
		DayPhoneErrorMessage = "- your Day Phone Number prefix has non-numbers in it\r";
	}


}
	if (DayPhone3Entered)
{
	AmountIsNaN = isNaN(DayPhone3Entered)
	if (AmountIsNaN == 1)
	{		
		DayPhoneErrorMessage = "- your Day Phone Number has non-numbers in it\r";
	}


}

//Expiration Date is valid

	ExpY = document.donate.ExpY.value
	ExpM = document.donate.ExpM.value


   if (ExpY && ExpM)	
   {
	if (ExpY < thisYear)
        {
        ExpErrorMessage = "- Your Credit Card has Expired\r";
        }

    	if (ExpY == thisYear && ExpM < thisMonth)
        {
        ExpErrorMessage = "- Your Credit Card has Expired\r";
        }
   }
 


// email error checking

if (emailEntered)
{
	emailEntered = document.donate.Email.value;
	emailValue = new String (emailEntered);
	emailHasAt = emailValue.indexOf("@");
	emailHasPeriod = emailValue.indexOf(".");

		
	if ((emailHasAt == -1) || (emailHasPeriod == -1))
	{
		emailErrorMessage = "- Your email address\r";
	}
}

//Check for numbers in text fields

if (firstNameEntered)
{
	for (i=0; i<firstNameEntered.length; i++) 
  {
		if (firstNameEntered.charAt(i) <= "9" && firstNameEntered.charAt(i) >= "0")
	{
			firstNameErrorMessage = "- your first name has numbers in it\r";	
	}
  }
}

if (lastNameEntered)
{
	for (i=0; i<lastNameEntered.length; i++) 
  {
		if (lastNameEntered.charAt(i) <= "9" && lastNameEntered.charAt(i) >= "0")
	{
			lastNameErrorMessage = "- your last name has numbers in it\r";	
	}
  }
}

if (CityEntered)
{
	for (i=0; i<CityEntered.length; i++) 
  {
		if (CityEntered.charAt(i) <= "9" && CityEntered.charAt(i) >= "0")
	{
			CityErrorMessage = "- your City has numbers in it\r";	
	}
  }
}


if (AddressCityEntered)
{
	for (i=0; i<AddressCityEntered.length; i++) 
  {
		if (AddressCityEntered.charAt(i) <= "9" && AddressCityEntered.charAt(i) >= "0")
	{
			AddressCityErrorMessage = "- your tribute city has numbers in it\r";	
	}
  }
}




// Letting the user know what was missed

if ((requiredFieldsErrorMessage) || (emailErrorMessage) || (zipCodeErrorMessage) || (AmountErrorMessage) || (CreditCardErrorMessage) || (ExpErrorMessage) || (DayPhoneErrorMessage) || (firstNameErrorMessage) || (lastNameErrorMessage) || (CityErrorMessage) || (AddressCityErrorMessage) || (OtherErrorMessage))
{
	alertMessage = "The necessary information in the following query is incomplete and/or incorrect.\r";

	//build remainder of the alert message
	alertMessage = alertMessage + requiredFieldsErrorMessage;
	alertMessage = alertMessage + pullDownErrorMessage;
	alertMessage = alertMessage + emailErrorMessage;
	alertMessage = alertMessage + AmountErrorMessage;
	alertMessage = alertMessage + CreditCardErrorMessage;
	alertMessage = alertMessage + ExpErrorMessage;
	alertMessage = alertMessage + DayPhoneErrorMessage;
	alertMessage = alertMessage + zipCodeErrorMessage;
	alertMessage = alertMessage + firstNameErrorMessage;
	alertMessage = alertMessage + lastNameErrorMessage;
	alertMessage = alertMessage + CityErrorMessage;
	alertMessage = alertMessage + AddressCityErrorMessage;
	alertMessage = alertMessage + OtherErrorMessage;
 
	

	// Now, display the error message
	alert ( alertMessage );
	return false;
      	}
else
   		{
		return true;
      	}
}



//--------------------------------
//END DONATE.ASP PAGE SCRIPT




<!--
/*
Submit Once form validation- 
*/
 
  function submitonce(theform)
    {
     //if IE 4+ or NS 6+
     if (document.all||document.getElementById)
      {
      //screen thru every element in the form, and hunt down "submit" and "reset"
      for (i=0;i<theform.length;i++)
        {
        var tempobj=theform.elements[i]
        if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
        //disable em
        tempobj.disabled=true
        }
      }
    }


//-->

