// commenter
var chatURL = "chat.php";
var xmlHttpGetMessages = createXmlHttpRequestObject();
var updateInterval = 1000; // how many miliseconds to wait to get new message
var debugMode = true;
var cacheA = new Array();
var lastMessageID = new Array(); 
var lstTime = 0;
var initLoc = window.location.href;

function ctoggle(obj,sndr) {
	var el = document.getElementById(obj);
	var snd = document.getElementById(sndr);

	if (el.style.display != 'none') {
		Effect.BlindUp(obj);
		if (snd.innerHTML == 'Hide Comment Form') {
      snd.innerHTML = 'Show Comment Form';  
    }
	} else {
		Effect.BlindDown(obj);
		if (snd.innerHTML == 'Show Comment Form') {
      snd.innerHTML = 'Hide Comment Form';  
    }
	}
}
  
function createXmlHttpRequestObject() {
  var xmlHttp;
  try {
    xmlHttp = new XMLHttpRequest();
  } catch(e) {
    var XmlHttpVersions = new Array("MSXML2.XMLHTTP.7.0","MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP");
    for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++) {
      try { 
        xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
      } catch (e) {
      
      }
    }
  }
  if (!xmlHttp)
    alert("Error creating the XMLHttpRequest object.");
  else 
    return xmlHttp;
}

function pause( msecs ) {
  var start = new Date();
  var actualDelay;
  while (true) {
    var now = new Date();
    actualDelay = now - start;
    if(msecs <= actualDelay) break;
  }
  return actualDelay;
} 

function getMyFocus(objID) {
  var oMessageBox = document.getElementById(objID);
  if (oMessageBox.value == "Write Something...") {
    oMessageBox.value = "";
    oMessageBox.className = "myfocus";
  } else if (objID.substring(0,8) == "userName") {
    if (oMessageBox.className != "wicon") oMessageBox.className = "woicon2";
  } else if (objID.substring(0,3) == "pwd") {
    oMessageBox.className = "wpw2";
  } else if (objID.substring(0,3) == "reg") {
    if (objID.substring(3,5) == "PW") {
      if (oMessageBox.className != "rwicon") oMessageBox.className = "rwpw2";
    } else {
      if (oMessageBox.className != "rwicon") oMessageBox.className = "rwoicon2";
    }
  } else {
    if (oMessageBox.className != "rwicon") oMessageBox.className = "myfocus";
  }
}

function loseMyFocus(objID) {
  var oMessageBox = document.getElementById(objID);
  if (oMessageBox.value == "") {
    oMessageBox.value = "Write Something...";
    oMessageBox.className = "";
  } else if (objID.substring(0,8) == "userName") {
    if (oMessageBox.className != "wicon") oMessageBox.className = "woicon";
  } else if (objID.substring(0,3) == "reg") {
    if (objID.substring(3,5) == "PW") {
      if (oMessageBox.className != "rwicon") oMessageBox.className = "rwpw";
    } else {
      if (oMessageBox.className != "rwicon") oMessageBox.className = "rwoicon";
    }
  } else {
    if (oMessageBox.className != "rwicon") oMessageBox.className = "";
  }
}

function validateEmail(txtMail1,txtMail2) {
  var tMail1 = document.getElementById(txtMail1);
  var tMail2 = document.getElementById(txtMail2);

  if (tMail1.value.length > 4 && tMail1.value != "Email" && (tMail1.value.indexOf("@") > 0)) {
    tMail1.className = "rwicon";
  } else {
    tMail1.className = "rwoicon2";
  }
  
  if (tMail2.value.length > 4 && tMail2.value != "Confirm Email") {
    if (tMail1.value == tMail2.value) {
      tMail2.className = "rwicon";
    } else {
      tMail2.className = "rwoicon2";
    }
  } else {
    tMail2.className = "rwoicon2";
  }
}

function validatePW(txtPW1,txtPW2) {
  var tPW1 = document.getElementById(txtPW1);
  var tPW2 = document.getElementById(txtPW2);

  if (tPW1.value.length > 4 && tPW1.value != "Password") {
    tPW1.className = "rwicon";
  } else {
    tPW1.className = "rwpw2";
  }
  
  if (tPW2.value.length > 4) {
    if (tPW1.value == tPW2.value) {
      tPW2.className = "rwicon";
    } else {
      tPW2.className = "rwpw2";
    }
  } else {
    tPW2.className = "rwpw2";
  }
}

function verifySend(mdPW,user,pid) {
  params =  "mode=verifySend" +
            "&user=" + encodeURIComponent(user) +
            "&pid=" + encodeURIComponent(pid) +
            "&pw=" + encodeURIComponent(mdPW);
  cacheA.unshift(params);
}

function verifyPW(mdPW,user,pid) {
  params =  "mode=verifyPW" +
            "&user=" + encodeURIComponent(user) +
            "&pid=" + encodeURIComponent(pid) +
            "&pw=" + encodeURIComponent(mdPW);
  cacheA.unshift(params);
}

function init(id,pid) {
  var myCookie = get_cookie("dbc_com_match");
  var userCookie = get_cookie("dbc_com_user");
  if (myCookie) {
    if (userCookie) {
      t=myCookie.indexOf("~");
      L=myCookie.length;
      mdUser=myCookie.substr(0,t);
      mdPW=myCookie.substr((t+1),L);
      if ((MD5(userCookie)) == mdUser) {
        verifyPW(mdPW,userCookie,pid);       
      }
    }
  }
  var omgid=id;
  var omgpid=pid;
  var oMessageBox = document.getElementById("messageBox"+omgpid);
  oMessageBox.value = "Write Something...";
  oMessageBox.setAttribute("autocomplete", "off");    
  //checkUsername(omgpid);
  lastMessageID[omgpid]=0;
  requestNewMessages(lastMessageID[omgpid],omgpid);
}

function checkUsername(pid) {
  var oUser=document.getElementById("userName"+pid);
  var mycheck1 = document.getElementById('mycheck1'+pid);
  var pwDiv = document.getElementById('acDiv'+pid);
  if (oUser.value == "") {
    delete_cookie("dbc_com_match");
    oUser.value = "Guest" + Math.floor(Math.random() * 1000);
    oUser.className="woicon";
    pwDiv.innerHTML = "";
  }
}
  
