
	var nospam = '<a href="mail' + 'to:' + 'info' + '@' + 'successful-life-coaching' + '.co.uk" title="info' + '@' + 'successful-life-coaching' + '.co.uk">Click Here</a>';

    function makeRequest(url,key) {
        var httpRequest;

        if (window.XMLHttpRequest) {
            httpRequest = new XMLHttpRequest();
            if (httpRequest.overrideMimeType) {
                httpRequest.overrideMimeType('text/xml');
            }
        } 
        else if (window.ActiveXObject) {
            try {
                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } 
                catch (e) {
                           try {
                                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                               } 
                             catch (e) {}
                          }
                                       }

        if (!httpRequest) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        httpRequest.onreadystatechange = function() { alertContents(httpRequest); };
        httpRequest.open('POST', url, true);
        httpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        httpRequest.send(key);

    }

    function alertContents(httpRequest) {

        if (httpRequest.readyState == 4) {
            if (httpRequest.status == 200) {
                result = httpRequest.responseText;
                if (result == 1)
                {
			document.getElementById('name').style.background = '#f4dcf1';
			document.getElementById('err').innerHTML = 'You forgot to tell me your name!';
			document.getElementById('msg').innerHTML = '';
			document.getElementById('name').focus();
		}
                else if (result == 2)
                {
			document.getElementById('name').style.background = '#f8f3c3';
			document.getElementById('email').style.background = '#f4dcf1';
			document.getElementById('err').innerHTML = 'Please enter a valid e-mail address!';
			document.getElementById('msg').innerHTML = '';
			document.getElementById('email').focus();
		}
                else if (result == 3)
                {
                	document.getElementById('name').style.background = '#f8f3c3';
                	document.getElementById('email').style.background = '#f8f3c3';
			document.getElementById('enquiry').style.background = '#f4dcf1';    
			document.getElementById('err').innerHTML = 'You forgot to enter your enquiry!';
			document.getElementById('msg').innerHTML = '';
			document.getElementById('enquiry').focus();
		}
                else if (result == 4)
                {
                	document.getElementById('name').style.background = '#f8f3c3';
                	document.getElementById('email').style.background = '#f8f3c3';
			document.getElementById('enquiry').style.background = '#f4dcf1';
			document.getElementById('err').innerHTML = 'You are not allowed to send html through my contact form!';
			document.getElementById('msg').innerHTML = '';
			document.getElementById('enquiry').focus();
		}
                else if (result == 5)
                {
                	document.getElementById('email').value = '';
			document.getElementById('tel').value = '';
			document.getElementById('enquiry').value = '';
			document.getElementById('name').disabled = true;
			document.getElementById('email').disabled = true;
			document.getElementById('tel').disabled = true;
			document.getElementById('enquiry').disabled = true;
			document.getElementById('send').disabled = true;
			document.getElementById('name').style.background = '#dedede';
			document.getElementById('email').style.background = '#dedede';
			document.getElementById('tel').style.background = '#dedede';
			document.getElementById('enquiry').style.background = '#dedede';
			document.getElementById('send').style.background = '#dedede';
			document.getElementById('send').style.color = '#aca899';
			document.getElementById('err').innerHTML = '';
			document.getElementById('msg').innerHTML = 'Thank you ' + document.getElementById('name').value + ', I will be in touch as soon as I can.';
			document.getElementById('name').value = '';
		}
		else {
                alert('There was a problem with the request.');
            	}
                
            } else {
                alert('There was a problem with the request.');
            }
        }

    }

   function send(obj) {
	var poststr = "name=" + encodeURI( document.getElementById("name").value ) +
                      "&email=" + encodeURI( document.getElementById("email").value ) +
                      "&tel=" + encodeURI( document.getElementById("tel").value ) +
                      "&enquiry=" + encodeURI( document.getElementById("enquiry").value);
      makeRequest('/ajax.php',poststr);
   }    
