var mObj, mObjS, mObjT; //recyclable ref to containers
var mStr;

var isSearchResults = location.pathname.match(/search-results/); 

//miscellaneous components
  window.makeButton = function(mName,mPath,mSrc,mW,mH){
    // this function creates right hand navigation buttons

    var mDot='pixel.gif'
    var mOver='pixel.gif'
    var mOut='pixel.gif'
    var mThisPage=0;

    if(mName && mSrc){
      eval('window.'+mName+'_out=new Image()'); eval('window.'+mName+'_out.src="'+mPath+mSrc+'.gif"');
      eval('window.'+mName+'_over=new Image()'); eval('window.'+mName+'_over.src="'+mPath+mSrc+'-over.gif"');
      mDot=mPath+mSrc+'-dot.gif';
      mOver=mPath+mSrc+'-over.gif';
      mOut=mPath+mSrc+'.gif';

      var tmpmSrc=mSrc;
      if(mSrc.indexOf('hosting')!=-1) tmpmSrc=/host|space|commerce/
      else if(mSrc.indexOf('game')!=-1) tmpmSrc=/hyper|game|inspiration/
      else if(mSrc.indexOf('design')!=-1) tmpmSrc=/design|graphics|javascript|cgiemail/

      if(location.pathname.match(tmpmSrc)) mThisPage=1
    }

    if(!mW) mW=0
    if(!mH) mH=0

    var html=''
    +'<table cellpadding="0" cellspacing="0" border="0">'
    +'  <tr valign="top">'
    +'    <td class="sub_panel"'

    if(mThisPage){ html+=''
      +'    ><img src="'+mDot+'" width="'+mW+'" height="'+mH+'"'
    } else { html+=''
      +'    ><img src="pixel.gif" width="'+mW+'" height="'+mH+'"'
    } html+=''
    +'    ></td>'
    +'    <td'

    if(mThisPage){ html+=''
      +' background="'+mPath+'extension.gif"'
    } html+=''
    +'    >'

    if(mName){ html+=''
        +'<a href="'+mSrc+'.htm" onfocus="blur()">'
    }

    if(mThisPage){ html+=''
      +'<img src="pixel.gif" width="'+mW+'" height="'+mH+'"'
    } else { html+=''
      +'<img src="'+mDot+'" width="'+mW+'" height="'+mH+'"'
    }

    if(mName){ html+=''
      +'onmouseover="document.'+mName+'.src=\''+mOver+'\'" '
      +'onmouseout="document.'+mName+'.src=\''+mOut+'\'" '
      +'></a'
    }

    html+=''
    +'></td>'
    +'  <td>'

    if(mName){
      html+=''
      +'<a href="'+mSrc+'.htm" onfocus="blur()">'
    }

    html+=''
    +'<img name="'+mName+'" src="'+mOut+'" '

    if(mName){
      html+=''
      +'onmouseover="this.src=\''+mOver+'\'" '
      +'onmouseout="this.src=\''+mOut+'\'" '
      +'alt="'+mSrc+'" width="344" height="'+mH+'" '
      +'></a'
    }

    html+=''
    +'></td>'
    +'</tr>'
    +'</table>'

    return html
  }  