/* function called when the Send button is pressed */
function sendMessage(pid){
  // save the message to a local variable and clear the text box
  var oCurrentMessage = document.getElementById("messageBox"+pid);
  var currentUser = document.getElementById("userName"+pid).value;
  var currentEmail = document.getElementById("email"+pid).value;
  var currentWebsite = document.getElementById("website"+pid).value;
  var myInfo = document.getElementById("myInfo"+pid);
  var tmpUser = MD5(currentUser);
  // don't send void messages
  if (trim(oCurrentMessage.value) != "" && trim(currentUser) != "" && oCurrentMessage.value != "Write Something...") {
    var myCookie = get_cookie("dbc_com_match");
    if (myCookie) {
      if (!(currentPW = document.getElementById("pwd"+pid))) {
        t=myCookie.indexOf("~");
        L=myCookie.length;
        mdPW=myCookie.substr((t+1),L);
        verifySend(mdPW,currentUser,pid);
      } else {
        var currentPW = document.getElementById("pwd"+pid).value
        var tmpPW = MD5(currentPW);
        t=myCookie.indexOf("~");
        L=myCookie.length;
        mdUser=myCookie.substr(0,t);
        mdPW=myCookie.substr((t+1),L);
        if (mdUser = tmpUser) {
          if (mdPW = tmpPW) {  
            params =  "mode=SendAndRetrieveNew" +
                      "&id=" + encodeURIComponent(lastMessageID[pid]) + 
                      "&name=" + encodeURIComponent(currentUser) + 
            	        "&email=" + encodeURIComponent(currentEmail) + 
            	        "&website=" + encodeURIComponent(currentWebsite) + 
                      "&message=" + oCurrentMessage.value.replace(new RegExp( "\\n", "g" ),"<br/>") +
                      "&pid=" + encodeURIComponent(pid);
            cacheA.unshift(params);
            if (initLoc.indexOf("#")) {
              tmpLoc = initLoc.substring(0,initLoc.indexOf("#")) + "#thetop" + pid;
              initLoc = initLoc.substring(0,initLoc.indexOf("#"));
            } else {
              tmpLoc = initLoc.substring(0,initLoc.indexOf("#")) + "#thetop" + pid;
            }
            window.location.href = tmpLoc;
            myInfo.innerHTML = "Sent!";
            ctoggle('formWrap'+pid,'sh'+pid);
            //requestNewMessages(encodeURIComponent(lastMessageID),encodeURIComponent(pid));
            oCurrentMessage.value = "";
          } else {
            myInfo.innerHTML = "Nice Try! The User is valid but the password is not, please try again!";
          }
        } else {
          myInfo.innerHTML = "Nice Try! Someone is already logged into the commenter, log out and log back in!";
        }
      }
    } else {
      var tmycheck = document.getElementById("pwd"+pid);
      if (tmycheck) {
        if (tmycheck.className != "wicon") {
          myInfo.innerHTML = "Nice Try! The Username is valid, but the password is not, try again!";
        } else {
          params =  "mode=SendAndRetrieveNew" +
                    "&id=" + encodeURIComponent(lastMessageID[pid]) + 
                    "&name=" + encodeURIComponent(currentUser) + 
          	        "&email=" + encodeURIComponent(currentEmail) + 
          	        "&website=" + encodeURIComponent(currentWebsite) + 
                    "&message=" + oCurrentMessage.value.replace(new RegExp( "\\n", "g" ),"<br/>") +
                    "&pid=" + encodeURIComponent(pid);
          cacheA.unshift(params);
          if (initLoc.indexOf("#")) {
            tmpLoc = initLoc.substring(0,initLoc.indexOf("#")) + "#thetop" + pid;
            initLoc = initLoc.substring(0,initLoc.indexOf("#"));
          } else {
            tmpLoc = initLoc.substring(0,initLoc.indexOf("#")) + "#thetop" + pid;
          }
          window.location.href = tmpLoc;
          myInfo.innerHTML = "Sent!";
          ctoggle('formWrap'+pid,'sh'+pid);
          //requestNewMessages(encodeURIComponent(lastMessageID),encodeURIComponent(pid));
          oCurrentMessage.value = "";
        }
      } else {
          params =  "mode=SendAndRetrieveNew" +
                    "&id=" + encodeURIComponent(lastMessageID[pid]) + 
                    "&name=" + encodeURIComponent(currentUser) + 
          	        "&email=" + encodeURIComponent(currentEmail) + 
          	        "&website=" + encodeURIComponent(currentWebsite) + 
                    "&message=" + oCurrentMessage.value.replace(new RegExp( "\\n", "g" ),"<br/>") +
                    "&pid=" + encodeURIComponent(pid);
          cacheA.unshift(params);
          if (initLoc.indexOf("#")) {
            tmpLoc = initLoc.substring(0,initLoc.indexOf("#")) + "#thetop" + pid;
            initLoc = initLoc.substring(0,initLoc.indexOf("#"));
          } else {
            tmpLoc = initLoc.substring(0,initLoc.indexOf("#")) + "#thetop" + pid;
          }
          window.location.href = tmpLoc;
          myInfo.innerHTML = "Sent!";
          ctoggle('formWrap'+pid,'sh'+pid);
          //requestNewMessages(encodeURIComponent(lastMessageID),encodeURIComponent(pid));
          oCurrentMessage.value = "";
      }
    }
  } else {
    myInfo.innerHTML = "You missed something!";
  }
}

function deleteMessages(pid) {
  params = "mode=DeleteAndRetrieveNew";  
  cacheA.push(params);
}

/* makes asynchronous request to retrieve new messages, post new messages, delete messages */
function requestNewMessages(id,pid) {
  // ###################################################
  //var mytestdiv = document.getElementById("mytestdiv");
  //mytestdiv.innerHTML = "id: " + id + " pid: " + pid+ "<br/>" + mytestdiv.innerHTML.substring(((mytestdiv.length)-95),95);                       
  // ###################################################
  if (typeof pid == 'object') {
    pid = pid.item(0).firstChild.data.toString();
  }
  if(xmlHttpGetMessages) {
    try {
      if (xmlHttpGetMessages.readyState == 4 || xmlHttpGetMessages.readyState == 0) {
        var params = "";
        if (cacheA.length>0) {
          params = cacheA.shift();       
        } else {
          params = "mode=RetrieveNew&id=" + lastMessageID[pid] + "&pid="+pid;
        }
        if (lastMessageID[pid]<id) {
          lastMessageID[pid] = id;
        }

        xmlHttpGetMessages.open("POST", chatURL, true);
        xmlHttpGetMessages.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        xmlHttpGetMessages.onreadystatechange = handleReceivingMessages;
        xmlHttpGetMessages.send(params);
      } else {
        // we will check again for new messages 
        params = "mode=RetrieveNew&id=" + lastMessageID[pid] + "&pid="+pid;
        if (lastMessageID[pid]<id) {
          lastMessageID[pid] = id;
        }
        cacheA.push(params);          
      }
    } catch(e) {
      displayError(e.toString(),id,pid);
    }
  }
}

/* function that handles the http response when updating messages */
function handleReceivingMessages() {
  // continue if the process is completed
  if (xmlHttpGetMessages.readyState == 4) {
    // continue only if HTTP status is "OK"
    if (xmlHttpGetMessages.status == 200) {
    //alert("http status 200");
      try {
        // process the server's response
        readMessages();
      } catch(e) {
        // display the error message
          alert(e.toString());
      }
    } else {
      // display the error message
      displayError(xmlHttpGetMessages.statusText,-1,1);
    }
  }
}

