// 
// @name bValidator.js
// @author visoot
// @namespace http://www.itorama.com
// @version 1.0.0
// 

var bValidator = function() {
    this.reWhitespace = /^\s+$/;
    this.reLetter = /^[a-zA-Z]$/;
    this.reAlphabetic = /^[a-zA-Z]+$/;
    this.reAlphanumeric = /^[a-zA-Z0-9]+$/;
    this.reDigit = /^\d/;
    this.reLetterOrDigit = /^([a-zA-Z]|\d)$/;
    this.reInteger = /(^\d*$)/;
    this.reSignedInteger = /(^-?\d\d*$)/;
    this.reFloat = /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
    this.reSignedFloat = /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
    this.reEmail = /^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,3}(\.[a-z]{2}){0,2})$/i;
    this.digits = "0123456789";
    this.lowercaseLetters = "abcdefghijklmnopqrstuvwxyz";
    this.uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    this.whitespace = " \t\n\r";
    this.phoneNumberDelimiters = "()- ";
    this.validUSPhoneChars = this.digits + this.phoneNumberDelimiters;
    this.validWorldPhoneChars = this.digits + this.phoneNumberDelimiters + "+";
    this.SSNDelimiters = "- ";
    this.validSSNChars = this.digits + this.SSNDelimiters;
    this.digitsInSocialSecurityNumber = 9;
    this.digitsInUSPhoneNumber = 10;
    this.ZIPCodeDelimiters = "-";
    this.ZIPCodeDelimeter = "-";
    this.validZIPCodeChars = this.digits + this.ZIPCodeDelimiters;
    this.digitsInZIPCode1 = 5;
    this.digitsInZIPCode2 = 9;
    this.creditCardDelimiters = " ";
    this.mPrefix = "You did not enter a value into the ";
    this.mSuffix = " field. This is a required field. Please enter it now.";
    this.sUSLastName = "Last Name";
    this.sUSFirstName = "First Name";
    this.sWorldLastName = "Family Name";
    this.sWorldFirstName = "Given Name";
    this.sTitle = "Title";
    this.sCompanyName = "Company Name";
    this.sUSAddress = "Street Address";
    this.sWorldAddress = "Address";
    this.sCity = "City";
    this.sStateCode = "State Code";
    this.sWorldState = "State, Province, or Prefecture";
    this.sCountry = "Country";
    this.sZIPCode = "ZIP Code";
    this.sWorldPostalCode = "Postal Code";
    this.sPhone = "Phone Number";
    this.sFax = "Fax Number";
    this.sDateOfBirth = "Date of Birth";
    this.sExpirationDate = "Expiration Date";
    this.sEmail = "Email";
    this.sSSN = "Social Security Number";
    this.sCreditCardNumber = "Credit Card Number";
    this.sOtherInfo = "Other Information";
    this.iStateCode = "This field must be a valid two character U.S. state abbreviation (like CA for California). Please reenter it now.";
    this.iZIPCode = "This field must be a 5 or 9 digit U.S. ZIP Code (like 94043). Please reenter it now.";
    this.iUSPhone = "This field must be a 10 digit U.S. phone number (like 415 555 1212). Please reenter it now.";
    this.iWorldPhone = "This field must be a valid international phone number. Please reenter it now.";
    this.iSSN = "This field must be a 9 digit U.S. social security number (like 123 45 6789). Please reenter it now.";
    this.iEmail = "This field must be a valid email address (like foo@bar.com). Please reenter it now.";
    this.iCreditCardPrefix = "This is not a valid ";
    this.iCreditCardSuffix = " credit card number. (Click the link on this form to see a list of sample numbers.) Please reenter it now.";
    this.iDay = "This field must be a day number between 1 and 31.  Please reenter it now.";
    this.iMonth = "This field must be a month number between 1 and 12.  Please reenter it now.";
    this.iYear = "This field must be a 2 or 4 digit year number.  Please reenter it now.";
    this.iDatePrefix = "The Day, Month, and Year for ";
    this.iDateSuffix = " do not form a valid date.  Please reenter them now.";
    this.pEntryPrompt = "Please enter a ";
    this.pStateCode = "2 character code (like CA).";
    this.pZIPCode = "5 or 9 digit U.S. ZIP Code (like 94043).";
    this.pUSPhone = "10 digit U.S. phone number (like 415 555 1212).";
    this.pWorldPhone = "international phone number.";
    this.pSSN = "9 digit U.S. social security number (like 123 45 6789).";
    this.pEmail = "valid email address (like foo@bar.com).";
    this.pCreditCard = "valid credit card number.";
    this.pDay = "day number between 1 and 31.";
    this.pMonth = "month number between 1 and 12.";
    this.pYear = "2 or 4 digit year number.";
    this.defaultEmptyOK = false;
    this.daysInMonth = new Array();
    this.USStateCodeDelimiter = "|";
    this.USStateCodes = "AL|AK|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|GA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|MP|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|UT|VT|VI|VA|WA|WV|WI|WY|AE|AA|AE|AE|AP";
    this._init();
}

