
Array.prototype.inArray = function( search_phrase)
{
  var i;
  for( i = 0; i < this.length; i++ )
  {
    if( search_phrase == this[i] )
    {
      return i;
    }
  }
  return false;
}


function isProdCode( x)
{
  var idx;
  digits = Array( '0','1','2','3','4','5','6','7','8','9', '-');
  if( x.length < 6) return false;
  for( idx = 0 ; idx <= 7 ; idx++)
   { if( false === digits.inArray( x.charAt( idx))) if( idx <= 5) return false; return true; }
  return true;
}

String.prototype.trim = function () { return this.replace(/^\s*/, "").replace(/\s*$/, ""); }


function InStr( strSearch, charSearchFor)
{
 for( i = 0 ; i < strSearch.length ; i++)
  {
   if( charSearchFor == strSearch.charAt( i)) return i;
  }
 return -1;
}


function checkEnter( control, force)
{
  val = document.getElementById( control).value;
  if( force === false && (val.length < 4 && (-1 == InStr( val, ' ')))) return false;

  document.getElementById( 'results').src='linkMSDS/msdSearch.php?searchText='+document.getElementById( 'productCode').value.trim( )+'&hurry=up';
 return false;
}