function randomizePID(lstID) {
  var newID=lstID;
  var insCnt = document.getElementsByClassName("content");
  for (g=0;g<(insCnt.length);g++) {
    var obj = document.getElementsByClassName("content")[g];
    if (obj.id.substring(7,(obj.id.length)) == lstID) {
      var obj2 = document.getElementsByClassName("content")[insCnt.length-1];
      if (obj.id.substring(7,(obj.id.length)) == obj2.id.substring(7,(obj.id.length))) {
        var obj3 = document.getElementsByClassName("content")[0];
        newID = obj3.id.substring(7,(obj.id.length))
        //alert("last PID on page, new ID is: " + newID);
      } else {
        var obj3 = document.getElementsByClassName("content")[g+1];
        newID = obj3.id.substring(7,(obj.id.length))
        //alert("last PID on page, new ID is: " + newID);
      }
    }
  }
  return newID;
}

function logout() {
  delete_cookie('dbc_com_match');
  delete_cookie('dbc_com_user');
}

function readMessages() {  
  var mytestdiv = document.getElementById("mytestdiv");
  var response = xmlHttpGetMessages.responseText;
  var responset = xmlHttpGetMessages.responseText;
  var insCnt = 0;
  if (response.indexOf("ERRNO") >= 0 || response.indexOf("error:") >= 0 || response.length == 0) {
    throw(response.length == 0 ? "Void server response." : response);
  }
  response = xmlHttpGetMessages.responseXML.documentElement;
  
  // got a user response back, check to see if it's valid
  if (validPWUser = response.getElementsByTagName("pwuser").item(0)) {
    var rtnVal = response.getElementsByTagName("pwvalid").item(0).firstChild.data;
    var pid = response.getElementsByTagName("pid").item(0).firstChild.data;
    if (rtnVal = "true") {
      var oCurrentMessage = document.getElementById("messageBox"+pid);
      var myInfo = document.getElementById("myInfo"+pid);
      params =  "mode=SendAndRetrieveNew" +
                "&id=" + encodeURIComponent(lastMessageID[pid]) + 
                "&name=" + encodeURIComponent(validPWUser.firstChild.data) + 
      	        "&email=" + encodeURIComponent("mail") + 
      	        "&website=" + encodeURIComponent("web") + 
                "&message=" + oCurrentMessage.value.replace(new RegExp( "\\n", "g" ),"<br/>") +
                "&pid=" + encodeURIComponent(pid);
      cacheA.unshift(params);
      if (initLoc.indexOf("#")) {
        tmpLoc = initLoc.substring(0,initLoc.indexOf("#")) + "#thetop" + pid;
        initLoc = initLoc.substring(0,initLoc.indexOf("#"));
      } else {
        tmpLoc = initLoc.substring(0,initLoc.indexOf("#")) + "#thetop" + pid;
      }
      window.location.href = tmpLoc;
      myInfo.innerHTML = "Sent!";
      ctoggle('formWrap'+pid, 'sh'+pid);
      oCurrentMessage.value = "";
    } else {
      alert(validUser.firstChild.data + " - Whoa cowboy, looks like your old cookie info is corrupt. I am deleting the corrupt cookie. Not to worry, just log back in to post!");
      logout();
    }
    requestNewMessages(lastMessageID[pid],pid);
    return;
  }
   
  if (validUser = response.getElementsByTagName("lguser").item(0)) {
    pid = response.getElementsByTagName("pid").item(0).firstChild.data;
    isVal = response.getElementsByTagName("valid").item(0).firstChild.data;
    if (isVal == "false") {
      alert(validUser.firstChild.data + " - Whoa cowboy, looks like your old cookie info is corrupt. I am deleting the corrupt cookie. Not to worry, just log back in to post!");
      logout();
      requestNewMessages(lastMessageID[pid],pid);
      return;
    }
    var currentUser = document.getElementById("userName"+pid);
    var currentEmail = document.getElementById("email"+pid);
    var currentWebsite = document.getElementById("website"+pid);
    var myLogout = document.getElementById("acDiv"+pid);
    currentUser.value = validUser.firstChild.data;
    currentUser.className = "wicon";
    currentUser.disabled = true;
    currentUser.style.display = "none";
    currentEmail.style.display = "none";
    currentWebsite.style.display = "none";
    myLogout.innerHTML = "<div class='myLogout' id='myLogout"+pid+"'>Preferences&nbsp;&nbsp;|&nbsp;&nbsp;<a href='' onClick='logout();'>Log Off "+validUser.firstChild.data+"</a></div>";
    myLogout.style.display = "inline";
    requestNewMessages(lastMessageID[pid],pid);
    return;
  }   
  clearChat = response.getElementsByTagName("clear").item(0).firstChild.data;    
  idArray = response.getElementsByTagName("id");
  pid = response.getElementsByTagName("pid").item(0).firstChild.data;
  nameArray = response.getElementsByTagName("name");
  timeArray = response.getElementsByTagName("time");
  messageArray = response.getElementsByTagName("message");
  emailArray = response.getElementsByTagName("email");
  websiteArray = response.getElementsByTagName("website");
  if (idArray.length>0){
    id = idArray.item(idArray.length - 1).firstChild.data.toString();
    displayMessages(idArray, nameArray, timeArray, messageArray, emailArray, websiteArray,pid);
    if (id>lastMessageID[pid]) {
      lastMessageID[pid] = idArray.item(idArray.length - 1).firstChild.data;
    }
    insCnt = document.getElementsByName("content");
    //mytestdiv.innerHTML += " --- " + pid;
    requestNewMessages(lastMessageID[pid],pid);
  } else {
    insCnt = document.getElementsByName("content");
    lstTime = randomizePID(pid);
    pid = randomizePID(pid);
    setTimeout("requestNewMessages("+lastMessageID[pid]+","+pid+");", updateInterval);
  }
}



