<!--
function emailfilter(s) {
    return true;
}

function ltrimword(string,wrd) {
    var ltrimwordTxt = string;

    if (ltrimwordTxt.indexOf(wrd) == 0) {
        ltrimwordTxt = ltrimwordTxt.substring(wrd.length,ltrimwordTxt.length);
    }
    return ltrimwordTxt;
}

function trimword(string,wrd) {
    var trimwordTxt = string;

    if (wrd.length > 0) {
        var trimwordTst = trimwordTxt.substring(trimwordTxt.length-wrd.length,trimwordTxt.length);
        if (trimwordTst == wrd) {
            trimwordTxt = trimwordTxt.substring(0,trimwordTxt.length-wrd.length);
        }
    }
    return trimwordTxt;
}

function remove(string,wrd) {
    var removeTxt = string;
    var removelowerTxt = removeTxt.toLowerCase();

    while (removelowerTxt.indexOf(wrd) > -1) {
        pos = removelowerTxt.indexOf(wrd);
        len = wrd.length;
        removeTxt = removeTxt.substring(0,pos) + removeTxt.substring((pos+len),removeTxt.length);
        removelowerTxt = removeTxt.toLowerCase();
    }
    return removeTxt;
}

function replace(string,old,newStr) {
    var replaceTxt = string;

    while (replaceTxt.indexOf(old) > -1) {
        pos = replaceTxt.indexOf(old);
        len = old.length;
        replaceTxt = replaceTxt.substring(0,pos) + newStr + replaceTxt.substring((pos+len),replaceTxt.length);
    }
    return replaceTxt;
}

function alltrim(string,ch) {
    return trim(ltrim(string,ch),ch);
}

function trim(string,ch) {
    var trimTxt = string;

    while (trimTxt.charAt(trimTxt.length-1) == ch) {
        trimTxt = trimTxt.substring(0,trimTxt.length-1);
    }
    return trimTxt;
}

function ltrim(string,ch) {
    var ltrimTxt = string;

    while (ltrimTxt.charAt(0) == ch) {
        ltrimTxt = ltrimTxt.substring(1,ltrimTxt.length);
    }
    return ltrimTxt;
}

function nospace(string) {
    var spaceTxt = "";
    string = '' + string;
    splitstring = string.split(" ");

    for(spaceI = 0; spaceI < splitstring.length; spaceI++) {
        spaceTxt += splitstring[spaceI];
    }
    return spaceTxt;
}

function strip(string) {
    var sTxt = string;
//	alert(sTxt);
//-- will try to strip invalid characters
    cmp  = "~`!#$%^&*()=+{}[]:;<>?/|\"\\\\\\";

    for (i = 0; i < cmp.length-1; i++) {
        wrd  = cmp.charAt(i);

        while (sTxt.indexOf(wrd) > -1) {
            pos = sTxt.indexOf(wrd);
            sTxt = sTxt.substring(0,pos) + sTxt.substring((pos+1),sTxt.length);
        }
    }

    sTxt = replace(sTxt,"  "," ");
    sTxt = replace(sTxt,",,",",");

    sTxt = remove(sTxt,"..");
    sTxt = remove(sTxt,".@");
    sTxt = remove(sTxt,"@.");

//-- will try to strip obscene words
	if (sTxt.toLowerCase() == "sex" && sTxt.length == 3) {
		sTxt = remove(sTxt,"sex");
	}
	if (sTxt.toLowerCase() == "shit" && sTxt.length == 4) {
		sTxt = remove(sTxt,"shit");
	}
	if (sTxt.toLowerCase() == "fuck" && sTxt.length == 4) {
		sTxt = remove(sTxt,"fuck");
	}
	if (sTxt.toLowerCase() == "damn" && sTxt.length == 4) {
		sTxt = remove(sTxt,"damn");
	}
	if (sTxt.toLowerCase() == "porn" && sTxt.length == 4) {
		sTxt = remove(sTxt,"porn");
	}
	if (sTxt.toLowerCase() == "cum" && sTxt.length == 3) {
		sTxt = remove(sTxt,"cum");
	}
	if (sTxt.toLowerCase() == "cunt" && sTxt.length == 4) {
		sTxt = remove(sTxt,"cunt");
	}
	if (sTxt.toLowerCase() == "prick" && sTxt.length == 5) {
		sTxt = remove(sTxt,"prick");
	}
	if (sTxt.toLowerCase() == "pecker" && sTxt.length == 6) {
		sTxt = remove(sTxt,"pecker");
	}
	if (sTxt.toLowerCase() == "asshole" && sTxt.length == 7) {
		sTxt = remove(sTxt,"asshole");
	}
	if (sTxt.toLowerCase() == "pinkhole" && sTxt.length == 8) {
		sTxt = remove(sTxt,"pinkhole");
	}
	if (sTxt.toLowerCase() == "pedophile" && sTxt.length == 9) {
		sTxt = remove(sTxt,"pedophile");
	}
	if (sTxt.toLowerCase() == "dick" && sTxt.length == 4) {
		sTxt = remove(sTxt,"dick");
	}
	if (sTxt.toLowerCase() == "pussy" && sTxt.length == 5) {
		sTxt = remove(sTxt,"pussy");
	}
	if (sTxt.toLowerCase() == "slut" && sTxt.length == 4) {
		sTxt = remove(sTxt,"slut");
	}
	if (sTxt.toLowerCase() == "blowjob" && sTxt.length == 7) {
		sTxt = remove(sTxt,"blowjob");
	}

    sTxt = alltrim(sTxt," ");
    //sTxt = alltrim(sTxt,".");
    //sTxt = alltrim(sTxt,"_");
    //sTxt = alltrim(sTxt,"@");

    return sTxt;
}

