// JavaScript Document
<!--
function ValidateForm(myform)
{
	var num = myform.length
	var validFlag = true
	for (var i = 0; i<num;i++) {
	if ((myform.elements[i].value == null ||
	myform.elements[i].value == "") &&
	(typeof myform.elements[i] != 'submit' || 
	typeof myform.elements[i] != 'reset'))
	{
	validFlag = false
	alert("the " + myform.elements[i].name + " field is blank. You need to enter a postcode.");
	myform.elements[i].focus();
	break}
	}
	return validFlag
		}
		
		
// Last updated 2006-02-21
function addRowToTable()
{
 
      var tbl = document.getElementById('myTable');
      var lastRow = tbl.rows.length;
      // if there's no header row in the table, then iteration = lastRow + 1
      var iteration = lastRow-1;
      var row = tbl.insertRow(lastRow);

      // left cell
      var cellLeft = row.insertCell(0);
      
      var myInnerHtml = "";

      myInnerHtml = '<div style="width=100%;" ><table border="0" width="100%"  cellpadding="4" cellspacing="1"  ><tbody>';
      myInnerHtml +=  '<tr>'
      myInnerHtml +=  '<td  class ="normal" style ="background-color :#f5f5f5">Post Code:</td>';
      myInnerHtml +=  '<td align="center" class ="normal" style ="background-color :#f5f5f5"><input type="text" name="postcode'+iteration+ '" size="7" class="required"/></td>';
      myInnerHtml += '<td  class ="normal" style ="background-color :#f5f5f5">';
      myInnerHtml +=  '<label  class ="normal"><input type="radio" name="pickup'+iteration+'" value="p" checked>';
      myInnerHtml +=  'Pickup</label> ';
      myInnerHtml +=  '<label  class ="normal"><input type="radio" name="pickup'+iteration+'" value="d">';
      myInnerHtml +=  'Delivery</label>';
      myInnerHtml +=  '<label  class ="normal"><input type="radio" name="pickup'+iteration+'" value="s">';
      myInnerHtml +=  'Shopping</label></td>';
      myInnerHtml +=  '<td style ="background-color :#f5f5f5"  class ="normal">&nbsp;&nbsp;<label><input  type="radio" name="wait'+iteration+'" value="w" checked>';
      myInnerHtml += 'Waiting</label>';
      myInnerHtml +=  '&nbsp;&nbsp;<label><input  type="radio" name="wait'+iteration+'" value="uw">';
      myInnerHtml += 'Without Waiting</label></td>';
      myInnerHtml += '</tr></tbody></table></div>';

       
      cellLeft.innerHTML = myInnerHtml;
        
      gogo.stopovers.value = iteration;
}

function removeRowFromTable()
{
 
  var tbl = document.getElementById('myTable');
  var lastRow = tbl.rows.length;
  if (lastRow > 2) 
  {
  tbl.deleteRow(lastRow - 1);
  gogo.stopovers.value = lastRow-1;
  
}
}

function addShoppingRowToTable(TableID,PC)
{
	
	//alert ("---" + TableID + "---" + PC);
	var tbl = document.getElementById('myTable'+TableID);
	var myPostcode = PC;
  	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 cellLeft = row.insertCell(0);
  //cellLeft.className = "Enrollment_InputBox";
  cellLeft.align="Center";
  var e0 = document.createElement('input');
  e0.type = 'text';
  e0.color ='white';
  e0.className = 'required validate-digits validate-quantity';
  e0.name = ('quantity' + TableID) + iteration;
  e0.id = ('quantity' + TableID) + iteration;
  e0.size = 2;
  
  cellLeft.appendChild(e0);

  
    // middle cell
  var cellMiddle = row.insertCell(1);
  cellMiddle.align="Center";
  var e1 = document.createElement('input');
  e1.type = 'text';
  e1.className = 'required validate-item';
  e1.name = ('item' + TableID) + iteration;
  e1.id = ('item' + TableID) + iteration;
  e1.size = 20;
  cellMiddle.appendChild(e1);
  
    // right cell
  var cellRight = row.insertCell(2);
  cellRight.align="Center";
  var e2 = document.createElement('input');
  e2.type = 'text';
  e2.className = 'required validate-number validate-price';
  e2.name = ('price' + TableID) + iteration;
  e2.id = ('price' + TableID) + iteration;
  e2.size = 5;
  cellRight.appendChild(e2);
  
      // hidden cell
  var cellHidden = row.insertCell(3);
  cellHidden.align="Center";
  var e3 = document.createElement('input');
  e3.type = 'hidden';
  e3.className = 'input1';
  e3.name = ('zip' + TableID) + iteration;
  e3.id = ('zip' + TableID) + iteration;
  e3.value = myPostcode;
  cellHidden.appendChild(e3);

  lastRow.className  = 'pickup';
}

function removeShoppingRowFromTable(TableID)
{
//alert ("---" + TableID + "---");
  var tbl = document.getElementById('myTable'+TableID);
  var lastRow = tbl.rows.length;
  if (lastRow > 3) 
  {
  tbl.deleteRow(lastRow - 1);

}
}


function openInNewWindow(frm)
{
  // open a blank window
  var aWindow = window.open('', 'TableAddRowNewWindow',
   'scrollbars=yes,menubar=yes,resizable=yes,toolbar=no,width=400,height=400');
   
  // set the target to the blank window
  frm.target = 'TableAddRowNewWindow';
  
  // submit
  frm.submit();
}
function validateRow(frm)
{
  var chkb = document.getElementById('chkValidate');
  if (chkb.checked) {
    var tbl = document.getElementById('tblSample');
    var lastRow = tbl.rows.length - 1;
    var i;
    for (i=1; i<=lastRow; i++) {
      var aRow = document.getElementById('txtRow' + i);
      if (aRow.value.length <= 0) {
        alert('Row ' + i + ' is empty');
        return;
      }
    }
  }
  openInNewWindow(frm);
}

// -->

  
//-->

