jQuery.fn.submitWithAjax=function(){this.submit(function(){$.post(this.action,$(this).serialize(),null,"script");return false;});return this;};var wCount=0;var winCur;var lastURL=new Array();var regexHost=new RegExp("http://"+location.host+"/");function zmax(){var zmax=0;$('.window,#infoTab').each(function(){var cur=+$(this).css('zIndex');zmax=cur>zmax?cur:zmax;});return+zmax;}
function frontWindow(){var zmax=0;var fWin="";$('.window').each(function(){var cur=+$(this).css('zIndex');if(cur>zmax){zmax=cur;fWin=$(this).attr('id');}});return fWin;}
function window_name(hash){var wname="";params=hash.split("/");if(params[0]=="window"){wname="w"+params[1];}else{wname="w"+params[0];}
return wname;}
function reinitialiseScrollPane(){$('#pane2').jScrollPane({scrollbarWidth:20,scrollbarMargin:10});}
function loadSubContent(url){switch(url[0]){case"portfolio":if(url[1]!=null&&$("#pane2").attr("title")!=url[1]){$("#pane2").load("/portfolio/"+url[1]+".js",'',function(){$(this).attr("title",url[1]);reinitialiseScrollPane();$('#pane1 a').removeClass("set");$('#pane1 a[href$="'+url[0]+"/"+url[1]+'"]').addClass("set");});$('#pane3').empty().attr("title","");}
if(url[3]!=null&&$("#pane3").attr("title")!=url[3]){$("#pane3").load("/portfolio/"+url[1]+"/jobs/"+url[3]+".js",'',function(){$(this).attr("title",url[3]);$('#pane2 a').removeClass("set");$('#pane2 a[href$="'+url[0]+"/"+url[1]+"/"+url[2]+"/"+url[3]+'"]').addClass("set");});}
break;case"clients":break;}}
function newWindow(hash){var url=hash.split("/");var zm=zmax();var path="/"+hash;wname=window_name(hash);if(url[0]=="portfolio"){hash=url[0];}
if($('#'+wname).length){$('#'+wname).css("z-Index",zm+1);$('#'+wname).children(".titleBar").children(".titleBarInner").removeClass("bg");loadSubContent(url);}else{$("#wrapper").append('<div id="'+wname+'" class="window drag" style="left: '+(20+(wCount*20))+'px; top: '+(65+(wCount*20))+'px; z-Index: '+(zm+1)+'"></div>');wCount=wCount+1;$('#'+wname).load("/"+hash+".js","",function(){var num=$('#'+wname+' a.icon').length;$('#'+wname+' .numItems').html(num+" items");loadSubContent(url);});}
$('#'+wname).siblings(".window").children(".titleBar").children(".titleBarInner").addClass("bg");javascript:pageTracker._trackPageview(path);}
function pageload(hash){if(hash){newWindow(hash);}else{$('.window').children(".titleBar").children(".titleBarInner").addClass("bg");}}
jQuery.ajaxSetup({'beforeSend':function(xhr){xhr.setRequestHeader("Accept","text/javascript");}});$(document).ready(function(){$.historyInit(pageload);$("a[rel='tslink']").livequery('click',function(event){return false;});$("a[rel='tslink']").livequery('dblclick',function(event){return false;});$("a.icon").livequery('click',function(event){$('a.icon').removeClass("selected");$(this).addClass("selected");});$("a[rel='tslink'].icon").livequery('dblclick',function(event){tabClose();hash=$(this).attr('href').replace(regexHost,'');hash=hash.replace(/^\//,'');$.historyLoad(hash);$(this).effect("transfer",{to:"#"+window_name(hash)},600);});$("a[rel='tslink'].click").livequery('click',function(event){hash=$(this).attr('href').replace(regexHost,'');hash=hash.replace(/^\//,'');$.historyLoad(hash);});$("a.download").livequery('dblclick',function(event){window.open(this.href);return false;});$(".scroll-pane a[rel='tslink']").livequery('click',function(event){hash=$(this).attr('href').replace(regexHost,'');hash=hash.replace(/^\//,'');$.historyLoad(hash);});function tabOpen(){$("#infoTab").css('zIndex',zmax()+1);$("#infoTab").animate({bottom:"0"},800);}
function tabClose(){$("#infoTab").animate({bottom:"-245px"},800);}
$('#infoTab').click(function(){if($(this).css('bottom')=="-245px"){tabOpen();}else{tabClose();}});if($('.window').length==0){tabOpen();}
$.fn.clickMenu.setDefaults({arrowSrc:'images/arrow_right.gif'});$('#mainMenu').clickMenu();$("#mainMenu li.tslink").click(function(){tabClose();hash=$(this).attr('title');$.historyLoad(hash);$(this).effect("transfer",{to:"#"+window_name(hash)},600);});$("ul#mainMenu").fadeIn("slow");$("#mainMenu li.pref").click(function(){var hash=this.id;switch(hash){case"bg-cyan":$("body").css("background","url(/images/bg-cyan.gif)");break;case"bg-red":$("body").css("background","url(images/bg-red.gif)");break;case"bg-grey":$("body").css("background","url(images/bg-grey.gif)");break;case"bg-white":$("body").css("background","none");break;case"bg-aqua":$("body").css("background","url(images/bg-aqua.jpg) no-repeat center center");break;case"font-console":$("body").css("font-family","Lucida Console, Monaco, monospace");break;case"font-lucida":$("body").css("font-family","Lucida Grande, Andale Mono, sans-serif");break;case"font-courier":$("body").css("font-family","Courier");break;case"font-georgia":$("body").css("font-family","Georgia");break;case"font-comic":alert("System Error");break;case"help":tabOpen();break;case"shutdown":alert("Thank you for visiting");$("html").css("background-color","#000000");$("body").fadeOut("slow");$("body").empty();break;}});$('.desktop').livequery(function(event){$(this).draggable();});$('.window .icon').livequery(function(event){$(this).draggable({containment:'parent'});});$('.drag').livequery(function(event){$(this).draggable({handle:'.titleBar'});});$('.window').livequery('mousedown',function(event){var zm=zmax();if(+$(this).css('zIndex')<zm){$(this).siblings(".window").children(".titleBar").children(".titleBarInner").addClass("bg");$(this).children().children().removeClass("bg");$(this).css('zIndex',zm+1);winPrev=winCur;winCur=$(this).attr("id");}});$(".closeWindow").livequery('click',function(event){$(this).parent().siblings().remove();$(this).parent().parent().hide("slow",function(){$(this).remove();if(wCount>0){$('#'+frontWindow()).children(".titleBar").children(".titleBarInner").removeClass("bg");}});wCount=wCount-1;});$('h2.add_thought').livequery('click',function(){$(this).next().slideToggle("slow",function(){$("#guest_book").jScrollPane({scrollbarWidth:20,scrollbarMargin:10});});$(this).children(".emphasis").html()=="(+)"?$(this).children(".emphasis").html("(-)"):$(this).children(".emphasis").html("(+)");});$("#new_comment").livequery(function(){$(this).submitWithAjax();});$("#new_guestbook").livequery(function(){$(this).submitWithAjax();});$("#new_contact").livequery(function(){$(this).submitWithAjax();});});function updateClock()
{var currentTime=new Date();var currentHours=currentTime.getHours();var currentMinutes=currentTime.getMinutes();var currentSeconds=currentTime.getSeconds();currentMinutes=(currentMinutes<10?"0":"")+currentMinutes;currentSeconds=(currentSeconds<10?"0":"")+currentSeconds;var timeOfDay=(currentHours<12)?"AM":"PM";currentHours=(currentHours>12)?currentHours-12:currentHours;currentHours=(currentHours==0)?12:currentHours;var currentTimeString=currentHours+":"+currentMinutes+":"+currentSeconds+" "+timeOfDay;document.getElementById("clock").firstChild.nodeValue=currentTimeString;}
window.onload=function(){updateClock();setInterval('updateClock()',1000);};