function checkForm(thisForm) {
if(thisForm.email.value=="") {alert("Please enter your email address.");thisForm.email.focus();return false;}
if(thisForm.email.value.indexOf('@', 0)==-1){alert("Please enter a valid email address.");thisForm.email.focus();return false;}
if(thisForm.email.value.indexOf('.', 0)==-1){alert("Please enter a valid email address.");thisForm.email.focus();return false;}
if(thisForm.fname.value==""){alert("Please enter your first name.");thisForm.fname.focus();return false;}
}

function checkForm2(thisForm) {
//alert ("test");
if(checkBarred(thisForm.verify.value)=='false') {return false;}
if(thisForm.email.value==""){alert("Please enter your email address.");thisForm.email.focus();return false;}
if(thisForm.email.value.indexOf('@', 0)==-1){alert("Please enter a valid email address.");thisForm.email.focus();return false;}
if(thisForm.email.value.indexOf('.', 0)==-1){alert("Please enter a valid email address.");thisForm.email.focus();return false;}
if(thisForm.realname.value==""){alert("Please enter your first name.");thisForm.realname.focus();return false;}
thisForm.id.value = '10298';
}

function checkBarred(code) {
var barred = new Array();
var x=0;
var result='true';
if(code != 'kEu21'){
        alert("Please enter the verification code");
        result = 'false';
}
return result;
}

function checkFields(myForm,namenum,emailnum,url) {
    user = myForm.elements[namenum];
    email = myForm.elements[emailnum];
    if (namenum == emailnum) {
        if (email.value == "") {
        alert("Please enter your email address");
        return false;
        }
    }
    else {      
        if ((user.type == "hidden") && (email.value == "")) {           
            alert("Please enter your email address");   
            return false; 
        }
        if (user.type == "hidden") {
            user.value = "Friend";
        }
        if ((user.value == "") || (email.value == "") ) {
            alert("Please enter your First Name and your Email address");
            return false;
        }
    }
// if (echeck(email.value)==false){ Used if echech function is used   
    if (check(myForm)==false) {    
        myForm.email.value="";    
        myForm.email.focus();    
        return false;  
    }
    if (url!="none") {
//url = 'http:\/\/www.wealthset.com\/' + url + '.html';
//window.open(url,'Thankyou','width=640,height=455');
        if (url=="processing1") {WinOpen1();
        }
        else if (url=="processing2") {WinOpen2();
        }
        else if (url=="processing3") {WinOpen3();
        }
        else {alert ("error wrong url sent");
        }
    }
    return true;
}

// email checker
function echeck(str) {  
    var at="@";  
    var dot=".";  
    var lat=str.indexOf(at);  
    var lstr=str.length;  
    var ldot=str.indexOf(dot);  
    if (str.indexOf(at)==-1){     
        alert("Invalid email address");     
        return false;  
    }   
    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){     
        alert("Invalid email address");     
        return false;  
    }  
    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){      
        alert("Invalid email address");      
        return false;  
    }  
    if (str.indexOf(at,(lat+1))!=-1){      
        alert("Invalid email address");      
        return false;   
    }   
    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){      
        alert("Invalid email address");   
        return false;   
    }   
    if (str.indexOf(dot,(lat+2))==-1){      
        alert("Invalid email address");      
        return false;   
    }   
    if (str.indexOf(" ")!=-1){      
        alert("Invalid email address");      
        return false;   
    }   
return true;          
}

// alternate email checker 
function check(myForm){
    email=myForm.email.value;
    if  (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) {
    return (true);
    }
    alert("Please double check your email address.");
    return (false);
}

//var msg = '';

function WinOpen1() {
if (!msg.closed && msg.location) {
    if (window.focus) {msg.focus()}
    return false;
}
msg=open("","DisplayWindow","HEIGHT=380,WIDTH=400,status=no,toolbar=no,directories=no,menubar=no,location=no,resizable=yes,left=400,top=200");
msg.document.write("<html><head>");
msg.document.write("<style type='text/css'>");
msg.document.write("<!--");
msg.document.write("body { background-color: #FFFFFF; font-family: Verdana}");
msg.document.write("-->");
msg.document.write("</style></head><body>");
msg.document.write("<table width='600' border='0' align='center' cellpadding='0' cellspacing='0' bgcolor='#FFFFFF'>");
msg.document.write("<p><table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' width='100%'><tr></p>");
msg.document.write("<p><td width='600' height='59' bgcolor='#000000'> <img src='http://www.wealthset.com/images/company_name.gif' hspace='15' width='159' height='18'></td></p>");
msg.document.write("<p></tr><tr><td width='400' height='19' bgcolor='#21A200'></td></tr></table></p>");
msg.document.write("<body text='black'>");
msg.document.write("<p><span style='font-weight: 400'><font face='Verdana' size='1'>Thankyou.  We are processing your request.&nbsp; This may take a moment or two.</p>");
msg.document.write("<p>Have you visited the <b>Wealth ToolShop</b>?  Here you'll find the latest tools and resources for investing and wealth creation.</p>");
msg.document.write("<p>To go to the ToolShop, close this window and click on <b>ToolShop</b> at the top of the WealthSet window.</p>");
msg.document.write("<p>Wishing you all the best<br><br>The WealthSet Team<br>Helping you Set your own course to Wealth</p>");
msg.document.write("<p align='right'><a href=javascript:window.close()><b>x Close</b></a></p>");
msg.document.write("<p><table><tr><td height='31' align='center' valign='middle' bgcolor='#000000' class='headtext' width='600'><font color='#FFFFFF' size='1' face='Verdana'>Copyright &copy; 2005 <strong>Wealthset.com</strong>. All rights Reserved</font></td></tr></table></p>");
msg.document.write("</body>");msg.document.write("</html>");
return;
}

