﻿function arg_length(f,len,number)
{
    if(len!=number) {document.write("function "+f+"called with "+len+" arguments, but expected "+number+"!");return 0;} else {return 1;}
}

function not_empty(par)
{
    if ((par!=null)&&(par!="")) return 1;
    if ((par==null)||(par=="")) return 0;
}

function space(par1,par2)
{
    if(not_empty(par1)&&not_empty(par2)) return 1;
    if(!not_empty(par1)||!not_empty(par2)) return 0;
}

function write_individual_not_empty_not_terminate(con1,con2,con3,con4,con5,con6,con7,con8,con9,con10,con11,con12,con13,con14,con15)
{
    if(arg_length("write_individual_not_empty_not_terminate",arguments.length,15))
    {
        document.write('<br><TABLE style="FONT-FAMILY: verdana; font-size:12px;" cellSpacing=0 cellPadding=0 border=0><TBODY>');
        document.write('<tr><td><b>');

        if(not_empty(con1)) document.write(con1);
        if(space(con1,con2)) document.write(' ');
        if(not_empty(con2)) document.write(con2);
         
        document.write('</b></tr></td>');
        document.write('<tr><td>');

        if(not_empty(con3)) document.write(con3);
        if(space(con3,con4)) document.write(', ');
        if(not_empty(con4)) document.write(con4);

        document.write(' </tr></td>');

        document.write('<tr><td>');
        if(not_empty(con5)) document.write(con5);
        document.write(' </tr></td>');

        document.write('<tr><td>');
        if(not_empty(con6)) document.write(con6);
        if(space(con6,con7)) document.write(', ');
        if(not_empty(con7)) document.write(con7);
        document.write('</tr></td>');

        document.write('<tr><td>');
        if(not_empty(con8)) document.write(con8);
        if(space(con8,con9)) document.write(', ');
        if(not_empty(con9)) document.write(con9);
        if(space(con9,con10)) document.write('&nbsp; &nbsp; ');
        if(not_empty(con10)) document.write(' '+ con10);
        document.write('</tr></td>');

        document.write('<tr><td>');
        if(not_empty(con11)) document.write('Phone: '+con11);
        document.write(' </tr></td>');

        document.write('<tr><td>');
        if(not_empty(con12)) document.write('Fax: '+con12);
        document.write(' </tr></td>');

        document.write('<tr><td>');
        if(not_empty(con13)) document.write('Email: <a href="mailto:'+con13+'">'+con13+'</a>');
        document.write(' </tr></td>');


        if(not_empty(con14)) document.write('<tr><td>'+con14+'</tr></td>');


        if(not_empty(con15)) document.write('<tr><td>'+con15+'</tr></td>');


        document.write('</table>');
    }
}


function findControlClick () 
{
    var okSoFar=true;
    var foundAt = 0;
    var foundDOT = 0;
    var foundSpace = 0;
    var foundDQuote = 0;
    var foundSQuote = 0;
    var element="";
    element=eval(ElementValue("eWebForm","C_2_1_ValueTextBox0")+".value");
    
    if (element=="" && okSoFar)
    {
        okSoFar = false;
        alert ("Please enter an email address.");
        return false;
    }
    if (element>"" && okSoFar)
    {
        foundAt = element.indexOf("@",0);
        foundDOT = element.indexOf(".",0);
        foundSpace = element.indexOf(" ",0);
        foundDQuote = element.indexOf("\"",0);
        foundSQuote =element.indexOf("\'",0);
    }
    if (foundAt < 1 && okSoFar)
    {
        okSoFar = false;
        alert ('Please enter a valid email address ("@" is missing).');
        return false;
    }

    if (foundDOT < 1 && okSoFar)
    {
        okSoFar = false;
        alert ('Please enter a valid email address ("." is missing).');

        return false;
    }
    
    if (foundSpace > 1 && okSoFar)
    {
        okSoFar = false;
        alert ("There is a space within the email address this is not valid, please re-enter.");

        return false;
    }
    if (foundDQuote > 1 && okSoFar)
    {
        okSoFar = false;
        alert ("There is a double quote within the email address this is not valid, please re-enter.");
        return false;
    }
    if (foundSQuote > 1 && okSoFar)
    {
        okSoFar = false;
        alert ("There is a single quote within the email address this is not valid, please re-enter.");
        return false;
    }
    if (okSoFar==true)
    {
        return true;
        submit();
    }
 }


