function TFSearchBox(divname, width) {
  this.tplstr = '\n<form class=\"tf_basicsearch tf_basicsearch_narrow\" action=\"http://www.thefind.com/query.php\"  method=\"get\">\n <h2>What can we <strong>find<\/strong> for you?<\/h2>\n\n <div class=\"tf_basicsearch_container\">\n  <button type=\"submit\"><img class=\"tf_png\" src=\"http://www.thefind.com/images//buttons/buttonFind.png\" alt=\"(find)\" title=\"\" width=\"50\" height=\"33\" /><\/button>\n  <div class=\"tf_basicsearch_input\"><input type=\"text\" name=\"query\" value=\"\" /><\/div>\n  <a href=\"http://www.thefind.com/\" class=\"tf_basicsearch_poweredby\"><img src=\"http://www.thefind.com/images/logos/poweredByTheFind.png\" alt=\"powered by TheFind.com\" class=\"tf_png\" width=\"140\" height=\"20\" /><\/a>\n  <input type=\"hidden\" name=\"cobrand\" value=\"pointclickhome\" /> <\/div>\n\n<\/form>';
  this.div;


  this.Create = function(divname, args) {
    this.div = document.getElementById(divname);
    if (!this.div) {
      // FIXME - need to not run this after DOM is finished loading
      document.write('<div id="' + divname + '"></div>');
      this.div = document.getElementById(divname);
    }

    if (this.div) {
      if (typeof args != 'undefined') {
        for (var k in args) {
          if (typeof args[k] == 'string')
            this.div.style[k] = args[k];
        }
      }
      this.div.innerHTML = this.tplstr;
      //tf_utils.fixPNG(); // FIXME - temporarily disabled
    }
  }
  this.fixPoweredBy = function() {
    /*@cc_on @*/
    /*@if (@_jscript_version <= 5.6)

    var poweredbylink = tf_utils.getElementsByClassName(this.div, "A", "tf_basicsearch_poweredby")[0];
    if (poweredbylink && typeof poweredbylink.firstChild != 'undefined') {
      var poweredbyimg = poweredbylink.firstChild;
      poweredbylink.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + poweredbyimg.src + "', sizingMethod='image');";
      poweredbylink.style.cursor = "pointer";
      poweredbyimg.style.visibility = "hidden";
    }

    @end @*/
  }

  this.Create(divname, width);
}

function TFUtilities() {
  this.loadCSS = function(file) {
    var head = document.getElementsByTagName("HEAD")[0];
    if (head) {
      var linkel = document.createElement("LINK");
      linkel.type = "text/css";
      linkel.rel = "stylesheet";
      linkel.href = file;

      head.appendChild(linkel);
    }
  }
  this.getElementsByClassName = function(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
  }
  this.fixPNG = function() {
    /*@cc_on @*/
    /*@if (@_jscript_version <= 5.6) // IE6 and below
      document.execCommand("BackgroundImageCache",false,true);
      var imglist = this.getElementsByClassName(document, "img", "tf_png");
  
      for (var i = 0; i < imglist.length; i++) {
        var img = imglist[i];
        var imgName = img.src.toUpperCase();
        if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
        {
          var imgID = (img.id) ? "id='" + img.id + "' " : ""
          var imgClass = (img.className) ? "class='" + img.className + "' " : ""
          var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
          var imgStyle = "display:inline-block;" + img.style.cssText
          if (img.align == "left") imgStyle = "float:left;" + imgStyle
          if (img.align == "right") imgStyle = "float:right;" + imgStyle
          if (img.parentElement.href || img.parentElement.tagName == 'BUTTON') imgStyle = "cursor:hand;" + imgStyle
          var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
          img.outerHTML = strNewHTML
        }
      }
    @end @*/
  }
}


var tf_utils = new TFUtilities();
tf_utils.loadCSS("http://www.thefind.com/css/main?search=basicsearch");