﻿//Sanjeev
//Banned KeyWords

function BannedKeyWords(Control, BannedKeyWordsList, Message, MessageSingle, ControlType) {

    var Obj = document.getElementById(Control);
    var result = BannedKeyWordsList;
   
    if (result == '') {
        return true;
    }
    else {
        var re = new RegExp(result, "gi");
        if (Obj.value.match(re)) {

            if (Obj.value.match(re)[1] != null) {
                alert(Obj.value.match(re) + ' ' + Message);
            }
            else {
                alert(Obj.value.match(re) + ' ' + MessageSingle);
            }
            if (ControlType == 'asp') {
                document.getElementById(Control).focus();
            }
            else {
                document.getElementById(Control + '_Text').focus();
            }

            return false;
        }
        else {
            return true;
        }
    }
}


//Code Added By Chayandip for removing unwanted css file dynamically//
function removejscssfile(filename, filetype) {
    var targetelement = (filetype == "js") ? "script" : (filetype == "css") ? "link" : "none" //determine element type to create nodelist from
    var targetattr = (filetype == "js") ? "src" : (filetype == "css") ? "href" : "none" //determine corresponding attribute to test for
    var allsuspects = document.getElementsByTagName(targetelement)
    for (var i = allsuspects.length; i >= 0; i--) { //search backwards within nodelist for matching elements to remove
        if (allsuspects[i] && allsuspects[i].getAttribute(targetattr) != null && allsuspects[i].getAttribute(targetattr).indexOf(filename) != -1)
            allsuspects[i].parentNode.removeChild(allsuspects[i]) //remove element by calling parentNode.removeChild()
    }
}
//Code Ended By Chayandip//