﻿        function IndexOF(ary,value)
        {
            var x=0;
            while (x < (ary.length))
            {
               if (ary[x] == value)
               {
                    return x;
               }
               x++;
            }
            return -1
        }
 function CanadianCards(region,ddl)
        {
            
            var str=['AB', 'BC', 'MB', 'NB', 'NL', 'NS', 'NT', 'NU', 'ON', 'PE', 'QC', 'SK', 'YT'];
            var ddl = document.getElementById(ddl);
            if (IndexOF(str,region) != -1)
            {
                ddl.remove(4);
                ddl.remove(3);
                ddl.remove(2);
                ddl.remove(1);
              var y=document.createElement('option');
              y.text='MasterCard'
              y.value='MasterCard'
              var x=document.getElementById("mySelect");
              try
                {
                       ddl.add(y); // IE only
                }
              catch(ex)
                {
                       ddl.add(y,null); // standards compliant
                }
               y = document.createElement('option');
              y.text='Visa'
              y.value='Visa'
              var x=document.getElementById("mySelect");
              try
                {
                       ddl.add(y); // IE only
                }
              catch(ex)
                {
                       ddl.add(y,null); // standards compliant
                }
            }else{
                ddl.remove(4);
                ddl.remove(3);
                ddl.remove(2);
                ddl.remove(1);
             var y=document.createElement('option');
              y.text='American Express'
              y.value='American Express'
              try
                {
                       ddl.add(y); // IE only
                }
              catch(ex)
                {
                       ddl.add(y,null); // standards compliant
                }
            y = document.createElement('option');
              y.text='Discover'
              y.value='Discover'
              try
                {
                       ddl.add(y); // IE only
                }
              catch(ex)
                {
                       ddl.add(y,null); // standards compliant
                }

            y=document.createElement('option');
              y.text='MasterCard'
              y.value='MasterCard'
              try
                {
                       ddl.add(y); // IE only
                }
              catch(ex)
                {
                       ddl.add(y,null); // standards compliant
                }
            y = document.createElement('option');
              y.text='Visa'
              y.value='Visa'
              try
                {
                       ddl.add(y); // IE only
                }
              catch(ex)
                {
                       ddl.add(y,null); // standards compliant
                }
            }
        }        