// ***********************************************************
// Javascript function library
// Name:	aptfree.js
// Created by:	Affordable Production Tools
// Web site:	http://www.aptools.com
// Last update:	March 26, 2000
//
// Placed in the public domain by Affordable Production Tools
//
// It is requested that if you use the functions in this
// library, the origination notices remain with the functions.
// ***********************************************************

//this is a dirty fun thing.
var form_is_dirty = false;
dodirty = function(){ form_is_dirty=true; }
undodirty = function() { form_is_dirty=false; }

// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well
function pageWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;} 
function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} 
function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;} 
function posTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;} 
function posRight() {return posLeft()+pageWidth();} 
function posBottom() {return posTop()+pageHeight();}

function vtString()
{
return (Math.random()*100);
}
    function popOutTripComments()
    {
    var subWindow = window.open("", "ext_window", "width=900,height=500,resizable=yes,status=no,menubar=no,toolbar=no,directories=no,scrollbars=yes");
    subWindow.focus();

    }
    function popOutCallComments()
    {
    var subWindow = window.open("", "ext_window", "width=1200,height=600,resizable=yes,status=no,menubar=no,toolbar=no,directories=no,scrollbars=yes");
    subWindow.focus();

    }
    function popOutPoContract()
    {
    var subWindow = window.open("", "ext_window", "width=700,height=500,resizable=yes,status=no,menubar=no,toolbar=no,directories=no,scrollbars=yes");
    subWindow.focus();

    }
    function popOutChargeBack()
    {
    var subWindow = window.open("", "ext_window", "width=500,height=700,resizable=no,status=no,menubar=no,toolbar=no,directories=no,scrollbars=yes");
    subWindow.focus();

    }
    function ResetForm(form)
    {
        for (var i=0; i< form.elements.length; i++)
        {
            if (form.elements[i].type=="text")
            {
            form.elements[i].value="";
            }
           
            if (form.elements[i].type=="select-one")
            {
           
              form.elements[i].selectedIndex=0;
              form.elements[i].blur();
            }
        }
    }

        function showCover() {
            Page_ClientValidate();
            //window.alert(Page_IsValid);
            if(Page_IsValid==true) 
            {
                $('cover-elements').setOpacity(0.5);
                $('cover-elements').show();
            }
        }
        function showCoverNoValidate() {
                $('cover-elements').setOpacity(0.5);
                $('cover-elements').show();
        }
        function hideCover() {
            $('cover-elements').hide();
        }
    




function addOption(selectbox,text,value,SavedVal )
{
//alert('im here');
//var optn = document.createElement("OPTION");
//optn.text = text;
//optn.value = value;

///alert('value:' + value + ' saved value: ' + SavedVal);

  if ( value == SavedVal)
  {
    $(selectbox).options[$(selectbox).options.length]=new Option(text,value,false,true);
  }
  else
  {
    $(selectbox).options[$(selectbox).options.length]=new Option(text,value,false,false);
  }
}

function removeAllOptions(selectbox)
{
var i;
for(i=$(selectbox).options.length-1;i>=0;i--)
{
    //selectbox.options.remove(i);
    $(selectbox).remove(i);
}
}
function stripCharacter(words,character) {
	//documentation for this script at http://www.shawnolson.net/a/499/
	  var spaces = words.length;
	  for(var x = 1; x<spaces; ++x){
	   words = words.replace(character, "");   
	 }
	 return words;
    }
    function stripCellphone(cellphone,fieldid)
    {
        var returnCellphone;
        
        returnCellphone=stripCharacter(cellphone,"-")
        returnCellphone=stripCharacter(returnCellphone," ")
        returnCellphone=stripCharacter(returnCellphone,"(")
        returnCellphone=stripCharacter(returnCellphone,")")
        returnCellphone=stripCharacter(returnCellphone,".")
        
        $(fieldid).value=returnCellphone;
        
        var res = Page_ClientValidate("PhoneNumbers");
        
    }