/* function that appends the new messages to the chat list  */
function displayMessages(idArray, nameArray, timeArray, messageArray, emailArray, websiteArray,pid) {
  var posts = idArray.length;
  // each loop adds a new message
  for(i=0; i<idArray.length; i++) {
    // get the message details
    time = timeArray.item(i).firstChild.data.toString();
    name = nameArray.item(i).firstChild.data.toString();
    message = messageArray.item(i).firstChild.data.toString();
	  email = emailArray.item(i).firstChild.data.toString();
	  website = websiteArray.item(i).firstChild.data.toString();
		//var xpid = pid.item(i).firstChild.data.toString();
	  titleLink = document.getElementById("commentlink"+pid);
    postid = idArray.item(i).firstChild.data.toString();
    
    // THIS IS WHERE THE IE BUG IS!!!!!!!!
    
    // compose the HTML code that displays the message
    var htmlMessage = "";
    if (posts == 1) {
      htmlMessage += "<div  name=\"mywrap"+postid+"\">";
    } else {
      htmlMessage += "<div name=\"mywrap"+postid+"\">";
    }
    htmlMessage += "<div id=\"xsnazzy\">";
    htmlMessage += "<b class=\"xtop\"><b name=\"xb1"+postid+"\" class=\"xb1\"></b><b name=\"xb2"+postid+"\" class=\"xb2\"></b><b name=\"xb3"+postid+"\" class=\"xb3\"></b><b name=\"xb4"+postid+"\" class=\"xb4\"></b></b>";
    htmlMessage += "<div name=\"xboxcontent"+postid+"\" class=\"xboxcontent\">";
    htmlMessage += "<div name=\"mypost"+postid+"\" id=\"newPost"+pid+"\" class=\"item\" onmouseover=\"showAdmin("+postid+");\" onmouseout=\"showAdmin("+postid+");\">"; 
    htmlMessage += "<div style='margin-top:5px;text-align:center;width:44px;height:54px;display:block;float:left;background:url(cal.png) no-repeat;'>";
    //htmlMessage += "<img src='cal.png' class='myIcon' />";
    htmlMessage += "<span style='font-size:8pt;color:#fff;position:relative;'><b>" + time.substring(0,3) + "</b></span><br/>";
    htmlMessage += "<span style='font-size:6pt;position:relative;'>" + time.substring(5,9) + "</span><br/>";
    htmlMessage += "<span style='font-size:10pt;'><b>" + time.substring(3,5) + "</b></span>";
    htmlMessage += "</div><div class='contDiv'>";
    htmlMessage += "<span class=\"username\"><a href='" + website +"' title='Visit " + website +"' alt='Visit " + website +"'>" + name + "</a></span>";
    htmlMessage += "<span class=\"datetime\"><em>&nbsp;&nbsp;&nbsp;Posted: " + time.substring(10,18) + "</em></span>";
    htmlMessage += "<span style=\"display:none;\" id=\"admin_panel"+postid+"\" class=\"admin_panel\">delete  |  edit</span><br />";
    //htmlMessage += "<div class='postText'>";
    htmlMessage += message.toString().replaceAll("&lt;br/&gt;","<br/>");
    //htmlMessage += "</div>";
    htmlMessage += "</div><div class='clear'></div>";
	  htmlMessage += "</div>";
	  htmlMessage += "</div>";
	  htmlMessage += "<b class=\"xbottom\"><b name=\"xb4"+postid+"\" class=\"xb4\"></b><b name=\"xb3"+postid+"\" class=\"xb3\"></b><b name=\"xb2"+postid+"\" class=\"xb2\"></b><b name=\"xb1"+postid+"\" class=\"xb1\"></b></b>";
	  htmlMessage += "</div>";
	  htmlMessage += "</div>";

  // display the comments message
  if (posts == 1) {
    titleLink.innerHTML = posts + " Comment";
        playme();
  }
  if (posts > 1) {
    titleLink.innerHTML = posts + " Comments";
  }
    
    displayMessage(htmlMessage,posts,pid,postid);
  }
}

 function playme() {
  Sound.play('sound/Bleep.wav');
 }

 // for main site, not commenter
