function jSearch() {
  self.location='/cgi-bin/mvi.exe/CATALOG.BROWSE?searchtext=' + escape(document.mainForm.searchtext.value);
  return;
}
function loginUser() {
  var userid = document.loginForm.userid.value;
  var password = document.loginForm.password.value;
  var url = '/cgi-bin/mvi.exe/CUST.LOGIN?userid=' + userid + "&password=" + password;
  if (userid == "") {
    alert("Please enter a valid userid."); 
	document.loginForm.userid.focus();
	return false;
  }
  if (password == "") {
    alert("Please enter a valid password.");
	document.loginForm.password.focus();
	return false;
  }
  //var x = window.open( url, 'loginWindow', 'width=500,height=400,scrollbars=no,');
  return true;
}
function prodjump() {
  var catid = document.jumpForm.jumpcat[document.jumpForm.jumpcat.selectedIndex].value;

  self.location='/cgi-bin/mvi.exe/CATALOG.BROWSE?catid=' + catid;
  return;
}
function topMenu( b_name ) {
  switch (b_name) {
    case 'button1':
      document.location = '/cgi-bin/mvi.exe/LOAD.STATIC?sid=specialfurniture';
    break;
    case 'button2':
      document.location = '/cgi-bin/mvi.exe/CATALOG.BROWSE?catid=1*1200001';
    break;
    case 'button3':
      document.location = '/cgi-bin/mvi.exe/CATALOG.BROWSE?catid=2*1400020';
    break;
    case 'button4':
      document.location = '/cgi-bin/mvi.exe/CATALOG.BROWSE?catid=2*1400021';
    break;
    case 'button5':
      document.location = '/cgi-bin/mvi.exe/CATALOG.BROWSE?catid=1*1200002';
    break;
    case 'button6':
      document.location = '/cgi-bin/mvi.exe/CATALOG.BROWSE?catid=2*1400012';
    break;
    case true:
      alert( b_name );
    break;
  }
}
function validateUSNumber( item ) { 
 var CleanedString=""; 
 var index = 0; 
 var LimitCheck; 
 var InitialString = item.value

 if (item.value == '') return true;

 //Get the length of the inputted string, to know how many characters to check
 LimitCheck = InitialString.length;
 
 //Walk through the inputted string and collect only number characters, appending them to CleanedString
 while (index != LimitCheck) { 
  if (isNaN(parseInt(InitialString.charAt(index)))) { } 
  else { CleanedString = CleanedString + InitialString.charAt(index); } 
  index = index + 1; 
 }
 
 //If CleanedString is exactly 10 digits long, then format it and allow form submission
 if (CleanedString.length == 10) { 
  item.value = CleanedString.substring(0,3) + "-" + CleanedString.substring(3,6) + "-" + CleanedString.substring(6,10); 
 }
 
 //If CleanedString is not 10 digits longs, show an alert and cancel form submission
 else { 
  CleanedString = InitialString; 
  alert("Please enter only your ten digit phone number.");
  if (document.all) { 
    item.focus();
    item.select();
  }
 return false
 } 
} 
function viewOrder( type, options, orderid ) {
  var url='/cgi-bin/mvi.exe/VIEW.ORDER?type=' + type + '&options=' + options + '&orderid=' + orderid;
  var x = window.open( url, 'orderWindow', 'width=600,height=550,scrollbars=yes');
}
function refreshOpener() {
  if (opener) {
    opener.history.go(0);
    window.focus();
  }
  return;
}
function addItemToQuickList( item, qty ) {
  var url='/cgi-bin/mvi.exe/QLIST.ADD?item=' + item + '&qty=' + qty;
  var x = window.open( url, 'QuickWindow', 'width=400,height=400,scrollbars=no');
}
function stext() {
  if (document.mainForm) {
    if (document.mainForm.searchtext) {
      if (document.mainForm.searchtext.value == '') {
        document.mainForm.searchtext.value = 'Keyword, Part #, UPC';
      }
    }
  }
}
function stextCheck() {
      if ( document.mainForm.searchtext.value == 'Keyword, Part #, UPC') {
        document.mainForm.searchtext.value = ''; 
      }
}
function maintainWebUser( edituser, cid ) {
  var url='/cgi-bin/mvi.exe/WEB.USER.MAINT?edituser=' + edituser + '&cid=' + cid;
  var x = window.open( url, 'userMaintWindow', 'width=400,height=400,scrollbars=no');
}
function taxExemptCheck(fieldObject, nextObject) {

  if (fieldObject.value != '') {
    if (confirm("NOTE: In order to be considered tax exempt, all of the addresses that you ship orders to from this web site must be tax exempt.  Are you sure that you are tax exempt?")) {
      nextObject.focus();
    } else {
      fieldObject.value = '';
      nextObject.focus();
    }
  }

}
function showCCAlert() {
  if (document.regform) {
    if (document.regform.terms) {
      if(document.regform.terms.checked = true) {
        if (confirm("WARNING: Even though you are using a credit card to process this order, it will still show up on your Company's statement.  If you would like to place a personal order, please create a personal account.")) {

         } else {
           document.regform.terms.checked = false;
         }
      }
    }
  }
  return;
}
