function getCluster( server ) {
  var currentDomain = document.domain;
  var cluster;
  if( currentDomain.indexOf( "localhost" ) != -1 ) {
    return "http://localhost.thereinc.com/";
  }
  else if( currentDomain.indexOf( "127.0.0.1" ) != -1 ) {
    return "http://127.0.0.1/";
  }

  // If we don't find a domain we recognize, return '/'
  var url         = "/";
  var startOffset = -1;

  // This _looks_ icky, but it's actually more efficent than 
  // the old method, which looped through the currentDomain
  // character by character.
  startOffset = currentDomain.indexOf( 'prod.' );
  if( startOffset == -1 ) {
    startOffset = currentDomain.indexOf( 'beta.' );
    if ( startOffset == -1 ) {
      startOffset = currentDomain.indexOf( 'qa.' );
    }
  }
  if ( startOffset != -1 ) {
    cluster = currentDomain.substring( startOffset );
    url = "http://" + server + '.' + cluster + "/";
  }
  //this is extweb. may see www.there.com, not www.there.prod.com.
  else if( currentDomain.indexOf( 'www.there.com' ) !== -1 ) {
     cluster = 'prod.there.com';
     url = "http://" + server + '.' + cluster + "/";
  }
  return url;
}

function writeFooter( which, where ) {
  var imgPath = '';
  var urlPath = '';
  if( where == 'a' ) {
    imgPath = '/';
    urlPath = imgPath;
  }
  else {
    imgPath = '../';
    urlPath = '/';
  }

  var now = new Date();
  var thisYear = now.getUTCFullYear();
  var footerString = '';
  var href = escape( window.location.href );
  if( which == 'noLinks' ) {
    footerString += '<table border="0" cellspacing="0" cellpadding="0">'
                  + '<tr>'
                  + '<td>'
                  + '<img src="' + imgPath + 'common/media/clear.gif" width="1" height="12"/>'
                  + '</td>'
                  + '</tr>'
                  + '<tr>'
                  + '<td align="center" class="gry9">'
                  + '&#169; Copyright ' + thisYear + '. There Inc. All rights reserved.'
                  + '</td>'
                  + '</tr>'
                  + '</table>';
  }
  else {
    footerString += '<table border="0" cellspacing="0" cellpadding="0">'
                  + '<tr>'
                  + '<td>'
                  + '<img src="' + imgPath + 'common/media/clear.gif" width="1" height="12"/>'
                  + '</td>'
                  + '</tr>'
                  + '<tr>'
                  + '<td align="center" class="gry9">'
                  + '<a class="mdBlu9" href="' + getCluster('webapps') + 'login/74.xml">Member Agreement</a> | <a class="mdBlu9" href="' + getCluster('webapps') + 'login/114.xml">Privacy Policy</a> | <a class="mdBlu9" href="' + getCluster('webapps') + 'login/73.xml">Behavior Guidelines</a><br />'
                  + '&#169; Copyright ' + thisYear + '. There Inc. All rights reserved.'
                  + '</td>'
                  + '</table>';
  }
  document.write( footerString );
}

