/***************************************************
*  JavaScript file for Delmar Gardens Enterprises  *
*  - - - - - - - - - - - - - - - - - - - - - - - - *
*  Created By: Valentine Marchetti                 *
*  Created By: Duane Tuffentsamer                  *
*  Dated Created: 12/6/2006                        *
*  Edited By: ___________________________________  *
*  Edited On: ___________________________________  *
*  - - - - - - - - - - - - - - - - - - - - - - - - *
*  Functions List:                                 *
*   + igniter                                      *
*   + centerPop                                    *
*   + locationImagePop                             *
*	+ locationMenu                                 *
***************************************************/
/*********************
*  Global Variables  *
*********************/
	var xmlHttp = createXmlHttpRequestObject();
	var searchForm;
	var thisanimation;
	var iTimeoutID;
	
/*********************
*  Igniter Function  *
*********************/
	igniter = function() {
		// If the facilityChoose div exists on the page, then call this function
			if (document.getElementById("facilityChoose")) {
				locationMenu();
			}
		// If the jar_facilityImage div exists on the page, then call this function
			if (document.getElementById("startImagePop")) {
				locationImagePop();
				mapClick();
			}
			if (document.getElementById("facility_video")) {
				locationVideoPop();
			}
		// Blah
			if (document.getElementById("divMessage")) {
				initPage();
			}
	}
/********************/	





/********************************
*  Location Image Pop Function  *
********************************/
	locationImagePop = function() {
		
		jc = document.getElementById("jar_content"); // Shortcut
		if (document.getElementById("divMessage")) {
			ujc = document.getElementById("divMessage");
		} else {
			ujc = document.getElementById("jar_content"); // Shortcut
		}
		//document.getElementById("jar_content").innerHTML += '<div id="jar_facilityImage"><div id="relative"><a id="close"></a><span id="hdr"></span><div><img src="http://www.delmargardens.com/dgenterprises/_media/images/locationphotos/Sunset.jpg" width="292" height="192" alt="Delmar Gardens Facility Image" id="facilityImage" /></div><span id="ftr"></span></div></div>';

		centerPop();
		
		/*
			<div id="jar_facilityImage">
				<div id="relative">
					<a id="close"></a>
					<span id="hdr"></span>
					<div>
						<img src="http://www.delmargardens.com/dgenterprises/_media/images/locationphotos/Sunset.jpg" width="292" height="192" alt="Delmar Gardens Facility Image" id="facilityImage" />
					</div>
					<span id="ftr"></span>
				</div>
			</div>
		*/

		window.onresize = centerPop;
		window.onscroll = centerPop;
		
		// Closes the pop up image window upon clicking the close button	
			pw = document.getElementById("jar_facilityImage"); // Shortcut			
			document.getElementById("close").onclick = function() {
				pw.style.display = "none"; // Closes!
				showSelectBoxes();
			}
			//alert (ujc.childNodes.length);						
		// This code will unhide a div when one of the thumbnails on the facilities page is clicked
			for (a=0; a<ujc.childNodes.length; a++) { // Loop through all tags within jar_content
				tlj = ujc.childNodes[a]; // Shortcut
				
				for (b=0; b<tlj.childNodes.length; b++) { // Loop through all tags within jar_facility
					tl = tlj.childNodes[b]; // Shortcut
					if (tl.className == 'facility_images') { // If tag has a class of "facility_images"
	
						for (c=0; c<tl.childNodes.length; c++) { // Loop through all tags within facility_images
							tla = tl.childNodes[c]; // Shortcut
							
							if (tla.nodeName=="A") { // If an Anchor tag
								tla.onclick=function() { // onclick
									document.getElementById("facilityImage").src = 'http://www.delmargardens.com/_media/images/bg_chooseAFacility.png'; // Sets the popup Image to a 1px already loaded image.
									document.getElementById("facilityImage").src = this.href; // Sets the popup Image to this anchor's href which is the larger image
									hideSelectBoxes();
									pw.style.display = "block"; // Opens!
									var vvp = document.getElementById("video_player");
									vvp.style.display="none"; //Closes the video div
									return false; // Don't go anywhere!
								}
							}						
						}
					}
				}
			}
	}

