﻿var _linkuser = "resources/services/ajaxuser.aspx";
var req;

function newsletter(_baseurl, _branchCode) {
    var email = document.getElementById("txtNews").value;
    if (email != '' && checkEmail(email)) {
        window.location = _baseurl + 'subscriber.aspx?auto=1&email=' + email;
        
//        Initialize();
//        if(req!=null)
//        {
//            req.onreadystatechange = PostVal;
//            req.open("GET",_baseurl + _linkuser + "?email=" + email, true);
//            req.send(null);
//        }
    }
    else {
        alert('נא הזן אימייל תקין');
    }
}

function checkEmail(email) {
    var regExprEmail = new RegExp("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
    regExprEmail.exec(email);
    return (regExprEmail.test(email));
}

//function PostVal()
//{
//    if (req.readyState == 4) {
//        alert(req.responseText);
//        document.getElementById("txtNews").value = '';
//    }
//}

//function Initialize()
//    {
//        try
//        {
//            req=new ActiveXObject("Msxml2.XMLHTTP");
//        }
//        catch(e)
//        {
//            try
//            {
//                req=new ActiveXObject("Microsoft.XMLHTTP");
//            }
//            catch(oc)
//            {
//                req=null;
//            }
//        }

//        if(!req&&typeof XMLHttpRequest!="undefined")
//        {
//            req= new
//            XMLHttpRequest();
//        }
//    }