$(document).ready(function(){function T(){var a=(u-$("#rightArrow").height())*.5+parseInt(document.body.scrollTop);$("#rightArrow").css("left",t-130);$("#rightArrow").css("top",a);$("#leftArrow").css("top",a);$("#left").css("height",u);$("#right").css("height",u);if(k){$("#right").css({left:t-183+"px",height:u+"px"});z()}else{$("#right").css({left:t-33+"px",height:u+"px"})}$("footer").css({top:u-130+"px"});if(r){$("#about").css({top:(u-$("#about").height())*.5+"px",left:(t-$("#about").width())*.5+"px"})}else{$("#about").css({top:$("#about").height()*-1.25+"px",left:(t-$("#about").width())*.5+"px"})}}function S(){r=false;$("#about").animate({opacity:0,top:$("#about").height()*-1},{duration:600,easing:"easeInBack"})}function R(){r=true;$("#about").css({top:$("#about").height()*-1});$("#about").animate({opacity:1,top:(u-$("#about").height())*.5},{duration:600,easing:"easeOutCirc"})}function Q(){$(".label").delay(1e3).animate({opacity:1},{duration:400,easing:"easeOutCirc"})}function P(){$(".label").animate({opacity:0},{duration:400,easing:"easeOutCirc"})}function O(){$("#wall").empty();A();E();P();var b=$("#srchterm").val();if(b!=""||b!="Search term"){pageTracker._trackEvent("Search",b);var c="&text="+b;var d="http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key="+a+c+"&format=json&nojsoncallback=1&per_page="+g+"&extras=url_m";$.getJSON(d,function(a){if(a.photos.photo.length==0){alert("There were no results for your search '"+b+"' ");F()}else{K(a)}})}}function N(){$("#wall").empty();A();E();P();var b="&date="+p;if(p=="")b="";var c="http://api.flickr.com/services/rest/?method=flickr.interestingness.getList&api_key="+a+b+"&format=json&nojsoncallback=1&per_page="+g+"&extras=url_m";$.getJSON(c,function(a){K(a)})}function M(){var b="";var c=$(".flickrid").val();var d="http://api.flickr.com/services/rest/?method=flickr.people.findByUsername&api_key="+a+"&username="+c+"&format=json&nojsoncallback=1";pageTracker._trackEvent("View_user",c);$.getJSON(d,function(a){if(a.stat=="ok"){b=a["user"].nsid;if(b!=""){L(b)}}else{alert("User not found. Please check and try again");H()}return b})}function L(b){$("#wall").empty();A();var c="http://api.flickr.com/services/rest/?method=flickr.people.getPublicPhotos&api_key="+a+"&user_id="+b+"&format=json&nojsoncallback=1&per_page="+g+"&extras=url_m";$.getJSON(c,function(a){K(a);if(a.photos.photo.length==0)alert("The user "+$(".flickrid").val()+" does not have any public photos.");H()})}function K(a){F();Q();h=0;f=0;e="";j=a;b=a.photos.total;c=a.photos.pages;d=a.photos.page;$.each(a.photos.photo,function(a,b){var c="http://farm"+b.farm+".static.flickr.com/"+b.server+"/"+b.id+"_"+b.secret+"_s.jpg";var d=b.id;e+='<img class="'+a+'" src="'+c+'" alt="'+b.title.replace(/(<([^>]+)>)/ig,"")+'" width="75" height="75" />';f++});var g=(t-13-Math.floor(t/75)*75)*.5;$("#wall").css({left:g});$(e).appendTo("#wall");$("#wall img."+h).bind("load",function(){$(this).fadeTo(200,.4,J)});$("#wall img").mouseover(function(a){id=$(this).attr("class").replace("i","");if(id<h){$(this).fadeTo(400,1)}D(id)});$("#wall img").mouseout(function(){id=$(this).attr("class").replace("i","");if(id<h){$(this).fadeTo(800,.4)}});$("#wall img").click(function(){i=$(this).attr("class").replace("i","");y()});$("#wall").mousemove(function(a){if(a.pageX<screen.width*.5){$(".label").css({top:a.pageY+50+"px",left:a.pageX+15+"px"})}else{$(".label").css({top:a.pageY+50+"px",left:a.pageX-$(".label").width()+"px"})}})}function J(){h++;$("#wall img."+h).fadeTo(20,.4,J)}function I(){var a=new Date($("#date").val());var b=new Date;var c=new Date(b.getFullYear(),b.getMonth(),b.getDate());H();if(s&&a.getTime()===c.getTime()){window.location.replace("http://interes.tingness.com/")}else{if(a>b){alert("Your date is in the future. \nWhile the future looks very cool please enter a date in the past.")}else if(a.getTime()===c.getTime()){alert("Your date is the same as the current date. Please select a date in the past.")}else{var d=new Date(a);if(d.toString()=="NaN"||d.toString()=="Invalid Date"){var e=b.getFullYear();var f=b.getMonth()+1;if(f<10)f="0"+f;var g=b.getDate();if(g<10)g="0"+g;$("#date").val(e+"-"+f+"-"+g);p="";alert("Please enter a date in the format YYYY-MM-DD")}else{var h=a.getFullYear();var i=a.getMonth()+1;if(i<10)i="0"+i;var j=a.getDate();if(j<10)j="0"+g;p=h+"-"+i+"-"+j;N()}}}s=false}function H(){$(".msg").delay(4e3).animate({left:(t-parseInt($(".msg").width()))*.5,top:(u-parseInt($(".msg").height()))*.5,opacity:0},{duration:1400,easing:"easeOutCirc"})}function G(){$(".msg").text("Displaying "+$(".flickrid").val()+"'s public photos");$(".msg").animate({left:(t-parseInt($(".msg").width()))*.5,top:(u-parseInt($(".msg").height()))*.5,opacity:1},{duration:800,easing:"easeInCirc"})}function F(){$("#loading").animate({left:(t-parseInt($("#loading").width()))*.5,top:(u-parseInt($("#loading").height()))*.5,opacity:0},{duration:1400,easing:"easeOutCirc"})}function E(){$("#loading").animate({left:(t-parseInt($("#loading").width()))*.5,top:(u-parseInt($("#loading").height()))*.5,opacity:1},{duration:800,easing:"easeInCirc"})}function D(a){var b=j.photos.photo[a].title.replace("\r","").replace("\n","").replace("  ","");if(b=="")b="Untitled";$(".label").text(b)}function C(){i--;if(i<0)i=j.photos.photo.length-1;y()}function B(){i++;if(i>=j.photos.photo.length)i=0;y()}function A(){Q();$("#right").css({height:u+"px"});k=false;$("#closeBtn").animate({opacity:0},{duration:400,easing:"easeOutCirc"});$("#right").animate({opacity:0,left:t-33,width:0},{duration:800,easing:"easeOutBack",complete:function(){}});$("#left").animate({opacity:0,width:0},{duration:800,easing:"easeOutBack",complete:function(){}});$("#limg #imgHolder").animate({opacity:0},{duration:800,easing:"easeOutCirc",complete:function(){$("#imgHolder").css({width:0,height:0});$("#limg").animate({left:t*.5,top:u*.5,width:0,height:0},{duration:800,easing:"easeOutCirc",complete:function(){$("#limg p").text("");$("#limg #imgHolder").empty()}})}});$("#limgBack").animate({opacity:0,left:t*.5,top:u*.5,width:0,height:0},{duration:800,easing:"easeInBack",complete:function(){$("#limg").css("z-index","1");$("#limgBack").css("z-index","1")}});$("#limg .info").animate({opacity:0},{duration:800,easing:"easeOutCirc"});$("#rightArrow,#leftArrow").animate({opacity:0},{duration:800,easing:"easeOutCirc"})}function z(){$("#limg").css("z-index","30");$("#limgBack").css("z-index","29");P();n=0;n=parseInt(m);n+=parseInt($(".info").height())+30;var a=(t-l+20)/2;var b=Number(l)+20;o=$(window).scrollTop();if(o<110)o+=o;$("#right").animate({opacity:.4,left:t-173,width:150},{duration:800,easing:"easeOutBack",complete:function(){}});$("#left").animate({opacity:.4,width:150},{duration:800,easing:"easeOutBack"});var c=(u-$("#rightArrow").height())*.5+o;$("#rightArrow").animate({opacity:1,left:t-130,top:c},{duration:800,easing:"easeOutBack"});$("#leftArrow").animate({opacity:1,top:c},{duration:800,easing:"easeOutBack"});if(!k){$("#closeBtn").css({opacity:0,left:a+b+10,top:(u-110-m)*.5+o});$("#limgBack").animate({opacity:.8,left:a,top:(u-110-m)*.5+o,width:b,height:n},{duration:1e3,easing:"easeOutBack",complete:function(){$("#closeBtn").animate({opacity:1},{duration:400,easing:"easeOutCirc"})}});$("#limg").animate({opacity:1,left:a,top:(u-110-m)*.5+o,width:b},{duration:400,easing:"easeOutBack"});$(" #imgHolder").animate({opacity:1,width:l,height:m},{duration:400,easing:"easeOutCirc"});$("#limg .info").animate({opacity:1},{duration:400,easing:"easeOutCirc"})}else{$("#limgBack").animate({opacity:.8,left:a,top:(u-110-m)*.5+o,width:b,height:n},{duration:400,easing:"easeOutCirc"});$("#closeBtn").animate({opacity:1,left:a+b+10,top:(u-110-m)*.5+o},{duration:400,easing:"easeOutCirc"});$("#limg #imgHolder img").animate({opacity:1},{duration:400,easing:"easeOutCirc"});$("#limg").animate({left:a,top:(u-110-m)*.5+o,width:b,height:n},{duration:400,easing:"easeOutCirc"});$("#imgHolder").animate({opacity:1,width:l,height:m},{duration:400,easing:"easeOutCirc"})}k=true}function y(){var b=j.photos.photo[i].secret;var c=j.photos.photo[i].id;pageTracker._trackEvent("Image view",c);$.getJSON("http://api.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key="+a+"&photo_id="+c+"+&secret="+b+"+&format=json&nojsoncallback=1",function(a){var b=a.photo.description["_content"];var c=a.photo.owner["username"];var d='<a href="http://www.flickr.com/'+c+'" target="_blank">'+c+"</a>";var e="Taken: "+a.photo.dates["taken"];if(b=="")b="No description";$("#limg p").html(b);$("#limg div span").html(d);$("#limg .taken").text(e);var f=j.photos.photo[i].title.replace("\r","").replace("\n","").replace("  ","");if(f=="")f="Untitled";$("#limg h3").text(f);$("#imgHolder").html(x(i));$.setTimeout(z(),1e3)})}function x(a){var b=j.photos.photo[i].farm;var c=j.photos.photo[i].server;var a=j.photos.photo[i].id;var d=j.photos.photo[i].secret;var e=j.photos.photo[i].title.replace(/(<([^>]+)>)/ig,"");l=j.photos.photo[i].width_m;m=j.photos.photo[i].height_m;var f=j.photos.photo[i].url_m;var g='<img src="'+f+'" alt="'+e+'" width="'+l+'" height="'+m+'" />';return g}function w(){if(document.body&&document.body.offsetWidth){t=parseInt(document.body.offsetWidth);u=parseInt(document.body.offsetHeight)}if(document.compatMode=="CSS1Compat"&&document.documentElement&&document.documentElement.offsetWidth){t=parseInt(document.documentElement.offsetWidth);u=parseInt(document.documentElement.offsetHeight)}if(window.innerWidth&&window.innerHeight){t=parseInt(window.innerWidth);u=parseInt(window.innerHeight)}}function v(){var a=new Date;var b=a.getDate();if(b<10)b="0"+b;var c=a.getMonth()+1;if(c<10)c="0"+c;var d=a.getFullYear();var e=d+"-"+c+"-"+b;$("#date").attr("value",e)}var a="c81f118a8d42f3d1a2a72b007d02ebe2";var b=0;var c=0;var d=0;var e="";var f=0;var g=500;var h=0;var i=0;var j;var k=false;var l=0;var m=0;var n=0;var o=0;var p="";var q="";var r=false;var s=false;var t=630,u=460;v();w();$(".flickrid").focus(function(){q=$(this).val();$(this).val("")});$(".flickrid").focusout(function(){if($(this).val()=="")$(this).val(q)});$(".flickrid").keypress(function(a){if(a.keyCode==13){a.preventDefault();if($(".flickrid").val()!="")window.location.replace("http://interes.tingness.com/"+$(".flickrid").val())}});$("#srch").submit(function(a){a.preventDefault();return false});$(".sbtn").click(function(){O()});$("#srchterm").focus(function(){$(this).val("")});$("#srchterm").focusout(function(){if($(this).val()=="")$(this).val("Search term")});$("#dateForm").submit(function(a){a.preventDefault();return false});$(".b").click(function(){I()});$("#closeBtn").click(function(){A()});$("#rightArrow,#right").click(function(){B()});$("#leftArrow,#left").click(function(){C()});$("#closeInfo").click(function(){S()});$("#aboutBtn").click(function(){if(r){S()}else{R();pageTracker._trackEvent("About","section_view")}});$("#right").css({left:t-33+"px",height:u+"px"});$("#loading").css({left:(t-parseInt($("#loading").width()))*.5,top:(u-parseInt($("#loading").height()))*.5});$(".msg").css({left:(t-parseInt($(".msg").width()))*.5,top:(u-parseInt($(".msg").height()))*.5});$("#limgBack,#limg").css({left:t*.5+"px",top:u*.5+"px"});$(window).scroll(function(){$("footer").css({top:u+$(window).scrollTop()-130+"px"});$("#left").css("height",u+$(window).scrollTop());$("#right").css("height",u+$(window).scrollTop())});T();A();if($(".flickrid").val()!="Your Flickr username"){s=true;M();G()}else{E();N()}$(window).resize(function(){w();T()})})
