function superbutton(input,input2,input3,input4){
  document.hlm.id.value=input;
  document.hlm.type.value=input2;
  document.hlm.low.value=input3;
  document.hlm.high.value=input4;
  document.hlm.submit();
}
function newImage(arg){
  if(document.images){
    rslt=new Image();
    rslt.src=arg;
    return rslt;
  }
}
function changeImages(){
  for(var i=0; i<changeImages.arguments.length; i+=2){
    document[changeImages.arguments[i]].src=changeImages.arguments[i+1];
  }
}
var preloadFlag=false;
function preloadImages(){
  if(document.images){
    musi_on=newImage("/graphics/musi_on.gif");
    band=newImage("/graphics/band_on.gif");
    gigs=newImage("/graphics/gigs_on.gif");
    gear=newImage("/graphics/gear_on.gif");
    news=newImage("/graphics/news_on.gif");
    feat=newImage("/graphics/feat_on.gif");
    prom=newImage("/graphics/prom_on.gif");
    find=newImage("/graphics/find_on.gif");
    logn=newImage("/graphics/logon_on.gif");
    rarr=newImage("/graphics/rarr_on.gif");
    larr=newImage("/graphics/larr_on.gif");
    bar_musi=newImage("/graphics/bar_musi_on.gif");
    bar_band=newImage("/graphics/bar_band_on.gif");
    bar_gigs=newImage("/graphics/bar_gigs_on.gif");
    bar_gear=newImage("/graphics/bar_gear_on.gif");
    bar_news=newImage("/graphics/bar_news_on.gif");
    bar_prom=newImage("/graphics/bar_prom_on.gif");
    bar_logo=newImage("/graphics/bar_logo_on.gif");
    bar_home=newImage("/graphics/bar_home_on.gif");
    preloadFlag=true;
  }
}
function isblank(s) {
  for(var i = 0; i < s.length; i++) {
    var c = s.charAt(i);
    if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
  }
  return true;
}
function verify(f) {
  var empty_fields = '';
  var errors = '';
  var debug = '';
  for(var i = 0; i < f.length; i++) {
    var e = f.elements[i];
    var n = e.name;     // variable name
    var t = e.type;     // variable type
    var v = e.value;    // vairable value
    var o = e.optional; // vairable option
    var mi = e.min;     // variable minimum
    var ma = e.max;     // variable maximum
    if (t != 'hidden') {
      debug += "\n - "+n+' ( '+v+' ) [ '+t+' ]';
      if (t == 'select-one' && !o) {
        if (v == null || v == 'Select' || v == 'None' || v == '' || v == 'Select One' || isblank(v)) {
          var errName = '';
          if (n == 'stat')                errName = 'State';
          else if (n == 'band_name')      errName = 'Band Name';
          else if (n == 'month')          errName = 'Month';
          else if (n == 'day')            errName = 'Day';
          else if (n == 'year')           errName = 'Year';
          else if (n == 'start_time')     errName = 'Start Time';
          else if (n == 'end_time')       errName = 'End Time';
          else if (n == 'end_time')       errName = 'End Time';
          else if (n == 'gig_type')       errName = 'Gig Type';
          else if (n == 'genre')          errName = 'Gig Style';
          else if (n == 'coun')           errName = 'Country';
          else if (n == 'inst1')          errName = 'Instrument 1';
          else if (n == 'genr11')         errName = 'First Style of Music';
          else if (n == 'product_type')   errName = 'Product Type';
          else if (n == 'hear_about_us')  errName = 'How did you heard about us';
          if (errName == null || errName == '') { continue; }
          empty_fields += "\n  *" + errName + ' - Please make a selection';
        }
        continue;
      }
      if (t == 'textarea' && !o) {
        if (v == null || isblank(v)) {
          var errName;
          if (n == 'comments')        errName = 'Comments';
          if (n == 'description')     errName = 'Description';
          else if (errName == null || errName == '') { continue; }
          empty_fields += "\n  *" + errName + ' - Please fill out this field';
        }
        continue;
      }
      if (t == 'text' && !o) {
        if (v == null || isblank(v)) {
          var errName;
          if (n == 'address')           errName = 'Address';
          else if (n == 'city')         errName = 'City';
          else if (n == 'zip')          errName = 'Zip Code';
          else if (n == 'first_name')   errName = 'First Name';
          else if (n == 'last_name')    errName = 'Last Name';
          else if (n == 'band_name')    errName = 'Band Name';
          else if (n == 'phone')        errName = 'Phone Number';
          else if (n == 'email')        errName = 'Email Address';
          else if (n == 'number')       errName = 'Number of Members';
          else if (n == 'product_name') errName = 'Product Name';
          else if (n == 'price')        errName = 'Price';
          else if (n == 'title')        errName = 'Title';
          if (empty_fields.match(errName)) { continue; }
          empty_fields += "\n  *" + errName + ' - Please fill out this field';
          continue;
        }
        if (e.numeric || mi != null || ma != null) {
          var i = parseFloat(v);
          if (isNaN(i) || (mi != null && i < mi) || (ma != null && i > ma)) {
            errors += '- The field ' + n + ' must be a number';
            if (mi != null) {
              errors += ' that is greater than ' + mi;
            }
            if (ma != null && mi != null) {
              errors += ' and less than ' + ma;
            } else if (ma != null) {
              errors += ' that is less than ' + ma;
            }
            errors += ".\n";
          }
          continue;
        }
        if (n == 'email') {
          var period = v.match(/\./);
          var at = v.match(/\@/);
          if (period == null || at == null) {
            errors += "\n  *Email address is not valid"; continue;
          }
          continue;
        }
        continue;
      }
    }
  }
  var msg = 'Please correct the following errors and then click the ' + f.elements[f.length-1].value + ' button:';
  if (!empty_fields && !errors) return true;
  if (empty_fields) { msg += empty_fields; }
  if (errors) { msg += errors; }
  if (msg) {
    alert(msg);
    return false; // false;
  }
}
function isValidCC(ccnum) {
  var c; var sum = 0; var nul = 1;
  for(var i = 0; i < ccnum.length; i++) {
    var num = ccnum.substring(ccnum.length-i-1,ccnum.length-i);
    var tnum = parseInt(num,10)*nul;
    if (tnum >= 10) { sum += (tnum % 10) + 1; } else { sum += tnum; }
    if (nul == 1) { nul++; } else { nul--; }
  }
  if((sum % 10) != 0) { return false; } else { return true; }
}
function populate() {
  if (document.cs.sameInfo.value !=null && document.cs.sameInfo.checked) {
    document.cs.addressb.value=document.cs.address.value;
    document.cs.bcity.value=document.cs.city.value;
    document.cs.bstate.value=document.cs.state.value;
    document.cs.bzip_code.value=document.cs.zip_code.value;
    document.cs.bcountry.value=document.cs.country.value;
  } else {
    document.cs.addressb.value='';
    document.cs.bcity.value='';
    document.cs.bstate.value='Select';
    document.cs.bzip_code.value='';
    document.cs.bcountry.value='';
  }
  return true;
}