
function submitEmail( url, str ) {
    var filter = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    if ( !filter.test( str ) ) {
        alert( str + ' does not appear to be a valid email address.' );
        document.forms[ 'email_signup' ].elements[ 'email' ].focus;
    } else {
        if ( str.length == 0 ) { 
            document.getElementById( "emailSignup" ).innerHTML = "";
            return;
        }
        xmlHttp=GetXmlHttpObject();
        if ( xmlHttp == null ) {
            alert ( "Your browser does not support AJAX!" );
            return;
        } 
        // var url = "index-ajax.php";
        url = ( url + "?email=" + str );
        url = ( url + "&sid=" + Math.random() );
        xmlHttp.onreadystatechange = stateChanged;
        xmlHttp.open( "GET", url, true );
        xmlHttp.send( null );
    }
}

function GetXmlHttpObject() {
    // The purpose of the function is to solve the problem 
    // of creating different XMLHTTP objects for different browsers.
    var xmlHttp = null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
    } catch ( e ) {
        // Internet Explorer
        try {
            xmlHttp = new ActiveXObject( "Msxml2.XMLHTTP" );
        } catch ( e ) {
            xmlHttp = new ActiveXObject( "Microsoft.XMLHTTP" );
        }
    }
    return xmlHttp;
}

function stateChanged() {
    if ( xmlHttp.readyState == 4 ) {
        document.getElementById( "emailSignup" ).innerHTML=xmlHttp.responseText;
    }
}



