
function setHelpFiles(fileHelp,fileFaq)
{
  return;
}

// Get index of selected item in list
function getSelectedIndex()
{
  var ndx = 0;
  var arg = arguments[0];
  for ( i=0; i < arg.length; i++)
  {
    if (arg[i].selected == true)
      ndx = i;
  }
  return ndx;
}

// Get value of selected item in list
function getSelectedValue()
{
  var val = 0;
  var arg = arguments[0];
  for ( i=0; i < arg.length; i++)
  {
    if (arg[i].selected == true)
      val = arg[i].value;
  }
  return val;
}

// Get index of checked radio button
function getRadioIndex()
{
  var ndx = 0;
  var arg = arguments[0];
  for ( i=0; i < arg.length; i++)
  {
    if (arg[i].checked == true)
      ndx = i;
  }
  return ndx;
}

// Get value of checked radio button
function getRadioValue()
{
  var val = 0;
  var arg = arguments[0];
  for ( i=0; i < arg.length; i++)
  {
    if (arg[i].checked == true)
      val = arg[i].value;
  }
  return val;
}

function openPopup(page,width,height,name,title,scroll)
{
    var iWidth = 700;
    var iHeight = 650;
    var cScroll = 'no';
    var cName = 'myWin';
    var cTitle = 'National Interoperability Information eXchange';
    var parms = '';

    if (width > 0 ) iWidth = width;
    if (height > 0 ) iHeight = height;
    if (scroll == "Y") cScroll = 'yes';
    if (name != null) cName = name;
    if (title != null) cTitle = title;

    if (page.indexOf("?") > -1 )
    {
        parms = "&title=" + title;
    }
    else
    {
        parms = "?title=" + title;
    }

    var myBars = "directories=no,location=no,menubar=no,status=no";
    myBars += ",titlebar=yes,toolbar=no,dependent=yes";
    var myOptions = "scrollbars="+cScroll+",width="+iWidth+",height="+iHeight+",resizable=yes,screenX=0,screenY=0";
    var myFeatures = myBars + "," + myOptions;
    var newWin = window.open(page+parms,cName,myFeatures);
    newWin.focus();
}

function openPop(page,width,height,name,title,scroll)
{
    var iWidth = 500;
    var iHeight = 400;
    var cScroll = 'no';
    var cName = 'myWin';
    var cTitle = 'National Interoperability Information eXchange';
    var parms = '';

    if (width > 0 ) iWidth = width;
    if (height > 0 ) iHeight = height;
    if (scroll == "Y") cScroll = 'yes';
    if (name != null) cName = name;
    if (title != null) cTitle = title;

    if (page.indexOf("?") > -1 )
    {
        parms = "&title=" + title;
    }
    else
    {
        parms = "?title=" + title;
    }

    var myBars = "directories=no,location=no,menubar=no,status=no";
    myBars += ",titlebar=yes,toolbar=no,dependent=yes";
    var myOptions = "scrollbars="+cScroll+",width="+iWidth+",height="+iHeight+",resizable=yes,screenX=250,screenY=200";
    var myFeatures = myBars + "," + myOptions;
    //alert(page+parms);
    var newWin = window.open(page+parms,cName,myFeatures);
    newWin.focus();
}

function openPopX(page,width,height)
{
    var iWidth = 300;
    var iHeight = 200;
    var cScroll = 'no';

    if (width > 0 ) iWidth = width;
    if (height > 0 ) iHeight = height;

    openPopup(page,iWidth,iHeight,name,"",scroll)

}

function openPopZ(page,width,height)
{
    var iWidth = 300;
    var iHeight = 200;
    var cScroll = 'no';
    var parms = '';

    if (width > 0 ) iWidth = width;
    if (height > 0 ) iHeight = height;

    var myBars = "directories=no,location=no,menubar=no,status=no";
    myBars += ",titlebar=no,toolbar=no,dependent=yes";
    var myOptions = "alwaysRaised=yes,scrollbars="+cScroll+",innerWidth="+iWidth+",innerHeight="+iHeight+",screenX=500,screenY=300";
    var myFeatures = myBars + "," + myOptions;
    var newWin = window.open(page+parms,"",myFeatures);
    newWin.focus();
}