function switchIntro(tab) {
  var myTab = document.getElementById("intro-right");
  var myArrow = document.getElementById("introarrow");
  switch (tab) {
    case 1:
      var myIntro = document.getElementById('abt');
      myIntro.src='layout/2-intro-abt-3.png';
      var myIntro = document.getElementById('serv');
      myIntro.src='layout/2-intro-serv-2.png';
      var myIntro = document.getElementById('blog');
      myIntro.src='layout/2-intro-blog-2.png';
      var myIntro = document.getElementById('port');
      myIntro.src='layout/2-intro-port-2.png';
      var myIntro = document.getElementById('more');
      myIntro.src='layout/2-intro-more-2.png';
      new Effect.Opacity('intro-right', { from: 0, to: 1 });
      new Effect.Opacity('introarrow', { from: 0, to: 1 });
      myArrow.style.top = "8px";
      myArrow.style.visibility = "visible";
      myTab.innerHTML = "<img src='layout/info-about.png' /><br/><br/>" +
                  "<b>What is all this?</b><br/>" +
                  "Designs by Chace is designed, developed & maintained by me, Chace. There are no other employees at this time. Why? This website originated as a repository for my projects and resume. Since then, it has evolved and matured to contain a <a href='http://blog.designsbychace.com'>weblog</a>, tutorials and reviews on various topics, <a href='http://www.designsbychace.com/downloads.php'>downloads</a>, <a href='http://www.designsbychace.com/photos.php'>pictures</a>, a <a href='http://forum.designsbychace.com/'>forum</a> and <a href='http://www.designsbychace.com/more.php'>more</a>.<br/><br/>" +
                  "<b>Who is Chace?</b><br/>" +
                  "I am currently 25 years old, born in Kansas in 1984. In 1989 my younger brother, mother and I moved to Northern Colorado, which is where I went to Grade School through High School. After a few semesters at AIMS Community College I enrolled in a Bachelor of Science program to get my Computer Information Systems degree at DeVry University and 2.5-3 years later I graduated Cum Laude with my BS in CIS.<br/><br/>" +
                  "Currently, I am a Senior Application Development Specialist for CIGNA Healthcare in the Denver Tech. Center. By night, and any free time I get, I work on side projects, family projects, and client websites.<br/><br/>" +
                  "<b>Qualifications:</b><br/>" +
                  "7+ years general programming & IT experience<br/>" +
                  "2.5+ years programming experience in coorperate setting<br/>" +
                  "2.5+ years scheduling/batch operations & TriZetto Facets batch scheduling<br/>" +
                  "2.5+ years designing, developing, modifying & creating XML files, VBScripts, Windows Batch Files, CBA Scripts & configuration files<br/>" +
                  "2.5+ years experience in SDLC, technical writing, data extraction, analysis & presentation<br/><br/>" +
                  "<b>Skills:</b><br/>" + 
                  "PHP, CSS, Flash, HTML, JAVA, JavaScript, MySQL, SQL, ASP.NET, Visual Basic, VBScript, XML, OOP, PL/SQL, Oracle(9i, 10g), SDLC, Access, Visio, Excel, Word, PowerPoint, Hyperion9.2, Microsoft Server 2003, UNIX, CA AutoSys, TOAD, Putty, AJAX, Computer Associates Harvest, Tivoli Workload Scheduler, Windows Batch";
      break;
    case 2:
      var myIntro = document.getElementById('abt');
      myIntro.src='layout/2-intro-abt-2.png';
      var myIntro = document.getElementById('serv');
      myIntro.src='layout/2-intro-serv-3.png';
      var myIntro = document.getElementById('blog');
      myIntro.src='layout/2-intro-blog-2.png';
      var myIntro = document.getElementById('port');
      myIntro.src='layout/2-intro-port-2.png';
      var myIntro = document.getElementById('more');
      myIntro.src='layout/2-intro-more-2.png';
      new Effect.Opacity('intro-right', { from: 0, to: 1 });
      new Effect.Opacity('introarrow', { from: 0, to: 1 });
      myTab.innerHTML = "<img src='layout/info-services.png' /><br/><br/>" +
                        "<b>Web Development</b> - Need a page setup with a backend for easy administration? We can do that. Need a custom made form for any purpose? We can do that too. Using various technologies such as: AJAX, PHP, XML, MySQL, JavaScript & ASP, we can develop whatever it is you need to get your site just the way you like it.<br/><br/>" +
                        "<b>Web & Layout Design</b> - Not only can we help with your development needs but we will also design any sized site from the ground up or add/update an existing site. From just a logo, to the whole page we can work with you to determine what you have in mind and work to recreate your ideas for you. Using a combination of technologies such as: HTML, CSS, JavaScript, Photoshop & Flash.<br/><br/>" +
                        "<b>Custom Code</b> - Are your needs not web based? That's ok, we can help with this too. We are skilled in many other non web based technologies as well. Whether you need a consult to fix existing code or need something custom created, we can help. More knowledgable technologies: AJAX, Visual Basic, JAVA, Windows Batch, VBScript & KornShell Scripting.<br/><br/><br/>" +
                        "" +
                        "<img style='float:right;' src='layout/info-latest.png' /><br/><br/>" +
                        "<span class='intro-latest'>none...</span><br/><br/>";
      myArrow.style.top = "92px";
      myArrow.style.visibility = "visible";
      break; 
    case 3:
      var myIntro = document.getElementById('abt');
      myIntro.src='layout/2-intro-abt-2.png';
      var myIntro = document.getElementById('serv');
      myIntro.src='layout/2-intro-serv-2.png';
      var myIntro = document.getElementById('blog');
      myIntro.src='layout/2-intro-blog-3.png';
      var myIntro = document.getElementById('port');
      myIntro.src='layout/2-intro-port-2.png';
      var myIntro = document.getElementById('more');
      myIntro.src='layout/2-intro-more-2.png';
      new Effect.Opacity('intro-right', { from: 0, to: 1 });
      new Effect.Opacity('introarrow', { from: 0, to: 1 });
      myTab.innerHTML = "<img src='layout/info-weblog.png' /><br/><br/>" +
                        "This is my blog. There will be a barrage of topics. From technology & programming to cooking & reviews. Anything that catches my fancy or attention might appear here.<br/><br/>" +
                        "This blog is not intended strictly for work or my web design services. There will also be personal content, pop culture, news, music and so on. Please feel welcome to sign up for an account and comment.<br/><br/><br/>" +
                        "<img style='float:right;' src='layout/info-latest.png' /><br/><br/>" +
                        "<span class='intro-latest'><a href='http://blog.designsbychace.com/?p=360'>It's that time again!</a> on 2010-01-23 03:09:08 is about 90 days away from this years March of Dimes...<br/>" +
                        "<a href='http://blog.designsbychace.com/?p=353'>10 Books Deal</a> on 2009-11-17 05:52:59 Hi all. Just recently I realized a couple things about myself...<br/>" +
                        "<a href='http://blog.designsbychace.com/?p=350'>Commenters beware!</a> on 2009-10-23 06:02:47 Hello All -- Just a quick post so you know if you've posted a...<br/>" +
                        "<a href='http://blog.designsbychace.com/?p=329'>VBScript Error Trapping</a> on 2009-10-22 00:02:42 Below is a very basic way to check for error's...<br/>" +
                        "<a href='http://blog.designsbychace.com/?p=323'>Rocktober is here!!!</a> on 2009-10-01 22:47:31 Rockies win 9-2 today against the Brewers!! This means they...<br/></span>";
      myArrow.style.top = "166px";
      myArrow.style.visibility = "visible";
      break; 
    case 4:
      var myIntro = document.getElementById('abt');
      myIntro.src='layout/2-intro-abt-2.png';
      var myIntro = document.getElementById('serv');
      myIntro.src='layout/2-intro-serv-2.png';
      var myIntro = document.getElementById('blog');
      myIntro.src='layout/2-intro-blog-2.png';
      var myIntro = document.getElementById('port');
      myIntro.src='layout/2-intro-port-3.png';
      var myIntro = document.getElementById('more');
      myIntro.src='layout/2-intro-more-2.png';
      new Effect.Opacity('intro-right', { from: 0, to: 1 });
      new Effect.Opacity('introarrow', { from: 0, to: 1 });
      myTab.innerHTML = "<img src='layout/info-port.png' /><br/><br/>" +
                        "<b><a href='http://www.designsbychace.com/portfolio.php'>Featured Portfolio</a></b> - This is the main portfolio on this site. This will review past clients and projects that were used or published at some point. Mostly items work showcasing.<br/><br/>" +
                        "<b>Other Downloads</b> - Along with my resume I have other projects and pieces of code you may want to take a look at and use. These items can be found on the <a href=''>downloads</a> page of the site and in my <a href=''>blog</a> posts.<br/><br/>" +  
                        "<b>Current Projects</b> - These are things that I am testing or in the middle of developing. Basically things that are in progress.<br/><br/><br/>" +
                        "<img style='float:right;' src='layout/info-latest.png' /><br/><br/>" +
                        "<span class='intro-latest'>Added mixtape covers on 06/20/10...</span><br/>" +
                        "<span class='intro-latest'>Added flyer/poster on 04/23/10...</span><br/>" +
                        "<span class='intro-latest'>Updated professional resume on 02/14/10...</span><br/><br/>";
      myArrow.style.top = "246px";
      myArrow.style.visibility = "visible";
      break;
    case 5:
      var myIntro = document.getElementById('abt');
      myIntro.src='layout/2-intro-abt-2.png';
      var myIntro = document.getElementById('serv');
      myIntro.src='layout/2-intro-serv-2.png';
      var myIntro = document.getElementById('blog');
      myIntro.src='layout/2-intro-blog-2.png';
      var myIntro = document.getElementById('port');
      myIntro.src='layout/2-intro-port-2.png';
      var myIntro = document.getElementById('more');
      myIntro.src='layout/2-intro-more-3.png';
      new Effect.Opacity('intro-right', { from: 0, to: 1 });
      new Effect.Opacity('introarrow', { from: 0, to: 1 });
      myTab.innerHTML = "<img src='layout/info-more.png' /><br/><br/>" +
                        "Last is the collection of leftovers that don't fall into any other category on the site.<br/><br/>" +
                        "Some of the items you'll find in the more section are: downloads, photos of various things, funny things, music, tutorials on various topics not restricted to computers, recipes, my resume, games and much more!<br/><br/>" +
                        "This is the place to go if you can't find what you're after from any of the main pages on the site.<br/><br/>" +
                        "If there is something you'd like to see here please don't hesitate to contact me with your request. Of course just because you ask doesn't always mean it will happy. As the great philosopher Jagger said, \"You can't always get what you want.\" ;)<br/><br/><br/>" +
                        "<img style='float:right;' src='layout/info-latest.png' /><br/><br/>" +
                        "<span class='intro-latest'>Updated professional resume on 02/14/10...</span><br/><br/><br/>";
      myArrow.style.top = "320px";
      myArrow.style.visibility = "visible";
      break;  
  }
}

