$(function(){
    $("#user-controls input[type='text'], #user-controls input[type='password'], #subscribe input[type='text'], #subscribe input[type='password'], #lightbox-email input[type='text']").click(function() {
        if (this.value == this.defaultValue) {
            this.value = '';
        }
    });
    $("#user-controls input[type='text'], #user-controls input[type='password'], #subscribe input[type='text'], #subscribe input[type='password'], #lightbox-email input[type='text']").blur(function() {
        if (this.value == '') {
            this.value = this.defaultValue;
        }
    });
    $("#subscribe input[type='text']").click(function(){
        $(this).parent().find("input[type='submit']").fadeIn();
    });  
    $("#subscribe input[type='text']").blur(function() {
        if (this.value == '' || this.value == this.defaultValue) {
            $(this).parent().find("input[type='submit']").fadeOut();
        }
    });
    $(".email").each(function() {
        var e = $(this).text().replace(" [+] ", "&#64;");
        $(this).html("<a href=\"mailto:" + e + "\">" + e + "</a>");
    });
    $("img").one("error",function(event){
    	src = $(this).attr("src").replace("http://yesassets.s3.amazonaws.com/map/cache/","http://assets.okdk.co.uk/imagecache/");
    	$(this).attr("src",src);
    	event.preventDefault();
    });
    $("#folio-shareclosed").click(function(){
    	$(this).hide();
    	$("#folio-shareopen").css("display","inline");
    	$("#folio-shareopen").fadeTo("slow",1);
    	$("#folio-caption").css("right","395px");
    });
    setminheight();
});
                                      
$(window).load(function(){
    setheader();
});

$(window).resize(function(){
    setminheight();
    setheader();
});

function setminheight(){
    $("#lightbox, #production, #artist, #post, #error").css("min-height",$(window).height() - 280+"px");
     $("#information").css("min-height",$(window).height() - 215+"px");
    $("#overview").css("min-height",$(window).height() - 321 - $("#filter").height()+"px");
}

function setheader(){
    if($(window).width() < 1263){
        $("header").css("left", "0px").css("margin-left", "0px");
    } else {
        $("header").css("left", "50%").css("margin-left", "-630px");
    }
}

window.log = function(){
    log.history = log.history || [];  
    log.history.push(arguments);
    arguments.callee = arguments.callee.caller;  
    if(this.console) console.log( Array.prototype.slice.call(arguments) );
};

(function(b){
    function c(){}
    for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c
        })(window.console=window.console||{});
function clean(string) {
    return string.toLowerCase().replace(/[^a-z,0-9]/gi, '');
}
