function isEMailAddr(elem) {
    var str = elem;
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) {
        //alert("Verify the e-mail address format.");
        //setTimeout("focusElement('" + elem.form.name + "', '" + elem.name + "')", 0);
        return false;
    } else {
        return true;
    }
}

var objHttp;
objHttp = null;

function addNotify(email, variantid, message)
        {

       

        //Mozilla
        if (window.XMLHttpRequest)
        {
        objHttp=new XMLHttpRequest();
        }
        //IE
        else if (!objHttp && window.ActiveXObject)
        {
        objHttp=new ActiveXObject('Microsoft.XMLHTTP');
        }

        try
        {
        if (isEMailAddr(email)) 
        {
        objHttp.open("POST", "NotificationService.asmx/addNotification", false);
        objHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        objHttp.send("variantID=" + variantid + "&email=" + email);
        if (objHttp.responseText == "")
            alert(message);
        else
            alert("There was a problem adding the notification.\n  Please Contact Trinity Airsoft");
        }
        else
        {
        alert("Invalid Email Address Format");
        }
        }
        catch(oc)
        {
        alert(oc);
        }
    }
    
function processReqChange() {
    alert(objHttp.responseText);
    alert(objHttp.readyState);
    alert(objHttp.status);
    if (objHttp.readyState == 4 && objHttp.status == 200)
    {
        alert(objHttp.responseText);
    }
}
    

function addNotifySOAP(email, variantid, message)
{
        var objHttp ;
        objHttp=null;
       

        //Mozilla
        if (window.XMLHttpRequest)
        {
        objHttp=new XMLHttpRequest();
        }
        //IE
        else if (!objHttp && window.ActiveXObject)
        {
        objHttp=new ActiveXObject('Microsoft.XMLHTTP');
        }

        try
        {
        if (isEMailAddr(email))
        {
        objHttp.open("POST", "NotificationService.asmx/addNotification", false);
        objHttp.setRequestHeader("Content-Type","text/xml; charset=utf-8");
        objHttp.setRequestHeader("SOAPAction","http://www.trinityairsoft.com/NotificationService");
        // setting the soap request body
            var soapRequest="<?xml version='1.0' encoding='utf-8'?>" +
            "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>" +
            "<soap:Body>"+
            "<addNotification xmlns='http://www.trinityairsoft.com/'>"+
            "<variantID>" + variantid + "</variantID> " +
            "<email>" + email + "</email> " +
            "</addNotification>"+
            " </soap:Body>"+
            "</soap:Envelope>";
            
        objHttp.send(soapRequest);
        alert(message);
        }
        else
        {
        alert("Invalid Email Address Format");
        }
        }
        catch(oc)
        {
        alert(oc);
        }

}