function switchPort(tab) {
  var myTab = document.getElementById("port-right");
  switch (tab) {
    case 1:
      document.getElementById("weiser").setAttribute("class", "port_list_on");
      document.getElementById("flywater").setAttribute("class", "port_list");
      document.getElementById("cpc").setAttribute("class", "port_list");
      document.getElementById("senior").setAttribute("class", "port_list");
      document.getElementById("ads").setAttribute("class", "port_list");
      new Effect.Opacity('port-right', { from: 0, to: 1 });
      myTab.innerHTML = "<span class='port_bold'>Technologies Used</span><br/>" +
                        "html, css, photoshop, php, mysql<br/><br/>" +    
                        "<span class='port_bold'>Roots</span><br/>" +
                        "My Aunt approached me with the idea of a Christmas gift for her husband. He had owned and ran an insurance business for many years and never had a website. She asked if I could whip something up for him before Christmas in 2007 and this is the results. I still need to finish the backend administration access so that he can update the news posts on the site from his office.<br/><br/>" +
                        "<span class='port_bold'>Thought Process</span><br/>" +
                        "Once again the idea behind this site was to keep it simple. A majority of the visitors would need a straight forward, easily navigated website. As you can see the designs is about as simple as it can get, with not much distraction. The images were taken by my Aunt and sent to me, in which I tried to do as much touch up as possible, including using the original stick-man figure in the header of the site, which I think turned out nicely.<br/><br/>" +
                        "<div class='port_screenshots' id='weiser4'>" +
                        "<a class='image' href=\"portfolio/Weiser_001.png\" rel=\"lightbox[weiser]\" title=\"This is the Weiser Agency's Services Page\"><img class='myimage' src='portfolio/Weiser_001_tn.jpg' title='' border=\"1\" /></a>&nbsp;" +
                        "<a class='image' href=\"portfolio/Weiser_002.png\" rel=\"lightbox[weiser]\" title=\"This is the Weiser Agency's Home Page\"><img class='myimage' src='portfolio/Weiser_002_tn.jpg' title='' border=\"1\" /></a>" +
                        "</div>";
      break;
    case 2:
      document.getElementById("weiser").setAttribute("class", "port_list");
      document.getElementById("flywater").setAttribute("class", "port_list_on");
      document.getElementById("cpc").setAttribute("class", "port_list");
      document.getElementById("senior").setAttribute("class", "port_list");
      document.getElementById("ads").setAttribute("class", "port_list");
      new Effect.Opacity('port-right', { from: 0, to: 1 });
      myTab.innerHTML = "<span class='port_bold'>Technologies Used</span><br/>" +
                    	  "html, css, photoshop<br/><br/>" +
                    	  "<span class='port_bold'>Roots</span><br/>" +
                    	  "This website was designed for my father, who was the president of the Construction division of Flywater Consulting. There were three divisions: Consulting, Engineering & Construction. The consulting and engineering divisions already had a website but didn't have the ability to update it with the construction piece so I was contracted to build it. While this site has not been updated in some time, this is due to the fact that my father is no longer in this current position and therefore there is no longer a Flywater Construction.<br/><br/>" +
                    	  "<span class='port_bold'>Thought Process</span><br/>" +
                    	  "The idea behind the site was to keep it simple and easy to use for possible clientele, some of which might not be accustomed to the internet or tricky navigational schemes. It is a very simple layout but effective. All of the pictures on the site were taken either by me or my father, including the imagery in the headers.<br/><br/>" +
                        "<div class='port_screenshots' id='flywater4'>" +
                    	  "<a class='image' href=\"portfolio/Flywater_001.png\" rel=\"lightbox[flywater]\" title=\"This is Flywater Constructions Homepage\"><img class='myimage' src='portfolio/Flywater_001_tn.jpg' title='' border=\"1\" /></a>&nbsp;" +
                    	  "<a class='image' href=\"portfolio/Flywater_002.png\" rel=\"lightbox[flywater]\" title=\"This is the Contact Page of Flywater Construction\"><img class='myimage' src='portfolio/Flywater_002_tn.jpg' title='' border=\"1\" /></a>&nbsp;" +
                    	  "<a class='image' href=\"portfolio/Flywater_003.png\" rel=\"lightbox[flywater]\" title=\"This is the Projects Page of Flywater Construction\"><img class='myimage' src='portfolio/Flywater_003_tn.jpg' title='' border=\"1\" /></a>" +
                        "</div>";
      break; 
    case 3:
      document.getElementById("weiser").setAttribute("class", "port_list");
      document.getElementById("flywater").setAttribute("class", "port_list");
      document.getElementById("cpc").setAttribute("class", "port_list_on");
      document.getElementById("senior").setAttribute("class", "port_list");
      document.getElementById("ads").setAttribute("class", "port_list");
      new Effect.Opacity('port-right', { from: 0, to: 1 });
      myTab.innerHTML = "<span class='port_bold'>Technologies Used</span><br/>" +
                  "html, css, flash, javascript, mysql, php, ajax, sql<br/><br/>" +
                  "<span class='port_bold'>Roots</span><br/>" +
                  "This website was created for a chain of local Pub's all over the Denver Metro area. There are six Pubs in all, and each one worth their weight. I earned this project actually when I was working as a server and bartender at Casey's their pub in East Denver in Stapleton. I worked there as I finished my degree. I originally created caseysbistro.com for the Pub solely. A co-owner of Casey's referred me to the Company that owned Casey's (skylarhospitality.com) and not only did the website expand to the five existing websites at the time, I also do odd job IT work for the company to this day. They just recently opened a new Pub and pizza joint in the heart of Denver University's campus called Jordan's. Unfortunately Colorado Pub Company is no more. They have hired someone solely for doing their websites, which are now separate entities for each pub.<br/><br/>" +
                  "<span class='port_bold'>Thought Process</span><br/>" +
                  "The idea of this site, despite being in the process of being reconstructed, was influenced by my client to give the color schema, size and display value (as it should be). The idea was to have the pubs at the forefront and carried throughout all the pages, but more than just your common header, a little extra was desired, hints the flash header that is in an iframe at the top of all pages. The design is currently being updated with some newer technologies, primarily the back-end which was created for this site, but there will be some noticeable graphical and aesthetic changes as well to the front-end.<br/><br/>" +
                  "<span class='port_bold'>Back-end</span><br/>" +
                  "The back-end was built for the company Managers, Owners or Office Assistant to update each Pub's event's, menu's and job opening's as well as send mass e-mails to Pub Club members and manage Pub Club members information as well as add or remove them. It is going to be drastically enhanced with the use of Ajax and some other minor tweaks here and there. The best part about the new back-end is it was programmed to be transported with relative ease.<br/><br/>" +
                  "<div class='port_screenshots' id='cpc5'>" +
                  "<a class='image' href=\"portfolio/CPC_001.png\" rel=\"lightbox[cpc]\" title=\"This is the Welcom/Splash screen for Colorado Pub Company\"><img class='myimage' src=\"portfolio/CPC_001_tn.jpg\" /></a>&nbsp;" +
                  "<a class='image' href=\"portfolio/CPC_002.png\" rel=\"lightbox[cpc]\" title=\"This is the Casey's Pub's Events Menu\"><img class='myimage' src=\"portfolio/CPC_002_tn.jpg\" /></a>&nbsp;" +
                  "<a class='image' href=\"portfolio/CPC_003.png\" rel=\"lightbox[cpc]\" title=\"This is the Darcy's Pub Food Menu\"><img class='myimage' src=\"portfolio/CPC_003_tn.jpg\" /></a>&nbsp;" +
                  "<a class='image' href=\"portfolio/CPC_004.png\" rel=\"lightbox[cpc]\" title=\"This is the Backend Control Panel\"><img class='myimage' src=\"portfolio/CPC_004_tn.jpg\" /></a>&nbsp;" +
                  "<a class='image' href=\"portfolio/CPC_005.png\" rel=\"lightbox[cpc]\" title=\"This is the Backend Menu Control\"><img class='myimage' src=\"portfolio/CPC_005_tn.jpg\" /></a>&nbsp;" +
                  "<a class='image' href=\"portfolio/CPC_006.png\" rel=\"lightbox[cpc]\" title=\"This is the Backend Login Screen\"><img class='myimage' src=\"portfolio/CPC_006_tn.jpg\" /></a>" +
                  "</div>";
      break; 
    case 4:
      document.getElementById("weiser").setAttribute("class", "port_list");
      document.getElementById("flywater").setAttribute("class", "port_list");
      document.getElementById("cpc").setAttribute("class", "port_list");
      document.getElementById("senior").setAttribute("class", "port_list_on");
      document.getElementById("ads").setAttribute("class", "port_list");
      new Effect.Opacity('port-right', { from: 0, to: 1 });
      myTab.innerHTML = "<span class='port_bold'>Technologies Used</span><br/>" +

                	  "photoshop, MS Access, SQL, JAVA<br/><br/>" +

                	  "<span class='port_bold'>Roots</span><br/>" +

                	  "This was my college senior project. We had team senior projects so this was done in a group of four people; however I primarily did virtually all the programming myself and not much of the business plan... ;)<br/><br/>" +

                	  "<span class='port_bold'>Thought Process</span><br/>" +

                	  "The idea behind the project was to make a client/contract matching system to house clients, contractors and the contracts and to generated matches for contracts based on skill sets. The overall project turned out pretty slick and we received an A+. You can download the .zip of the code and the build if you want to play around with it below.<br/><br/>" +

                	  "<span class='port_bold'>Download</span><br/>" +

                	  "<a href='../../downloads/GCConceptsFinal.zip'>GCConcepts.zip</a> - This is the source code and all. Once you extract the zip file, you must copy the contents of the 'ToTheC' folder to the 'C:\' directory because that is where the java is coded to look for these files.<br/><br/>" +

                    "<div class='port_screenshots' id='senior5'>" +
                	  "<a class='image' href=\"portfolio/senior_001.png\" rel=\"lightbox[senior]\" title=\"\"><img class='myimage' src='portfolio/senior_001_tn.jpg' title='' border=\"1\" /></a>&nbsp;" +
                	  "<a class='image' href=\"portfolio/senior_002.png\" rel=\"lightbox[senior]\" title=\"\"><img class='myimage' src='portfolio/senior_002_tn.jpg' title='' border=\"1\" /></a>&nbsp;" +
                	  "<a class='image' href=\"portfolio/senior_003.png\" rel=\"lightbox[senior]\" title=\"\"><img class='myimage' src='portfolio/senior_003_tn.jpg' title='' border=\"1\" /></a>&nbsp;" +
                	  "<a class='image' href=\"portfolio/senior_004.png\" rel=\"lightbox[senior]\" title=\"\"><img class='myimage' src='portfolio/senior_004_tn.jpg' title='' border=\"1\" /></a>&nbsp;" +
                	  "<a class='image' href=\"portfolio/senior_005.png\" rel=\"lightbox[senior]\" title=\"\"><img class='myimage' src='portfolio/senior_005_tn.jpg' title='' border=\"1\" /></a>&nbsp;" +
                	  "<a class='image' href=\"portfolio/senior_006.png\" rel=\"lightbox[senior]\" title=\"\"><img class='myimage' src='portfolio/senior_006_tn.jpg' title='' border=\"1\" /></a>&nbsp;" +
                	  "<a class='image' href=\"portfolio/senior_007.png\" rel=\"lightbox[senior]\" title=\"\"><img class='myimage' src='portfolio/senior_007_tn.jpg' title='' border=\"1\" /></a>&nbsp;" +
                	  //"<a class='image' href=\"portfolio/senior_008.png\" rel=\"lightbox[senior]\" title=\"\"><img class='myimage' src='portfolio/senior_008_tn.jpg' title='' border=\"1\" /></a>&nbsp;" +
                	  "<a class='image' href=\"portfolio/senior_009.png\" rel=\"lightbox[senior]\" title=\"\"><img class='myimage' src='portfolio/senior_009_tn.jpg' title='' border=\"1\" /></a>" +
                    "</div>";
      break; 
    case 5:
      document.getElementById("weiser").setAttribute("class", "port_list");
      document.getElementById("flywater").setAttribute("class", "port_list");
      document.getElementById("cpc").setAttribute("class", "port_list");
      document.getElementById("senior").setAttribute("class", "port_list");
      document.getElementById("ads").setAttribute("class", "port_list_on");
      new Effect.Opacity('port-right', { from: 0, to: 1 });
      myTab.innerHTML = "<span class='port_bold'>Whiskey River & Thomas Tha Franchise</span><br/>" +
                	  "A flyer & poster to advertise for an upcoming event.<br/>" +
                    "<div class='port_screenshots' id='senior5'>" +
                	  "<a class='image' href=\"portfolio/thomas-whiskeyriver.png\" rel=\"lightbox[ads]\" title=\"\"><img class='myimage' src='portfolio/thomas-whiskeyriver_tn.png' title='' border=\"1\" /></a>&nbsp;" +
                    "</div><br/>" +
                    "<span class='port_bold'>OMG_ITS_TTF Mixtape Covers</span><br/>" +
                	  "A mixtape cover and back to Thomas tha Franchise's new mixtape, released June 19th, 2010.<br/>" +
                    "<div class='port_screenshots' id='senior5'>" +
                    "<a class='image' href=\"portfolio/omgitsttf-cover-sample2.jpg\" rel=\"lightbox[ads]\" title=\"\"><img class='myimage' src='portfolio/omgitsttf-cover-sample2_tn.jpg' title='' border=\"1\" /></a>&nbsp;" +
                	  "<a class='image' href=\"portfolio/omgitsttf-inside-sample1.jpg\" rel=\"lightbox[ads]\" title=\"\"><img class='myimage' src='portfolio/omgitsttf-inside-sample1_tn.jpg' title='' border=\"1\" /></a>&nbsp;" +
                    "</div>";
      break; 
  }
}

