var url;
var email;

var page;

function saveAddress(address) {
	url = '/include/processEmail.php?email=' + address;

	loadXMLDoc(url);
}


function emailSuccess (r) {
	document.getElementById('subscribeForm').innerHTML = '<span class="emailResponse">Thank you. Your email address <br>has been added to our mailing list.</span>';
	document.getElementById('subscribeForm').style.bottom = '5px';
}
/*
function emailSuccessHome(r)
{
	document.getElementById('email_div').style.background = "url('/images/gen/joinyogatodaysuccess.jpg') bottom left no-repeat";
	document.getElementById('email_form').style.display = 'none';
	//document.getElementById('email_fail').style.display = 'none';
	//document.getElementById('email_success').style.display = 'inline';
	//document.getElementById('success').innerHTML = 'Thank you. The email address, ' + document.getElementById('email').value + ', has been successfully added to our mailing list.';
}
*/
function emailFail(r) {
	document.getElementById('emailMessage').innerHTML = '<span class="emailResponse">Sorry. Your address is not valid. Please, try again.</span>';		
}


function processReqChange() 
{
    // only if req shows "complete"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            // ...processing statements go here...
      response  = req.responseXML.documentElement;

      method    =
response.getElementsByTagName('method')[0].firstChild.data;

      result    = 
response.getElementsByTagName('result')[0].firstChild.data;

      eval(method + '(result)');
        } else {
            alert("There was a problem retrieving the XML data:\n" + req.statusText);
        }
    }
}


function loadXMLDoc(url) 
{
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET", url, true);
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.send();
        }
    }
}
