/*
main.js
http://scottdarby.com/

Copyright (c) 2009 Scott Darby
info@scottdarby.com

You are free to use this code as inspiration, but please don't copy it without crediting me.
*/
function indentTxt(a){$(a).css("textIndent","-9999em")}function unIndentTxt(a){$(a).css({textIndent:"0"})}function indentAll(){$("input.indent[type=text]").each(function(){$(this).prev("label").addClass("indentable");if($(this).val()===""){unIndentTxt($(this).prev())}else{indentTxt($(this).prev())}$(this).prev("label").click(function(){indentTxt(this);$(this).next().focus()});$(this).focus(function(){indentTxt($(this).prev())});$(this).blur(function(){if(this.value===""){unIndentTxt($(this).prev())}});$(this).prev("label").mouseover(function(){$(this).css("cursor","text")})})}jQuery.fn.fader=function(){return this.each(function(){var a=$(this);if(!a.parent().hasClass("current_page_item")){a.append('<span class="fade-img"></span>');a.children().css("opacity","0");a.hover(function(){$(this).children().stop().animate({opacity:1},"slow");$(this).css("background","none")},function(){$(this).children().stop().animate({opacity:0},"slow")})}})};function slideContent(a){$(a).parent().addClass("slideContent");clicked=false;if(clicked==false){selected=0}portfolioLength=$(a).length-1;changeSelected(a);changeImage("prev",a);changeImage("next",a)}function changeSelected(a){$(".selected").removeClass("selected");$(a).eq(selected).addClass("selected");$(".selected .project-image, .selected h2, .selected .project-details").hide().fadeIn("slow");timer=setInterval("miniSlideShow()",4000)}function miniSlideShow(){var a=$(".selected .project-image a.active");if(a.length==0){a=$(".selected .project-image a:last")}var b=a.next().length?a.next():$(".selected .project-image a:first");a.addClass("last-active");b.hide().addClass("active").fadeIn("slow",function(){a.removeClass("active last-active")});a.removeClass("active")}function changeImage(a,b){$("."+a+"-project").click(function(){clearInterval(timer);$(".selected h2, .selected .project-details").fadeOut("slow");$(".selected .project-image").fadeOut("slow",function(){if(a=="prev"){selected--}else{selected++}if(selected==-1){selected=portfolioLength}else{if(selected>portfolioLength){selected=0}}clicked=true;changeSelected(b)});return false})}function replaceLegend(){var c=$("legend");var b=c.text();var a=$("<h2></h2>");a.text(b);c.replaceWith(a)}function addTexture(){var a=$("#wrapper");if(a.height()>1000){a.addClass("textured")}}function newWindow(){$('a[rel="blank"]').attr("target","_blank")}$(document).ready(function(){indentAll();slideContent("#content .portfolio-list li");$("#s").focus(function(){$(this).parent().parent().toggleClass("focussed")});$("#s").blur(function(){$(this).parent().parent().toggleClass("focussed")});replaceLegend();$(".stats li:last-child").prev().addClass("penultimate");addTexture();newWindow()});$(window).load(function(){$("#primaryNav li a").fader()});