function toggleIntro(introID) {
  var myIntro = document.getElementById(introID);
  switch (introID) {
    case 'abt':
      tmpVar = myIntro.src;
      if ((tmpVar.substring((tmpVar.length-5), (tmpVar.length-4))) == 2) {
        myIntro.src='layout/2-intro-abt.png';
      } else if ((tmpVar.substring((tmpVar.length-5), (tmpVar.length-4))) == 3) {
        myIntro.src='layout/2-intro-abt.png';
      } else {
        myIntro.src='layout/2-intro-abt-2.png';
      }
      break;
    case 'serv':
      tmpVar = myIntro.src;
      if ((tmpVar.substring((tmpVar.length-5), (tmpVar.length-4))) == 2) {
        myIntro.src='layout/2-intro-serv.png';
      } else if ((tmpVar.substring((tmpVar.length-5), (tmpVar.length-4))) == 3) {
        myIntro.src='layout/2-intro-serv.png';
      } else {
        myIntro.src='layout/2-intro-serv-2.png';
      }
      break;
    case 'blog':
      tmpVar = myIntro.src;
      if ((tmpVar.substring((tmpVar.length-5), (tmpVar.length-4))) == 2) {
        myIntro.src='layout/2-intro-blog.png';
      } else if ((tmpVar.substring((tmpVar.length-5), (tmpVar.length-4))) == 3) {
        myIntro.src='layout/2-intro-blog.png';
      } else {
        myIntro.src='layout/2-intro-blog-2.png';
      }
      break;
    case 'port':
      tmpVar = myIntro.src;
      if ((tmpVar.substring((tmpVar.length-5), (tmpVar.length-4))) == 2) {
        myIntro.src='layout/2-intro-port.png';
      } else if ((tmpVar.substring((tmpVar.length-5), (tmpVar.length-4))) == 3) {
        myIntro.src='layout/2-intro-port.png';
      } else {
        myIntro.src='layout/2-intro-port-2.png';
      }
      break;
    case 'more':
      tmpVar = myIntro.src;
      if ((tmpVar.substring((tmpVar.length-5), (tmpVar.length-4))) == 2) {
        myIntro.src='layout/2-intro-more.png';
      } else if ((tmpVar.substring((tmpVar.length-5), (tmpVar.length-4))) == 3) {
        myIntro.src='layout/2-intro-more.png';
      } else {
        myIntro.src='layout/2-intro-more-2.png';
      }
      break;
  }
}
 