function stripURL(string) {
    var sTxt = string;

//-- will try to strip invalid characters
    cmp  = "#%^&{}[];<>?|\"\\\\\\";

    for (i = 0; i < cmp.length-1; i++) {
        wrd  = cmp.charAt(i);

        while (sTxt.indexOf(wrd) > -1) {
            pos = sTxt.indexOf(wrd);
            sTxt = sTxt.substring(0,pos) + sTxt.substring((pos+1),sTxt.length);
        }
    }

    sTxt = replace(sTxt,"  "," ");
    sTxt = replace(sTxt,",,",",");

    sTxt = remove(sTxt,"..");
    sTxt = remove(sTxt,".@");
    sTxt = remove(sTxt,"@.");

//-- will try to strip obscene words
    sTxt = remove(sTxt,"sex");
    sTxt = remove(sTxt,"shit");
    sTxt = remove(sTxt,"fuck");
    sTxt = remove(sTxt,"damn");
    sTxt = remove(sTxt,"porn");
    sTxt = remove(sTxt,"cum");
    sTxt = remove(sTxt,"cunt");
    sTxt = remove(sTxt,"prick");
    sTxt = remove(sTxt,"pecker");
    sTxt = remove(sTxt,"asshole");
    sTxt = remove(sTxt,"pinkhole");
    sTxt = remove(sTxt,"pedophile");
    sTxt = remove(sTxt,"dick");
    sTxt = remove(sTxt,"pussy");
    sTxt = remove(sTxt,"slut");
    sTxt = remove(sTxt,"blowjob");

    sTxt = alltrim(sTxt," ");
    sTxt = alltrim(sTxt,".");
    sTxt = alltrim(sTxt,"_");
    sTxt = alltrim(sTxt,"@");

    return sTxt;
}
/*
function atom(s) {
	var bad=["bloody","war","terror"];
	var detected=[];
	for(var i=0;i<bad.length;i++)
	if(s.indexOf(bad[i])!=-1) {
		detected.unshift(bad[i]);
		break;
	}
	if(detected.length>1)
		alert("The following curse words were found in your entry: "+detected.join(", ");
	}
}
*/
function filterURL(s) {
    //alert("atom");
    s.value = remove(stripURL(s.value),"@");
    s.value = trimword(s.value," and");
    s.value = ltrimword(s.value,"and ");
//	alert(s.value);
    return true;
}

function searchfilter(s) {
    s.value = remove(strip(s.value),"@");
    s.value = trimword(s.value," and");
    s.value = ltrimword(s.value,"and ");
    return true;
}

function namefilter(s) {
    //s.value = nospace(remove(strip(s.value),","));
    s.value = remove(strip(s.value),",");
    return true;
}

function phonefilter(s){
    nr = s.value;
    flg = 0;

    for (i = 0; i < nr.length; i++) {
        cmp = "0123456789-() ";
        tst = nr.substring(i,i+1);
        if (cmp.indexOf(tst) < 0) {
            flg++;
        }
    }
    if (flg > 0) {
        alert("Invalid telephone");
        s.focus();
        return false;
    } else {
        return true;
    }
}

function numberfilter(s){
    nr = s.value;
    flg = 0;

    for (i = 0; i < nr.length; i++) {
        cmp = "0123456789";
        tst = nr.substring(i,i+1);
        if (cmp.indexOf(tst) < 0) {
            flg++;
        }
    }
    if (flg > 0) {
        alert("Invalid characters encountered.\n\nUse NUMERIC characters only.\nDO NOT put spaces.");
        s.focus();
        return false;
    } else {
        return true;
    }
}

function passwordfilter(s) {
    s.value = nospace(remove(strip(s.value),","));
    txt = s.value;

    for (i = 0; i < txt.length; i++) {
        cmp = "abcdefghijklmnopqrstuvwxyz0123456789";
        tst = txt.substring(i,i+1);
        tst = tst.toLowerCase();
        if (cmp.indexOf(tst) < 0) {
            alert("Invalid characters encountered.\n\nUse ALPHA-NUMERIC characters only.\nDO NOT put spaces.");
            s.value = "";
            s.focus();
            return false;
        }
    }

    if ((txt.length < 8) && (txt.length > 0)) {
        alert("Passwords must be at least 8 characters long");
        s.focus();
        return false;
    }
    return true;
}

function setCriteria()
{
	var paramArray = new Array();
	paramArray = window.document.forms[0].elements["param"];

	if ( trim(paramArray[1].value,' ').length>0 )
	{
		window.document.forms[0].elements["v_criteria"].value = "N";
		//alert(window.document.forms[0].elements["v_criteria"].value);
		window.document.forms[0].toggle.value = "bn";
		window.document.forms[0].origin.value = "searchbox";
		window.document.forms[0].elements["v_business_name"].value = paramArray[1].value;
	}
	else if ( trim(paramArray[0].value,' ').length>0 )
	{
		window.document.forms[0].elements["v_criteria"].value = "D";
		//alert(window.document.forms[0].elements["v_criteria"].value);
		window.document.forms[0].origin.value = "searchbox";
		window.document.forms[0].elements["v_business_name"].value = paramArray[0].value;
	}
	else
	{
		alert("Search parameter required. Please enter a category or business name. ");
		return false;
	}
	return true;
}

//-->
