var ompic={};if(typeof console=="undefined"){console={log:function(){}}}ompic=$.extend(ompic,{init:function(){var B=jQuery.extend({id:null,key:"01cc21c83d6c92f5d00c8e4c1426c2ff",time:20},arguments[1]||{});this.options=B;this.current_img=null;this.current_twit=null;this.ready=true;this.loaded=false;this.current_keyword="the";this.interval=null;this.current_twit={t:""};var A={w:$(window).width(),h:$(window).height()};var C={w:$("#pic").width(),h:$("#pic").height()};var D=this;$("#pic").bind("pic_loaded",function(E){D.loaded=true;$("#next #loader").html("ready!");D.enableNext();if(D.ready){console.log("img loaded and ready");D.showImg()}else{console.log("img loaded but not ready, so wait!")}});$("#pic").bind("tm_ready",function(E){D.ready=true;if(D.interval!=null){clearInterval(D.interval);$("#timer").hide().html(D.options.time)}if(D.loaded){console.log("ready and img loaded");D.showImg()}else{console.log("ready, but img not yet loaded, so wait!");if($("#pic img").length>0){$("#pic").css({opacity:0.5})}}});this.menu={status:"closed",o_h:300,c_h:35};this.initMenu();this.disableNext()},initMenu:function(){var A=this;$("#footer").animate({opacity:0.1},"slow").bind("mouseenter",function(B){$("#footer").animate({opacity:0.9},"fast")}).bind("mouseleave",function(B){$("#footer").animate({opacity:0.1},"fast")}).find("ul li a").click(function(B){console.log(A.menu.status);if(A.menu.status=="closed"){A.menu.status="opening";console.log("opening by "+(A.menu.o_h-A.menu.c_h));$("#footer").animate({left:"+="+(A.menu.o_h-A.menu.c_h)+"px"},"slow",function(){console.log("...");$("#footer ul li a").eq(0).html("c<br/>l<br/>o<br/>s<br/>e");A.menu.status="opened"})}else{if(A.menu.status=="opened"){A.menu.status="closing";console.log("closing by "+(A.menu.o_h-A.menu.c_h));$("#footer").animate({left:"-="+(A.menu.o_h-A.menu.c_h)+"px"},"slow",function(){$("#footer ul li a").eq(0).html("m<br/>e<br/>n<br/>u");A.menu.status="closed"})}}return false})},enableNext:function(){var A=this;$("#next a").unbind("click").click(function(B){if(!A.loading){A.loading=true;$("#pic").trigger("tm_ready")}return false})},disableNext:function(){var A=this;$("#next a").unbind("click").click(function(B){return false})},searchTiwtter:function(){$("#next #loader").html('<span style="color:#555">pre</span>loading...').show("slow");this.disableNext();var A="http://www.podipodi.com/flitter/flitter.php"+((typeof this.current_twit.twts!="undefined")?"?twts="+this.current_twit.twts:"");$.getScript(A)},deliveredPic:function(B){console.log(B);this.current_img=B.flickr;this.current_twit=B.twitter;this.current_tags=B.tags;var C=this;var D=this.current_img.src;var A=new Image();A.src=D;if(A.complete){$("#pic").trigger("pic_loaded")}else{A.onload=function(){$("#pic").trigger("pic_loaded")}}},updateTimer:function(B){var A=this;if(B){this.time=this.options.time;$("#timer").show()}this.interval=setInterval(function(){A.time--;$("#timer").html(A.time);if(A.time==0){$("#pic").trigger("tm_ready")}},1000)},showImg:function(){var B=this;$("#next a").show("slow");var A={w:$(window).width(),h:$(window).height()};$("#pic").animate({opacity:0},function(){$("#pic span").remove();$("#pic > div").empty();$("<img></img>").attr("src",B.current_img.src).appendTo("#pic > div");$("<div></div>").addClass("descr").html(B.current_img.title+' taken by <a href="http://www.flickr.com/photos/'+B.current_img.uid+'" target="_blank">'+B.current_img.user+"</a> on "+B.current_img.date).appendTo("#pic > div");$("<div></div>").addClass("descr").css({maxWidth:"80%",margin:"0 auto 5px",position:"abosolute"}).html('<span class="twit">'+B.current_twit.t+'</span> (<a href="http://www.twitter.com/'+B.current_twit.u+'"  target="_blank">'+B.current_twit.u+"</a>)").prependTo("#pic > div");$("#pic").css({opacity:1,top:"-9999px"}).show();var C={w:$("#pic").width(),h:$("#pic").height()};$("#pic").css({top:((A.h/2)-(C.h)/2)+"px",opacity:0}).animate({opacity:1},function(){B.loading=false;B.updateTimer(true);B.ready=false;B.loaded=false;ompic.searchTiwtter()})})}});