function FormatNumber(Number,Decimals,Separator)
{
 // **********************************************************
 // Placed in the public domain by Affordable Production Tools
 // March 21, 1998
 // Web site: http://www.aptools.com
 //
 // November 24, 1998 -- Error which allowed a null value
 // to remain null fixed. Now forces value to 0.
 //
 // This function accepts a number to format and number
 // specifying the number of decimal places to format to. May
 // optionally use a separator other than '.' if specified.
 //
 // If no decimals are specified, the function defaults to
 // defaults to 0. Decimal separator defaults to '.' .
 // two decimal places. If no number is passed, the function
 //
 // If the number passed is too large to format as a decimal
 // number (e.g.: 1.23e+25), or if the conversion process
 // results in such a number, the original number is returned
 // unchanged.
 // **********************************************************
 Number += ""          // Force argument to string.
 Decimals += ""        // Force argument to string.
 Separator += ""       // Force argument to string.
 if((Separator == "") || (Separator.length > 1))
  Separator = "."
 if(Number.length == 0)
  Number = "0"
 var OriginalNumber = Number  // Save for number too large.
 var Sign = 1
 var Pad = ""
 var Count = 0
 // If no number passed, force number to 0.
 if(parseFloat(Number)){
  Number = parseFloat(Number)} else {
  Number = 0}
 // If no decimals passed, default decimals to 2.
 if((parseInt(Decimals,10)) || (parseInt(Decimals,10) == 0)){
  Decimals = parseInt(Decimals,10)} else {
  Decimals = 2}
 if(Number < 0)
 {
  Sign = -1         // Remember sign of Number.
  Number *= Sign    // Force absolute value of Number.
 }
 if(Decimals < 0)
  Decimals *= -1    // Force absolute value of Decimals.
 // Next, convert number to rounded integer and force to string value.
 // (Number contains 1 extra digit used to force rounding)
 Number = "" + Math.floor(Number * Math.pow(10,Decimals + 1) + 5)
 if((Number.substring(1,2) == '.')||((Number + '')=='NaN'))
  return(OriginalNumber) // Number too large to format as specified.
 // If length of Number is less than number of decimals requested +1,
 // pad with zeros to requested length.
 if(Number.length < Decimals +1) // Construct pad string.
 {
  for(Count = Number.length; Count <= Decimals; Count++)
   Pad += "0"
 }
 Number = Pad + Number // Pad number as needed.
 if(Decimals == 0){
  // Drop extra digit -- Number is formatted.
  Number = Number.substring(0, Number.length -1)} else {
  // Or, format number with decimal point and drop extra decimal digit.
 Number = Number.substring(0,Number.length - Decimals -1) +
          Separator +
          Number.substring(Number.length - Decimals -1,
          Number.length -1)}
 if(Sign == -1)
  Number = "-" + Number  // Set sign of number.
 if(Number.length == 0)
  Number="0"
 return(Number)
}

function PadLeft(String,Length,PadChar)
{
 // **********************************************************
 // Placed in the public domain by Affordable Production Tools
 // April 1, 1998
 // Web site: http://www.aptools.com
 //
 // December 2, 1998 -- Modified to allow specification of
 // pad character.
 //
 // This function accepts a number or string, and a number
 // specifying the desired length. If the length is greater
 // than the length of the value passed, the value is padded
 // with spaces (default) or the specified pad character
 // to the length specified.
 //
 // The function is useful in right justifying numbers or
 // strings in HTML form fields.
 // **********************************************************
 String += ""       // Force argument to string.
 Length += ""       // Force argument to string.
 PadChar += ""      // Force argument to string.
 if((PadChar == "") || (!(PadChar.length == 1)))
  PadChar = " "
 var Count = 0
 var PadLength = 0
 Length = parseInt(0 + Length,10)
 if(Length <= String.length) // No padding necessary.
  return(String)
 PadLength = Length - String.length
 for(Count = 0; Count < PadLength; Count++)
  String = PadChar + String
 return(String)
}

function PadRight(String,Length,PadChar)
{
 // **********************************************************
 // Placed in the public domain by Affordable Production Tools
 // April 1, 1998
 // Web site: http://www.aptools.com
 //
 // December 2, 1998 -- Modified to allow specification of
 // pad character.
 //
 // This function accepts a number or string, and a number
 // specifying the desired length. If the length is greater
 // than the length of the value passed, the value is padded
 // with spaces (default) or the specified pad character
 // to the length specified.
 // **********************************************************
 String += ""       // Force argument to string.
 Length += ""       // Force argument to string.
 PadChar += ""      // Force argument to string.
 if((PadChar == "") || (!(PadChar.length == 1)))
  PadChar = " "
 var Count = 0
 var PadLength = 0
 Length = parseInt(0 + Length,10)
 if(Length <= String.length) // No padding necessary.
  return(String)
 PadLength = Length - String.length
 for(Count = 0; Count < PadLength; Count++)
  String += PadChar
 return(String)
}

