function FrontPage_Form1_Validator(theForm)
{

  if (theForm.CustomerName.value == "")
  {
    alert("Please enter a value for the \"CustomerName\" field.");
    theForm.CustomerName.focus();
    return (false);
  }

  if (theForm.CustomerName.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"CustomerName\" field.");
    theForm.CustomerName.focus();
    return (false);
  }

  if (theForm.CustomerName.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"CustomerName\" field.");
    theForm.CustomerName.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ \t\r\n\f";
  var checkStr = theForm.CustomerName.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter and whitespace characters in the \"CustomerName\" field.");
    theForm.CustomerName.focus();
    return (false);
  }

  if (theForm.telephone.value == "")
  {
    alert("Please enter a value for the \"telephone\" field.");
    theForm.telephone.focus();
    return (false);
  }

  if (theForm.telephone.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"telephone\" field.");
    theForm.telephone.focus();
    return (false);
  }

  if (theForm.telephone.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"telephone\" field.");
    theForm.telephone.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789- \t\r\n\f";
  var checkStr = theForm.telephone.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter a number in the \"telephone\" field.");
    theForm.telephone.focus();
    return (false);
  }
  return (true);
}

// NEW SYSTEM --------------------------

var totalrows = 1;

function remrow(numb)
{
    var type = document.getElementById(numb+'_type');
    type.disabled="true";
	var txt = document.getElementById('txtRow'+numb);
    txt.disabled="true";
	var incdec = document.getElementById(numb+'_incdec');
    incdec.disabled="true";
	
    var tbl = document.getElementById('exchanges').rows;
    var row = tbl[numb].cells;
	row[3].innerHTML="Removed";
	
	totalrows--;
	document.getElementById("amnt").value = totalrows;
	document.getElementById("total").innerHTML = totalrows+" items";
}

function changeButton(numb)
{
    var tbl = document.getElementById('exchanges').rows;
    var row = tbl[numb].cells;
    row[3].innerHTML="<a href=\"Javascript:remrow('"+numb+"');\">Remove</a>";
}

function addrow()
{
  var tbl = document.getElementById('exchanges');
  var lastRow = tbl.rows.length;
  // if there's no header row in the table, then iteration = lastRow + 1
  var iteration = lastRow;
  var row = tbl.insertRow(lastRow);
  
  // left cell
  var cellZero = row.insertCell(0);
  if(iteration%2){
	  cellZero.style.background="#DDDDDD";
  }
  var sel = document.createElement('div');
  var seltxt = "<select name=\"";
  seltxt +=iteration;
  seltxt +="_type\" id=\"";
  seltxt +=iteration;
  seltxt +="_type\">";
  seltxt += "<option value=\"0\" selected>-- Please Select --</option>";
  seltxt += "<option value=\"1\">Duvet Cover SuperKing</option>";
  seltxt += "<option value=\"2\">Duvet Cover King</option>";
  seltxt += "<option value=\"3\">Duvet Cover Single</option>";
  seltxt += "<option value=\"4\">Sheets King Size</option>";
  seltxt += "<option value=\"5\">Sheets Double</option>";
  seltxt += "<option value=\"6\">Sheets Single</option>";
  seltxt += "<option value=\"7\">Pillowcases</option>";
  seltxt += "<option value=\"8\">Hand Towels</option>";
  seltxt += "<option value=\"9\">Bath Towels</option>";
  seltxt += "<option value=\"10\">Bath Sheets</option>";
              seltxt += "<option value=\"11\">Turkish Roller Towel</option>";
              seltxt += "<option value=\"12\">Bath Mats</option>";
              seltxt += "<option value=\"13\">Glass Cloths</option>";
              seltxt += "<option value=\"14\">Oven Cloths</option>";
              seltxt += "<option value=\"15\">Waiters Cloths</option>";
              seltxt += "<option value=\"16\">Kitchen Cloths</option>";
              seltxt += "<option value=\"17\">Napkins (White)</option>";
              seltxt += "<option value=\"18\">Tablecloths (White) 36x36</option>";
              seltxt += "<option value=\"19\">Tablecloths (White) 54x54</option>";
              seltxt += "<option value=\"20\">Tablecloths (White) 63x63</option>";
              seltxt += "<option value=\"21\">Tablecloths (White) 70x70</option>";
              seltxt += "<option value=\"22\">Tablecloths (White) 90x90</option>";
              seltxt += "<option value=\"23\">Tablecloths (White) 70x108</option>";
              seltxt += "<option value=\"24\">Tablecloths (White) 70x144</option>";
              seltxt += "<option value=\"25\">Banquet 2yds</option>";
              seltxt += "<option value=\"26\">Banquet 3yds</option>";
              seltxt += "<option value=\"27\">Banquet 4yds</option>";
              seltxt += "<option value=\"28\">Banquet 6yds</option>";
              seltxt += "<option value=\"29\">Leisure towels</option>";
              seltxt += "<option value=\"30\">Oxford Pillowcases</option></select>";
  sel.innerHTML = seltxt;
  cellZero.appendChild(sel);
  
  // right cell
  var cellOne = row.insertCell(1);
  cellOne.align="center";
  if(iteration%2){
	  cellOne.style.background="#DDDDDD";
  }
  var eg = document.createElement('input');
  eg.type = 'text';
  eg.name = 'txtRow' + iteration;
  eg.id = 'txtRow' + iteration;
  eg.size = 5;
  cellOne.appendChild(eg);
  
  var cellTwo = row.insertCell(2);
  cellTwo.align="center";
  if(iteration%2){
	  cellTwo.style.background="#DDDDDD";
  }
  var em = document.createElement('div');
  
  var textlol = "<a href=\"Javascript:cellMinus('";
	textlol += iteration;
	textlol += "_incdec')\">-</a> <input name='";
  	textlol += iteration;
	textlol += "_incdec' type='text' id='";
	textlol += iteration;
	textlol += "_incdec' size='5' value='0'> <a href=\"Javascript:cellAdd('";
	textlol += iteration;
	textlol += "_incdec')\">+</a></td>";

	em.innerHTML = textlol;
  cellTwo.appendChild(em);
  
  var cellThree = row.insertCell(3);
  if(iteration%2){
	  cellThree.style.background="#DDDDDD";
  }
  var button = document.createElement('div');
  button.innerHTML = "<a href=\"Javascript:addrow();\">Add</a>";
  cellThree.appendChild(button);
  
  changeButton(iteration-1);

	totalrows++;
	//Add 1 to the ammount
	document.getElementById("amnt").value = iteration;	//must iter through all 
	document.getElementById("total").innerHTML = totalrows+" items";	//only show enabled rows

}


function cellAdd(cell)
{
	var curr = document.getElementById(cell).value;
	
	document.getElementById(cell).value = ++curr;
}

function cellMinus(cell)
{
	var curr = document.getElementById(cell).value;
	
	document.getElementById(cell).value = --curr;
}