/**
 *	Theme Name:		MH20
 *	Theme URI:		www.popokatea.co.uk
 *	Author:			Laura @ popokatea
 **/

mh20={listeners:{hasInitialized:function(){$("*:first-child").addClass("firstChild");$("*:last-child").addClass("lastChild");twttr.anywhere(function(A){A("a.chirp").hovercards({username:function(B){return B.text;}});A("img.chirp").hovercards({username:function(B){return B.alt;}});});$(document).trigger("CORE:HAS_RESIZED");},hasResized:function(){var A=$(document).width();if(A>1024){if(typeof $.fancybox=="function"){$(".containsGallery a,.eStore-thumbnail a, a.enlarge").fancybox();}if($("#screen > header > form").length==1){$("#screen > header > form").remove();}}else{if(typeof $.fancybox=="function"){$(".containsGallery a,.eStore-thumbnail a, a.enlarge").unbind("click.fb");}if($("#screen > header > form").length==0){$("#footerOne > li:nth-child(1) > form").clone().insertBefore("#screen > header > h1");}if(A>595){if($("#screen > header > form fieldset").length==2){$("#screen > header > form fieldset:nth-child(2)").remove();}}else{if($("#screen > header > form fieldset").length==1){$("#screen > header > form").append('<fieldset><label for="mobile-menu"></label><select id="mobile-menu"><option value="">Go to...</option></select><select id="mobile-sec-menu"><option value="">Go to...</option></select></fieldset>');$("#screen > header > nav > ul").each(function(C){var B=$(this),D=C+1;$("li li a",B).each(function(){if($(this).parent().is("strong")){$("#screen > header > form select:nth-of-type("+D+")").append('<option selected value="'+$(this).attr("href")+'">'+$(this).text()+"</option>");}else{$("#screen > header > form select:nth-of-type("+D+")").append('<option value="'+$(this).attr("href")+'">'+$(this).text()+"</option>");}});});$("#mobile-sec-menu, #mobile-menu").change(function(){window.location.href=$(this).val();});}}}},foundTweetlist:function(){var D="",B={},C=$("#containsTweets"),A=$("#containsChirps");$(document).bind("CORE:FOUND_TWEETS:FETCH",function(){$.getJSON("http://search.twitter.com/search.json?callback=?&rpp=10&q="+D.replace(/\+OR\+$/,""),function(E){if(typeof E.results=="object"||typeof E.results=="array"){B=E.results;$(document).trigger("CORE:FOUND_TWEETS:UPDATE");}});});$(document).bind("CORE:FOUND_TWEETS:UPDATE",function(){C.empty();for(var E in B){var F=B[E];F.text=F.text.replace(/((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/g,'<a href="$1">$1</a>');F.text=F.text.replace(/\@(\w+)/g,'<a class="chirp" href="http://twitter.com/$1">@$1</a>');C.append('<li><img alt="" src="'+F.profile_image_url+'" /><blockquote><p><a class="chirp" href="http://twitter.com/'+F.from_user+'">'+F.from_user+"</a>: "+F.text+'</p></blockquote><p><a href="http://twitter.com/'+F.from_user+"/status/"+F.id+'/">'+$.timeago(F.created_at)+"</a></p></li>");}setTimeout(function(){$(document).trigger("CORE:FOUND_TWEETS:FETCH");},180000);});$("li h2 a",A).each(function(){D+="from%3A"+$(this).html()+"+OR+";});$(document).trigger("CORE:FOUND_TWEETS:FETCH");}}};$(document).bind("CORE:HAS_INITIALIZED",mh20.listeners.hasInitialized).bind("CORE:HAS_RESIZED",mh20.listeners.hasResized).bind("CORE:FOUND_TWEETLIST",mh20.listeners.foundTweetlist);