function checkRequired(form)
{
    var errormessage = new String();

    for ( x = 0; x < form.elements.length; x++ )
    {
        if ( form.elements[x].name == "required" )
        {
            var elementName = form.elements[x].value;

            var element = form[ elementName ];

            var elementType;

            if ( element.length == undefined )
            {
                elementType = element.type;
            }
            else
            {
                elementType = element[0].type;
            }

            //alert( "elementName: " + elementName );
            //alert( "elementType: " + elementType );

            var msg = form[ "required-" + elementName + "-message" ].value;

            if ( elementType == "radio"
              || elementType == "checkbox" )
            {
                if(NoneWithCheck(element))
                { errormessage += "\n\n" + msg; }
            }
            else if ( elementType == "text"
                   || elementType == "textarea"
                   || elementType == "password" )
            {
                if(WithoutContent(element))
                { errormessage += "\n\n" + msg }
            }

        }//end if

    }//end for x

    if(errormessage.length > 2)
    {
        alert(errormessage);
        return false;
    }

    return true;

}//end function

function NoneWithCheck(ss)
{
    for( var i = 0; i < ss.length; i++ )
    {
        if(ss[i].checked) { return false; }
    }

    return true;
}

function WithoutContent(ss)
{
    if ( isBlank( ss.value ) )
    {
        ss.value = "";
    }

    if(ss.value.length > 0) { return false; }
    return true;
}

