JavaScript function to determine if the string contains a particular sub-string.

function strContains(haystack, needle, ignoreCase) {
    if (!needle) return false;
    if (!haystack) return false;

    if (ignoreCase) {
        needle = needle.toUpperCase();
        haystack = haystack.toUpperCase();
    }

    return haystack.indexOf(needle) !== -1;
}