if(typeof String.prototype.trim!=='function'){String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,'');}}
function $2(e){var d=document;if(typeof e=='string'){if(d.getElementById){e=d.getElementById(e);}else if(d.all){e=d.all[name];}else if(d.layers){e=d.layers[name];}}return e;}
function addOnLoad(f){if(window.onload){var o=window.onload;window.onload=function(){o();f();};}else{window.onload=f;}}
function getMouseX(e){e=e?e:window.event;return e.pageX?e.pageX:(e.clientX?e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft:0);}
function indexOf(a,o){for(var i=0;i<a.length;i++){if(a[i]==o){return i;}}return -1;}
function contains(a,o){return indexOf(a,o)>=0;}
function remove(a,o) {var i=indexOf(a,o);return(i>=0)?a.slice(i,1):a;}
function hasClass(x,c){return x.className.match(new RegExp('\\b'+c+'\\b','i'));}
function addClass(x,c){x.className+=' '+c;}
function removeClass(x,c){x.className=x.className.replace(new RegExp('\\b'+c+'\\b','gi'),'').trim();}
function toggleClass(x,c){var b=hasClass(x,c);b?removeClass(x,c):addClass(x,c);return !b;}
function toggleHidden(n){n=$2(n);if(n){toggleClass(n,'hidden');}}
function toggleDisplay(n){n=$2(n);if(n){var d=n.style.display;n.style.display=(d&&d=='none')?'':'none';}}
function setDisplay(n,b){n=$2(n);if(n){n.style.display=b?'':'none';}}
function clamp(x,a,b){return(x<a?a:(x>b?b:x));}
function event_target(e){e=e?e:window.event;var t=e.target?e.target:e.srcElement;return(t.nodeType==3)?t.parentNode:t;}
function pageHeight(){var d=document;return window.innerHeight!=null?window.innerHeight:d.documentElement&&d.documentElement.clientHeight?d.documentElement.clientHeight:d.body!=null?d.body.clientHeight:null;}
function set_tag_visibility(n,h){var t=document.getElementsByTagName(n),i=t.length-1;for(;i>=0;i--)t[i].style.visibility=h;}
function toggle_objects(h){set_tag_visibility('SELECT',h);set_tag_visibility('IFRAME',h);set_tag_visibility('OBJECT',h);}
function for_all_with_tag_and_class(t,c,f) {var es=$2('content').getElementsByTagName(t),i,e,x=false;for(i=0,e;(e=es[i]);i++){if(hasClass(e,c)){f(e);x=true;}}return x;}

///// Preloading /////
var img=new Image();img.src='/images/black1.png';

///// Flash-Expander /////
var expandable,expander,expand_startWidth=0,expand_startPos=0,mouseIsUp=true,expand_heightAlso=false;
//set the initial position of the resize-bar
function expand_start(e){expand_startPos=getMouseX(e);expand_startWidth=parseInt(expandable.style.width.replace(/px/gi,''));mouseIsUp=false;}
//reset the position of the resize-bar when the mouse moves while button down
function create_expander(elem, expandHeightAlso){
  expandable = $2(elem);
  expandable.className += ' expandable';
  expandable.expandHeightAlso = expandHeightAlso;
  expander = document.createElement('div');
  expander.className = 'expander clearfix';
  expander.style.height = parseInt(expandable.style.height.replace(/px/gi,'')) + 'px';
  expander.onmousedown = expand_start;
  expandable.parentNode.insertBefore(expander, expandable.nextSibling);
  var clear = document.createElement('br');
  clear.style.clear = 'both';
  expander.parentNode.insertBefore(clear, expander.nextSibling);
}
document.onmousemove=function expand_update(e){if(!mouseIsUp){
  var newWidth = expand_startWidth + getMouseX(e) - expand_startPos;
  newWidth = clamp(newWidth,15,725)+'px';
  expandable.style.width = newWidth;
  if (expandable.expandHeightAlso) { expandable.style.height = expander.style.height = newWidth; }
}};
document.onmouseup=function(){mouseIsUp=true;};
addOnLoad(function(){for_all_with_tag_and_class('OBJECT','expandable',function(o){create_expander(o.parentNode,hasClass(o,'exp-both'))});});

///// Zoom Images /////
var close_keys = [8, 13, 27, 32, 88, 120];
function zoom_hide(){var o=$2('overlay');o.style.display='none';o.firstChild.nextSibling.src=null;toggle_objects('visible');document.onkeypress=document.onclick=null;}
function zoom_key_press(e){e=e?e:window.event;var k=e.keyCode?e.keyCode:e.which;if(contains(close_keys,k)){zoom_hide();return false;}}
function zoom(i){var o=$2('overlay'),s=i.getAttribute('full');o.firstChild.nextSibling.src=s?s:i.src;o.style.display='';document.onkeypress=zoom_key_press;setTimeout(function(){document.onclick=zoom_hide}, 0);}
addOnLoad(function(){
  if (for_all_with_tag_and_class('IMG','zoom',function(i){i.onclick=function(e){zoom(event_target(e));};})) {
    var o=document.createElement('div'),b=document.getElementsByTagName('BODY')[0];
    o.setAttribute('id','overlay');
    o.appendChild(document.createTextNode('\u00a0'));
    o.appendChild(document.createElement('img'));
    o.appendChild(document.createTextNode('\u00a0'));
    b.insertBefore(o, b.firstChild);
    o.style.display = 'none';
    o.style.lineHeight = (pageHeight()-1)+'px';
    window.onresize = function() { o.style.lineHeight = (pageHeight()-1)+'px'; }
  }
});

///// Projects Page Toggling /////
var best_on=true;
function toggleType(x) {
  var t = x.id.substr(4), on = !toggleClass(x, 'inactive'), bb = $2('browseboxes'), a = bb.firstChild;
  var re = new RegExp('\\b'+t+'\\b','i');
  while (a && a.tagName=='A') {
    if (on&&a.inactive&&contains(a.inactive,t)) {
      remove(a.inactive, t);
      a.name += ' '+t;
      if (!best_on || a.rev=='best') a.style.display = '';
    } else if (!on&&a.name.match(t)) {
      if (!a.inactive) { a.inactive = []; }
      a.inactive.push(t);
      a.name = a.name.replace(re,'').trim();
      if (!a.name) { a.style.display = 'none'; }
    }
    a = a.nextSibling;
  }
}
function toggleBest(x) {
  var bb = $2('browseboxes'), a = bb.firstChild;
  best_on = toggleClass(x, 'inactive');
  while (a && a.tagName=='A') {
    if (best_on&&a.rev!='best') { a.style.display = 'none'; }
    else if (!best_on&&a.name) { a.style.display = ''; }
    a = a.nextSibling;
  }
}
addOnLoad(function(){var p=$2('projsel');if(window.location.hash!='#respond'){toggleHidden('commentformcontainer');}if(p)p.style.display='';});

