$(document).ready(function() { window.links = new Array("", "connect", "profile", "project", "cv", "links"); window.tabs = new Array("category", "tags", "archives", "rss"); $("div.header-content").css("visibility","visible"); $("div.header-content, #header #close").each(function() { $(this).hide(); }); $("#header").css( {backgroundPosition: "0 -158px"} ); window.current = 0; $(".connect-link").click(function(e) { Change(1, e); }); $(".profile-link").click(function(e) { Change(2, e); }); $(".project-link").click(function(e) { Change(3, e); }); $(".cv-link").click(function(e) { Change(4, e); }); $(".links-link").click(function(e) { Change(5, e); }); $("#categorytab").click(function(e) { ChangeTab(0,e); }); $("#tagstab").click(function(e) { ChangeTab(1,e); }); $("#archivestab").click(function(e) { ChangeTab(2,e); }); $("#rsstab").click(function(e) { ChangeTab(3,e); }); $("#close-link").click(function(e) { e.preventDefault(); window.current = 0; $("#" + linkname + "-content, #header #close").stop().fadeOut(500, function() { $("#header").stop().animate( {backgroundPosition: "(0 -158px)"} , 1000, function() { $("#column").css( {top: "0px"} ); $("#header").css( {height: "130px"} ); }); $("body #column #bg, body #column #bg-ie").stop().animate( {marginTop: "-180px"}, 1000); $("." + linkname + "-link img").attr("src", window.themeroot + "/img/arrow-down.png"); }); }); $(".no-link").click(function(e) { e.preventDefault(); }); if (window.tab != 0) { Change(window.tab, false); } if (window.enableLive) { updateTweets(); } }); function Change(id, e) { if (e) { e.preventDefault(); } linkname = window.links[id]; if (window.current != id) { if (window.current == 0) { window.current = id; $("#column").css( {top: "-170px"} ); $("#header").css( {height: "300px"} ); $("body #column #bg, body #column #bg-ie").stop().animate( {marginTop: "0px"}, 1000); $("#header").stop().animate( {backgroundPosition: "(0 12px)"} , {duration:1000, complete:function() { $("#" + linkname + "-content, #header #close").stop().fadeIn(500); $("." + linkname + "-link img").attr("src", window.themeroot + "/img/arrow-up.png"); }}); } else { $("#" + window.links[window.current] + "-content").stop().fadeOut(500, function() { $("#" + linkname + "-content").stop().fadeIn(500); $("." + linkname + "-link img").attr("src", window.themeroot + "/img/arrow-up.png"); $("." + window.links[window.current] + "-link img").attr("src", window.themeroot + "/img/arrow-down.png"); window.current = id; }); } } else { window.current = 0; $("#" + linkname + "-content, #header #close").stop().fadeOut(500, function() { $("body #column #bg, body #column #bg-ie").stop().animate( {marginTop: "-180px"}, 1000); $("#header").stop().animate( {backgroundPosition: "(0 -158px)"} , 1000, function() { $("#column").css( {top: "0px"} ); $("#header").css( {height: "130px"} ); }); $("." + linkname + "-link img").attr("src", window.themeroot + "/img/arrow-down.png"); }); } } function ChangeTab(id,e) { if (e) { e.preventDefault(); } tabname = window.tabs[id]; // clear existing set tabs and content $("ul.tabs li, div.blogtool").removeClass("active"); // set new tab and content $("ul.tabs #" + tabname + "tab, #" + tabname).addClass("active"); } function updateTweets() { /*$.get("http://www.chris-alexander.co.uk/subdomains/gateway/", { chris: "true", random: Math.random()}, function(data) { // blank off the old stuff $("ul.tweets").empty(); // add the new stuff $.each(data, function(i,item) { formatted = item.Tweet.replace(/(https?:\/\/([-\w\.]+)+(:\d+)?(\/([\w\/_\.]*(\?\S+)?)?)?)/, "$1"); formatted = formatted.replace(/([^a-zA-Z0-9-_&])?@([0-9a-zA-Z_]+)/g, "$1@$2"); formatted = formatted.replace(/([^a-zA-Z0-9-_&])?#([0-9a-zA-Z_]+)/g, "$1#$2"); $("ul.tweets").append("
  • " + formatted + "
    " + getTimeString(item.Time) + "
    Reply Retweet

  • "); }); window.setTimeout('updateTweets()', 30000); }, "json");*/ } function getTimeString(timestamp) { date = new Date(); diff = Math.round(date.getTime()/1000) - timestamp; s = "s"; if (diff < 60) { if (diff == 1) { s = ""; } return diff + " second" + s + " ago"; } else if (diff < 3600) { diff = Math.round(diff/60); if (diff == 1) { s = ""; } return diff + " minute" + s + " ago"; } else if (diff < 86400) { diff = Math.round(diff/3600); if (diff == 1) { s = ""; } return diff + " hour" + s + " ago"; } else { diff = Math.round(diff/86400); if (diff == 1) { s = ""; } return diff + " day" + s + " ago"; } } (function($) { $.extend($.fx.step,{ backgroundPosition: function(fx) { if (fx.state === 0 && typeof fx.end == 'string') { var start = $.curCSS(fx.elem,'backgroundPosition'); start = toArray(start); fx.start = [start[0],start[2]]; var end = toArray(fx.end); fx.end = [end[0],end[2]]; fx.unit = [end[1],end[3]]; } var nowPosX = []; nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0]; nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1]; fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1]; function toArray(strg){ strg = strg.replace(/left|top/g,'0px'); strg = strg.replace(/right|bottom/g,'100%'); strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2"); var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/); return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]]; } } }); })(jQuery);