function PadCenter(String,Length,PadChar)
{
 // **********************************************************
 // Placed in the public domain by Affordable Production Tools
 // April 1, 1998
 // Web site: http://www.aptools.com
 //
 // December 2, 1998 -- Modified to allow specification of
 // pad character.
 //
 // This function accepts a number or string, and a number
 // specifying the desired length. If the length is greater
 // than the length of the value passed, the value is padded
 // with spaces (default) or the specified pad character
 // to the length specified.
 //
 // Uses functions PadLeft() and PadRight()
 // **********************************************************
 String += ""       // Force argument to string.
 Length += ""       // Force argument to string.
 PadChar += ""      // Force argument to string.
 if((PadChar == "") || (!(PadChar.length == 1)))
  PadChar = " "
 var Count = 0
 var PadLength = 0
 var LeftPad = 0
 var RightPad = 0
 Length = parseInt(0 + Length,10)
 if(Length <= String.length) // No padding necessary.
  return(String)
 PadLength = Length - String.length
 LeftPad = Math.floor(PadLength/2)
 RightPad = PadLength - LeftPad
 String = PadLeft(String,LeftPad+String.length,PadChar)
 String = PadRight(String,RightPad+String.length,PadChar)
 return(String)
}

function LeftTrim(String,TrimChar)
{
 // **********************************************************
 // Placed in the public domain by Affordable Production Tools
 // April 27, 1998
 // Web site: http://www.aptools.com
 //
 // December 2, 1998 -- Modified to allow specification of
 // character to be trimmed.
 //
 // This function trims spaces (default) or the specified
 // character from the left of a string or form field.
 // **********************************************************
 String += ""         // Force argument to string.
 TrimChar += ""       // Force argument to string.
 if((TrimChar == "") || (!(TrimChar.length == 1)))
  TrimChar = " "
 if(String.length == 0)
  return(String)
 var Count = 0
 for(Count = 0;Count < String.length;Count++)
 {
  if(!(String.charAt(Count) == TrimChar))
   return(String.substring(Count,String.length))
 }
 return("")
}

function RightTrim(String,TrimChar)
{
 // **********************************************************
 // Placed in the public domain by Affordable Production Tools
 // April 27, 1998
 // Web site: http://www.aptools.com
 //
 // December 2, 1998 -- Modified to allow specification of
 // character to be trimmed.
 //
 // This function trims spaces (default) or the specified
 // character from the right of a string or form field.
 // **********************************************************
 String += ""        // Force argument to string.
 TrimChar += ""      // Force argument to string.
 if((TrimChar == "") || (!(TrimChar.length == 1)))
  TrimChar = " "
 if(String.length == 0)
  return(String)
 var Count = 0
 for(Count = String.length -1;Count >= 0;Count--)
 {
  if(!(String.charAt(Count) == TrimChar))
   return(String.substring(0,Count + 1))
 }
 return("")
}

function AllTrim(String,TrimChar)
{
 // **********************************************************
 // Placed in the public domain by Affordable Production Tools
 // April 27, 1998
 // Web site: http://www.aptools.com
 //
 // December 2, 1998 -- Modified to allow specification of
 // character to be trimmed.
 //
 // This function trims spaces (default) or the specified
 // character from the left and the right of a string or form field.
 //
 // Note that this functions uses two other library functions,
 // TrimLeft() and TrimRight().
 // **********************************************************
 String += ""        // Force argument to string.
 TrimChar += ""      // Force argument to string.
 if((TrimChar == "") || (!(TrimChar.length == 1)))
  TrimChar = " "
 return(RightTrim(LeftTrim(String,TrimChar),TrimChar))
}