function sendReg() {
  alert("working on this!");
}

function showAdmin(pid) {
	var myAdmin = document.getElementById("admin_panel"+pid);
	if (myAdmin.style.display=="inline") {
    myAdmin.style.display="none";
  } else {
    myAdmin.style.display="inline";
  }
  //alert(myBox);
}

// fade new post message
function fadePost(postid) {
  var ver = getInternetExplorerVersion();
  if (ver > -1) {
    if (ver >= 8.0) {
    
    }
  } else {
    var postArray = document.getElementsByName("mypost"+postid);
    var wrapArray = document.getElementsByName("mywrap"+postid);
    var boxFix1 = document.getElementsByName("xb1"+postid);
    var boxFix2 = document.getElementsByName("xb2"+postid);
    var boxFix3 = document.getElementsByName("xb3"+postid);
    var boxFix4 = document.getElementsByName("xb4"+postid);
  
    new Effect.Appear(wrapArray.item(0), {duration: 1.0});
    new Effect.Highlight(boxFix1.item(0), {startcolor:'#ffff99',endcolor:'#BBDAFF',duration:2.0});
    new Effect.Highlight(boxFix2.item(0), {startcolor:'#ffff99',endcolor:'#EEEEFF',duration:2.0});
    new Effect.Highlight(boxFix3.item(0), {startcolor:'#ffff99',endcolor:'#EEEEFF',duration:2.0});
    new Effect.Highlight(boxFix4.item(0), {startcolor:'#ffff99',endcolor:'#EEEEFF',duration:2.0});
    new Effect.Highlight(boxFix1.item(1), {startcolor:'#ffff99',endcolor:'#BBDAFF',duration:2.0});
    new Effect.Highlight(boxFix2.item(1), {startcolor:'#ffff99',endcolor:'#EEEEFF',duration:2.0});
    new Effect.Highlight(boxFix3.item(1), {startcolor:'#ffff99',endcolor:'#EEEEFF',duration:2.0});
    new Effect.Highlight(boxFix4.item(1), {startcolor:'#ffff99',endcolor:'#EEEEFF',duration:2.0});
    new Effect.Highlight(postArray.item(0), {startcolor:'#ffff99',endcolor:'#EEEEFF',duration:2.0});
  }

}

function getInternetExplorerVersion() {
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer') {
    var ua = navigator.userAgent;
    var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null) rv = parseFloat(RegExp.$1);
  }
  return rv;
}

// displays a message
function displayMessage(message,posts,pid,postid) {
  var postArr = document.getElementsByName("mypost"+postid);
  if (postArr.length == 0) {
    // get the scroll object
    var oScroll = document.getElementById("scroll"+pid);
    vTemp = oScroll.innerHTML.String;
    oScroll.innerHTML = message + oScroll.innerHTML;
    fadePost(postid);
  } else {
    //alert("it tried again!");
  }
}

// function that displays an error message
function displayError(message,id,pid){
  //okID = pid.item(0).firstChild.data.toString();
  var myInfo = document.getElementById("myInfo"+pid);
  // display error message, with more technical details if debugMode is true
  myInfo.innerHTML = "There was an error! " + "<br/>" + message + "<br/>" + id + "<br/>" + pid;
  cacheA.shift();
}

/* handles keydown to detect when enter is pressed */
 
function handleKey(e) {

}

/* removes leading and trailing spaces from the string */
function trim(s) {
    return s.replace(/(^\s+)|(\s+$)/g, "");
}

String.prototype.replaceAll = function(strTarget,	strSubString){
	var strText = this;
	var intIndexOfMatch = strText.indexOf( strTarget );

	while (intIndexOfMatch != -1){
		strText = strText.replace( strTarget, strSubString )
		intIndexOfMatch = strText.indexOf( strTarget );
	}
	return( strText );
}
