/* usage */
/*
var plaque  = 1551;
var lines = new Array(1550, 1553, 1545, 1546, 1547, 1548);

if (! validatePlaque(plaque, lines)) {
  return false;
}
*/

function validatePlaque(plaque, lines) {
  var hasSelection = (product_option('po' + plaque).selectedIndex > 0);
  var hasValues = false;

  for (i = 0; i < lines.length; i++) {
    if (product_option('po' + lines[i]).value.length > 50) {
      alert('A maximum of 50 characters of engraving text per line is allowed');  
      product_option('po' + lines[i]).focus();  
      product_option('po' + lines[i]).select(); 
      return false; 
    }
    
    if (product_option('po' + lines[i]).value != '') {
      hasValues = true;
    }
  }
  
  if (hasValues && !hasSelection) {
    alert('You have entered text for the Brass Plaque, but have not selected the Plaque option, please add this option or remove the text');  
    return false; 
  } else if (!hasValues && hasSelection) {
    alert('Please enter the text you would like on the Brass Plaque');  
    return false; 
  }
  
  return true;
}