//Last JavaScript verification 09/14/01

var SEARCHANY = 1
var SEARCHALL = 2
var SEARCHURL = 4
var searchType = ""
var showMatches = 10
var currentMatch = 0
var copyArray = new Array()

function validate(entry)
{
 Entry = entry.toUpperCase()
 if (entry.charAt(0) == "+")
 {
  entry = entry.substring(1,entry.length)
  searchType = SEARCHALL
 }
 else if (entry.substring(0,4) == "url:") 
 {
  entry = entry.substring(4,entry.length)
  searchType = SEARCHURL
 }
 else 
 { 
  searchType = SEARCHANY 
 }
 while (entry.charAt(0) == ' ') 
 {
  entry = entry.substring(1,entry.length)
  document.forms['search'].query.value = entry
 }
 while (entry.charAt(entry.length - 1) == ' ') 
 {
  entry = entry.substring(0,entry.length - 1)
  document.forms['search'].query.value = entry
 }

 if (entry.indexOf('CDRW') != -1)
 {
  entry = entry + ' CD-RW'
 }
 else if (entry.indexOf('CD-RW') != -1)
 {
  entry = entry + ' CDRW'
 }
 if (entry.indexOf('DVDRW') != -1)
 {
  entry = entry + ' DVD-RW'
 }
 else if (entry.indexOf('DVD-RW') != -1)
 {
  entry = entry + ' DVDRW'
 }

 if (entry.length < 3)
 {
  document.forms['search'].query.select()
  if (navigator.platform=="MacPPC"){
   var searchwin = window.open("","searchwin","width=300,height=300,resizable=1,scrollbars=yes")  
  }
  else{
   var searchwin = window.open("search.html","searchwin","width=300,height=300,resizable=1,scrollbars=yes")
  }
  var out = "<html><head><title>" + wintitle + "</title></head>"
  out += "<body style='background-color: #ffffff; color: #000000'>"
  out += "<table width='90%' border='0' align='center'><tr><td valign='top'>"
  out += "<span style='font-family: Arial Unicode MS, arial, helvetica, sans-serif; font-size: 13.5pt; font-weight: bold'>" + srtext + "</span><br><br><hr>"
  out += "<div style='font-family: Arial Unicode MS, arial, helvetica, sans-serif; font-size: 10pt; font-weight: bold'>" + document.forms['search'].query.value + "<br><br>" + threeletters + "</div>"
  out += "<hr></td></tr></table></body></html>"
  //searchwin.focus()
  searchwin.document.open()
  searchwin.document.write(out)
  searchwin.document.close()
  return
 }
 convertString(entry)
}

function convertString(reentry) 
{
 var searchArray = reentry.split(" ")
 if (searchType == SEARCHALL)
 { 
  requireAll(searchArray) 
 }
 else 
 { 
  allowAny(searchArray) 
 }
}

function allowAny(t) 
{
 var findings = new Array(0)
 for (i = 0; i < profiles.length; i++) 
 {
  var compareElement  = profiles[i].toUpperCase()
  if(searchType == SEARCHANY) 
  { 
   var refineElement = compareElement.substring(0,compareElement.indexOf('|LOC:')) 
  }
  else 
  { 
   var refineElement = compareElement.substring(compareElement.indexOf('|LOC:'), compareElement.length) 
  }
  for (j = 0; j < t.length; j++) 
  {
   var compareString = t[j].toUpperCase()
   if (refineElement.indexOf(compareString) != -1) 
   {
    findings[findings.length] = profiles[i]
    break
   }
  }
 }
 verifyManage(findings)
}

// Define a function to perform a search that requires
// a match of all terms the user provided
function requireAll(t) 
{
 var findings = new Array();
 for (i = 0; i < profiles.length; i++) 
 {
  var allConfirmation = true
  var allString = profiles[i].toUpperCase()
  var refineAllString = allString.substring(0,allString.indexOf('|LOC:'))
  for (j = 0; j < t.length; j++) 
  {
   var allElement = t[j].toUpperCase()
   if (refineAllString.indexOf(allElement) == -1) 
   {
    allConfirmation = false
    continue
   }
  }
  if (allConfirmation) 
  {
   findings[findings.length] = profiles[i]
  }
 }
 verifyManage(findings)
}

// Determine whether the search was successful
// If so print the results; if not, indicate that, too
function verifyManage(resultSet) 
{
 if (resultSet.length == 0) 
 { 
  noMatch() 
 }
 else 
 {
  copyArray = resultSet.sort()
  formatResults(copyArray, currentMatch, showMatches)
 }
}

