<!--

// Check for mobile device -----------------------------------------

var user_is_mobile = false;
(function(a,b){if(/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))user_is_mobile=true})(navigator.userAgent||navigator.vendor||window.opera,'http://detectmobilebrowser.com/mobile');

// domtap utility -----------------------------------------

function domtap(id) {
  var obj;
  var fullDoc = document;
  if (typeof(id)=='string') {
    if (id.indexOf('.')==-1) {
      obj = (fullDoc.getElementById) ? fullDoc.getElementById(id) : fullDoc.all[id];
    } else {
      var mainId = id.substr(0,id.indexOf('.'));
      var dots = 0;
      var startAt = 0;
      var propertyName = new Array();
      while (id.indexOf('.',startAt)>-1) {
        propertyName[dots] = id.substr(
                                       id.indexOf('.',startAt)+1,
                                       id.indexOf('.',id.indexOf('.',startAt))
                                        - id.indexOf('.',startAt)
                                        - 1
                                      )
        startAt = id.indexOf(propertyName[dots]) + 1;
        dots++;
      }
      obj = (fullDoc.getElementById) ? fullDoc.getElementById(mainId) : fullDoc.all[mainId];
      for (var j=0;j<propertyName.length;j++) {
        obj = obj[propertyName[j]];
      }
    }
  } else if (is_def(id) && id!=null) {
    obj = id;
  }
  return obj;
}

// Cookie functions -----------------------------------------

function makeCookie(name,value,duration) {
  if (duration) {
    var exp_date = new Date();
    exp_date.setTime(exp_date.getTime()+(duration*24*60*60*1000));
    var expiration = "; expires=" + exp_date.toGMTString();
  } else var expiration = "";
  document.cookie = name + "=" + value + expiration + "; path=/";
}

function checkCookie(name) {
  var name_string = name + "=";
  var all_cookies = document.cookie.split(';');
  for(var i=0;i < all_cookies.length;i++) {
    var single_cookie = all_cookies[i];
    while (single_cookie.charAt(0)==' ') single_cookie = single_cookie.substring(1,single_cookie.length);
    if (single_cookie.indexOf(name_string) == 0) return single_cookie.substring(name_string.length,single_cookie.length);
  }
  return null;
}

function clearCookie(name) {
  makeCookie(name,"",-1);
}

// Image functions -----------------------------------------

function img_setsrc() {
  if (document.images) {
    for (i=0; i<img_setsrc.arguments.length; i+=2) {
      if (typeof(img_setsrc.arguments[i])=='string')
        document[img_setsrc.arguments[i]].src = img_setsrc.arguments[i+1];
      else
        img_setsrc.arguments[i].src = img_setsrc.arguments[i+1];
    }
  }
}

function img_preload() {
  if (document.images) {
    var numImages = img_preload.arguments.length;
    var imageToPreload = new Array(numImages);
    for (i=0; i<numImages; i++) {
      imageToPreload[i] = new Image();
      imageToPreload[i].src = img_preload.arguments[i];
    }
  }
}

// Styling functions -----------------------------------------

function bufoStyleSmallNums(el) {
  if (!el) el = document.getElementsByTagName('BODY')[0];
  else el = document.getElementById(el);
  var elContent = el.innerHTML;
  var pointer = 0;
  var digits = '0123456789';
  var cData = true;
  var bufoStyled = true;
  var bufoNotUserText = true;
  do {
    if (elContent.charAt(pointer)=='<') cData = false;
    if (elContent.charAt(pointer)=='>') cData = true;
    if (elContent.substr(pointer,5).toLowerCase()=='<dfn>') bufoStyled = false;
    if (elContent.substr(pointer,6).toLowerCase()=='</dfn>') bufoStyled = true;
    if (elContent.substr(pointer,10).toLowerCase()=='<textarea ') bufoNotUserText = false;
    if (elContent.substr(pointer,11).toLowerCase()=='</textarea>') bufoNotUserText = true;
    if (cData && bufoStyled && bufoNotUserText) {
      if (digits.indexOf(elContent.charAt(pointer))>-1) {
        var startIt = pointer;
        var howFar = 0;
        for (var i=startIt; i<elContent.length; i++) {
          if (digits.indexOf(elContent.charAt(i))>-1) {
            howFar++;
          } else {
            break;
          }
        }
        var styleNum = '<var>' + elContent.substr(startIt,howFar) + '</var>';
        var firstPortion = elContent.substr(0,pointer);
        var secondPortion = elContent.substr(pointer+howFar);
        elContent = firstPortion + styleNum + secondPortion;
        pointer += styleNum.length;
      } else pointer++;
    } else pointer++;
  } while (pointer<elContent.length);
  el.innerHTML = elContent;
}

