// verify newsletter signup
function newsletter_signup( frm )
{
    var f_email = frm.email_address;
    var f_coun = frm.country;

//  var pattern = /[a-z][(\w|-|.)]*\w\@[a-z].[(\w|-|.)]*\w\.[a-z]{2,3}/i;
    var pattern  = /^([a-z]+!)*[0-9a-z_&.+-]+@(([0-9a-z]([0-9a-z-]*[0-9a-z])?\.)+[a-z]{2,3}|([0-9]{1,3}\.){3}[0-9]{1,3})$/i ;

    msg1 = "Please enter an email address!";
    msg2 = "Email address must be of the form user@domain.com";
    msg3 = "Please choose a language for your newsletter!";
    msg4 = "Please enter the country!";

    // verify email address

    // check string
    if ( f_email.value == null || f_email.value == "" )
    {
        onError(f_email, msg1);
        return false;
    }

    // check syntax
    if ( !pattern.test( f_email.value ) )
    {
        onError(f_email, msg2);
        return false;
    }

    // check language
    if ( frm.news_language.value == "/" )
    {
        alert(msg3);
        return false;
    }

    // check string
    if ( f_coun.value == null || f_coun.value == "" )
    {
        onError(f_coun, msg4);
        return false;
    }

    // all is well
    return true;
}

function onError(element, msg) {
         
    var w = msg.length + 420;
    var h = 110;

    element.select();
    element.focus();

    var prop = "scroollbars=no,resizable=no,width=" + w + ",height=" + h + ",left=300,top=250";

    aPopUp= window.open('','',prop);

    ndoc= aPopUp.document;
    ndoc.close();
    ndoc.open();
    astr ='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\n';
    astr +='<HTML>\n';
    astr +='
<!-- Mirrored from www.walid.com/en/scripts/newsLetter.js by HTTrack Website Copier/3.x [XR&CO'2003], Mon, 08 Dec 2003 16:48:29 GMT -->
<HEAD>\n';
    astr +='<TITLE>Error</TITLE>\n';
    astr +='<META content="text/html; charset=windows-1252" http-equiv=Content-Type>\n';
    astr +='<bgsound src="../images/Chord.wav" loop=0>\n';
    astr +='</HEAD>\n';
    astr +='<BODY bgcolor=#c0c0c0 onBlur="self.focus()" onkeypress="window.close()">\n';
    astr +='<TABLE ALIGN=center BORDER=0>\n';
    astr +=' <TR>\n';
    astr +='   <TD><img src=../images/exclam.gif align=bottom></TD>\n';
    astr +='   <TD>&nbsp; &nbsp;</TD>\n';
    astr +='   <TD align=bottom>'+ msg +'</TD>\n';
    astr +=' </TR>\n';
    astr +=' <TR ALIGN=CENTER>\n';
    astr +='   <TD colspan=3></TD>\n';
    astr +=' </TR>\n';
    astr +=' <TR>\n';
    astr +='   <TD colspan=3 rowspan=2 align=center><INPUT TYPE=button NAME=okBtn VALUE="close" onClick="window.close()">\n';
    astr +='  </TD>\n';
    astr +=' </TR>\n';
    astr +='</TABLE>\n';
    astr +='</BODY>\n';
    astr +='
<!-- Mirrored from www.walid.com/en/scripts/newsLetter.js by HTTrack Website Copier/3.x [XR&CO'2003], Mon, 08 Dec 2003 16:48:29 GMT -->
</HTML>\n';
    ndoc.write(astr);
    ndoc.close();
    
    return false;
}