bValidator.prototype = {
    makeArray : function(n) {
        for (var i = 1; i <= n; i++) {
            this[i] = 0;
        } 
        return this;
    },
    _init : function() {
        this.daysInMonth = this.makeArray(12);
        this.daysInMonth[1] = 31;
        this.daysInMonth[2] = 29;
        this.daysInMonth[3] = 31;
        this.daysInMonth[4] = 30;
        this.daysInMonth[5] = 31;
        this.daysInMonth[6] = 30;
        this.daysInMonth[7] = 31;
        this.daysInMonth[8] = 31;
        this.daysInMonth[9] = 30;
        this.daysInMonth[10] = 31;
        this.daysInMonth[11] = 30;
        this.daysInMonth[12] = 31;
    },
    
    isEmpty : function(s) {
        return ((s == null) || (s.length == 0));
    },
    
    isWhitespace : function(s) {
        return (this.isEmpty(s) || this.reWhitespace.test(s));
    },
    
    stripCharsInRE : function(s, bag) {
        return s.replace(bag, "");
    },
    
    stripCharsInBag : function(s, bag) {
        var i;
        var returnString = "";
        for (i = 0; i < s.length; i++) {   
            var c = s.charAt(i);
            if (bag.indexOf(c) == -1) 
                returnString += c;
        }
        return returnString;
    },
    
    stripCharsNotInBag : function(s, bag) {   
        var i;
        var returnString = "";
        for (i = 0; i < s.length; i++) {   
            var c = s.charAt(i);
            if (bag.indexOf(c) != -1) 
                returnString += c;
        }
        return returnString;
    },
    
    stripWhitespace : function(s) {
        return this.stripCharsInBag (s, this.whitespace);
    },
    
    charInString : function(c, s) {
	    for (i = 0; i < s.length; i++) {
		    if (s.charAt(i) == c) 
			    return true;
        }
        return false;
    },

    stripInitialWhitespace : function(s) {
	    var i = 0;
	    while ((i < s.length) && charInString (s.charAt(i), this.whitespace))
		    i++;
	    return s.substring (i, s.length);
    },

    isLetter : function(c) {
	    return this.reLetter.test(c);
    },

    isDigit : function(c) {
	    return this.reDigit.test(c);
    },

    isLetterOrDigit : function(c) {
	    return this.reLetterOrDigit.test(c);
    },

    isInteger : function(s) {
	    var i;
	    if (this.isEmpty(s)) 
		    if (isInteger.arguments.length == 1) 
			    return this.defaultEmptyOK;
		    else 
			    return (isInteger.arguments[1] == true);
	    return this.reInteger.test(s);
    },

    isSignedInteger : function(s) {
	    if (this.isEmpty(s))
		    if (isSignedInteger.arguments.length == 1) 
			    return this.defaultEmptyOK;
		    else 
			    return (isSignedInteger.arguments[1] == true);
	    else {
		    return this.reSignedInteger.test(s);
	    }
    },

    isPositiveInteger : function(s) {
	    var secondArg = this.defaultEmptyOK;
	    if (isPositiveInteger.arguments.length > 1)
		    secondArg = isPositiveInteger.arguments[1];
	    return (isSignedInteger(s, secondArg) && ( (this.isEmpty(s) && secondArg)  || (parseInt (s) > 0) ) );
    },

    isNonnegativeInteger : function(s) {
	    var secondArg = this.defaultEmptyOK;
	    if (isNonnegativeInteger.arguments.length > 1)
		    secondArg = isNonnegativeInteger.arguments[1];
	    return (isSignedInteger(s, secondArg) && ( (this.isEmpty(s) && secondArg)  || (parseInt (s) >= 0) ) );
    },

    isNegativeInteger : function(s) {
	    var secondArg = this.defaultEmptyOK;
	    if (isNegativeInteger.arguments.length > 1)
		    secondArg = isNegativeInteger.arguments[1];
	    return (isSignedInteger(s, secondArg) && ( (this.isEmpty(s) && secondArg)  || (parseInt (s) < 0) ) );
    },

    isNonpositiveInteger : function(s) {
	    var secondArg = this.defaultEmptyOK;
	    if (isNonpositiveInteger.arguments.length > 1)
		    secondArg = isNonpositiveInteger.arguments[1];
	    return (isSignedInteger(s, secondArg) && ( (this.isEmpty(s) && secondArg)  || (parseInt (s) <= 0) ) );
    },

    isFloat : function(s) {
	    if (this.isEmpty(s)) 
		    if (isFloat.arguments.length == 1) 
			    return this.defaultEmptyOK;
		    else 
			    return (isFloat.arguments[1] == true);
	    return this.reFloat.test(s);
    },

    isSignedFloat : function(s) {
	    if (this.isEmpty(s)) 
		    if (isSignedFloat.arguments.length == 1)
			    return this.defaultEmptyOK;
		    else 
			    return (isSignedFloat.arguments[1] == true);
	    else {
		    return this.reSignedFloat.test(s);
	    }
    },

    isAlphabetic : function(s) {
	    var i;
	    if (this.isEmpty(s)) 
		    if (isAlphabetic.arguments.length == 1) 
			    return this.defaultEmptyOK;
		    else 
			    return (isAlphabetic.arguments[1] == true);
	    else {
		    return this.reAlphabetic.test(s);
	    }
    },

    isAlphanumeric : function(s) {
	    var i;
	    if (this.isEmpty(s)) 
		    if (isAlphanumeric.arguments.length == 1) 
			    return this.defaultEmptyOK;
		    else 
			    return (isAlphanumeric.arguments[1] == true);
	    else {
		    return this.reAlphanumeric.test(s);
	    }
    },

    reformat : function(s) {
	    var arg;
	    var sPos = 0;
	    var resultString = "";
	    for (var i = 1; i < reformat.arguments.length; i++) {
		    arg = reformat.arguments[i];
		    if (i % 2 == 1) 
			    resultString += arg;
		    else {
			    resultString += s.substring(sPos, sPos + arg);
			    sPos += arg;
		    }
	    }
	    return resultString;
    },

    isSSN : function(s) {
	    if (this.isEmpty(s)) 
		    if (isSSN.arguments.length == 1) 
			    return this.defaultEmptyOK;
		    else 
			    return (isSSN.arguments[1] == true);
	    return (isInteger(s) && s.length == this.digitsInSocialSecurityNumber);
    },

    isUSPhoneNumber : function(s) {   
	    if (this.isEmpty(s)) 
		    if (isUSPhoneNumber.arguments.length == 1) 
			    return this.defaultEmptyOK;
	    else 
		    return (isUSPhoneNumber.arguments[1] == true);
	    return (isInteger(s) && s.length == this.digitsInUSPhoneNumber);
    },

    isInternationalPhoneNumber : function(s) {
	    if (this.isEmpty(s)) 
		    if (isInternationalPhoneNumber.arguments.length == 1) 
			    return this.defaultEmptyOK;
		    else 
			    return (isInternationalPhoneNumber.arguments[1] == true);
	    return (isPositiveInteger(s));
    },

    isZIPCode : function(s) {
	    if (this.isEmpty(s)) 
		    if (isZIPCode.arguments.length == 1) 
			    return this.defaultEmptyOK;
		    else 
			    return (isZIPCode.arguments[1] == true);
	    return (isInteger(s) && ((s.length == this.digitsInZIPCode1) || (s.length == this.digitsInZIPCode2)));
    },

    isStateCode : function(s) {
	    if (this.isEmpty(s)) 
		    if (isStateCode.arguments.length == 1) 
			    return this.defaultEmptyOK;
		    else 
			    return (isStateCode.arguments[1] == true);
	    return ((this.USStateCodes.indexOf(s) != -1) && (s.indexOf(this.USStateCodeDelimiter) == -1))
    },

    isEmail : function(s) {
	    if (this.isEmpty(s)) 
		    if (isEmail.arguments.length == 1) 
			    return this.defaultEmptyOK;
		    else 
			    return (isEmail.arguments[1] == true);
	    else {
		    return this.reEmail.test(s);
	    }
    },

    isYear : function(s) {
	    if (this.isEmpty(s)) 
		    if (isYear.arguments.length == 1) 
			    return this.defaultEmptyOK;
		    else 
			    return (isYear.arguments[1] == true);
	    if (!isNonnegativeInteger(s)) 
		    return false;
	    return ((s.length == 2) || (s.length == 4));
    },

    isIntegerInRange : function(s, a, b) {
	    if (this.isEmpty(s)) 
		    if (isIntegerInRange.arguments.length == 1) 
			    return this.defaultEmptyOK;
		    else 
			    return (isIntegerInRange.arguments[1] == true);
	    if (!isInteger(s, false)) 
		    return false;
	    return ((num >= a) && (num <= b));
    },
    
    	isMonth : function(s) {
		if (this.isEmpty(s)) 
			if (isMonth.arguments.length == 1) 
				return this.defaultEmptyOK;
			else 
				return (isMonth.arguments[1] == true);
		return isIntegerInRange (s, 1, 12);
	},

	isDay : function(s) {
		if (this.isEmpty(s)) 
			if (isDay.arguments.length == 1) 
				return this.defaultEmptyOK;
			else 
				return (isDay.arguments[1] == true);   
		return isIntegerInRange (s, 1, 31);
	},

	daysInFebruary : function(year) {
		return (  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
	},

	isDate : function(year, month, day) {
		if (! (isYear(year, false) && isMonth(month, false) && isDay(day, false))) 
			return false;
		var intYear = parseInt(year);
		var intMonth = parseInt(month);
		var intDay = parseInt(day);
		if (intDay > this.daysInMonth[intMonth]) 
			return false; 
		if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) 
			return false;
		return true;
	},

	prompt : function(s) {
		window.status = s;
	},

	promptEntry : function(s) {
		window.status = this.pEntryPrompt + s;
	},

	warnEmpty : function(theField, s) {
		theField.focus();
		alert(this.mPrefix + s + this.mSuffix);
		return false;
	},

	warnInvalid : function(theField, s) {
		theField.focus();
		theField.select();
		alert(s);
		return false;
	},

	checkString : function(theField, s, emptyOK) {
		if (checkString.arguments.length == 2) 
			emptyOK = this.defaultEmptyOK;
		if ((emptyOK == true) && (this.isEmpty(theField.value))) 
			return true;
		if (this.isWhitespace(theField.value)) 
			return warnEmpty (theField, s);
		else 
			return true;
	},

	checkStateCode : function(theField, emptyOK) {
		if (checkStateCode.arguments.length == 1) 
			emptyOK = this.defaultEmptyOK;
		if ((emptyOK == true) && (this.isEmpty(theField.value))) 
			return true;
		else {
			theField.value = theField.value.toUpperCase();
			if (!isStateCode(theField.value, false)) 
				return warnInvalid (theField, this.iStateCode);
			else 
				return true;
		}
	},

	reformatZIPCode : function(ZIPString) {
		if (ZIPString.length == 5) 
			return ZIPString;
		else 
			return (reformat (ZIPString, "", 5, "-", 4));
	},

	checkZIPCode : function(theField, emptyOK) {
		if (checkZIPCode.arguments.length == 1) 
			emptyOK = this.defaultEmptyOK;
		if ((emptyOK == true) && (this.isEmpty(theField.value))) 
			return true;
		else {
			var normalizedZIP = this.stripCharsInBag(theField.value, this.ZIPCodeDelimiters)
			if (!isZIPCode(normalizedZIP, false)) 
				return warnInvalid (theField, this.iZIPCode);
			else {
				theField.value = reformatZIPCode(normalizedZIP);
				return true;
			}
		}
	},

	reformatUSPhone : function(USPhone) {
		return (reformat (USPhone, "(", 3, ") ", 3, "-", 4));
	},

	checkUSPhone : function(theField, emptyOK) {
		if (checkUSPhone.arguments.length == 1) 
			emptyOK = this.defaultEmptyOK;
		if ((emptyOK == true) && (this.isEmpty(theField.value))) 
			return true;
		else {
			var normalizedPhone = this.stripCharsInBag(theField.value, this.phoneNumberDelimiters);
			if (!isUSPhoneNumber(normalizedPhone, false)) 
				return warnInvalid (theField, this.iUSPhone);
			else {
				theField.value = reformatUSPhone(normalizedPhone);
				return true;
			}
		}
	},

	checkInternationalPhone : function(theField, emptyOK) {
		if (checkInternationalPhone.arguments.length == 1) 
			emptyOK = this.defaultEmptyOK;
		if ((emptyOK == true) && (this.isEmpty(theField.value))) 
			return true;
		else {
			if (!isInternationalPhoneNumber(theField.value, false)) 
				return warnInvalid (theField, this.iWorldPhone);
			else 
				return true;
		}
	},

	checkEmail : function(theField, emptyOK) {
		if (checkEmail.arguments.length == 1) 
			emptyOK = this.defaultEmptyOK;
		if ((emptyOK == true) && (this.isEmpty(theField.value))) 
			return true;
		else if (!isEmail(theField.value, false)) 
			return warnInvalid (theField, this.iEmail);
		else return true;
	},

	reformatSSN : function(SSN) {
		return (reformat (SSN, "", 3, "-", 2, "-", 4));
	},

	checkSSN : function(theField, emptyOK) {
		if (checkSSN.arguments.length == 1) 
			emptyOK = this.defaultEmptyOK;
		if ((emptyOK == true) && (this.isEmpty(theField.value))) 
			return true;
		else {
			var normalizedSSN = this.stripCharsInBag(theField.value, this.SSNDelimiters);
			if (!isSSN(normalizedSSN, false)) 
				return warnInvalid (theField, this.iSSN);
			else {
				theField.value = reformatSSN(normalizedSSN);
				return true;
			}
		}
	},

	checkYear : function(theField, emptyOK)	{   
		if (checkYear.arguments.length == 1) 
			emptyOK = this.defaultEmptyOK;
		if ((emptyOK == true) && (this.isEmpty(theField.value))) 
			return true;
		if (!isYear(theField.value, false)) 
			return warnInvalid (theField, this.iYear);
		else 
			return true;
	},

	checkMonth : function(theField, emptyOK) {
		if (checkMonth.arguments.length == 1) 
			emptyOK = this.defaultEmptyOK;
		if ((emptyOK == true) && (this.isEmpty(theField.value))) 
			return true;
		if (!isMonth(theField.value, false)) 
			return warnInvalid (theField, this.iMonth);
		else 
			return true;
	},

	checkDay : function(theField, emptyOK) {
		if (checkDay.arguments.length == 1) 
			emptyOK = this.defaultEmptyOK;
		if ((emptyOK == true) && (this.isEmpty(theField.value))) 
			return true;
		if (!isDay(theField.value, false)) 
			return warnInvalid (theField, this.iDay);
		else 
			return true;
	},

	checkDate : function(yearField, monthField, dayField, labelString, OKtoOmitDay) {   
		if (checkDate.arguments.length == 4) 
			OKtoOmitDay = false;
		if (!isYear(yearField.value)) 
			return warnInvalid (yearField, this.iYear);
		if (!isMonth(monthField.value)) 
			return warnInvalid (monthField, this.iMonth);
		if ( (OKtoOmitDay == true) && this.isEmpty(dayField.value) ) 
			return true;
		else if (!isDay(dayField.value)) 
			return warnInvalid (dayField, this.iDay);
		if (isDate (yearField.value, monthField.value, dayField.value))
			return true;
		alert (this.iDatePrefix + labelString + this.iDateSuffix);
		return false;
	},

	getRadioButtonValue : function(radio) {
		for (var i = 0; i < radio.length; i++) {
			if (radio[i].checked) { 
				break;
			}
		}
		return radio[i].value;
	},

	checkCreditCard : function(radio, theField) {
		var cardType = getRadioButtonValue(radio);
		var normalizedCCN = this.stripCharsInBag(theField.value, this.creditCardDelimiters);
		if (!isCardMatch(cardType, normalizedCCN)) 
			return warnInvalid (theField, this.iCreditCardPrefix + cardType + this.iCreditCardSuffix);
		else {
			theField.value = normalizedCCN;
			return true;
		}
	},

	isCreditCard : function(st) {
		if (st.length > 19)
			return (false);
		sum = 0; mul = 1; l = st.length;
		for (i = 0; i < l; i++) {
			digit = st.substring(l-i-1,l-i);
			tproduct = parseInt(digit ,10)*mul;
			if (tproduct >= 10)
				sum += (tproduct % 10) + 1;
			else
				sum += tproduct;
			if (mul == 1)
				mul++;
			else
				mul--;
		}
		if ((sum % 10) == 0)
			return (true);
		else
			return (false);
	},

	isVisa : function(cc) {
		if (((cc.length == 16) || (cc.length == 13)) &&	(cc.substring(0,1) == 4))
			return isCreditCard(cc);
		return false;
	},

	isMasterCard : function(cc) {
		firstdig = cc.substring(0,1);
		seconddig = cc.substring(1,2);
		if ((cc.length == 16) && (firstdig == 5) &&	((seconddig >= 1) && (seconddig <= 5)))
			return isCreditCard(cc);
		return false;
	},

	isAmericanExpress : function(cc) {
		firstdig = cc.substring(0,1);
		seconddig = cc.substring(1,2);
		if ((cc.length == 15) && (firstdig == 3) &&	((seconddig == 4) || (seconddig == 7)))
			return isCreditCard(cc);
		return false;
	},

	isDinersClub : function(cc) {
		firstdig = cc.substring(0,1);
		seconddig = cc.substring(1,2);
		if ((cc.length == 14) && (firstdig == 3) && ((seconddig == 0) || (seconddig == 6) || (seconddig == 8)))
			return isCreditCard(cc);
		return false;
	},

	isCarteBlanche : function(cc) {
		return isDinersClub(cc);
	},

	isDiscover : function(cc) {
		first4digs = cc.substring(0,4);
		if ((cc.length == 16) && (first4digs == "6011"))
			return isCreditCard(cc);
		return false;
	},

	isEnRoute : function (cc) {
		first4digs = cc.substring(0,4);
		if ((cc.length == 15) &&
		((first4digs == "2014") ||
		(first4digs == "2149")))
			return isCreditCard(cc);
		return false;
	},
	isJCB : function (cc) {
		first4digs = cc.substring(0,4);
		if ((cc.length == 16) &&
		((first4digs == "3088") ||
		(first4digs == "3096") ||
		(first4digs == "3112") ||
		(first4digs == "3158") ||
		(first4digs == "3337") ||
		(first4digs == "3528")))
			return isCreditCard(cc);
		return false;
	},

	isAnyCard :function (cc) {
		if (!isCreditCard(cc))
			return false;
		if (!isMasterCard(cc) && !isVisa(cc) && !isAmericanExpress(cc) && !isDinersClub(cc) && !isDiscover(cc) && !isEnRoute(cc) && !isJCB(cc)) {
			return false;
		}
		return true;
	},

	isCardMatch : function (cardType, cardNumber) {
		cardType = cardType.toUpperCase();
		var doesMatch = true;
		if ((cardType == "VISA") && (!isVisa(cardNumber)))
			doesMatch = false;
		if ((cardType == "MASTERCARD") && (!isMasterCard(cardNumber)))
			doesMatch = false;
		if (((cardType == "AMERICANEXPRESS") || (cardType == "AMEX") ) && (!isAmericanExpress(cardNumber))) 
			doesMatch = false;
		if ((cardType == "DISCOVER") && (!isDiscover(cardNumber)))
			doesMatch = false;
		if ((cardType == "JCB") && (!isJCB(cardNumber)))
			doesMatch = false;
		if ((cardType == "DINERS") && (!isDinersClub(cardNumber)))
			doesMatch = false;
		if ((cardType == "CARTEBLANCHE") && (!isCarteBlanche(cardNumber)))
			doesMatch = false;
		if ((cardType == "ENROUTE") && (!isEnRoute(cardNumber)))
			doesMatch = false;
		return doesMatch;
	},

	IsCC : function (st) {
	return isCreditCard(st);
	},

	IsVisa : function (cc)  {
		return isVisa(cc);
	},

	IsVISA : function (cc)  {
		return isVisa(cc);
	},

	IsMasterCard : function (cc)  {
		return isMasterCard(cc);
	},

	IsMastercard : function (cc)  {
		return isMasterCard(cc);
	},

	IsMC : function (cc)  {
		return isMasterCard(cc);
	},

	IsAmericanExpress : function (cc)  {
		return isAmericanExpress(cc);
	},

	IsAmEx : function (cc)  {
		return isAmericanExpress(cc);
	},

	IsDinersClub : function (cc)  {
		return isDinersClub(cc);
	},

	IsDC : function (cc)  {
		return isDinersClub(cc);
	},

	IsDiners : function (cc)  {
		return isDinersClub(cc);
	},

	IsCarteBlanche : function (cc)  {
		return isCarteBlanche(cc);
	},

	IsCB : function (cc)  {
		return isCarteBlanche(cc);
	},

	IsDiscover : function (cc)  {
		return isDiscover(cc);
	},

	IsEnRoute : function (cc)  {
		return isEnRoute(cc);
	},

	IsenRoute : function (cc)  {
		return isEnRoute(cc);
	},

	IsJCB : function (cc)  {
		return isJCB(cc);
	},

	IsAnyCard : function (cc)  {
		return isAnyCard(cc);
	},

	IsCardMatch : function (cardType, cardNumber)  {
		return isCardMatch (cardType, cardNumber);
	}
}


