function remove_it(qtysku) {
   document.quantities.elements[qtysku].value = 0;
   document.quantities.submit();
}

function disable() {
   if (document.checkout.type.value == 'member') {
       document.checkout.username.disabled = false;
       document.checkout.password.disabled = false;
   } else {
       document.checkout.username.disabled = true;
       document.checkout.password.disabled = true;
   }
}

function wholesaleCopy() {
      document.ws_register.shipping_address1.value = document.ws_register.billing_address1.value;
      document.ws_register.shipping_address2.value = document.ws_register.billing_address2.value;
      document.ws_register.shipping_attention.value = document.ws_register.company_name.value;
      document.ws_register.shipping_city.value = document.ws_register.billing_city.value;
      document.ws_register.shipping_state.value = document.ws_register.billing_state.value;
      document.ws_register.shipping_zip.value = document.ws_register.billing_zip.value;
}

function changeDate(id,id2) {
   document.ship_form.elements[id].value = document.ship_form.elements[id2].value;
}

function use_alias(id,alias) {
      var first_name = 's_firstname'+id;
      var last_name = 's_lastname'+id;
      var title = 's_title'+id;
      var company = 's_company'+id;
      var addy1 = 's_address1'+id;
      var addy2 = 's_address2'+id;
      var city = 's_city'+id;
      var state = 's_state'+id;
      var country = 's_country'+id;
      var zip = 's_zip'+id;
      var phone = 's_phone'+id;
      var alias_id = document.ship_form.elements[alias].value;
      var nullvar;
      document.ship_form.elements[first_name].value = info['s_firstname'][alias_id];
      document.ship_form.elements[last_name].value = info['s_lastname'][alias_id];
      if (info['s_title'][alias_id] != nullvar) {
      } else {
        document.ship_form.elements[title].value = "";
      }
      if (info['s_company'][alias_id] != nullvar) {
        if (info['s_title'][alias_id] != nullvar) {
        document.ship_form.elements[title].value = info['s_title'][alias_id];
      } else {
        document.ship_form.elements[title].value = "";
      }
      if (info['s_company'][alias_id] != nullvar) {
        document.ship_form.elements[company].value = info['s_company'][alias_id];
      } else {
        document.ship_form.elements[company].value = "";
      }
      } else {
        document.ship_form.elements[company].value = "";
      }
      document.ship_form.elements[addy1].value = info['s_address1'][alias_id];
      if (info['s_address2'][alias_id] != nullvar) {
        document.ship_form.elements[addy2].value = info['s_address2'][alias_id];
      } else {
        document.ship_form.elements[addy2].value = "";
      }
      document.ship_form.elements[city].value = info['s_city'][alias_id];
      document.ship_form.elements[state].value = info['s_state'][alias_id];
      document.ship_form.elements[country].value = info['s_country'][alias_id];
      document.ship_form.elements[zip].value = info['s_zip'][alias_id];
      if (info['s_phone'][alias_id] != nullvar) {
        document.ship_form.elements[phone].value = info['s_phone'][alias_id];
      } else {
        document.ship_form.elements[phone].value = "";
      }
}

function addressCopy() {
      document.ship_form.first_name.value = document.ship_form.s_firstname1.value;
      document.ship_form.last_name.value = document.ship_form.s_lastname1.value;
      document.ship_form.billing_address1.value = document.ship_form.s_address11.value;
      document.ship_form.billing_address2.value = document.ship_form.s_address21.value;
      document.ship_form.billing_state.value = document.ship_form.s_state1.value;
      document.ship_form.billing_city.value = document.ship_form.s_city1.value;
      document.ship_form.billing_zip.value = document.ship_form.s_zip1.value;
      document.ship_form.billing_country.value = document.ship_form.s_country1.value;
      document.ship_form.title.value = document.ship_form.s_title1.value;
      document.ship_form.company.value = document.ship_form.s_company1.value;
      document.ship_form.phone.value = document.ship_form.s_phone1.value;
}


function paymentMethod(method) {
  if (method == 'creditcard') {
    togglePO(true,'#EEE');
    toggleGC(true,'#EEE');
    toggleCC(false,'white');
  } else if (method == 'purchaseorder') {
    toggleGC(true,'#EEE');
    toggleCC(true,'#EEE');
    togglePO(false,'white');
  } else if (method == 'giftcertificate') {
    togglePO(true,'#EEE');
    toggleCC(true,'#EEE');
    toggleGC(false,'white');
  } else {
    togglePO(true,'#EEE');
    toggleCC(true,'#EEE');
    toggleGC(true,'#EEE');
  }
}

function toggleCC(val,col) {
  if (document.ship_form.print_cc.value == 'y') {
    document.ship_form.ccname.disabled=val;
    document.ship_form.cctype.disabled=val;
    document.ship_form.ccnum.disabled=val;
    document.ship_form.ccexpy.disabled=val;
    document.ship_form.ccname.style.background=col;
    document.ship_form.cctype.style.background=col;
    document.ship_form.ccnum.style.background=col;
    document.ship_form.ccexpy.style.background=col;
    if (typeof document.ship_form.cvv2 != 'undefined') {
      document.ship_form.cvv2.disabled=val;
      document.ship_form.cvv2.style.background=col;
    }
    document.ship_form.ccexpm.disabled=val;
    document.ship_form.ccexpm.style.background=col;
  }
}


function togglePO(val,col) {
  if (document.ship_form.print_po.value == 'y') {
    document.ship_form.purchase_order.disabled=val;
    document.ship_form.purchase_order.style.background=col;
  }
}

function toggleGC(val,col) {
  if (document.ship_form.print_gc.value == 'y') {
    document.ship_form.gift_certificate.disabled=val;
    document.ship_form.gift_certificate.style.background=col;
  }
}

function use_wishlist(id,wishlist) {
      var first_name = 's_firstname'+id;
      var last_name = 's_lastname'+id;
      var addy1 = 's_address1'+id;
      var addy2 = 's_address2'+id;
      var city = 's_city'+id;
      var state = 's_state'+id;
      var country = 's_country'+id;
      var zip = 's_zip'+id;
      var wl_id = document.ship_form.elements[wishlist].value;
      var nullvar;
      document.ship_form.elements[first_name].value = wl['first_name'][wl_id];
      document.ship_form.elements[last_name].value = wl['last_name'][wl_id];
      document.ship_form.elements[addy1].value = wl['address1'][wl_id];
      if (wl['address2'][wl_id] != nullvar) {
        document.ship_form.elements[addy2].value = wl['address2'][wl_id];
      } else {
        document.ship_form.elements[addy2].value = "";
      }
      document.ship_form.elements[city].value = wl['city'][wl_id];
      document.ship_form.elements[state].value = wl['state'][wl_id];
      document.ship_form.elements[country].value = wl['country'][wl_id];
      document.ship_form.elements[zip].value = wl['zip'][wl_id];
}


