var pageIndex = new Array();
pageIndex[1] = 'experience';
pageIndex[2] = 'contact';
pageIndex[3] = 'portfolio';
pageIndex[4] = 'index';
pageIndex[5] = 'community';

var baseColor = 'green', rollColor = 'blue', selColor = 'grey';
getColors();

var button1_nm = new Image(26,26);   button1_nm.src = './gfx/' + baseColor + '/button1.gif';
var button1_up = new Image(26,26);   button1_up.src = './gfx/' + rollColor + '/button1.gif';

var button2_nm = new Image(42,42);   button2_nm.src = './gfx/' + baseColor + '/button2.gif';
var button2_up = new Image(42,42);   button2_up.src = './gfx/' + rollColor + '/button2.gif';

var button3_nm = new Image(64,64);   button3_nm.src = './gfx/' + baseColor + '/button3.gif';
var button3_up = new Image(64,64);   button3_up.src = './gfx/' + rollColor + '/button3.gif';

var button4_nm = new Image(116,116); button4_nm.src = './gfx/' + baseColor + '/button4.gif';
var button4_up = new Image(116,116); button4_up.src = './gfx/' + rollColor + '/button4.gif';

var button5_nm = new Image(66,66);   button5_nm.src = './gfx/' + baseColor + '/button5.gif';
var button5_up = new Image(66,66);   button5_up.src = './gfx/' + rollColor + '/button5.gif';

function drawHeader() {
  var writeIn = '';

  writeIn += '<DIV ID="loadCover" STYLE="background-color: 999999; position: absolute; left: 0px; top: 2px; width: 669; height: 200; z-index: 7; text-align: center;">';
  writeIn += '<FONT FACE="Arial, Helvetica"><B><br><br><br><br><br>R E N D E R I N G . . .</B></FONT>\n';
  writeIn += '</DIV>\n';

  writeIn += '<DIV ID="intBG" STYLE="position: absolute; left: 0px; top: 2px; z-index: 0">\n';
  writeIn += '<IMG SRC="./gfx/bg1.gif" WIDTH=669 HEIGHT=200>\n';
  writeIn += '</DIV>\n';

  if (currentPage() != 1) {
    writeIn += '<DIV TITLE="e x p e r i e n c e  [site list / resume]" ID="button1" STYLE="background-image: url(./gfx/' + baseColor + '/button1.gif); width: 26; height: 26; position: absolute; left: 7px; top: 65px; z-index: 2">\n';
    writeIn += '<A HREF="./experience.html" onMouseOver="imgSwap(\'button1\',\'up\');" onMouseOut="imgSwap(\'button1\',\'nm\');"><IMG SRC="./gfx/blank.gif" BORDER=0 WIDTH=26 HEIGHT=26></A></DIV>\n';
  }
  if (currentPage() == 1) {
    writeIn += '<DIV ID="button1" STYLE="background-image: url(./gfx/' + selColor + '/button1.gif); width: 26; height: 26; position: absolute; left: 7px; top: 65px; z-index: 2"></DIV>\n';
  }

  if (currentPage() != 2) {
    writeIn += '<DIV TITLE="c o n t a c t  [send email]" ID="button2" STYLE="background-image: url(./gfx/' + baseColor + '/button2.gif); width: 42; height: 42; position: absolute; left: 44px; top: 24px; z-index: 1">\n';
    writeIn += '<A HREF="./contact.html" onMouseOver="imgSwap(\'button2\',\'up\');" onMouseOut="imgSwap(\'button2\',\'nm\');"><IMG SRC="./gfx/blank.gif" BORDER=0 WIDTH=42 HEIGHT=42></A></DIV>\n';
  }
  if (currentPage() == 2) {
    writeIn += '<DIV ID="button2" STYLE="background-image: url(./gfx/' + selColor + '/button2.gif); width: 42; height: 42; position: absolute; left: 44px; top: 24px; z-index: 1"></DIV>\n';
  }

  if (currentPage() != 3) {
    writeIn += '<DIV TITLE="p o r t f o l i o  [art and UI work]" ID="button3" STYLE="background-image: url(./gfx/' + baseColor + '/button3.gif); width: 64; height: 64; position: absolute; left: 109px; top: 13px; z-index: 1">\n';
    writeIn += '<A HREF="./portfolio.html" onMouseOver="imgSwap(\'button3\',\'up\');" onMouseOut="imgSwap(\'button3\',\'nm\');"><IMG SRC="./gfx/blank.gif" BORDER=0 WIDTH=64 HEIGHT=64></A></DIV>\n';
  }
  if (currentPage() == 3) {
    writeIn += '<DIV ID="button3" STYLE="background-image: url(./gfx/' + selColor + '/button3.gif); width: 64; height: 64; position: absolute; left: 109px; top: 13px; z-index: 1"></DIV>\n';
  }

  if (currentPage() != 4) {
    writeIn += '<DIV TITLE="h o m e  [start page]" ID="button4" STYLE="background-image: url(./gfx/' + baseColor + '/button4.gif); width: 116; height: 116; position: absolute; left: 22px; top: 78px; z-index: 1">\n';
    writeIn += '<A HREF="./index.html" onMouseOver="imgSwap(\'button4\',\'up\');" onMouseOut="imgSwap(\'button4\',\'nm\');"><IMG SRC="./gfx/blank.gif" BORDER=0 WIDTH=116 HEIGHT=116></A></DIV>\n';
  }
  if (currentPage() == 4) {
    writeIn += '<DIV ID="button4" STYLE="background-image: url(./gfx/' + selColor + '/button4.gif); width: 116; height: 116; position: absolute; left: 22px; top: 78px; z-index: 1"></DIV>\n';
  }

  if (currentPage() != 5) {
    writeIn += '<DIV TITLE="c o m m u n i t y  [interact]" ID="button5" STYLE="background-image: url(./gfx/' + baseColor + '/button5.gif); width: 66; height: 66; position: absolute; left: 515px; top: 98px; z-index: 1">\n';
    writeIn += '<A HREF="./community.html" onMouseOver="imgSwap(\'button5\',\'up\');" onMouseOut="imgSwap(\'button5\',\'nm\');"><IMG SRC="./gfx/blank.gif" BORDER=0 WIDTH=66 HEIGHT=66></A></DIV>\n';
  }
  if (currentPage() == 5) {
    writeIn += '<DIV ID="button5" STYLE="background-image: url(./gfx/' + selColor + '/button5.gif); width: 66; height: 66; position: absolute; left: 515px; top: 98px; z-index: 1"></DIV>\n';
  }

  if (pageIndex[currentPage()] != null) {
    writeHeaderName = pageIndex[currentPage()];
    if (writeHeaderName == 'index') writeHeaderName = 'home';
    writeIn += '<DIV ID="pageTitleM" CLASS="pageTitleM">' + writeHeaderName + '</DIV>\n';
    writeIn += '<DIV ID="pageTitleL" CLASS="pageTitleL">' + writeHeaderName + '</DIV>\n';
    writeIn += '<DIV ID="pageTitleD" CLASS="pageTitleD">' + writeHeaderName + '</DIV>\n';
  }

    writeIn += '<DIV STYLE="position: absolute; left: 270px; top: 175px; z-index: 1">\n';
    if (currentPage() != 4)
      writeIn += '<A HREF="./index.html" onMouseOver="imgSwap(\'button4\',\'up\');" onMouseOut="imgSwap(\'button4\',\'nm\');">home</A> | ';
    if (currentPage() == 4)
      writeIn += '<B>home</B> | ';
    if (currentPage() != 1)
      writeIn += '<A HREF="./experience.html" onMouseOver="imgSwap(\'button1\',\'up\');" onMouseOut="imgSwap(\'button1\',\'nm\');">experience</A> | ';
    if (currentPage() == 1)
      writeIn += '<B>experience</B> | ';
    if (currentPage() != 2)
      writeIn += '<A HREF="./contact.html" onMouseOver="imgSwap(\'button2\',\'up\');" onMouseOut="imgSwap(\'button2\',\'nm\');">contact</A> | ';
    if (currentPage() == 2)
      writeIn += '<B>contact</B> | ';
    if (currentPage() != 3)
      writeIn += '<A HREF="./portfolio.html" onMouseOver="imgSwap(\'button3\',\'up\');" onMouseOut="imgSwap(\'button3\',\'nm\');">portfolio</A> | ';
    if (currentPage() == 3)
      writeIn += '<B>portfolio</B> | ';
    if (currentPage() != 5)
      writeIn += '<A HREF="./community.html" onMouseOver="imgSwap(\'button5\',\'up\');" onMouseOut="imgSwap(\'button5\',\'nm\');">community</A>\n';
    if (currentPage() == 5)
      writeIn += '<B>community</B>\n';
    writeIn += '</DIV>\n';

  document.write(writeIn);
}