// Home page switches -----------------------------------------

switchName = new Array('Geoph Essex', 'Jeff Essex', 'Semper Bufo');
switchSkill = new Array('a writer', 'an artist', 'a cartoonist', 'an illustrator', 'a digital artist', 'a 3D graphic artist', 'a graphic designer', 'a web developer', 'a programmer', 'a game designer', 'an animator', 'a video editor', 'a photographer', 'a filmmaker', 'an audio editor', 'a sound artist', 'a songwriter', 'a musician', 'a singer', 'an actor', 'a creator', 'a scientist', 'a teacher', 'a thinker', 'an adventurer');
switchSite = new Array('website', 'portfolio', 'gallery', 'r&eacute;sum&eacute;', 'demo', 'place');
switchWelcome = new Array('Fasten your seatbelt and put a drink on your tray table', 'Due to bandwidth considerations, you must be this tall to surf this site', 'Have some tea biscuits and some biscuit tea', "Please don't feed the scurffs", 'You are encouraged to touch the art', 'Warning: ambidexterity may be contagious', 'Imagine, if you will, the square root of negative one', 'This site looks best in the key of D-flat major', 'This text is actual size', 'Your singular repository of sesquipedalianism within the confines of the interconnective technological data-driven environment', 'Beware of falling anvils. In general, I mean');
var switchNamePt = Math.floor(Math.random()*(switchName.length));
if (switchNamePt>=switchName.length) switchNamePt = switchName.length - 1;
var switchSkillPt = Math.floor(Math.random()*(switchSkill.length));
if (switchSkillPt>=switchSkill.length) switchSkillPt = switchSkill.length - 1;
var switchSitePt = Math.floor(Math.random()*(switchSite.length));
if (switchSitePt>=switchSite.length) switchSitePt = switchSite.length - 1;
var switchWelcomePt = Math.floor(Math.random()*(switchWelcome.length));
if (switchWelcomePt>=switchWelcome.length) switchWelcomePt = switchWelcome.length - 1;
function bufoHomeSwitches() {
  document.getElementById('switch_name').innerHTML = switchName[switchNamePt];
  document.getElementById('switch_skill').innerHTML = switchSkill[switchSkillPt];
  document.getElementById('switch_site').innerHTML = switchSite[switchSitePt];
  var nameFirstPause = (Math.random()*500) + 500;
  setTimeout('bufoHomeSwitchName()', nameFirstPause);
  var skillFirstPause = (Math.random()*500) + 500;
  setTimeout('bufoHomeSwitchSkill()', skillFirstPause);
  var siteFirstPause = (Math.random()*500) + 500;
  setTimeout('bufoHomeSwitchSite()', siteFirstPause);
  document.getElementById('switch_welcome').innerHTML = switchWelcome[switchWelcomePt];
}
function bufoHomeSwitchName() {
  switchNamePt++;
  if (switchNamePt>=switchName.length) switchNamePt = 0;
  document.getElementById('switch_name').innerHTML = switchName[switchNamePt];
  bufoStyleSmallNums('switch_name');
  var nextPause = (Math.random()*4500) + 1000;
  setTimeout('bufoHomeSwitchName()', nextPause);
}
function bufoHomeSwitchSkill() {
  switchSkillPt++;
  if (switchSkillPt>=switchSkill.length) switchSkillPt = 0;
  document.getElementById('switch_skill').innerHTML = switchSkill[switchSkillPt];
  bufoStyleSmallNums('switch_skill');
  var nextPause = (Math.random()*2500) + 1000;
  setTimeout('bufoHomeSwitchSkill()', nextPause);
}
function bufoHomeSwitchSite() {
  switchSitePt++;
  if (switchSitePt>=switchSite.length) switchSitePt = 0;
  document.getElementById('switch_site').innerHTML = switchSite[switchSitePt];
  bufoStyleSmallNums('switch_site');
  var nextPause = (Math.random()*3000) + 1000;
  setTimeout('bufoHomeSwitchSite()', nextPause);
}

