    var reqSendingEmail; // HttpRequest Object.
    function sendingEmail(objForm,objBtn) {
        document.getElementById("divAlert").style.display="none";
        //var vchRecipient = "mlkp@mlhuillier.com"; //objForm.Select2.value; //objForm.vchRecipient.value;
        var vchRecipient = "customercare@mlhuillier.com";
	//var vchRecipient = "fei@raksoct.com";
        
        var vchSender    = objForm.vchSender.value;
        var vchFirstName = objForm.vchFirstName.value;
        var vchLastName  = objForm.vchLastName.value;
        var vchMessage   = objForm.vchMessage.value;
        
        if( !chkInput(objForm.vchSender,'email') || !chkInput(objForm.vchFirstName,'') || !chkInput(objForm.vchLastName,'') || !chkInput(objForm.vchMessage,'') ) {
            return;
        }
        
        if( confirm("This message will be sent to the MLhuillier web administrator.")==false )
            return;
        
        var url = "/sendingEmailReq.asp?vchRecipient="+escape(vchRecipient)
                + "&vchSender="+escape(vchSender)
                + "&vchFirstName="+escape(vchFirstName)
                + "&vchLastName="+escape(vchLastName)
                + "&vchMessage="+escape(vchMessage);
        //alert(url);
        try {
            reqSendingEmail = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                reqSendingEmail = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e2) {
                reqSendingEmail = false;
            }
        }
        
        if( !reqSendingEmail && typeof XMLHttpRequest != 'undefined' ) {
            reqSendingEmail = new XMLHttpRequest();
        }

        if( !reqSendingEmail ) alert("Error initializing XMLHttpRequest!");
        
        objBtn.disabled=true;
    	//reqSendingEmail.open("GET", url, true);
        reqSendingEmail.onreadystatechange = function() {
            if (reqSendingEmail.readyState == 4) {
                if (reqSendingEmail.status == 200) {
                    //alert("["+reqSendingEmail.responseText+"]");
                    var result = reqSendingEmail.responseText;
                    var objDivAlert = document.getElementById("divAlert");
                    objDivAlert.style.display = "block";
                    if (result == "1") { // Success
                        objDivAlert.innerHTML = "<div id='alert'>Mail has been successfully sent</div>";
                    } else { // failure
                        objDivAlert.innerHTML = "<div id='alert'><font color='red'>Mail has not been sent.</font></div>";
                    }
                    document.getElementById("Submit").disabled = false;
                }
                else if (reqSendingEmail.status == 404) {
                    alert("Request URL does not exist");
                    document.getElementById("Submit").disabled = false;
                }
                else if (reqSendingEmail.status == 500) {
                    alert("Server Error.");
                    document.getElementById("Submit").disabled = false;
                }
            }
            else {
                //alert("Error: status code is " + reqSendingEmail.readyState);
                var objDivAlert = document.getElementById("divAlert");
                objDivAlert.style.display = "block";

                objDivAlert.innerHTML = "<div id='alert'><img alt='' src='/images/ajax-loader.gif'/></div>";

            }
        }
    	
        reqSendingEmail.open("GET", url);
        reqSendingEmail.send(null);
    }
    

    function chkInput(obj,cls) {
        
        if(obj.value=="") {
            alert("Required input data.");
            obj.focus();
            return false;
        }
        
        if(cls=="email") {
            var re = new RegExp();
            re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
            if(!re.test(obj.value)) {
                alert("Invalid e-mail address.");
                obj.focus();
                return false;
            }
        }
        
        return true;
    }

    function CheckStrLen(maxlen) {
    	var temp; //input text
    	var msglen;
    	msglen = maxlen*2;
    	
    	l = document.mainForm.vchMessage.value.length;
    	tmpstr = "" ;
    
    	if (l == 0)  
    		document.mainForm.remain.value = maxlen*2;
    	else 
    	{
    		for(k=0;k<l;k++)
    		{
    			temp = mainForm.vchMessage.value.charAt(k);
    
    			if (escape(temp).length > 4)
    				msglen -= 2;
    			else
    				msglen--;
    		
    			if(msglen < 0) 
    			{
    				alert("You can type "+(maxlen*2)+"bytes.");
    				document.mainForm.vchMessage.value = tmpstr;
    				break;
    			}
    			else 
    			{
    				document.mainForm.remain.value = msglen;
    				tmpstr += temp;
    			}
    		}
    	}
    }

    function renewPage() {
        if(!confirm('Are you going to reset?')) { 
            return;
        } else { 
            document.mainForm.vchSender.value    = "";
            document.mainForm.vchFirstName.value = "";
            document.mainForm.vchLastName.value  = "";
            document.mainForm.vchMessage.value   = "";
            
            CheckStrLen(600);
            document.mainForm.vchFirstName.focus();
            document.getElementById('divAlert').style.display='none';

        }
    }

