if(!window.topGenericSearches){
  window.topGenericSearches = new Array('',
    'web design','web hosting','web space','personal website','company website','build a website'
  ); // related searches in case no specific phrases are available
}


window.parseStr = function(str){
  // parse key/value pairs
  if(!str) str = location.search; if(str){
    window.mForm = new Array()
    window.mForm_raw = str.substring(((str.indexOf('?') || 0)+1),str.length)
    window.mForm_raw = window.mForm_raw.split(/&/)
    for(var i=0; i<window.mForm_raw.length; i++){
      temp=window.mForm_raw[i].split(/=/)
      window.mForm[temp[0]] = unescape(temp[1]); 
      try{ window.mForm[temp[0]] = window.mForm[temp[0]].replace(/\+/g,' ') } catch(e){}
    }
  }

  //look for known query patterns...
    var r = 'enter your search here'
    if(window.mForm){ r = window.mForm["happy"] || window.mForm["q"] || r }
    return r
}



window.ivnRotate = function(sSelf, aArr, obj){ 
  // rotate a list of suggestions through a form input 

  this.nextWord = function(){ 
    if(++this.wordIdx>=this.arr.length) this.wordIdx = 0; 
    if(--this.safety<0) this.kill() 
  }

  this.typeText = function(){ 
    if(++this.charIdx>this.arr[this.wordIdx].length){ 
      this.nextWord(); this.charIdx = -20;
    } 
    if(this.charIdx<0) return; //pause between words
    if(this.charIdx==0) this.obj.value = ''; 
    this.obj.value += this.arr[this.wordIdx].charAt(this.charIdx) 
  }

  this.kill = function(){ clearInterval(this.mtimer); this.mtimer = null; return; }
  if(sSelf == 'kill') this.kill()

  if(sSelf && !this.init){
    this.init = 1; 
    this.str = location.search || document.referrer;
    this.arr = aArr || window.topGenericSearches || new Array('','web hosting','web space','web design'); 
      if(window.parseStr){ this.arr[0] = window.parseStr(this.str) }
    this.obj = obj; this.obj.value = ''; 
    this.self = sSelf;     
    this.wordIdx = 0; this.charIdx = -1; this.safety = 25; 
    if(this.mtimer) this.kill()
    this.mtimer = eval("setInterval('"+this.self+".typeText()',50)")
  }
}


/*
  Search Library
  Purpose - suggest related searches, demonstrate the usage of on page search tools, and 
    draw attention to the search tools (useful when competing with banners or other visual noise)

  Author: Thomas Ballard (thomas2003*esqsoft^om - antibot: *=@, ^=.c)
  © 2002-2004  E.S.Q. Software (www.ESQSoft.com)
  Questions, comments, work? Visit our site or contact us by email.
*/
