//*************************************************************************************
// File     : bcpe_functions.js
// Requires : jquery.js (version 1.3.1+)
// Author   : Kyle Weems (ksw)
// Origin   : mindfly.com
// Created  : March 18, 2009
// Modified : March 18, 2009
//*************************************************************************************

$(document).ready(function() {
    aposFilter();
});

// aposFilter - Checks if an apostrophe has been placed in the name field when searching. If so, prevents search and advises user.
function aposFilter() {
    $('form[name="frmSearch"]').submit(function() {
        var searchString = $('form[name="frmSearch"] input[name="Name"]').attr("value");
        if (searchString.indexOf("'") > -1) {
            alert("I’m sorry, you cannot enter apostrophes into this search. Please enter the portion of the name after the apostrophe.");
            return false;
        }
    });
    $('form[name="frmList"]').submit(function() {
        var searchString1 = "";
        if ($('form[name="frmList"] input[name="Name"]').length > 0) { searchString1 = $('form[name="frmList"] input[name="Name"]').attr("value"); }
        var searchString2 = "";
        if ($('form[name="frmList"] input[name="firstname"]').length > 0) { searchString2 = $('form[name="frmList"] input[name="firstname"]').attr("value"); }
        var searchString3 = "";
        if ($('form[name="frmList"] input[name="lastname"]').length > 0) { searchString3 = $('form[name="frmList"] input[name="lastname"]').attr("value"); }
        //alert(searchString1.indexOf("'") + "|" + searchString2.indexOf("'") + "|" + searchString3.indexOf("'"));
        //return false;
        if (searchString1.indexOf("'") > -1 || searchString2.indexOf("'") > -1 || searchString3.indexOf("'") > -1) {
            alert("I’m sorry, you cannot enter apostrophes into this search. Please enter the portion of the name after the apostrophe.");
            return false;
        }
    });
}