/********************************
*  Location Image Video Pop Function  *
********************************/
	locationVideoPop = function() {
		var vup = document.getElementById("video_player");
		centerVideoPop();
		
		if (document.getElementById("videolink")) {
			document.getElementById("videolink").onclick = function() {
				vup.style.display="block"; //Opens the video div
				document.getElementById("jar_facilityImage").style.display = "none"; // Closes pic window!
				return false;
			}
		}
		
		//window.onresize = centerVideoPop;
		//window.onscroll = centerVideoPop;
	}




/************************
*  Center Pop Function  *
************************/
	centerPop = function() {
		// This code will keep the popup div centered on the page at all times.
			pw = document.getElementById("jar_facilityImage"); // Shortcut
			
			if( /Opera|Safari/.test(navigator.userAgent) ) { // If Opera or Safari
				browserHeight = window.innerHeight; // Gets Browser Height for Opera & Safari
				pw.style.top = ( ( ( ( browserHeight - 277 ) / 2 ) - 277 ) + document.body.scrollTop ) + 'px'; // sets the absolute location of the jar_facilityImage div to the browser height - 277px divided by 2 - another 277px + the scroll offset of the page.
			} else { // Else any other browser we support
				browserHeight = document.documentElement['clientHeight']; // Gets Browser Height for all other browsers
				pw.style.top = ( ( ( ( browserHeight - 277 ) / 2 ) - 277 ) + document.documentElement['scrollTop'] ) + 'px'; // sets the absolute location of the jar_facilityImage div to the browser height - 277px divided by 2 - another 277px + the scroll offset of the page.
			}
			centerVideoPop();
	}
/***********************/

/************************
*  Center Video Pop Function  *
************************/
	centerVideoPop = function() {
		// This code will keep the popup div centered on the page at all times.
			var vp = document.getElementById("video_player"); // Shortcut
			
			if( /Opera|Safari/.test(navigator.userAgent) ) { // If Opera or Safari
				browserHeight = window.innerHeight; // Gets Browser Height for Opera & Safari
				vp.style.top = ( ( ( ( browserHeight - 300 ) / 2 ) - 300 ) + document.body.scrollTop ) + 'px'; // sets the absolute location of the jar_facilityImage div to the browser height - 277px divided by 2 - another 277px + the scroll offset of the page.
			} else { // Else any other browser we support
				browserHeight = document.documentElement['clientHeight']; // Gets Browser Height for all other browsers
				vp.style.top = ( ( ( ( browserHeight - 300 ) / 2 ) - 300 ) + document.documentElement['scrollTop'] ) + 'px'; // sets the absolute location of the jar_facilityImage div to the browser height - 277px divided by 2 - another 277px + the scroll offset of the page.
			}
	}
/***********************/


