

if (typeof XMLHttpRequest == "undefined")
  XMLHttpRequest = function() {
    try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch(e) {};
    try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch(e) {};
    try { return new ActiveXObject("Msxml2.XMLHTTP"); }     catch(e) {};
    try { return new ActiveXObject("Microsoft.XMLHTTP"); }  catch(e) {};

    throw new Error("This browser does not support XMLHttpRequest or XMLHTTP.");
  };
  
function checkEmail(email){
    if(email.match(new RegExp("[\\s]*(?:[a-zA-Z0-9_%\\-\\+]+\\.)*[a-zA-Z0-9_%\\-\\+]+@(?:[a-zA-Z0-9\\-]+\\.)+[a-zA-Z0-9\\-]+[\\s]*"))){
        var freeEmails = ['@gmail\\.', '@yahoo\\.', '@hotmail\\.', '@aol\\.', '@live\\.', '@earthlink\\.', '@lycos\\.', '@msn\\.' ]
        for(var i in freeEmails){
            var freeEmail = freeEmails[i];
            if(email.match(new RegExp(".*" + freeEmail + ".*", "i"))){
                return false;
            }
        }
        return true;
    }
    return false;
}

function checkEmailSimple(email){
    if(email.match(new RegExp("[\\s]*(?:[a-zA-Z0-9_%\\-\\+]+\\.)*[a-zA-Z0-9_%\\-\\+]+@(?:[a-zA-Z0-9\\-]+\\.)+[a-zA-Z0-9\\-]+[\\s]*"))){
        return true;
    }
    return false;
}

function addLead(firstname, lastname, company, email, phone, leadsource) {
	if(company == "")
		company = "na";
	if(phone = "")
		phone="5555555555555";
	var url = "http://rpc.boldchat.com/aid/2307475884/bc.rrpc/InternalServer?m=addLead&si=bold01234&p0=SalesforceIntegration";
	url = url + "&p1=" + escape(firstname);
	url = url + "&p2=" + escape(lastname);
	url = url + "&p3=" + escape(company);
	url = url + "&p4=" + escape(email);
	url = url + "&p5=" + escape(phone);
	url = url + "&p6=" + escape(leadsource);
	
	var script = document.createElement("script");
	script.type = "text/javascript";
	script.src = url;
	document.body.appendChild(script);
	return false;
}

//These two functions handle what is returned from the InternalServer.  
//Yes, they are empty.  They are supposed to be. Leave them alone.
function e(data) {}
function err(data) {}