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();
        }
    }
}

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)');
        }
    }
}


function checkEmail(input, response)
{
  if (response != ''){ 
    // Response mode
    
    if (response == 'invalid'){
      document.getElementById("emailCheck").innerHTML = "<span class='warning'>Warning: Email entered does not appear to be valid.<br /></span><br />";
      nudgeFirefox();
    }
  }else{
    // Input mode
    url  = 'http://costablancatranslations.com//xml_validate.php?checkEmail=' + input;
    loadXMLDoc(url);
  }

}

function clearSpan(){
	document.getElementById("emailCheck").innerHTML = "";
	nudgeFirefox();
}

function progress(){
	intWidth = parseInt(document.getElementById("container1").style.width) + 1;
	if(intWidth <= 400){
	     document.getElementById("container1").style.width = intWidth+"px";
	}else{
 	    document.getElementById("container1").style.width = 0;
	}
 	setTimeout("progress()",300);
}

function nudgeFirefox(){
	/* sort out a height problem in firefox */
	document.getElementsByTagName('body')[0].style.width='99%';
	document.getElementsByTagName('body')[0].style.width='auto';
	/* sort out a height problem in IE */
	document.getElementById("valid").style.bottom='-14px';
	document.getElementById("valid").style.bottom='-15px';
}

function formSubmission(){
	document.getElementById('container0').style.display='';
	document.getElementById('container2').style.display='none';
	progress();
	nudgeFirefox()
}