// start: template functions -----------------------------------------------------------------------
  window.templateHeader = function(mElem){
    if(!document.getElementById) return
    mObj = document.getElementById(mElem)
    var mHeading=''
    if(mObj && mObj.innerHTML) mHeading = mObj.innerHTML
    var html=''
    +'<table cellpadding="0" cellspacing="0" align="center" width="750" style="height:100%;" border="0">'
    +'  <tr valign="top">'
    +'    <td>'
    +'<div align="center" style="padding:20px;">'

    if(location.host && !isSearchResults){
      html += ''
      +'<iframe id="a1690f06" name="a1690f06" src="http://hostagnostic.com/openads/adframe.php?n=a1690f06&amp;clientid=7&amp;target=_blank" framespacing="0" frameborder="no" scrolling="no" width="160" '
      +'  height="600" allowtransparency="true"><a href="http://hostagnostic.com/openads/adclick.php?n=a1690f06" target="_blank"><img src="http://hostagnostic.com/openads/adview.php?clientid=7&amp;n=a1690f06" '
      +'  border="0" alt=""></a></iframe>'
    }

    html += ''
    +'</div>'
    +'    </td>'
    +'    <td class="main_panel_left" width="5"><img src="pixel.gif" width="5" height="1"></td>'
    +'    <td rowspan="6" class="main_panel" width="1%"><img src="pixel.gif" width="450" height="10"><br'

    +'<div class="panelmain" id="panel0">'

    +'<table width="100%" border="0">'
    if(mHeading){
    html+=''
    +'	<tr>'
    +'		<td align="center" class="heading">'
    +'			<h1 id="mwow">'+mHeading+'</h1>'
    +'		</td>'
    +'	</tr>'
    }

    html+=''
    +'  <tr>'
    +'    <td>'
    document.write(html)
  } //end: templateHeader




  window.templateFooter = function(counter){
    var html=''
    +'      </td>'
    +'    </tr>'
    +'  </table>'
    +'  </div>'
    +'  <br><br><br><br>'
    +'    </td>'
    +'    <td valign="top">'
    +'      <table border="0" cellspacing="0" cellpadding="0" width="100%">'
    +'        <tr>'
    +'          <td class="top_panel_left"><img src="pixel.gif" width="5" height="1"></td>'
    +'          <td class="top_panel"><img src="pixel.gif" width="35" height="1"></td>'
    +'          <td align="center" class="top_panel">'
    +'            <a href="index.html" '
    +'            ><img src="2003/esq1.gif" alt="ESQ Software" border="0"'
    +'            ></a>'
    +'          </td>'
    +'          <td class="top_panel"><img src="pixel.gif" width="35" height="1"></td>'
    +'          <td class="top_panel_right"><img src="pixel.gif" width="10" height="1"></td>'
    +'        </tr>'
    +'      </table>'

    // buttons
    var w=45; var h=40; var btn=0
    html+=''
    +window.makeButton('','','',w,20)
    +window.makeButton('btn'+(++btn),'2003/','web-design',w,h)
    +window.makeButton('btn'+(++btn),'2003/','web-hosting',w,h)
    +window.makeButton('btn'+(++btn),'2003/','games-web-gadgets',w,h)
    +window.makeButton('btn'+(++btn),'2003/','contact-us',w,h)
    +window.makeButton('','','',w,20)

    +'<table cellpadding="0" cellspacing="0" width="100%">'
    +'    <tr valign="top">'
    +'      <td class="sub_panel" width="45"><img src="pixel.gif" width="45" height="800"></td>'
    +'      <td align="center">'
    +'        <div><img src="pixel.gif" width="1" height="20"></div>'

    html+=''
    +'        <!-- Search Google -->'
    +'        <style>'
    +'        .gfrm{ width:350px; margin:2px; padding:10px 0 10px 0; background: #bbb; border-top: 1px #fff solid; border-bottom: 1px #666 solid; }'
    +'        </style>'
    +'        <form class="gfrm" action="http://www.esqsoft.com/search-results.htm" id="cse-search-box">'
    +'          <div>'
    +'            <input type="hidden" name="cx" value="partner-pub-1157892973816149:lkuvri-9srr" />'
    +'            <input type="hidden" name="cof" value="FORID:11" />'
    +'            <input type="hidden" name="ie" value="ISO-8859-1" />'
    +'            <input type="text" name="q" size="33" />'
    +'            <input type="submit" name="sa" value="Search" />'
    +'          </div>'
    +'        </form>'
    +'        <sc'+'ript type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang=en"></sc'+'ript>'
    +'        <!-- Search Google -->'

    html+=''
    +'    <div><img src="pixel.gif" width="1" height="20"></div>'

    if(location.host && !isSearchResults){
        html+=''
        +'<br><iframe id="a51d3125" name="a51d3125" src="http://hostagnostic.com/openads/adframe.php?n=a51d3125&amp;clientid=8" framespacing="0" frameborder="no" scrolling="no" width="300" height="250" allowtransparency="true"><a href="http://hostagnostic.com/openads/adclick.php?n=a51d3125" target="_blank"><img src="http://hostagnostic.com/openads/adview.php?clientid=8&amp;n=a51d3125" border="0" alt=""></a></iframe>'
    }

    html+=''
    +getTracking()
    +'      </td>'
    +'    </tr>'
    +'  </table>'
    +'</td></tr></table>'

    document.write(html)


  /* walk ul/li and prefix with &raquo; */
  var arr = document.getElementsByTagName('li')
  for(var i=0; i<arr.length; i++){
    if(arr[i].parentNode.nodeName == 'UL'){
      arr[i].innerHTML = '&raquo; '+arr[i].innerHTML;
    }
  }

  }// end: templateFooter