function bufoErrorSwitches() {
  switchError = new Array('Have a blast. Bring marshmallows. (They help you get past the three-headed dog on the second level.)', "Don't worry. It's not rocket science. Unless you're a rocket scientist. In which case, please get in touch &mdash; I've got some requests.", "Or where you <i>should</i> be. Which can be different things, if you think of it from a broader, more epistemological point of view.", "Please don't think for a moment that this error reflects you as a person. It totally doesn't. You rock.", "If you click the right button, a chocolate bar will pop out of your <kbd>USB</kbd> port. (Offer void everywhere.)", "We all make misteaks. See?");
  var switchErrorPt = Math.floor(Math.random()*(switchError.length));
  if (switchErrorPt>=switchError.length) switchErrorPt = switchError.length - 1;
  document.getElementById('switch_errorquip').innerHTML = switchError[switchErrorPt];
}

// Retractable menu functions -----------------------------------------

var menuIsLocked = false;
if (checkCookie('bufoMenuLock')=='yes') menuIsLocked = true;
else clearCookie('bufoMenuLock');
var menuIsMoving = false;
var menuRetractTo = -106;
var menuOpenTo = 0;
var menuSpeed = 5;
function menuInit() {
  document.getElementById('sidebarTab').style.visibility = 'visible';
}
function menuLock() {
  menuIsLocked = (menuIsLocked) ? false : true;
  if (menuIsLocked) makeCookie('bufoMenuLock','yes',90);
  else clearCookie('bufoMenuLock');
  menuIsMoving = "open";
  menuMovement("open");
}
function menuMovement(act) {
  if (act=="open" && menuIsMoving=="open") {
    var curLeft = parseInt(document.getElementById('sidebarMenu').style.left) + menuSpeed;
    if (curLeft<menuOpenTo) {
      document.getElementById('sidebarMenu').style.left = ''+curLeft+'px';
      setTimeout("menuMovement('"+act+"')",1);
    } else {
      document.getElementById('sidebarMenu').style.left = ''+menuOpenTo+'px';
      menuIsMoving = false;
    }
  }
  if (act=="retract" && menuIsMoving=="retract" && !menuIsLocked) {
    var curLeft = parseInt(document.getElementById('sidebarMenu').style.left) - menuSpeed;
    if (curLeft>menuRetractTo) {
      document.getElementById('sidebarMenu').style.left = ''+curLeft+'px';
      setTimeout("menuMovement('"+act+"')",1);
    } else {
      document.getElementById('sidebarMenu').style.left = ''+menuRetractTo+'px';
      menuIsMoving = false;
    }
  }
}

// Select box selector -----------------------------------------

function set_selectindex(id,index) {
  domtap(id).selectedIndex = index;
}

// Copyright -----------------------------------------

function gen_copyrightYear(creationYear,extendDate,finalYear) {
  var currentDate = new Date();
  var currentYear = currentDate.getYear();
  if (typeof(creationYear)!='number')
    creationYear = currentYear;
  var copyrightString = '&copy;'+creationYear.toString();
  if (currentYear < 2000)
    currentYear = currentYear + 1900;
  var lastYear = (typeof(finalYear)=='number' && finalYear<currentYear) ?
    finalYear :
    currentYear;
  if (lastYear>creationYear && extendDate==true)
    copyrightString += '-'+lastYear;
  copyrightString += ' ';
  return copyrightString;
}

// Captcha -----------------------------------------

function refreshCaptchaBox() {
  var captchaTime = new Date();
  var captchaMS = captchaTime.getTime();

  document.getElementById('bufo_captcha_image').src = 'func/bufocapimage.php?x='+ captchaMS;
}

//-->

