$("#txtTags").keyup(function(e){if((e.which>=97&&e.which<=122)||(e.which>=65&&e.which<=90)){getTags($(this).val());$("#txtTags").attr("rel","")}}).blur(function(){if(!$(".autoComplete").hasClass("on")){$(".autoComplete").hide();$(this).unbind("keypress")}});function getTags(tagStart){serviceGalleryProxy.invoke("GetTags",{tagStartsWith:tagStart},getTagsSuccess,getTagsFail)}function getTagsSuccess(tags){var aC=$(".autoComplete");if(tags!=""){aC.html("<ul></ul>");for(var i=0;i<tags.length;i++){var tagParts=tags[i].split("|");aC.children("ul").append("<li rel='"+tagParts[0]+"'>"+tagParts[1]+"</li>")}aC.show();$("#txtTags").keypress(function(e){var aC=$(".autoComplete");if(e.keyCode==40){if(!$(".autoComplete li").hasClass("on")){$(".autoComplete li:first").addClass("on")}else{if(!$(".autoComplete li:last").hasClass("on")){$(".autoComplete li.on").removeClass("on").next().addClass("on")}}}else{if(e.keyCode==38){if($(".autoComplete li:first").hasClass("on")){aC.hide()}else{$(".autoComplete li.on").removeClass("on").prev().addClass("on")}}else{if(e.keyCode==39||e.keyCode==13||e.keyCode==9){if($(".autoComplete li").hasClass("on")){$(this).val($(".autoComplete li.on").text())}else{$(this).val($(".autoComplete li:first").text())}aC.hide(1,function(){$(this).html()});if(e.keyCode==9){return false}}else{}}}})}else{aC.html("").hide()}}$(".autoComplete").live("mouseover",function(){$(this).addClass("on")}).live("mouseout",function(){$(this).removeClass("on")});$(".autoComplete li").live("click",function(){$("#txtTags").val($(this).text()).focus();$("#txtTags").attr("rel",$(this).attr("rel"));$(".autoComplete").hide()});function getTagsFail(){}function addTag(){var str=$("#txtTags").val();if(str!=""&&!(str.indexOf(" ")>=0)){$(".selTags select").append("<option value='"+str+"' rel='"+$("#txtTags").attr("rel")+"'>"+str+"</option>");$("#txtTags").val("")}}function removeTag(){$(".selTags select :selected").remove()}$(".submitEntry").click(function(){var str="";$(".selTags option").each(function(){str+=$(this).text()+","});$("#hidTags").val(str)});$(".sortBy a").each(function(){var thisUrl=location.href;if(thisUrl.indexOf($(this).attr("href"))>=0){$(this).parent().siblings(".on").removeClass("on");$(this).parent().addClass("on")}});$("#gallery .updated").each(function(){var dt=new Date();var y=dt.getYear();if(y<1000){y+=1900}var time=$(this).text();var timeParts=time.split(" ");var dateParts=timeParts[0].split("/");var textUpdated=timeParts[1];if((dateParts[0]==dt.getMonth()+1)&&(dateParts[2]==y)){var daysSince=dt.getDate()-dateParts[1];if(daysSince==0){textUpdated="Today"}else{if(daysSince==1){textUpdated="1 day ago"}else{textUpdated=daysSince+" days ago"}}}else{if(dateParts[2]==y){var monthsSince=dt.getMonth()+1-dateParts[0];if(monthsSince==1){textUpdated="1 month ago"}else{textUpdated=monthsSince+" months ago"}}else{var yearsSince=y-dateParts[2];if(yearsSince==1){textUpdated="1 year ago"}else{textUpdated=yearsSince+" years ago"}}}$(this).text(textUpdated)});$("#gallery .rating").each(function(){var rating=$(this).children().text();$(this).css("background-position","left -"+(13*rating)+"px");$(this).attr("title",rating/2)});function swapGI(id1,id2){$("."+id1).hide();$("."+id2).fadeIn("slow")};