// end: template functions -----------------------------------------------------------------------



function getTracking(){
  var html = ''

  /* StatCounter */
  html += ''
  +'<sc'+'ript type="text/javascript" language="javascript">'
  +'var sc_project=412504; '
  +'var sc_partition=2; '
  +'</sc'+'ript>'
  +'<sc'+'ript type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"></sc'+'ript>'

  return html
}



window.toggleHelpGadget = function(mObj){
  // toggle the help gadgets (open/close)
  if(!document.getElementById || !mObj) return

  //help gadget is triggered by a graphic
  //opens a neighboring div
  //example names:  graphic = "help1", div = "help1_div"

  //if graphic, get the div
  var tmpName = mObj.name
  if(!tmpName) tmpName = mObj.id

  if(tmpName.indexOf('_div')!=-1){
    //if div, get the graphic
    tmpName = tmpName.replace(/_div/g,'')
  }

  mObj = document.getElementById(tmpName); // get ref to graphic
  mDivObj = document.getElementById(tmpName+'_div'); //get ref to corresponding DIV

  if(mDivObj && mDivObj.style){
    if(mObj.toggle){
      mDivObj.style.visibility = 'hidden'
      mObj.toggle = 0
    }
    else{
      mDivObj.style.visibility = 'visible'
      mObj.toggle = 1
    }
  }

  return false
}



// start: postLoad components ----------------------------------------------------------------

/* apply look/feel templating to content -- doing this post-load can help with render times and has some other user benefits */

window.runPostLoad = function(){
  return; /* disabling this for now */
  //find all postload elements (based on id containing "postload")
  //assume corresponding src and target elements
  window.postLoadSrc = new Array()
  window.postLoadTarget = new Array()

  mElem = document.getElementsByTagName('div')

  //if for some reason we haven't picked up any divs try n more times
  if(!window.runPostLoadAttemptsLeft) window.runPostLoadAttemptsLeft=5
  if(!mElem.length){
    if(--window.runPostLoadAttemptsLeft>0){
      mtimer=setTimeout("window.runPostLoad()",1000)
      return
    }
  }

  for(var i=0; i<mElem.length; i++){
    if(mElem[i].id.match(/postloadsrc/i)){
      window.postLoadSrc.push(mElem[i])
    }
    else if(mElem[i].id.match(/postloadtarget/i)){
      window.postLoadTarget.push(mElem[i])
    }
  }

  for(var i=0; i<postLoadSrc.length; i++){
    mObj = postLoadSrc.pop()
    tObj = postLoadTarget.pop()
    if(mObj && mObj.innerHTML && tObj) tObj.innerHTML = mObj.innerHTML
  }

  
}
window.writePostLoader = function(){
  /*
    10/13/03 12:52AM - Thomas (testing notes)
    onload fires before rendering is complete
    methods like getElementsByTagName return 
    incomplete values if called before rendering has completed 
    it appears that by using setTimeout to call the function works reliably
    ...if not please tell me (thomas2003*esqsoft^om  antibot: *=@, ^=.c)
  */
//  setTimeout("window.runPostLoad()",100)
}
//document.onload = window.writePostLoader()
// end: postLoad components ------------------------------------------------------------------