function isBlank(val)
{

    if(val==null) { return true;}
    for(var i=0;i<val.length;i++)
    {
        if((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}
    }
    return true;
}

// modified 7/23/2008
function validateProfile( form, minUserLength, maxUserLength, minPassLength, maxPassLength, passwordFormat, passwordExplanation )
{
    // Password - - - - - - - - - - - - - - - -
    
    if ( chkPass( form.pass.value, minPassLength, maxPassLength ) > 0 )
    {
        return false;
    }

    var country = dwr.util.getValue( "country" );
    var nextLine = "\n";

    // Name & Address - - - - - - - - - - - - -

    var minimumLengths = "";

    if ( form.first_name.value.length < 2 ) { minimumLengths += "\nFirst Name must be at least 2 characters."  }
    if ( form.last_name.value.length < 2 ) { minimumLengths += "\nLast Name must be at least 2 characters."  }
    if ( form.org.value.length < 2 ) { minimumLengths += "\nOrganization must be at least 2 characters."  }

    if ( form.city.value.length < 2 ) { minimumLengths += "\nCity must be at least 2 characters."  }
    if ( form.address.value.length < 5 ) { minimumLengths += "\nAddress must be at least 5 characters."  }
       
    if ( minimumLengths.length > 0 )
    {
        alert( minimumLengths );
        return false;
    }

    // Zip/Postal code - - - - - - - - - - - - -
    if (validateZip( country, form.zip.value ) > 0)
    {
        return false;
    }

    // Email Address - - - - - - - - - - - - - -
    if ( form.email.value.length < 5 )
    {
        alert( "Email must be at least 5 characters." );
        return false;
    }
    
    // Phone numbers  - - - - - - - - - - - - - -

    var minimumLengths = "";

    if ( form.phone.value.length < 10 ) { minimumLengths += "\nWork Phone must be at least 10 characters."  }
    if ( form.phone2.value.length > 0 && form.phone2.value.length < 10) { minimumLengths += "\nAlternate Phone must be at least 10 characters."  }
    if ( form.fax.value.length > 0 && form.fax.value.length < 10) { minimumLengths += "\nFax Number must be at least 10 characters."  }

    // Security Question  - - - - - - - - - - - -

    var minimumLengths = "";

    if ( form.security_question.value.length < 1 ) { minimumLengths += "\nSecurity Question must be filled in."  }
    if ( form.security_answer.value.length < 1 ) { minimumLengths += "\nSecurity Answer must be filled in."  }

    if ( minimumLengths.length > 0 )
    {
        alert( minimumLengths );
        return false;
    }

    // checkRequired  - - - - - - - - - - - - - -

    if ( checkRequired(form) == false )
    {
        return false;
    }

    return true;
}

// added 7/23/2008
function validateZip( country, zipcode )
{
    var minimumLengths = "";
    var nextLine = "\n";

    if ( country == "USA" )
    {
        if ( zipcode.length != 5 && zipcode.length != 10 ) { minimumLengths += "Zip code must be either 5 or 9 digits\n(formatted as nnnnn or nnnnn-nnnn)"  }
    }
    else if (country == "MEX" )
    {
        if ( zipcode.length != 5 ) { minimumLengths += "Zip code must be 5 characters."  }
    }
    else if ( country == "CAN" )
    {
        if ( zipcode.length < 6 ) { minimumLengths += "Postal code must be 6 characters."  }
    }

    if ( minimumLengths.length > 0 )
    {
        alert(minimumLengths);
        return true;
    }

    if ( country == "USA" )
    {
        var zip = zipcode.toUpperCase();
        var validUsZip = false;
        if (zip.match(/^[0-9][0-9][0-9][0-9][0-9]$/)) 
        {
            validUsZip = true;
        }
        else if (zip.match(/^[0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]$/)) 
        {
            validUsZip = true;
        }
        
        if ( validUsZip == false )
        {
            alert( "Zip code must be numeric\n(formatted as nnnnn or nnnnn-nnnn)" );
            return true;
        }    
    }    
    else if ( country == "CAN" )
    {
        var validCanadaZip = false;
        var zip = zipcode.toUpperCase();
        if (zip.match(/^[A-Z][0-9][A-Z][0-9][A-Z][0-9]$/)) 
        {
        validCanadaZip = true;
        }
        if (zip.match(/^[A-Z][0-9][A-Z] [0-9][A-Z][0-9]$/)) {
        validCanadaZip = true;
        }
        
        if ( validCanadaZip == false )
        {
            alert( "Invalid Canadian postal code format" );
            return true;
        }
    }
    else if ( country == "MEX" )
    {
        var zip = zipcode.toUpperCase();
        var validMexicoZip = false;
        if (zip.match(/^[0-9][0-9][0-9][0-9][0-9]$/)) 
        {
            validMexicoZip = true;
        }
        
        if ( validMexicoZip == false )
        {
            alert( "Zip code must be numeric." );
            return true;
        }    
    }    

    return false;
}

function closeDiv(id)
{
    document.getElementById( id ).style.display = 'none';
}

function trimFields()
{
    var theForm = $("form[name='RegisterForm']");

    var txtInputs = theForm.find( "input[type='text']" );

    txtInputs.each( function(){
        var preTrim = $(this).val();
        var field = trimField( preTrim );

        if ( preTrim != field )
            $(this).val( field );
    });

    var txtAreas = theForm.find( "textarea" );

    txtAreas.each( function() {
        var preTrim = $(this).val();
        var field = trimField( preTrim );

        if ( preTrim != field )
            $(this).val( field );
    });

}

function trimField( field )
{
    if ( field.length == 0 ) return field;

    while ( field.indexOf( ' ' ) == 0 ) field = field.substring( 1 );
    while ( field.lastIndexOf( '\n' ) == (field.length -1) || field.lastIndexOf( ' ' ) == (field.length -1) )
        field = field.substring( 0, field.length - 1 );

    return field;
}

var formSection = "";
function validateRegistration( form, minUserLength, maxUserLength, minPassLength, maxPassLength, floatingErrorDiv, passwordFormat )
{
    // Check if filled in  - - - - - - - - - - - -
    var nextLine = "\n";
    var errMsg = "";
   
    var country = dwr.util.getValue( "country" );

    if ( floatingErrorDiv != undefined )
    {
        nextLine = "<br>";
    }

    formSection = "Contact Information";
    var minimumLengths = "";

    if ( form.first_name.value.length < 1 ) { minimumLengths += nextLine + "First name must be filled in."  }
    if ( form.last_name.value.length < 1 ) { minimumLengths += nextLine + "Last name must be filled in."  }
    if ( form.city.value.length < 1 ) { minimumLengths += nextLine + "City must be filled in."  }

    if ( form.job_title.value.length < 1 ) { minimumLengths += nextLine + "Job title must be filled in."  }

    if ( form.address.value.length < 1 ) { minimumLengths += nextLine + "Address must be filled in."  }
    
    if ( country == "" ) { minimumLengths += nextLine + "Country must be selected." }
        
    if ( form.email.value.length < 1 ) { minimumLengths += nextLine + "Email must be filled in."  }
    if ( form.phone.value.length < 1 ) { minimumLengths += nextLine + "Work Phone must be filled in."  }

    if ( minimumLengths.length > 0 )
    {
        if ( floatingErrorDiv == undefined )
            alert( minimumLengths );
        else
            showFloatingAlert(floatingErrorDiv, minimumLengths );

        return false;
    }

    // Check min lengths  - - - - - - - - - - - - -

    var minimumLengths = "";

    if ( form.first_name.value.length < 2 ) { minimumLengths += nextLine + "First name must at least 2 characters."  }
    if ( form.last_name.value.length < 2 ) { minimumLengths += nextLine + "Last name must at least 2 characters."  }
    if ( form.city.value.length < 2 ) { minimumLengths += nextLine + "City must at least 2 characters."  }

    if ( form.job_title.value.length < 3 ) { minimumLengths += nextLine + "Job title  must be at least 3 characters."  }

    if ( form.address.value.length < 5 ) { minimumLengths += nextLine + "Address must at least 5 characters."  }
   
    // Zip Code
    if (validateZip( country, form.zip.value ) > 0)
    {
        return false;
    }

    if ( form.email.value.length < 5 ) { minimumLengths += nextLine + "Email must be at least 5 characters."  }

    if ( form.phone.value.length < 10 ) { minimumLengths += nextLine + "Work Phone must be at least 10 characters."  }
    if ( form.phone2.value.length > 0 && form.phone2.value.length < 10) { minimumLengths += nextLine + "Alternate Phone must be at least 10 characters."  }
    if ( form.fax.value.length > 0 && form.fax.value.length < 10) { minimumLengths += nextLine + "Fax Number must be at least 10 characters."  }

    if ( minimumLengths.length > 0 )
    {
        if ( floatingErrorDiv == undefined  )
            alert( minimumLengths );
        else
            showFloatingAlert(floatingErrorDiv, minimumLengths );

        return false;
    }

    // Phone Numbers  - - - - - - - - - - - - -  - -

    if ( getSelectedValue(form.state) == "" )
    {
        if ( floatingErrorDiv == undefined  )
            alert( "Please select your state." );
        else
            showFloatingAlert(floatingErrorDiv, nextLine + "Please select your state." );

        return false;
    }

    if (chkPhoneNum(form.phone, "Work phone is incorrect. ", floatingErrorDiv) == 1)
    {
        return false;
    }

    if (form.phone2.value.length > 0 )
    {
        if (chkPhoneNum(form.phone2, "Alternate phone is incorrect. ", floatingErrorDiv) == 1)
        {
            return false;
        }
    }

    if (form.fax.value.length > 0 )
    {
        if (chkPhoneNum(form.fax, "Fax is incorrect. ", floatingErrorDiv) == 1)
        {
            return false;
        }
    }

    // Eligibility  - - - - - - - - - - - - - - - -
    formSection = "Eligibility Information";
    var minimumLengths = "";

    if ( form.eligibility.value.length < 1 )
    {
        minimumLengths += nextLine + "Eligibility Information must be filled in."
    }
    else if ( form.eligibility.value.length < 5 )
    {
        minimumLengths += nextLine + "Eligibility Information must at least 5 characters."
    }

    if ( minimumLengths.length > 0 )
    {
        if ( floatingErrorDiv == undefined )
            alert( minimumLengths );
        else
            showFloatingAlert(floatingErrorDiv, minimumLengths );

        return false;
    }

    // Login Info  - - - - - - - - - - - - - - - -
    formSection = "Login Information";
    if ( form.userId.value.length < 1 || form.passWd.value.length < 1 || form.passConfirm.value.length < 1)
    {
        errMsg += nextLine + "Login Information must be filled in.";
    }
    
    if ( form.userId.value.indexOf( " " ) > -1 )
    {
        errMsg += nextLine + "User id must not contain spaces";
    }

    if ( errMsg.length > 0 )
    {
        if ( floatingErrorDiv == undefined )
            alert( errMsg );
        else
            showFloatingAlert(floatingErrorDiv, errMsg );

        return false;
    }

    // Username  - - - - - - - - - - - - - - - - -
    var minimumLengths = "";

    if ( form.userId.value.length < 1 )
    {
        errMsg = nextLine + "Username must be filled in."

        if ( floatingErrorDiv == undefined )
            alert( errMsg );
        else
            showFloatingAlert(floatingErrorDiv, errMsg );

        return false;
    }
    else if ( form.userId.value.length < parseInt(minUserLength) || form.userId.value.length > parseInt(maxUserLength) )
    {
        errMsg = nextLine + "Username must be between " + minUserLength + " and " + maxUserLength + " characters.";

        if ( floatingErrorDiv == undefined )
            alert( nextLine + errMsg );
        else
            showFloatingAlert(floatingErrorDiv, errMsg );

        return false;
    }

    // Password  - - - - - - - - - - - - - - - - -


    if ( form.passWd.value.length < 1 || form.passWd.value.length < 1)
    {
        if ( floatingErrorDiv == undefined  )
            alert( "Password fields must be filled in." );
        else
            showFloatingAlert(floatingErrorDiv, "Password fields must be filled in." );
        return false;
    }

    if ( form.passWd.value.length < 8 )
    {
        errMsg = "Password must be between " + minPassLength + " and " + maxPassLength + " characters.";
        if ( floatingErrorDiv == undefined  )
            alert( errMsg );
        else
            showFloatingAlert(floatingErrorDiv, errMsg );
        return false;
    }

    if ( form.passConfirm.value.length < 8 )
    {
        errMsg = nextLine + "Confirmation Password must be between " + minPassLength + " and " + maxPassLength + " characters.";
        if ( floatingErrorDiv == undefined  )
            alert( errMsg );
        else
            showFloatingAlert(floatingErrorDiv, errMsg );
        return false;
    }

    if ( form.userId.value == form.passWd.value )
    {
        errMsg = nextLine + "Password can not be the same as the Username.";
        if ( floatingErrorDiv == undefined  )
            alert( errMsg );
        else
            showFloatingAlert(floatingErrorDiv, errMsg );
        return false;
    }

    if ( form.passWd.value != form.passConfirm.value )
    {
        errMsg = nextLine + "Passwords entered do not match.";
        if ( floatingErrorDiv == undefined )
            alert( errMsg );
        else
            showFloatingAlert(floatingErrorDiv, errMsg );
        return false;
    }

    if ( passwordFormat == "" && chkPass( form.passWd.value, minPassLength, maxPassLength ) > 0 )
    {
        return false;
    }

    // Security  - - - - - - - - - - - - - - - - - -

    formSection = "Security Question";
    if ( form.security_question.value.length < 1 && form.security_answer.value.length < 1 )
    {
        errMsg = nextLine + "Security Information must be filled in.";
        if ( floatingErrorDiv == undefined  )
            alert( errMsg );
        else
            showFloatingAlert(floatingErrorDiv, errMsg );
        return false;
    }
    else
    {
        var minimumLengths = "";

        if ( form.security_question.value.length < 1 )
         { minimumLengths += nextLine + "Security Question must be filled in."  }

        if ( form.security_answer.value.length < 1 )
         { minimumLengths += nextLine + "Security Answer must be filled in."  }

        if ( minimumLengths.length > 0 )
        {
            if ( floatingErrorDiv == undefined  )
                alert( minimumLengths );
            else
                showFloatingAlert(floatingErrorDiv, minimumLengths );
            return false;
        }
    }

    // - - - - - - - - - - - - - - - - - - - - - - -

    if ( checkRequired(form) == false )
    {
        return false;
    }

    // - - - - - - - - - - - - - - - - - - - - - - -

    formSection = "Terms of Service";
    if (form.agree.checked == false)
    {
        errMsg = nextLine + "Please read and agree to the Terms of Service";
        if ( floatingErrorDiv == undefined  )
            alert( errMsg );
        else
            showFloatingAlert(floatingErrorDiv, errMsg );
        return false;
    }

    return true;

}//end function

function showFloatingAlert( divObj, errMsg )
{
    var header = '<div style="padding: 3px; border: solid 1px red; text-align: right; background: #ffa616;"><div style="float: left; padding-right: 10px;">Errors on Form</div><a href="javascript:closeDiv(\'errorDiv\')">Close</a></div>';
    var sectionErr = formSection.length > 0 ? '<div style="font-weight: bold; text-align: center;">'+formSection+'</div>' : '';

    divObj.style.display = '';

    divObj.innerHTML = header + sectionErr + errMsg;
}

function chkPhoneNum(phoneNumber, formnumber, floatErrorObj)
{
  if( phoneNumber.value.length > 0 )
  {
    var regexp1 = /^(\d{10}|\d{3}-\d{3}\-\d{4})$/;
    var regexp2 = /^(\d{10}|\d{3}.\d{3}\.\d{4})$/;
    var firstbool;
    var secondbool;
    var thirdbool;

    var phone = phoneNumber.value;
    var extension = "";

    var token1 = phoneNumber.value;
    var token2 = "";
    var token3 = "";

    try
    {
        if (phoneNumber.value.charAt(3) == " ")
        {
            phone = phone.replace( " ", "-" );
            token1 = phone;
        }
    }
    catch (er) {}

    var ndx = token1.indexOf(" ");
    if (ndx > 0)
    {
        token2 = token1.substring(ndx+1,token1.length);
        token1 = token1.substring(0,ndx);
        //alert("'"+token1+"' '"+token2+"'");
        ndx = token2.indexOf(" ");
        if (ndx > 0)
        {
            token3 = token2.substring(ndx+1,token2.length);
            token2 = token2.substring(0,ndx);
            //alert("'"+token1+"'  '"+token2+"'  '"+token3+"'");
        }
        if (token1.length == 5 && token2.length == 8)
        {
            if (token1.substring(0,1) == "(")
            {
                token1 = token1.substring(1,4);
                //alert(token1);
                phone = token1+"-"+token2;
                //alert(phone);
            }
        }
    }

    var len = phone.length;

    // Assume extension is blank delimited
    var ndx = phone.indexOf(" ");
    if (ndx > 0)
    {
        phone = phone.substring(0,ndx);
        extension = phone.substring(ndx+1,len);
    }

    // Validate the base phone number
    if( regexp1.test( phone ) == false && regexp2.test( phone ) == false)
    {
        var msg = formnumber + "Phone numbers must be in the form xxx-xxx-xxxx or xxx.xxx.xxxx or xxxxxxxxxx.\nAn extension can also be added.";

        if ( floatErrorObj == undefined  )
            alert( msg );
        else
            showFloatingAlert(floatErrorObj, msg );
        return 1;
    }
    else
    {
        if(phone.length == 10 )
        {
            if(  isNaN( parseFloat(phone) ) != false || phone.indexOf("e") != -1 )
            {
                var msg = formnumber + "phone number must be numeric";

                if ( floatErrorObj == undefined  )
                    alert( msg );
                else
                    showFloatingAlert(floatErrorObj, msg );
                return 1;
            }

        }
        else
        {
            firstbool = checkPhoneVal(phone, formnumber, "The first range", " 100 to 999", 100, 999,0,3, floatErrorObj);

            secondbool = checkPhoneVal(phone, formnumber, "The second range", " 000 to 999", 0,999,4,7, floatErrorObj);

            thirdbool = checkPhoneVal(phone, formnumber, "The third range", "0000 to 9999", 0,9999,8,12, floatErrorObj);

            if( firstbool == true || secondbool == true || firstbool == true )
            {
                return 1;
            }
        }
    }
  }

  return 0;
}

function checkPhoneVal(phoneNumber,formnumber, phonename, phonerange,lower, upper , stringlower, stringupper, floatErrorObj)
{

    var value = phoneNumber;

    if(  isNaN( parseFloat(value.substring(stringlower,stringupper) ) ) != false
     || value.substring(stringlower,stringupper).indexOf("e") != -1 )
    {
        var msg = formnumber + phonename + " must be a number";
        if ( floatErrorObj == undefined  )
            alert( msg );
        else
            showFloatingAlert(floatErrorObj, msg );
        return true;
    }
    else
    {
        if( parseFloat( value.substring(stringlower,stringupper))< lower || parseFloat( value.substring(stringlower,stringupper)) > upper )
        {
            var msg = formnumber+ phonename + " must be between " + phonerange;
            if ( floatErrorObj == undefined  )
                alert( msg );
            else
                showFloatingAlert(floatErrorObj, msg );
            return true;
        }
    }

    return false;
}

function validateNumber( value, check )
{
    if ( isNaN( value ) )
    {
        alert( "Please enter a number" );
        return false;
    }

    if ( check > 0 )
    {
        if ( value >= check )
        {
            result = confirm( "Are you sure you entered the correct amount?" );

            return result;

        }//end if

    }//end if

    return true;
}

function validateTextarea(theText, maxLength, textAreaType)
{
    if ( theText.length > maxLength )
    {
        alert( textAreaType + ' can only be ' + maxLength + ' characters long.' );
        return false;
    }

    return true;
}

// this function validates that a password conforms to length and pattern rules
// additional validation rules are implemented elsewhere
function  chkPass( cPass, iMinLen, iMaxlen)
{
  var iErrCnt = 0;
  var RegExp =  /[0-9.a-z.A-Z.!.#.$.%.&.\*._.\-.\+]/g;
  var regExpSmall = /[a-z]/;
  var regExpUpper = /[A-Z]/;
  var regExpNum = /[0-9]/;
  var regExpSpec = /[!.#.$.%.&.\*._.\-.\+]/;
  var SmallPres = false;
  var UpperPres = false;
  var NumPres = false;
  var SpecPres = false;

  var matches = cPass.match( RegExp );
    
  if (cPass == "********")
  {
     return 0;
  }

  if (cPass.length == 0)
  {
      alert( "You cannot enter an empty password." );
      return 1;
  }

  if( cPass.length < iMinLen )
  {
     alert("Your password must have at least " + iMinLen + " characters." );
     iErrCnt++;
     return iErrCnt;
  }
  if( cPass.length > iMaxlen )
  {
     alert("Your password cannot have more than " + iMaxlen + " characters.");
     iErrCnt++;
     return iErrCnt;
  }
  if( matches.length != cPass.length )
  {
     alert("Your password can only contain small letters, capital letters, numbers, or special characters (!#$%&*_-+)." );
     iErrCnt++;
     return iErrCnt;
  }

  if( regExpSmall.test( cPass ) )
  {
    SmallPres = true;
  }

  if( regExpUpper.test( cPass ) )
  {
    UpperPres = true;
  }

  if( regExpNum.test( cPass ) )
  {
    NumPres = true;
  }

  if( regExpSpec.test( cPass ) )
  {
    SpecPres = true;
  }

  if( ( SmallPres == true && UpperPres == true && NumPres == true ) ||
      ( SmallPres == true && UpperPres == true && SpecPres == true ) ||
      ( SmallPres == true && NumPres == true && SpecPres == true ) ||
      ( UpperPres == true && NumPres == true && SpecPres == true ) )
  {
  }
  else
  {
    alert("Your new password must contain at least 3 of the 4 following character types: small letters, capital letters, numbers, or special characters (!#$%&*+_-)." );
    iErrCnt++;
  }

  return iErrCnt;
}

function FloatDiv( divId )
{
    var startX = 50, startY = 300;
    /*
    floatSpeed = speed of floating object on page.
        Higher int = slower to catchup to scroll position.
        Lower int  = quicker to catchup to scroll position
    */
    var floatSpeed = 20;

    var ns = (navigator.appName.indexOf("Netscape") != -1);
    var px = document.layers ? "" : "px";

    function mkLayer(id)
    {
        var el = document.getElementById ? document.getElementById(id) : document.all ? document.all[id] : document.layers[id];
        if(document.layers) el.style = el;

        el.setPt = function(x,y)
                   {
                       this.style.left = x + px;
                       this.style.top = y + px;
                   };
        el.x = startX;
        el.y = startY;

        return el;
    }

    window.stayTopLeft = function()
    {
        var pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;

        fltObj.y += (pY + startY - fltObj.y) / floatSpeed;
        fltObj.setPt(fltObj.x, fltObj.y);

        setTimeout("stayTopLeft()", 10);
    }

    fltObj = mkLayer( divId );

    stayTopLeft();
}


