
    
  //  var http = createRequestObject();
    var areal = Math.random() + "";
    var real = areal.substring(2,6);

    function submitajax(){
		
        var ajaxRequest;  // The variable that makes Ajax possible!
        
        try{
            // Opera 8.0+, Firefox, Safari
			
            ajaxRequest = new XMLHttpRequest();
        } 
        catch (e){
            // Internet Explorer Browsers
            try{
                ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
            } 
            catch (e) {
                try{
                    ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
                } 
                catch (e){
                    // Something went wrong
                    alert("Ajax calls not supported");
                    return false;
                }
            }
        }
        // Create a function that will receive data sent from the server
        ajaxRequest.onreadystatechange = function(){
            if(ajaxRequest.readyState == 4){
                var datareturn = ajaxRequest.responseText;
				 document.getElementById("name").value="";
				document.getElementById("email").value="";
		        document.getElementById("phone").value="";
		        document.getElementById("message").value="";
                document.getElementById("confirmation").innerHTML = datareturn;

               // document.getElementById("confirmation").style.visibility="visible";
            }
		}
            var rnd = Math.random();
            var name = escape(document.getElementById("name").value);
            var email = escape(document.getElementById("email").value);
            var phone = escape(document.getElementById("phone").value);
            var message= escape(document.getElementById("message").value);
            var rqrystr='name='+name+'&email='+email+'&phone='+phone+'&message='+message+'&rnd='+rnd;
            ajaxRequest.open("POST", "mail.php?"+rqrystr, true);
            ajaxRequest.send(rqrystr); 
    }
    
    
    

    
    function sendRequest() {
        var rnd = Math.random();
        var name = escape(document.getElementById("name").value);
        var email = escape(document.getElementById("email").value);
        var subject = escape(document.getElementById("phone").value);
        var message= escape(document.getElementById("message").value);
        
        try{
            alert('here');
            http.open('POST',  'pform.php');
            http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            http.onreadystatechange = handleResponse;
            alert('sending');
            http.open("GET",'pform.jsp?name='+name+'&email='+email+'&phone='+phone+'&message='+message+'&rnd='+rnd,true);
            alert('open');
            http.send('name='+name+'&email='+email+'&phone='+phone+'&message='+message+'&rnd='+rnd);
            alert('sent');
        }
        catch(e){}
        finally{}
    }
    
    function cvalues() {
        var valid = '';
        
        var name = document.getElementById("name").value;
        var email = document.getElementById("email").value;
        var phone= document.getElementById("phone").value;
        var message = document.getElementById("message").value;
        if(trim(name) == "" || trim(email) == "" || trim(phone) == "" || trim(message) == "") {
            alert("Please complete all fields");
        }
        else {
            if(isEmail(email)) {
                //document.getElementById("submit").disabled=true;
                // document.getElementById("submit").value='Please Wait..';
                sendRequest();
            } 
            else {
                alert("Email appears to be invalid.nPlease check.");
                document.getElementById("email").focus();
                document.getElementById("email").select();
            }
        }
    }
    
    function handleResponse() {
        try{
            if((http.readyState == 4)&&(http.status == 200)){
                var response = http.responseText;
				alert(response);
                document.getElementById("confirmation").innerHTML = response;
                document.getElementById("confirmation").style.display ="";
            }
        }
        catch(e){}
        finally{}
    }
    
    function isUndefined(a) {
        return typeof a == 'undefined';
    }
    
    function trim(a) {
        return a.replace(/^s*(S*(s+S+)*)s*$/, "$1");
    }
    
    function isEmail(a) {
        return (a.indexOf(".") > 0) && (a.indexOf("@") > 0);
    }
    
