if(typeof PIECESOFUK=="undefined"){var PIECESOFUK={}}PIECESOFUK.numCasts=0;PIECESOFUK.atCast=0;PIECESOFUK.pauseScreenCast=false;PIECESOFUK.bodyWidth=0;PIECESOFUK.bodyHeight=0;PIECESOFUK.oddColour="#232323";PIECESOFUK.evenColour="#353535";PIECESOFUK.calBgrd={calendarPromo:"#DAA520",calendarTV:"navy",calendarLive:"#B0171F",calendarNew:"green",calendarOther:"#00eeee"};PIECESOFUK.status={calendar:"initialising",screenCast:"initialising",jewelsBlog:"initialising",news:"initialising",forum:"xinitialising"};PIECESOFUK.attempts={calendar:0,screenCast:0,jewelsBlog:0,news:0,forum:0};PIECESOFUK.unableToLoadImg=new Image();PIECESOFUK.unableToLoadImg.src="Graphics/unableToLoadImg.png";PIECESOFUK.controller=function(){$("#jewelsBlogStatus").text(PIECESOFUK.status.jewelsBlog+" "+PIECESOFUK.attempts.jewelsBlog);$("#newsStatus").text(PIECESOFUK.status.news+" "+PIECESOFUK.attempts.news);$("#calendarStatus").text(PIECESOFUK.status.calendar+" "+PIECESOFUK.attempts.calendar);if(PIECESOFUK.status.screenCast=="initialising"){PIECESOFUK.status.screenCast="loading";PIECESOFUK.attempts.screenCast++;PIECESOFUK.getSpread()}else{if(PIECESOFUK.status.news=="initialising"){PIECESOFUK.status.news="loading";PIECESOFUK.attempts.news++;PIECESOFUK.contactBlogger()}else{if(PIECESOFUK.status.jewelsBlog=="initialising"){PIECESOFUK.status.jewelsBlog="loading";PIECESOFUK.attempts.jewelsBlog++;PIECESOFUK.contactJewelsNewBlog()}else{if(PIECESOFUK.status.calendar=="initialising"){PIECESOFUK.status.calendar="loading";PIECESOFUK.attempts.calendar++;PIECESOFUK.contactGoogleCalendar()}else{if(PIECESOFUK.status.forum=="initialising"){PIECESOFUK.status.forum="loading";PIECESOFUK.attempts.forum++;PIECESOFUK.contactForumNews()}else{if(PIECESOFUK.status.screenCast=="loaded"){PIECESOFUK.status.screenCast="complete"}else{if(PIECESOFUK.status.jewelsBlog=="loaded"){PIECESOFUK.status.jewelsBlog="complete";$("#jewelsBlog").jScrollPane({scrollbarMargin:0,showArrows:true});$("#jewelsBlogContainer").css("backgroundImage","none")}else{if(PIECESOFUK.status.calendar=="loaded"){PIECESOFUK.status.calendar="complete";$("#calendar").jScrollPane({scrollbarMargin:0,showArrows:true});$("#calendarContainer").css("backgroundImage","none")}else{if(PIECESOFUK.status.news=="loaded"){PIECESOFUK.status.news="complete";$("#news").jScrollPane({scrollbarMargin:0,showArrows:true});$("#POUKBlogContainer").css("backgroundImage","none");$("#POUKBlogContainer > .jScrollPaneContainer").width($("#POUKBlogContainer").width()-5);$("#news").width($("#POUKBlogContainer").width()-15)}else{if(PIECESOFUK.status.forum=="loaded"){PIECESOFUK.status.forum="complete";$("#jewelForum").jScrollPane({scrollbarMargin:0,showArrows:true});$("#jewelForumContainer").css("backgroundImage","none")}else{if(PIECESOFUK.status.jewelsBlog=="failed"){if(PIECESOFUK.attempts.jewelsBlog>5){PIECESOFUK.status.jewelsBlog="aborted"}else{PIECESOFUK.status.jewelsBlog="initialising"}}else{if(PIECESOFUK.status.news=="failed"){if(PIECESOFUK.attempts.news>5){PIECESOFUK.status.news="aborted"}else{PIECESOFUK.status.news="initialising"}}else{if(PIECESOFUK.status.calendar=="failed"){if(PIECESOFUK.attempts.calendar>5){PIECESOFUK.status.calendar="aborted"}else{PIECESOFUK.status.calendar="initialising"}}}}}}}}}}}}}}setTimeout(PIECESOFUK.controller,1000)};$(document).ready(function(){setTimeout(PIECESOFUK.controller,1000);$("#screenCast").hover(function(){PIECESOFUK.pauseScreenCast=true},function(){PIECESOFUK.pauseScreenCast=false});$("#bottomBanner").hover(function(){$("#bottomBanner").hide("fast",function(){$("#bottomMenu").show("fast")})},function(){});$("#bottomMenu").hover(function(){},function(){$("#bottomMenu").hide("fast",function(){$("#bottomBanner").show("fast")})});$("#aboutLink").click(function(C){C.preventDefault();var B=(PIECESOFUK.bodyWidth-$("#aboutBox").width())/2;var A=(PIECESOFUK.bodyHeight-$("#aboutBox").height())/2;$("#aboutBox").css("left",B+"px").css("top",A+$("html").scrollTop()+"px");return false});$("#aboutBox").click(function(){$(this).css("left","-9999px")})});window.onload=function(){PIECESOFUK.bodyWidth=$("body").width();PIECESOFUK.bodyHeight=$(window).height();var C=$("#screenCast").width();var A=$("#calendarDetails").width();var B=$("#jewelsBlog").width();$("#calendarContainer").width(PIECESOFUK.bodyWidth-A-30);var D=0;if($.browser.msie){D=10}$("#POUKBlogContainer").width(PIECESOFUK.bodyWidth-C-20-D)};PIECESOFUK.addScript=function(B){var A=document.createElement("script");A.type="text/javascript";A.src=B;document.getElementsByTagName("head")[0].appendChild(A)};PIECESOFUK.today=new Date();PIECESOFUK.todayDD=PIECESOFUK.today.getDate();PIECESOFUK.todayMM=PIECESOFUK.today.getMonth()+1;PIECESOFUK.todayYYYY=PIECESOFUK.today.getFullYear();PIECESOFUK.today=new Date(PIECESOFUK.todayYYYY,PIECESOFUK.todayMM-1,PIECESOFUK.todayDD);PIECESOFUK.calendarData={};PIECESOFUK.activeCalendar="";PIECESOFUK.thisMonth={};PIECESOFUK.days={0:"Sunday",1:"Monday",2:"Tuesday",3:"Wednesday",4:"Thursday",5:"Friday",6:"Saturday"};PIECESOFUK.months={1:"Jan",2:"Feb",3:"Mar",4:"Apr",5:"May",6:"Jun",7:"Jul",8:"Aug",9:"Sep",10:"Oct",11:"Nov",12:"Dec"};PIECESOFUK.contactGoogleCalendar=function(){var B=PIECESOFUK.todayMM;var C=PIECESOFUK.today.getFullYear();if(B===0){B=12;--C}B=(B<10?"0"+B:B);var A=PIECESOFUK.todayDD;A=(A<10?"0"+A:A);theURL="http://www.google.com/calendar/feeds/o75curq5sg0qvg313odgfgg9ec%40group.calendar.google.com/public/full-noattendees?orderby=starttime&alt=json-in-script&callback=?&singleevents=true&sortorder=ascending&futureevents=false&max-results=30&start-min="+C+"-"+B+"-"+A;$.getJSON(theURL,PIECESOFUK.readingCalendar)};PIECESOFUK.readingCalendar=function(A){if(A.feed==undefined){PIECESOFUK.status.calendar="failed";return false}PIECESOFUK.calendarData=A.feed;PIECESOFUK.homeCalendar(PIECESOFUK.calendarData);var B=$(".calendarItem").eq(0);B.toggleClass("calendarHighlight");var C=B.attr("class").split(" ")[0];$("#calendarDetails").html("<b>"+B.find("b").text()+"</b> "+B.find(".summary").text()+"<br><b>Where: </b>"+B.find(".location").text()+"<br><b>Info: </b>"+B.find(".calendarContent").text()).css("backgroundColor",PIECESOFUK.calBgrd[C]);$(".calendarItem").hover(function(D){var F=$(this).attr("class").split(" ")[0];var E=$(this);$("#calendarDetails").html("<b>"+E.find("b").text()+"</b> "+E.find(".summary").text()+"<br><b>Where: </b>"+E.find(".location").text()+"<br><b>Info: </b>"+E.find(".calendarContent").text()).css("backgroundColor",PIECESOFUK.calBgrd[F]);if(B){B.toggleClass("calendarHighlight");B=null}$(this).toggleClass("calendarHighlight")},function(){$(this).toggleClass("calendarHighlight")});PIECESOFUK.status.calendar="loaded"};PIECESOFUK.homeCalendar=function(W){$("#calendar").html("");var J=0;var I=1000*24*60*60;for(var T=0;T<W.entry.length;T++){var R=W.entry[T];var U=R.gd$when[0].startTime.match(/(\d{4})[-](\d{2})[-](\d{2})/);var G=U[1];var H=U[2];var N=U[3];var B="";var Q=new Date(G,H-1,N);if(R.gd$when[0].startTime.search(/T/)==-1){Q.setHours(0);Q.setMinutes(0);Q.setSeconds(0)}else{var U=R.gd$when[0].startTime.match(/(\d{4})[-](\d{2})[-](\d{2})[T](\d{2})[:](\d{2})[:](\d{2})/);Q.setHours(U[4]);Q.setMinutes(U[5]);Q.setSeconds(U[6]);B=" @ "+U[4]+":"+U[5]}if(Q>=PIECESOFUK.today){var E=R.title.$t;var X=E.substring(2,4);var P=E.substring(0,2);E=E.slice(5);PIECESOFUK.thisMonth[N]={DD:N,MM:H,YYYY:G,Title:E,Type:X,Country:P,Where:R.gd$where[0].valueString,Description:R.content.$t};var F="";var D="";var S=Q.valueOf();var M=PIECESOFUK.today.valueOf();if(S<M){D=PIECESOFUK.months[Q.getMonth()+1]+" "+Q.getDate()}else{if(S<(M+I)){D="Today"}else{if(S<(M+(I*2))){D="Tomorrow"}else{if(S<(M+(I*7))){D=PIECESOFUK.days[Q.getDay()]}else{D=PIECESOFUK.months[Q.getMonth()+1]+" "+Q.getDate()}}}}var V="calendarOther";if(X=="PR"){V="calendarPromo"}else{if(X=="TV"){V="calendarTV"}else{if(X=="NR"){V="calendarNew"}else{if(X=="LV"){V="calendarLive"}}}}E=$("<span></span>").text(E).addClass("summary");var L=$("<abbr></abbr>").addClass("dtstart").attr("title",R.gd$when[0].startTime.slice(0,19));var C=$("<abbr></abbr>").addClass("dtend").attr("title",R.gd$when[0].endTime.slice(0,19));var A=$("<span></span>").addClass("location").html(R.gd$where[0].valueString);var O=$("<div></div>").html(""+R.content.$t).addClass("calendarContent").addClass("description");var K=$("<img />").attr("src","Images/"+P+".gif");$("<div></div>").addClass(V).addClass("calendarItem").addClass("vevent").html("<b>"+D+"</b>").append(E).append(", ").append(A).append(B).append(L).append(C).append(" ").append(K).append(O).css("backgroundColor",(++J%2)?PIECESOFUK.oddColour:PIECESOFUK.evenColour).appendTo("#calendar")}}};PIECESOFUK.thisWeek=function(){};PIECESOFUK.getSpread=function(){var A="http://spreadsheets.google.com/feeds/list/pKZa-x-ME9yHlhJMUo1SJMg/od6/public/values?alt=json-in-script&callback=PIECESOFUK.getPiecesData";PIECESOFUK.addScript(A)};PIECESOFUK.getPiecesData=function(B){if(B.feed==undefined){PIECESOFUK.status.screenCast="failed";return false}for(var A=0;A<B.feed.entry.length;A++){var C=B.feed.entry[A];if(C.gsx$item.$t=="PiecesOfUK"){$("#jewelCurrentText").html(C.gsx$content.$t)}if(C.gsx$item.$t=="screenCast"){$("<div></div>").addClass("castData").html(C.gsx$content.$t).prependTo("#ScreenCastData")}}if($.browser.msie&&parseInt($.browser.version,10)<7){$("#getFireFox").removeClass("testCastData").addClass("castData")}PIECESOFUK.numCasts=$(".castData").length;PIECESOFUK.atCast=0;setTimeout(PIECESOFUK.displayScreenCast,50);PIECESOFUK.status.screenCast="loaded"};PIECESOFUK.displayScreenCast=function(){if(PIECESOFUK.pauseScreenCast===true||$("#videoLayer").length){setTimeout(PIECESOFUK.displayScreenCast,5000);return }$("#screenCastBody").fadeOut("slow",function(){$("#screenCastBody").html($(".castData").eq(PIECESOFUK.atCast).html()).slideDown("slow");$("#screenCastBody > p").css("width",$("#screenCastBody").css("width"));var A=$("#screenCastBody").find(".videoLink");A.unbind("click");if(A.length){A.click(function(C){C.preventDefault();var B=$(this).attr("href").match(/=([\w|-]*)/);PIECESOFUK.setupYouTube(B[1])})}++PIECESOFUK.atCast;if(PIECESOFUK.atCast===PIECESOFUK.numCasts){PIECESOFUK.atCast=0}});setTimeout(PIECESOFUK.displayScreenCast,5000)};PIECESOFUK.jewelsBlogs=[];PIECESOFUK.jewelsIdx=-1;PIECESOFUK.jewelsBlogItem=function(E,B,A,C,D){this.Title=E;this.Date=B;this.Url=A;this.Type=C;this.Text=D};PIECESOFUK.contactJewelsNewBlog=function(){$.getJSON("http://pipes.yahoo.com/pipes/pipe.run?_id=mGIJe3c53RG_l_r16UjTQA&_render=json&_callback=?",PIECESOFUK.jewelsBlogPipe)};PIECESOFUK.jewelsBlogPipe=function(B){if(B.value==undefined){PIECESOFUK.status.jewelsBlog="failed";return }for(var A=0;A<B.value.items.length;A++){++PIECESOFUK.jewelsIdx;var C=new Date(B.value.items[A].date);PIECESOFUK.jewelsBlogs[PIECESOFUK.jewelsIdx]=new PIECESOFUK.jewelsBlogItem(B.value.items[A].title,C,B.value.items[A].link,"Blog","")}PIECESOFUK.displayJewelsBlog()};PIECESOFUK.jewelsBlog=function(B){if(B.groups==undefined){PIECESOFUK.status.jewelsBlog="failed";return }for(var A=0;A<B.groups.item.length;A++){++PIECESOFUK.jewelsIdx;var C=new Date(B.groups.item[A].date[0]["value"].split(" on ")[1]);PIECESOFUK.jewelsBlogs[PIECESOFUK.jewelsIdx]=new PIECESOFUK.jewelsBlogItem(B.groups.item[A].title[0]["value"],C,B.groups.item[A].title[0]["href"],"Blog","")}PIECESOFUK.displayJewelsBlog()};PIECESOFUK.displayJewelsBlog=function(){PIECESOFUK.jewelsBlogs.sort(PIECESOFUK.sortDates);var C=0;$("#jewelsBlog").html("");for(var B=0;B<PIECESOFUK.jewelsBlogs.length;B++){var A=$("<a></a>").attr("href",PIECESOFUK.jewelsBlogs[B].Url).html(PIECESOFUK.jewelsBlogs[B].Title);var E=$("<span></span>").addClass("jewelsBlogDate").text(PIECESOFUK.jewelsBlogs[B].Date.toString().slice(0,15));var D=$("<div></div>").addClass("jewelsBlogContent").html(PIECESOFUK.jewelsBlogs[B].Text);$("<div></div>").append(A).append(E).append(D).css("backgroundColor",(++C%2)?PIECESOFUK.oddColour:PIECESOFUK.evenColour).appendTo("#jewelsBlog")}PIECESOFUK.status.jewelsBlog="loaded"};PIECESOFUK.sortDates=function(C,B){var A=C.Date.valueOf();var D=B.Date.valueOf();return((A<D)?1:((A>D)?-1:0))};PIECESOFUK.newsData={};PIECESOFUK.activeNews="";PIECESOFUK.contactBlogger=function(){var A="http://piecesofuk.blogspot.com/feeds/posts/default?alt=json-in-script&max-results=5&callback=PIECESOFUK.readBlogger";PIECESOFUK.addScript(A)};PIECESOFUK.readBlogger=function(A){if(A.feed.entry==undefined){PIECESOFUK.status.news="failed";return false}PIECESOFUK.newsData=A.feed;PIECESOFUK.displayNews(PIECESOFUK.newsData);$("#news").find(".playVidImg").click(function(C){C.preventDefault();var B=$(this).parent().css("backgroundImage").split("/vi/")[1].split("/0")[0];PIECESOFUK.setupYouTube(B)});PIECESOFUK.status.news="loaded"};PIECESOFUK.displayNews=function(D){var M=$("<div></div>");var H=0;for(var I=0;I<D.entry.length;I++){var L=D.entry[I];if(PIECESOFUK.checkJewel(L)){var B=$("<div></div>");var E=$("<b></b>").addClass("blogDate").text(PIECESOFUK.formatDate(L.published.$t)+" ");B.append(E);B.addClass("bloggerDiv");var A;for(var F=0;F<L.link.length;F++){if(L.link[F].rel=="alternate"){A=L.link[F].href;break}}var C=$("<a></a>").addClass("blogLink").attr({href:A,target:"_blank"}).text(L.title.$t).appendTo(B);var K=$("<div></div>");K.addClass("bloggerSummary");bloggerTxt=L.content.$t;while(bloggerTxt.search(/<\/object>/)>-1){var J=bloggerTxt.match(/(.*)(<object)(.*)(object>)(.*)/);var G=J[3].split("/v/")[1].split("&hl=en")[0];var N='<div id="id'+G+'" style="width: 320px; height: 250px; background-image: url(Graphics/unableToLoadImg.png);"></div>';bloggerTxt=J[1]+N+J[5];$img=$("<img>").load(function(){var O=$(this).width()/2-25;var P=$(this).height()/2-25;var Q=$(this).attr("src").split("/vi/")[1].split("/0.jpg")[0];var R="#id"+Q;$(R).css("width",$(this).width()+"px").css("height",$(this).height()+"px").css("backgroundImage","url("+$(this).attr("src")+")");$("<div></div>").addClass("playVidImg").css("left",O+"px").css("top",P+"px").appendTo(R);$(R).find(".playVidImg").click(function(T){T.preventDefault();var S=$(this).parent().css("backgroundImage").split("/vi/")[1].split("/0")[0];PIECESOFUK.setupYouTube(S)})}).css("visibility","hidden").attr("src","http://img.youtube.com/vi/"+G+"/0.jpg").appendTo("#hidden")}K.html(bloggerTxt+"<br clear='left'>").appendTo(B);B.css("backgroundColor",(++H%2)?PIECESOFUK.oddColour:PIECESOFUK.evenColour).appendTo(M)}$("#news").html(M)}};PIECESOFUK.formatDate=function(F){var A={"01":"January","02":"February","03":"March","04":"April","05":"May","06":"June","07":"July","08":"August","09":"September","10":"October","11":"November","12":"December"};var B={1:"st",2:"nd",3:"rd",4:"th",5:"th",6:"th",7:"th",8:"th",9:"th",10:"th",11:"th",12:"th",13:"th",14:"th",15:"th",16:"th",17:"th",18:"th",19:"th",20:"th",21:"st",22:"nd",23:"rd",24:"th",25:"th",26:"th",27:"th",28:"th",29:"th",30:"th",31:"st"};var D=F.slice(0,4);var E=F.slice(5,7);var C=parseInt(F.slice(8,10),10);if(C<10){C="0"+C}return A[E].slice(0,3)+" "+C};PIECESOFUK.checkJewel=function(A){if(A.category){for(i=0;i<A.category.length;i++){if(A.category[i].term=="Jewel"){return true}}}return false};