function FormatNumberField(Object,Decimals,Pad,Separator,PadChar)
{
 // **********************************************************
 // Placed in the public domain by Affordable Production Tools
 // March 23, 1998
 // Web site: http://www.aptools.com
 //
 // November 24, 1998 -- Error which allowed a null field
 // to remain null fixed. Now forces value to 0.
 //
 // December 2, 1998 -- Modified to allow specification of
 // pad character.
 //
 // This function formats a number in an HTML form field,
 // setting the decimal precision and right justifying the
 // number in the field. An optional decimal separator other
 // than '.' may be specified and an optional pad character
 // may be specified (default is space).
 //
 // Note that this function uses two other library functions,
 // FormatNumber() and PadLeft().
 //
 // Usage: Call the function with an onblur or onchange event
 // attached to the field:
 //
 // onblur="FormatNumberField(this,Decimals,Pad,[Separator],[PadChar])"
 // where Decimals is the number of decimals desired and Pad
 // is the size of the field.
 // **********************************************************
 if(Object.value == "")
  Object.value = "0"
 if(Object == null)
  return(null)
 Separator += ""      // Force argument to string.
 if((Separator == "") || (Separator.length > 1))
  Separator = "."
 PadChar += ""
 if((PadChar == "") || (!(PadChar.length == 1)))
  PadChar = " "
 Object.value = FormatNumber(Object.value,Decimals,Separator)
 Object.value = PadLeft(Object.value,Pad,PadChar)
 return(Object.value)
}