//Last JavaScript verification 09/14/01
// Define a function that indicates that the returned no results
function noMatch() 
{
  if (navigator.platform=="MacPPC"){
   var searchwin = window.open("","searchwin","width=300,height=300,resizable=1,scrollbars=yes")  
  }
  else{
   var searchwin = window.open("search.html","searchwin","width=300,height=300,resizable=1,scrollbars=yes")
  }
 var out = "<html><head><title>" + wintitle + "</title></head>"
 out += "<body style='background-color: #ffffff; color: #000000'>"
 out += "<table width='90%' border='0' align='center'><tr><td valign='top'>"
 out += "<span style='font-family: Arial Unicode MS, arial, helvetica, sans-serif; font-size: 13.5pt; font-weight: bold'>" + srtext + "</span><br><br><hr>"
 out += "<div style='font-family: Arial Unicode MS, arial, helvetica, sans-serif; font-size: 10pt; font-weight: bold'>" + document.forms['search'].query.value + "<br><br>" + notfound + "</div>"
 out += "<hr></td></tr></table></body></html>"
 //searchwin.focus()
 searchwin.document.open()
 searchwin.document.write(out)
 searchwin.document.close()
 document.forms['search'].query.select()
 searchwin.focus()
}

// Define a function to print the results of a successful search
function formatResults(results, reference, offset)
{
 var currentRecord = (results.length < reference + offset ? results.length : reference + offset)
 var currentRecord = results.length
   if (navigator.platform=="MacPPC"){
   var searchwin = window.open("","searchwin","width=300,height=600,resizable=1,scrollbars=yes")  
  }
  else{
  var searchwin = window.open("search.html","searchwin","width=300,height=600,resizable=1,scrollbars=yes")
  }
var out = "<html><head><title>" + wintitle + "</title>"
 out += "</head>"
 out += "<body style='background-color: #ffffff; color: #000000'>"
 out += "<table width='90%' border='0' align='center' cellpadding='3'><tr><td valign='top'>"
 out += "<span style='font-family: Arial Unicode MS, arial, helvetica, sans-serif; font-size: 13.5pt; font-weight: bold'>" + srtext + "</span><br><br><hr>"
 out += "<span style='font-family: Arial Unicode MS, arial, helvetica, sans-serif; font-size: 10pt'>"
 out += "<span style='font-weight: bold'>" + parent.frames['menu'].document.forms['search'].query.value + "</span>"
 //out += srtext + " <b>" /*+ (reference + 1) + " - " + currentRecord + " of "*/ + results.length + "</b>"
 out += "</span><br><br>"
 if (searchType == SEARCHURL) 
 {
  for (var i = reference; i < currentRecord; i++)
  {
   var divide = results[i].split("|")
   var secdivide = results[i].split("|LOC:")
   out += "<span style='font-family: Arial Unicode MS, arial, helvetica, sans-serif; font-size: 10pt; font-weight: bold'>"
   out += "<a href='" + secdivide[1] + "' target='content' onClick='window.opener.focus();'>" + secdivide[1] + "</a></span><br>"
   out += "<table><tr><td>&nbsp;&nbsp;</td><td><span style='font-family: Arial Unicode MS, arial, helvetica, sans-serif; font-size: 10pt'>" + divide[1] + "</span></td></tr></table><br>"
  }
 }
 else
 {
  for (var i = reference; i < currentRecord; i++)
  {
   var divide = results[i].split("|")
   var secdivide = results[i].split("|LOC:")
   out += "<span style='font-family: Arial Unicode MS, arial, helvetica, sans-serif; font-size: 10pt; font-weight: bold'>"
   out += "<a href='" + secdivide[1] + "' target='content' onClick='window.opener.focus();'>" + divide[0] + "</a></span><br>"
   out += "<table><tr><td>&nbsp;&nbsp;</td><td><span style='font-family: Arial Unicode MS, arial, helvetica, sans-serif; font-size: 10pt'>" + divide[1] + "</span></td></tr></table><br>"
  }
 }
 //searchwin.focus()
 searchwin.document.open()
 searchwin.document.write(out)
 //var curloc = this
 //prevNextResults(results.length, reference, offset, searchwin)
 out = "<table width='90%' border='0' align='center' cellpadding='3'><hr></table></td></tr></table></body></html>"
 searchwin.document.write(out)
 searchwin.document.close()
 document.forms['search'].query.select()
 searchwin.focus()
}