function activateHeader() {
  document.getElementById('loadCover').style.zIndex = -1;
}

function imgSwap(imgTarg,imgValue) {
  buttonValue = (imgTarg + '_' + imgValue + '.src');
  document.getElementById(imgTarg).style.backgroundImage = 'url(' + eval(buttonValue) + ')';
}

function viewPort(imgLoc,imgWidth,imgHeight,imgName,imgDesc) {
  var viewItem = './viewport.html?./portfolio/' + imgLoc + '&x=' + imgWidth + '&y=' + imgHeight + '&n=' + escape(imgName) + '&d=' + escape(imgDesc);
  document.location.href = viewItem;
}

function getColors() {
  if (document.cookie) {
    getColor = document.cookie.indexOf("d6Colors=") + 7;
    fullColor = document.cookie.substring(getColor,document.cookie.length);
    baseC = fullColor.substring(fullColor.indexOf("&baseColor:") + 11,fullColor.indexOf("&rollColor:"));
    rollC = fullColor.substring(fullColor.indexOf("&rollColor:") + 11,fullColor.indexOf("&selColor:"));
    selC = fullColor.substring(fullColor.indexOf("&selColor:") + 10,fullColor.indexOf("&end"));
    baseColor = baseC, rollColor = rollC, selColor = selC;
  }
}

function setColors(baseC,rollC,selC) {
  setThisCookie = 'd6Colors=' + '&baseColor:' + baseC + '&rollColor:' + rollC + "&selColor:" + selC + "&end";
  document.cookie = setThisCookie + '; expires=Thu, 31-Dec-2099 00:00:01 GMT' + '; path=/';
  document.location.reload();
}

function currentPage() {
  i = 4;
  pageName = document.location.href;
  while (pageName.indexOf('/') > -1) {
    pageName = pageName.substring((pageName.indexOf('/') + 1),pageName.length)
  }
  if (pageName.indexOf('.') > -1) {
    pageName = pageName.substring(0,pageName.indexOf('.'))
    for (i=1;pageIndex[i]!=pageName && i<=pageIndex.length;i++) {
    }
  }
  return i;
}