/***************************
*  Location Menu Function  *
***************************/
	locationMenu = function() {

		// Writes the HTML for the callout and the menu into <div id="facilityChoose"> </div>
			document.getElementById("facilityChoose").innerHTML += '<a id="call_chooseFacility">Choose a facility</a><div id="chooseAFacility"><a id="close"></a><h4>Choose a facility:</h4><div id="jar_facility"><p id="facilityInfo"></p><ul><li><a href="/gvnorth/" id="gvn">Garden Villas North</a></li><li><a href="/dgnorth/" id="dgn">Delmar Gardens North</a></li><li><a href="/gvsouth/" id="gvs">Garden Villas South</a></li><li><a href="/dgsouth/" id="dgs">Delmar Gardens South</a></li><li><a href="/gv/" id="gv">Garden Villas</a></li><li><a href="/dgwest/" id="dgw">Delmar Gardens West</a></li><li><a href="/chesterfieldv/" id="cv">Chesterfield Villas</a></li><li><a href="/dgchesterfield/" id="dgoc">Delmar Gardens of Chesterfield</a></li><li><a href="/dgonthegreen/" id="dgotg">Delmar Gardens On The Green</a></li><li><a href="/dgcrevecoeur/" id="dgocc">Delmar Gardens of Creve Coeur</a></li><li><a href="/adamsplace/" id="ap">Adams Place</a></li><li><a href="/dgmeramecvalley/" id="dgomv">Delmar Gardens of Meramec Valley</a></li><li><a href="/dgofallon/" id="dgoo">Delmar Gardens of O\'Fallon</a></li><li><a href="/gvlenexa/" id="gvol">Garden Villas of Lenexa</a></li><li><a href="/dglenexa/" id="dgol">Delmar Gardens of Lenexa</a></li><li><a href="/dgoverlandpark/" id="dgoop">Delmar Gardens of Overland Park</a></li><li><a href="/dgsmyrnav/" id="dgosv">Delmar Gardens of Smyrna (Retirement)</a></li><li><a href="/dgsmyrnan/" id="dgosn">Delmar Gardens of Smyrna (Nursing)</a></li><li><a href="/dggwinnettv/" id="dgog">Delmar Gardens of Gwinnett (Retirement)</a></li><li><a href="/dggwinnettn/" id="dgogn">Delmar Gardens of Gwinnett (Nursing)</a></li><li><a href="/dggreenvalley/" id="dgogv">Delmar Gardens of Green Valley</a></li><li><a href="/stjosephv/" id="sjv">St. Joseph Villa</a></li><li><a href="/homecare/" id="dghc">Delmar Gardens Home Care</a></li><li><a href="/privateservices/" id="dgps">Delmar Gardens Private Services</a></li><li><a href="/pathways/" id="pch">Pathways Community Hospice</a></li><li><a href="/stjosephvhh/" id="sjvhh">St. Joseph Villa Homecare &amp; Hospice</a></li><li><a href="http://www.medresourcesinc.com" id="medrec">MedResources</a></li></ul></div><span></span></div>';
			/*
				<a id="call_chooseFacility">Choose a facility</a>
				<div id="chooseAFacility">
					<a id="close"></a>
					<h4>Choose a facility:</h4>
					<div id="jar_facility">
						<p id="facilityInfo"></p>
						<ul>
							<li><a href="/gvnorth/" id="gvn">Garden Villas North</a></li>
							<li><a href="/dgnorth/" id="dgn">Delmar Gardens North</a></li>
							<li><a href="/gvsouth/" id="gvs">Garden Villas South</a></li>
							<li><a href="/dgsouth/" id="dgs">Delmar Gardens South</a></li>
							<li><a href="/gvwest/" id="gv">Garden Villas</a></li>
							<li><a href="/dgwest/" id="dgw">Delmar Gardens West</a></li>
							<li><a href="/chesterfieldv/" id="cv">Chesterfield Villas</a></li>
							<li><a href="/dgchesterfield/" id="dgoc">Delmar Gardens of Chesterfield</a></li>
							<li><a href="/dgonthegreen/" id="dgotg">Delmar Gardens On The Green</a></li>
							<li><a href="/dgcrevecoeur/" id="dgocc">Delmar Gardens of Creve Coeur</a></li>
							<li><a href="/adamsplace/" id="ap">Adams Place</a></li>
							<li><a href="/dgmeramecvalley/" id="dgomv">Delmar Gardens of Meramec Valley</a></li>
							<li><a href="/dgofallon/" id="dgoo">Delmar Gardens of O\'Fallon</a></li>
							<li><a href="/gvlenexa/" id="gvol">Garden Villas of Lenexa</a></li>
							<li><a href="/dglenexa/" id="dgol">Delmar Gardens of Lenexa</a></li>
							<li><a href="/dgoverlandpark/" id="dgoop">Delmar Gardens of Overland Park</a></li>
							<li><a href="/dgsmyrnav/" id="dgosv">Delmar Gardens of Smyrna (Villa)</a></li>
							<li><a href="/dgsmyrnan/" id="dgosn">Delmar Gardens of Smyrna (Nursing)</a></li>
							<li><a href="/dggwinnettv/" id="dgog">Delmar Gardens of Gwinnett (Villa)</a></li>
							<li><a href="/dggwinnettn/" id="dgogn">Delmar Gardens of Gwinnett (Nursing)</a></li>
							<li><a href="/dggreenvalley/" id="dgogv">Delmar Gardens of Green Valley</a></li>
							<li><a href="/stjosephv/" id="sjv">St. Joseph Villa</a></li>
						</ul>
					</div>
					<span></span>
				</div>			
			*/
		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
		// Sets a shortcut for myMenu & forces it to hide
			myMenu = document.getElementById("chooseAFacility"); // Shortcut
			myMenu.style.display = "none"; // force hide
		// - - - - - - - - - - - - - - - - - - - - - - - -
		
		// Opens and closes the Location Menu
			document.getElementById("call_chooseFacility").onclick = function() {
				myMenu.style.display = "block"; // Opens
			}
			document.getElementById("close").onclick = function() {
				myMenu.style.display = "none"; // Closes
			}
		// - - - - - - - - - - - - - - - - - -			
		
		// Setup for changing location image and contact info
			info = document.getElementById("facilityInfo");  // Shortcut
			// Initial Display
			info.innerHTML = 'Garden Villas North<br/>Retirement Community<br/>4505 Parker Road<br/>Florissant, Missouri 63033<br/>(314) 355-6100';			
			info.style.backgroundImage = 'url(/dgenterprises/_media/images/locationThumbs.png)';
			info.style.backgroundPosition = '0 5px';

			// Garden Villas North
				document.getElementById("gvn").onmouseover = function() {
					info.innerHTML = 'Garden Villas North<br/>Retirement Community<br/>4505 Parker Road<br/>Florissant, Missouri 63033<br/>(314) 355-6100';
					info.style.backgroundPosition = '0 5px';
				}
			// Delmar Gardens North
				document.getElementById("dgn").onmouseover = function() {
					info.innerHTML = 'Delmar Gardens North<br/>Nursing &amp; Rehabilitation Center<br/>4401 Parker Road<br/>Florissant, Missouri 63033<br/>(314) 355-1516';
					info.style.backgroundPosition = '0 -145px';
				}
			// Garden Villas South
				document.getElementById("gvs").onmouseover = function() {
					info.innerHTML = 'Garden Villas South<br/>Retirement Community<br/>13457 Tesson Ferry Road<br/>St. Louis, Missouri 63128<br/>(314) 843-7788';
					info.style.backgroundPosition = '0 -295px';
				}
			// Delmar Gardens South
				document.getElementById("dgs").onmouseover = function() {
					info.innerHTML = 'Delmar Gardens South<br/>Nursing &amp; Rehabilitation Center<br/>5300 Butler Hill Road<br/>St. Louis, Missouri 63128<br/>(314) 842-0588';
					info.style.backgroundPosition = '0 -445px';					
				}
			// Garden Villas (West)
				document.getElementById("gv").onmouseover = function() {
					info.innerHTML = 'Garden Villas<br/>Retirement Community<br/>13590 South Outer 40 Road<br/>Town &amp; Country, Missouri 63017<br/>(314) 434-2520';
					info.style.backgroundPosition = '0 -595px';										
				}
			// Delmar Gardens West
				document.getElementById("dgw").onmouseover = function() {
					info.innerHTML = 'Delmar Gardens West<br/>Nursing &amp; Rehabilitation Center<br/>13550 South Outer 40 Road<br/>Town &amp; Country, Missouri 63017<br/>(314) 878-1330';
					info.style.backgroundPosition = '0 -745px';	
				}
			// Chesterfield Villas
				document.getElementById("cv").onmouseover = function() {
					info.innerHTML = 'Chesterfield Villas<br/>Retirement Community<br/>14901 North Outer 40 Road<br/>Chesterfield, Missouri 63017<br/>(636) 532-9296';
					info.style.backgroundPosition = '0 -895px';	
				}
			// Delmar Gardens of Chesterfield
				document.getElementById("dgoc").onmouseover = function() {
					info.innerHTML = 'Delmar Gardens of Chesterfield<br/>Nursing &amp; Rehabilitation Center<br/>14855 North Outer 40 Road.<br/>Chesterfield, Missouri 63017<br/>(636) 532-0150';
					info.style.backgroundPosition = '0 -1045px';	
				}
			// Delmar Gardens on the Green
				document.getElementById("dgotg").onmouseover = function() {
					info.innerHTML = 'Delmar Gardens on the Green<br/>Nursing &amp; Rehabilitation Center<br/>15197 Clayton Road<br/>Chesterfield, Missouri 63017<br/>(636) 394-7515';
					info.style.backgroundPosition = '0 -1195px';	
				}			
			// Delmar Gardens of Creve Coeur
				document.getElementById("dgocc").onmouseover = function() {
					info.innerHTML = 'Delmar Gardens of Creve Coeur<br/>Nursing &amp; Rehabilitation Center<br/>850 Country Manor Lane<br/>Creve Coeur, Missouri 63141<br/>(314) 434-5900';
					info.style.backgroundPosition = '0 -1345px';	
				}
			// Adams Place
				document.getElementById("ap").onmouseover = function() {
					info.innerHTML = 'Adams Place<br/>Retirement Community<br/>120 West Adams<br/>Kirkwood, Missouri 63122<br/>(314) 965-7070';
					info.style.backgroundPosition = '0 -1495px';
				}
			// Delmar Gardens of Meramec Valley
				document.getElementById("dgomv").onmouseover = function() {
					info.innerHTML = 'Delmar Gardens of Meramec Valley<br/>Nursing &amp; Rehabilitation Center<br/>#1 Arbor Terrace<br/>Fenton, Missouri 63026<br/>(636) 343-0016';
					info.style.backgroundPosition = '0 -1645px';
				}
			// Delmar Gardens of O'fallon
				document.getElementById("dgoo").onmouseover = function() {
					info.innerHTML = 'Delmar Gardens of O\'Fallon<br/>Nursing &amp; Rehabilitation Center<br/>7068 South Outer 364<br/>O\'Fallon, Missouri 63368<br/>(636) 240-6100';
					info.style.backgroundPosition = '0 -1795px';
				}
			// Garden Villas of Lenexa
				document.getElementById("gvol").onmouseover = function() {
					info.innerHTML = 'Garden Villas of Lenexa<br/>Retirement Community<br/>9705 Monrovia<br/>Lenexa, Kansas 66215<br/>(913) 492-1133';
					info.style.backgroundPosition = '0 -1945px';
				}
			// Delmar Gardens of Lenexa
				document.getElementById("dgol").onmouseover = function() {
					info.innerHTML = 'Delmar Gardens of Lenexa<br/>Nursing &amp; Rehabilitation Center<br/>9701 Monrovia<br/>Lenexa, Kansas 66215<br/>(913) 492-1130';
					info.style.backgroundPosition = '0 -2095px';
				}
			// Delmar Gardens of Overland Park
				document.getElementById("dgoop").onmouseover = function() {
					info.innerHTML = 'Delmar Gardens of Overland Park<br/>Nursing &amp; Rehabilitation Center<br/>12100 West 109th Street<br/>Overland Park, Kansas 66210<br/>(913) 469-4210';
					info.style.backgroundPosition = '0 -2245px';	
				}
			// Delmar Gardens of Smyrna (Villas)
				document.getElementById("dgosv").onmouseover = function() {
					info.innerHTML = 'Delmar Gardens of Smyrna<br/>Retirement Community<br/>404 King Springs Village Parkway<br/>Smyrna, Georgia 30082<br/>(770) 432-4444';
					info.style.backgroundPosition = '0 -2395px';	
				}
			// Delmar Gardens of Smyrna (Nursing)
				document.getElementById("dgosn").onmouseover = function() {
					info.innerHTML = 'Delmar Gardens of Smyrna<br/>Nursing &amp; Rehabilitation Center<br/>404 King Springs Village Parkway<br/>Smyrna, Georgia 30082<br/>(770) 432-4444';
					info.style.backgroundPosition = '0 -2545px';	
				}
			// Delmar Gardens of Gwinnett (Villas)
				document.getElementById("dgog").onmouseover = function() {
					info.innerHTML = 'Delmar Gardens of Gwinnett<br/>Retirement Community<br/>3100 Club Drive<br/>Lawrenceville, Georgia 30044<br/>(770) 923-3100';
					info.style.backgroundPosition = '0 -2695px';	
				}
			// Delmar Gardens of Gwinnett (Nursing)
				document.getElementById("dgogn").onmouseover = function() {
					info.innerHTML = 'Delmar Gardens of Gwinnett<br/>Nursing &amp; Rehabilitation Center<br/>3100 Club Drive<br/>Lawrenceville, Georgia 30044<br/>(770) 923-3100';
					info.style.backgroundPosition = '0 -2845px';	
				}
			// Delmar Gardens of Green Valley
				document.getElementById("dgogv").onmouseover = function() {
					info.innerHTML = 'Delmar Gardens of Green Valley<br/>Nursing &amp; Rehabilitation Center<br/>100 Delmar Gardens Drive<br/>Henderson, Nevada 89074<br/>(702) 361-6111';
					info.style.backgroundPosition = '0 -2995px';	
				}
			// St. Joseph Villa
				document.getElementById("sjv").onmouseover = function() {
					info.innerHTML = 'St. Joseph Villa<br/>Nursing &amp; Rehabilitation Center<br/>2305 South 10th Street<br/>Omaha, Nebraska 68108<br/>(402) 345-5683';
					info.style.backgroundPosition = '0 -3145px';	
				}
				// Home Care
				document.getElementById("dghc").onmouseover = function() {
					info.innerHTML = 'Delmar Gardens Home Care<br/>14805 N. Outer 40 Road Suite 320<br/>Chesterfield, MO 63017<br/>(636) 733-7330';
					info.style.backgroundPosition = '0 -3295px';	
				}
				// Private Services
				document.getElementById("dgps").onmouseover = function() {
					info.innerHTML = 'Delmar Gardens Private Services<br/>14805 N. Outer 40 Road Suite 120<br/>Chesterfield, MO 63017<br/>(636) 733-7100';
					info.style.backgroundPosition = '0 -3445px';	
				}
				// Pathways
				document.getElementById("pch").onmouseover = function() {
					info.innerHTML = 'Pathways<br/>Community Hospice<br/>14805 N. Outer 40 Road Suite 160<br/>Chesterfield, MO 63017<br/>(636) 733-7399';
					info.style.backgroundPosition = '0 -3595px';	
				}
				// St. Joseph Villa Homecare & Hospice
				document.getElementById("sjvhh").onmouseover = function() {
					info.innerHTML = 'St. Joseph Villa<br/>Homecare &amp; Hospice<br/>1000 North 90th Street, Suite 203<br/>Omaha, Nebraska 68114<br/>(402) 926-4444';
					info.style.backgroundPosition = '0 -3745px';	
				}
				// MedResources
				document.getElementById("medrec").onmouseover = function() {
					info.innerHTML = 'MedResources<br/>14805 North Outer 40 Road, Suite 100<br/>Chesterfield, MO 63017<br/>(636) 733-7200';
					info.style.backgroundPosition = '0 -3895px';	
				}
		// - - - - - - - - - - - - - - - - - - - - - - - - - -
	}
	/**************************/

	function createXmlHttpRequestObject()
	{
		// will store the reference to the XMLHttpRequest object
		var xmlHttp;
		// if running Internet Explorer
		if(window.ActiveXObject)
		{
			try
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				xmlHttp = false;
			}
		}
		// if running Mozilla or other browsers
		else
		{
			try
			{
				xmlHttp = new XMLHttpRequest();
			}
			catch (e)
			{
				xmlHttp = false;
			}
		}
		// return the created object or display an error message
		if (!xmlHttp)
			alert("Error creating the XMLHttpRequest object.");
		else
			return xmlHttp;
	}

	function initPage() {
				if (document.getElementById("search")) {
			searchForm = document.getElementById('search');		
			searchForm.onsubmit = function () {
				process();
				return false;
		    }
    	}    	if (document.getElementById("btn_aniSearch")) {
	    	searchButton = document.getElementById('btn_aniSearch');
			searchButton.onclick = function () {
				process();
				//alert ("onclick");
				return false;
	    	}
    				searchButton.onmouseover = function () {
				document.getElementById('btn_aniSearch').style.backgroundPosition = '0 0';
			}
		}  	
	}
	
	function mapClick(){
		var popuplinks = document.getElementsByTagName("a");
		for (var i=0; i < popuplinks.length; i++) {	
			if ((popuplinks[i].getAttribute("class") == "map")||(popuplinks[i].getAttribute("class") == "website")) {
				popuplinks[i].onclick = function() {
					openPopUp(this.getAttribute("href"));
					return false;
				} 
			}
		}
	}
	
	function openPopUp(linkURL) {
		//window.open(linkURL,'popup','width=600,height=600')
		window.open(linkURL,'popup')
	}
	
	function process()
	{
		callAnimation(1);
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
		{
			zipcode = encodeURIComponent(document.getElementById("zipcode").value);
			radius = encodeURIComponent(document.getElementById("radius").value);
			xmlHttp.open("GET", "locations.php?zipcode=" + zipcode+"&radius=" + radius, true);
			xmlHttp.onreadystatechange = handleServerResponse;
			xmlHttp.send(null);
			
		}
		else
			// if the connection is busy, try again after one second
			setTimeout('process()', 1000);
			return false;
	}
	// executed automatically when a message is received from the server
	function handleServerResponse()
	{
	// move forward only if the transaction has completed
	
		 if( xmlHttp.readyState == 1 ) {/*this.OnLoading();*/ }
		 else if( xmlHttp.readyState == 2 ){ /* this.OnLoaded(); */ }
		 else if( xmlHttp.readyState == 3 ){ /*  this.OnInteractive(); */ }
		 else if (xmlHttp.readyState == 4)
		  {
			// status of 200 indicates the transaction completed successfully
			if (xmlHttp.status == 200)
			{
	
				xmlResponse = xmlHttp.responseText;
				document.getElementById("divMessage").innerHTML = xmlResponse;
	
				callAnimation(2);			
				document.getElementById('btn_aniSearch').style.backgroundPosition = '0 -125px';		
				igniter();
				return true;
			}
			// a HTTP status different than 200 signals an error
		  else
		  {
			alert("There was a problem accessing the server: " +xmlHttp.statusText);
		  }
		}
	}
	function hideSelectBoxes()
	{
		var selects=document.getElementsByTagName("Select");
		for(var i=0;i<selects.length;i++){selects[i].style.display = "none";}
	}
	function showSelectBoxes()
	{
		var selects=document.getElementsByTagName("Select");
		for(var i=0;i<selects.length;i++){selects[i].style.display = "inline";}
	}	
	
	shiftAmount = -25;
	function btnAnimate() {
		if (shiftAmount == -125) {
			shiftAmount = -25;
		}
		searchButton = document.getElementById('btn_aniSearch');
		
		searchButton.style.backgroundPosition = '0 '+shiftAmount+'px';
		shiftAmount = shiftAmount - 25;
	}	
	
	var theAnimation;
	function callAnimation(x) {	
	
		if(x == 1) {
			theAnimation = setInterval(btnAnimate, 500);
		}
		if(x == 2) {
			clearInterval(theAnimation);
			theAnimation = 0;
		}
	}


// Once page has loaded, start the Igniter function
	window.onload = igniter;


/*
	echo tests here on home page:  
		document.getElementById("zipcode").value
*/