function WinOpen2() {
if (!msg.closed && msg.location) {
if (window.focus) {msg.focus()}return false;
}
msg=open("","DisplayWindow","HEIGHT=380,WIDTH=400,status=no,toolbar=no,directories=no,menubar=no,location=no,resizable=yes,left=400,top=200");msg.document.write("<html><head>");
msg.document.write("<style type='text/css'>");
msg.document.write("<!--");
msg.document.write("body { background-color: #FFFFFF; font-family: Verdana}");
msg.document.write("-->");
msg.document.write("</style></head><body>");
msg.document.write("<table width='600' border='0' align='center' cellpadding='0' cellspacing='0' bgcolor='#FFFFFF'>");
msg.document.write("<p><table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' width='100%'><tr></p>");
msg.document.write("<p><td width='600' height='59' bgcolor='#000000'> <img src='http://www.wealthset.com/images/company_name.gif' hspace='15' width='159' height='18'></td></p>");
msg.document.write("<p></tr><tr><td width='400' height='19' bgcolor='#21A200'></td></tr></table></p>");
msg.document.write("<body text='black'>");
msg.document.write("<p><span style='font-weight: 400'><font face='Verdana' size='1'>Thankyou.  We are processing your request.&nbsp; This may take a moment or two.</p>");
msg.document.write("<p>Have you visited the LaunchPad?  If you want to get off to a flying start then go straight to the LaunchPad.</p>");
msg.document.write("<p>To go to the LaunchPad, close this window and click on <b>LaunchPad</b> at the top of the WealthSet window.</p>");
msg.document.write("<p></p>");
msg.document.write("<p>Wishing you all the best<br><br>The WealthSet Team<br>Helping you Set your own course to Wealth</p>");
msg.document.write("<p align='right'><a href=javascript:window.close()><b>x Close</b></a></p>");
msg.document.write("<p><table><tr><td height='31' align='center' valign='middle' bgcolor='#000000' class='headtext' width='600'><font color='#FFFFFF' size='1' face='Verdana'>Copyright &copy; 2005 <strong>Wealthset.com</strong>. All rights Reserved</font></td></tr></table></p>");
msg.document.write("</body>");
msg.document.write("</html>");
return;
}

function WinOpen3() {
if (!msg.closed && msg.location) {
if (window.focus) {msg.focus()}
return false;
}
msg=open("","DisplayWindow","HEIGHT=380,WIDTH=400,status=no,toolbar=no,directories=no,menubar=no,location=no,resizable=yes,left=400,top=200");
msg.document.write("<html><head>");
msg.document.write("<style type='text/css'>");
msg.document.write("<!--");
msg.document.write("body { background-color: #FFFFFF; font-family: Verdana}");
msg.document.write("-->");
msg.document.write("</style></head><body>");
msg.document.write("<table width='600' border='0' align='center' cellpadding='0' cellspacing='0' bgcolor='#FFFFFF'>");
msg.document.write("<p><table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' width='100%'><tr></p>");
msg.document.write("<p><td width='600' height='59' bgcolor='#000000'> <img src='http://www.wealthset.com/images/company_name.gif' hspace='15' width='159' height='18'></td></p>");
msg.document.write("<p></tr><tr><td width='400' height='19' bgcolor='#21A200'></td></tr></table></p>");
msg.document.write("<body text='black'>");
msg.document.write("<p><span style='font-weight: 400'><font face='Verdana' size='1'>Thankyou.  We are processing your request.&nbsp; This may take a moment or two.</p>");
msg.document.write("<p>Have you visited the Learning Center?  Learn the latest techniques and strategies to investing for wealth.</p>");
msg.document.write("<p>To go to the Learning Center, close this window and click on <b>Learning Center</b> at the top of the WealthSet window.</p>");
msg.document.write("<p></p>");
msg.document.write("<p>Wishing you all the best<br><br>The WealthSet Team<br>Helping you Set your own course to Wealth</p>");
msg.document.write("<p align='right'><a href=javascript:window.close()><b>x Close</b></a></p>");
msg.document.write("<p><table><tr><td height='31' align='center' valign='middle' bgcolor='#000000' class='headtext' width='600'><font color='#FFFFFF' size='1' face='Verdana'>Copyright &copy; 2005 <strong>Wealthset.com</strong>. All rights Reserved</font></td></tr></table></p>");
msg.document.write("</body>");
msg.document.write("</html>");
return;
}