function isEmail (strEmail)
{
// Regular expression matches an email address of form blah@abc.abc.123.abc
// Good email addresses do not break any of the following rules:
//  1) There must be one and only one "@" symbol in the address. 
//    (i.e "george.bush" and "re@gan@lalaland.org" are bad addresses)
//  2) There must be text preceding the @ symbol and that text cannot
//    include any of the following characters: /#,^*\ 
//    (i.e. "pl#ck@you.edu" is a bad address)
//  3) After the @ symbol there must be some text with at least one period. 
//    (i.e. "fee@fiefoefum" and "fee@." are bad addresses)
//  4) The text following the final period in the address must be composed of
//    alphabetical letters and there must be either 2 or three letters.
//    (i.e. "fee@fie.foefu.m" and "cha@ka.kahn.r3" are bad addresses)
//  5) Other character elements following the @ symbol and preceeding periods
//    can only consist of letters, numbers or hyphens (-). These strings must be
//    at least one character in length 
//    (in other words "fi@fo..com" and "fee@fo.?.com" are a bad addresses)
    return (strEmail.match(/^[^\/\#\,\^\*\\]+\@([A-Za-z0-9\-]{1,}\.)+([A-Za-z]{2,3})$/) ? true:false);    
}

<!-- Original:  Simon Tneoh (tneohcb@pc.jaring.my) -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var Cards = new makeArray(2);
Cards[0] = new CardType("MasterCard", "51,52,53,54,55", "16");
var MasterCard = Cards[0];
Cards[1] = new CardType("VisaCard", "4", "13,16");
var VisaCard = Cards[1];
//Cards[2] = new CardType("AmExCard", "34,37", "15");
//var AmExCard = Cards[2];
//Cards[3] = new CardType("DinersClubCard", "30,36,38", "14");
//var DinersClubCard = Cards[3];
//Cards[4] = new CardType("DiscoverCard", "6011", "16");
//var DiscoverCard = Cards[4];
//Cards[5] = new CardType("enRouteCard", "2014,2149", "15");
//var enRouteCard = Cards[5];
//Cards[6] = new CardType("JCBCard", "3088,3096,3112,3158,3337,3528", "16");
//var JCBCard = Cards[6];
//var LuhnCheckSum = Cards[7] = new CardType();

/*************************************************************************\
CheckCardNumber(form)
function called when users click the "check" button.
\*************************************************************************/
function CheckCardNumber() {
var tmpyear;
if (document.form1.accountnumber.value.length == 0) {
alert("Please enter a Card Number.");
document.form1.accountnumber.focus();
return false;
}
if (document.form1.year.value.length == 0) {
alert("Please enter the Expiration Year.");
document.form1.year.focus();
return false;
}
tmpyear = document.form1.year.options[document.form1.year.selectedIndex].value;

tmpmonth = document.form1.month.options[document.form1.month.selectedIndex].value;
// The following line doesn't work in IE3, you need to change it
// to something like "(new CardType())...".
// if (!CardType().isExpiryDate(tmpyear, tmpmonth)) {
if (!(new CardType()).isExpiryDate(tmpyear, tmpmonth)) {
alert("This card has already expired.");
return false;
}

var retval = eval("MasterCard" + ".checkCardNumber(\"" + document.form1.accountnumber.value +
"\", " + tmpyear + ", " + tmpmonth + ");");
cardname = "";
if (retval)



// comment this out if used on an order form
return true;


else 
{

	var retval2 = eval("VisaCard" + ".checkCardNumber(\"" + document.form1.accountnumber.value +
	"\", " + tmpyear + ", " + tmpmonth + ");");
	cardname = ""; 

	if (retval2)
	{
		// comment this out if used on an order form
		return true;
	}
	else
	{
		alert("Invalid Credit Card Number.")
		return false;
	}
  }
}
/*************************************************************************\
Object CardType([String cardtype, String rules, String len, int year, 
                                        int month])
cardtype    : type of card, eg: MasterCard, Visa, etc.
rules       : rules of the cardnumber, eg: "4", "6011", "34,37".
len         : valid length of cardnumber, eg: "16,19", "13,16".
year        : year of expiry date.
month       : month of expiry date.
eg:
var VisaCard = new CardType("Visa", "4", "16");
var AmExCard = new CardType("AmEx", "34,37", "15");
\*************************************************************************/
function CardType() {
var n;
var argv = CardType.arguments;
var argc = CardType.arguments.length;

this.objname = "object CardType";

var tmpcardtype = (argc > 0) ? argv[0] : "CardObject";
var tmprules = (argc > 1) ? argv[1] : "0,1,2,3,4,5,6,7,8,9";
var tmplen = (argc > 2) ? argv[2] : "13,14,15,16,19";

this.setCardNumber = setCardNumber;  // set CardNumber method.
this.setCardType = setCardType;  // setCardType method.
this.setLen = setLen;  // setLen method.
this.setRules = setRules;  // setRules method.
this.setExpiryDate = setExpiryDate;  // setExpiryDate method.

this.setCardType(tmpcardtype);
this.setLen(tmplen);
this.setRules(tmprules);
if (argc > 4)
this.setExpiryDate(argv[3], argv[4]);

this.checkCardNumber = checkCardNumber;  // checkCardNumber method.
this.getExpiryDate = getExpiryDate;  // getExpiryDate method.
this.getCardType = getCardType;  // getCardType method.
this.isCardNumber = isCardNumber;  // isCardNumber method.
this.isExpiryDate = isExpiryDate;  // isExpiryDate method.
this.luhnCheck = luhnCheck;// luhnCheck method.
return this;
}

/*************************************************************************\
boolean checkCardNumber([String cardnumber, int year, int month])
return true if cardnumber pass the luhncheck and the expiry date is
valid, else return false.
\*************************************************************************/
function checkCardNumber() {
var argv = checkCardNumber.arguments;
var argc = checkCardNumber.arguments.length;
var cardnumber = (argc > 0) ? argv[0] : this.cardnumber;
var year = (argc > 1) ? argv[1] : this.year;
var month = (argc > 2) ? argv[2] : this.month;

this.setCardNumber(cardnumber);
this.setExpiryDate(year, month);

if (!this.isCardNumber())
return false;
if (!this.isExpiryDate())
return false;

return true;
}
/*************************************************************************\
String getCardType()
return the cardtype.
\*************************************************************************/
function getCardType() {
return this.cardtype;
}
/*************************************************************************\
String getExpiryDate()
return the expiry date.
\*************************************************************************/
function getExpiryDate() {
return this.month + "/" + this.year;
}
/*************************************************************************\
boolean isCardNumber([String cardnumber])
return true if cardnumber pass the luhncheck and the rules, else return
false.
\*************************************************************************/
function isCardNumber() {
var argv = isCardNumber.arguments;
var argc = isCardNumber.arguments.length;
var cardnumber = (argc > 0) ? argv[0] : this.cardnumber;
if (!this.luhnCheck())
return false;

for (var n = 0; n < this.len.size; n++)
if (cardnumber.toString().length == this.len[n]) {
for (var m = 0; m < this.rules.size; m++) {
var headdigit = cardnumber.substring(0, this.rules[m].toString().length);
if (headdigit == this.rules[m])
return true;
}
return false;
}
return false;
}

/*************************************************************************\
boolean isExpiryDate([int year, int month])
return true if the date is a valid expiry date,
else return false.
\*************************************************************************/
function isExpiryDate() {
var argv = isExpiryDate.arguments;
var argc = isExpiryDate.arguments.length;

year = argc > 0 ? argv[0] : this.year;
month = argc > 1 ? argv[1] : this.month;

if (!isNum(year+""))
return false;
if (!isNum(month+""))
return false;
today = new Date();
expiry = new Date(year, month);
if (today.getTime() > expiry.getTime())
return false;
else
return true;
}

/*************************************************************************\
boolean isNum(String argvalue)
return true if argvalue contains only numeric characters,
else return false.
\*************************************************************************/
function isNum(argvalue) {
argvalue = argvalue.toString();

if (argvalue.length == 0)
return false;

for (var n = 0; n < argvalue.length; n++)
if (argvalue.substring(n, n+1) < "0" || argvalue.substring(n, n+1) > "9")
return false;

return true;
}

/*************************************************************************\
boolean luhnCheck([String CardNumber])
return true if CardNumber pass the luhn check else return false.
Reference: http://www.ling.nwu.edu/~sburke/pub/luhn_lib.pl
\*************************************************************************/
function luhnCheck() {
var argv = luhnCheck.arguments;
var argc = luhnCheck.arguments.length;

var CardNumber = argc > 0 ? argv[0] : this.cardnumber;

if (! isNum(CardNumber)) {
return false;
  }

var no_digit = CardNumber.length;
var oddoeven = no_digit & 1;
var sum = 0;

for (var count = 0; count < no_digit; count++) {
var digit = parseInt(CardNumber.charAt(count));
if (!((count & 1) ^ oddoeven)) {
digit *= 2;
if (digit > 9)
digit -= 9;
}
sum += digit;
}
if (sum % 10 == 0)
return true;
else
return false;
}

/*************************************************************************\
ArrayObject makeArray(int size)
return the array object in the size specified.
\*************************************************************************/
function makeArray(size) {
this.size = size;
return this;
}

/*************************************************************************\
CardType setCardNumber(cardnumber)
return the CardType object.
\*************************************************************************/
function setCardNumber(cardnumber) {
this.cardnumber = cardnumber;
return this;
}

/*************************************************************************\
CardType setCardType(cardtype)
return the CardType object.
\*************************************************************************/
function setCardType(cardtype) {
this.cardtype = cardtype;
return this;
}

/*************************************************************************\
CardType setExpiryDate(year, month)
return the CardType object.
\*************************************************************************/
function setExpiryDate(year, month) {
this.year = year;
this.month = month;
return this;
}

/*************************************************************************\
CardType setLen(len)
return the CardType object.
\*************************************************************************/
function setLen(len) {
// Create the len array.
if (len.length == 0 || len == null)
len = "13,14,15,16,19";

var tmplen = len;
n = 1;
while (tmplen.indexOf(",") != -1) {
tmplen = tmplen.substring(tmplen.indexOf(",") + 1, tmplen.length);
n++;
}
this.len = new makeArray(n);
n = 0;
while (len.indexOf(",") != -1) {
var tmpstr = len.substring(0, len.indexOf(","));
this.len[n] = tmpstr;
len = len.substring(len.indexOf(",") + 1, len.length);
n++;
}
this.len[n] = len;
return this;
}

/*************************************************************************\
CardType setRules()
return the CardType object.
\*************************************************************************/
function setRules(rules) {
// Create the rules array.
if (rules.length == 0 || rules == null)
rules = "0,1,2,3,4,5,6,7,8,9";
  
var tmprules = rules;
n = 1;
while (tmprules.indexOf(",") != -1) {
tmprules = tmprules.substring(tmprules.indexOf(",") + 1, tmprules.length);
n++;
}
this.rules = new makeArray(n);
n = 0;
while (rules.indexOf(",") != -1) {
var tmpstr = rules.substring(0, rules.indexOf(","));
this.rules[n] = tmpstr;
rules = rules.substring(rules.indexOf(",") + 1, rules.length);
n++;
}
this.rules[n] = rules;
return this;
}
