// JavaScript Document

var target;
var country;

function check_btn() {
  if (false) { // add optional required state/prov here
  } else if ((document.myForm.WKENAM) && ('' == document.myForm.WKENAM.value)) {
    alert('Sorry, you must complete Company Name.');
    return;
  } else if ((document.myForm.WKRSLN) && ('' == document.myForm.WKRSLN.value)) {
    alert('Sorry, you must complete Resale Number.');
    return;
  } else if ((document.myForm.WKPHN) && ('' == document.myForm.WKPHN.value)) {
    alert('Sorry, you must complete Telephone.');
    return;
  } else if ((document.myForm.WKCGRP) && ('' == document.myForm.WKCGRP.value)) {
    alert('Sorry, you must complete Business Type.');
    return;
  } else if ((document.myForm.WKSPLC) && ('' == document.myForm.WKSPLC.value)) {
    alert('Sorry, you must complete Specialty.');
    return;
  } else if ((document.myForm.WKBAYS) && ('' == document.myForm.WKBAYS.value)) {
    alert('Sorry, you must complete Bays.');
    return;
  } else if ((document.myForm.WKTCHS) && ('' == document.myForm.WKTCHS.value)) {
    alert('Sorry, you must complete Techs.');
    return;
  } else if ((document.myForm.WKLFTS) && ('' == document.myForm.WKLFTS.value)) {
    alert('Sorry, you must complete Lifts.');
    return;
  } else if ((document.myForm.WKRFBY) && ('' == document.myForm.WKRFBY.value)) {
    alert('Sorry, you must complete Referred By.');
    return;
  } else if ((document.myForm.WKCNTR) && ('' == document.myForm.WKCNTR.value)) {
    alert('Sorry, you must complete Country/Region.');
    return;
  } else if ((document.myForm.WKADR1) && ('' == document.myForm.WKADR1.value)) {
    alert('Sorry, you must complete Street Address.');
    return;
  } else if ((document.myForm.WKCITY) && ('' == document.myForm.WKCITY.value)) {
    alert('Sorry, you must complete City.');
    return;
  } else if ((document.myForm.WKZIP) && ('' == document.myForm.WKZIP.value)) {
    alert('Sorry, you must complete Zip.');
    return;
  } else if ((document.myForm.WKFNAM) && ('' == document.myForm.WKFNAM.value)) {
    alert('Sorry, you must complete First Name.');
    return;
  } else if ((document.myForm.WKLNAM) && ('' == document.myForm.WKLNAM.value)) {
    alert('Sorry, you must complete Last Name.');
    return;
  } else if ((document.myForm.WKJOBT) && ('' == document.myForm.WKJOBT.value)) {
    alert('Sorry, you must complete Job Title.');
    return;
  }
  document.myForm.submit();
}

function cancel_btn() {
  window.close();
}

function set_req(req) {
  if (document.all) {
    spanObj = document.all.idWKSTE;
  } else {
    spanObj = document.getElementById('idWKSTE');
  }
  spanObj.innerHTML = req;
}

function get_state(co,pr) {
  var myreq;
  if ( (co.value == 'USA') || 
       (co.value == '041') ) {
    co.focus();
    target = pr;
    country = co;
    myreq = '*';
    show_confirm(co.value,pr.value);
  } else {
    myreq = '&nbsp;';
    target.value = '';
  }
  set_req(myreq);
}

function show_confirm(code, value) {
  var dw = 300; var dh = 150;
  var aw = ( screen.availWidth - dw ) / 2;
  var ah = ( screen.availHeight - dh ) / 2;
  var features = 'resizable=yes' +
      ',width=' + dw + ',height=' + dh + 
      ',left=' + aw + ',top=' + ah ;
  var url = "confirm.php?code=" + code + "&value=" + value + "&modal=yes";
  var newWin = window.open ( url, "newWin", features );
}

function set_state(newstr) {
  target.value = newstr;
}

function reset_country() {
  country.options[0].selected = true;
  target.value = '';
  set_req('&nbsp;');
}

function spinner(formID, addVal) {
  var fid = eval('document.myForm.' + formID);
  var qty = parseInt(fid.value) + addVal;
  if (! qty || qty < 0) qty = 0;
  fid.value = qty;
}

