// ColorBox v1.3.8 - a full featured, light-weight, customizable lightbox based on jQuery 1.3
(function(b,gb){var v="none",t="click",N="LoadedContent",d=false,x="resize.",o="y",u="auto",f=true,M="nofollow",q="on",n="x";function e(a,c){a=a?' id="'+k+a+'"':"";return b("
")}function p(a,b){b=b===n?m.width():m.height();return typeof a==="string"?Math.round(a.match(/%/)?b/100*parseInt(a,10):parseInt(a,10)):a}function Q(c){c=b.isFunction(c)?c.call(h):c;return a.photo||c.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i)}function cb(){for(var c in a)if(b.isFunction(a[c])&&c.substring(0,2)!==q)a[c]=a[c].call(h);a.rel=a.rel||h.rel||M;a.href=a.href||b(h).attr("href");a.title=a.title||h.title}function db(d){h=d;a=b.extend({},b(h).data(r));cb();if(a.rel!==M){i=b("."+H).filter(function(){return (b(this).data(r).rel||this.rel)===a.rel});g=i.index(h);if(g===-1){i=i.add(h);g=i.length-1}}else{i=b(h);g=0}if(!w){w=F=f;R=h;try{R.blur()}catch(e){}b.event.trigger(hb);a.onOpen&&a.onOpen.call(h);y.css({opacity:+a.opacity,cursor:a.overlayClose?"pointer":u}).show();a.w=p(a.initialWidth,n);a.h=p(a.initialHeight,o);c.position(0);S&&m.bind(x+O+" scroll."+O,function(){y.css({width:m.width(),height:m.height(),top:m.scrollTop(),left:m.scrollLeft()})}).trigger("scroll."+O)}T.add(I).add(J).add(z).add(U).hide();V.html(a.close).show();c.slideshow();c.load()}var eb={transition:"elastic",speed:300,width:d,initialWidth:"600",innerWidth:d,maxWidth:d,height:d,initialHeight:"450",innerHeight:d,maxHeight:d,scalePhotos:f,scrolling:f,inline:d,html:d,iframe:d,photo:d,href:d,title:d,rel:d,opacity:.9,preloading:f,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:d,loop:f,slideshow:d,slideshowAuto:f,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:d,onLoad:d,onComplete:d,onCleanup:d,onClosed:d,overlayClose:f,escKey:f,arrowKey:f},r="colorbox",k="cbox",hb=k+"_open",P=k+"_load",W=k+"_complete",X=k+"_cleanup",fb=k+"_closed",G=b.browser.msie&&!b.support.opacity,S=G&&b.browser.version<7,O=k+"_IE6",y,j,E,s,Y,Z,ab,bb,i,m,l,K,L,U,T,z,J,I,V,C,D,A,B,h,R,g,a,w,F,c,H=k+"Element";c=b.fn[r]=b[r]=function(c,d){var a=this;if(!a[0]&&a.selector)return a;c=c||{};if(d)c.onComplete=d;if(!a[0]||a.selector===undefined){a=b("");c.open=f}a.each(function(){b(this).data(r,b.extend({},b(this).data(r)||eb,c)).addClass(H)});c.open&&db(a[0]);return a};c.init=function(){var h="hover";m=b(gb);j=e().attr({id:r,"class":G?k+"IE":""});y=e("Overlay",S?"position:absolute":"").hide();E=e("Wrapper");s=e("Content").append(l=e(N,"width:0; height:0"),L=e("LoadingOverlay").add(e("LoadingGraphic")),U=e("Title"),T=e("Current"),J=e("Next"),I=e("Previous"),z=e("Slideshow"),V=e("Close"));E.append(e().append(e("TopLeft"),Y=e("TopCenter"),e("TopRight")),e().append(Z=e("MiddleLeft"),s,ab=e("MiddleRight")),e().append(e("BottomLeft"),bb=e("BottomCenter"),e("BottomRight"))).children().children().css({"float":"left"});K=e(d,"position:absolute; width:9999px; visibility:hidden; display:none");b("body").prepend(y,j.append(E,K));s.children().hover(function(){b(this).addClass(h)},function(){b(this).removeClass(h)}).addClass(h);C=Y.height()+bb.height()+s.outerHeight(f)-s.height();D=Z.width()+ab.width()+s.outerWidth(f)-s.width();A=l.outerHeight(f);B=l.outerWidth(f);j.css({"padding-bottom":C,"padding-right":D}).hide();J.click(c.next);I.click(c.prev);V.click(c.close);s.children().removeClass(h);b("."+H).live(t,function(a){if(a.button!==0&&typeof a.button!=="undefined"||a.ctrlKey||a.shiftKey||a.altKey)return f;else{db(this);return d}});y.click(function(){a.overlayClose&&c.close()});b(document).bind("keydown",function(b){if(w&&a.escKey&&b.keyCode===27){b.preventDefault();c.close()}if(w&&a.arrowKey&&!F&&i[1])if(b.keyCode===37&&(g||a.loop)){b.preventDefault();I.click()}else if(b.keyCode===39&&(g").children();a.h=b.height();b.replaceWith(b.children())}l.css({height:a.h});c.position(a.transition===v?0:a.speed)}};c.prep=function(o){var d="hidden";function n(t){var o,q,s,n,d=i.length,e=a.loop;c.position(t,function(){function t(){G&&j[0].style.removeAttribute("filter")}if(w){G&&p&&l.fadeIn(100);a.iframe&&b("").appendTo(l).attr({src:a.href,name:(new Date).getTime()});l.show();U.show().html(a.title);if(d>1){T.html(a.current.replace(/\{current\}/,g+1).replace(/\{total\}/,d)).show();J[e||g")[0].src=n;if(Q(q))b("")[0].src=q}}L.hide();a.transition==="fade"?j.fadeTo(f,1,function(){t()}):t();m.bind(x+k,function(){c.position(0)});b.event.trigger(W);a.onComplete&&a.onComplete.call(h)}})}if(w){var p,f=a.transition===v?0:a.speed;m.unbind(x+k);l.remove();l=e(N).html(o);l.hide().appendTo(K.show()).css({width:function(){a.w=a.w||l.width();a.w=a.mw&&a.mwa.mw){e=(d.width-a.mw)/d.width;q()}if(a.mh&&d.height>a.mh){e=(d.height-a.mh)/d.height;q()}}if(a.h)d.style.marginTop=Math.max(a.h-d.height,0)/2+"px";setTimeout(function(){m(d)},1);i[1]&&(g","/":"?","\\":"|"}};function keyHandler(handleObj){if(typeof handleObj.data!=="string"){return}var origHandler=handleObj.handler,keys=handleObj.data.toLowerCase().split(" ");handleObj.handler=function(event){if(this!==event.target&&(/textarea|select/i.test(event.target.nodeName)||event.target.type==="text")){return}var special=event.type!=="keypress"&&jQuery.hotkeys.specialKeys[event.which],character=String.fromCharCode(event.which).toLowerCase(),key,modif="",possible={};if(event.altKey&&special!=="alt"){modif+="alt+"}if(event.ctrlKey&&special!=="ctrl"){modif+="ctrl+"}if(event.metaKey&&!event.ctrlKey&&special!=="meta"){modif+="meta+"}if(event.shiftKey&&special!=="shift"){modif+="shift+"}if(special){possible[modif+special]=true}else{possible[modif+character]=true;possible[modif+jQuery.hotkeys.shiftNums[character]]=true;if(modif==="shift+"){possible[jQuery.hotkeys.shiftNums[character]]=true}}for(var i=0,l=keys.length;i=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
function highres() {
$('#_cboxHighres').unbind('click').hide();
if ($('.s').hasClass('h')) {
$('#_cboxHighres').bind('click', function(){
window.location.href=$('.s').attr('href').replace(/(\/[^\/]+)$/, '/.highres$1');
}).show();
}
}
function hash() {
if ($("#colorbox").css("display") != "none") {
window.location.hash = $('.s').children('img').attr('src').replace( /.*\//, "" );;
}
else {window.location.hash='_';}
}
function select() {
$('li a').removeClass('s');
$.colorbox.element().addClass('s');
}
function prev() {
if ($("#colorbox").css("display") == "none") {
var links = $('li:visible a');
links.eq((links.index($(".s").removeClass("s"))-1+links.length)%links.length).addClass("s");
scroll()
}
}
function next() {
if ($("#colorbox").css("display") == "none") {
var links = $('li:visible a');
links.eq((links.index($(".s").removeClass("s"))+1+links.length)%links.length).addClass("s");
scroll()
}
}
function isScrolledIntoView(elem)
{
var docViewTop = $(window).scrollTop();
var docViewBottom = docViewTop + $(window).height();
var elemTop = $(elem).offset().top;
var elemBottom = elemTop + $(elem).height();
return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom)
&& (elemBottom <= docViewBottom) && (elemTop >= docViewTop) );
}
function scroll() {
if (!isScrolledIntoView($('.s')))
$.scrollTo('.s', 500, {offset: -120});
}
$(document).ready(function(){
// attach colorbox to folder & pics
var opts = {
rel:'group1',
maxWidth:'95%',
maxHeight:'95%',
slideshow:true,
slideshowAuto:false,
onComplete:function(){hash();highres();},
onClosed:function(){hash();scroll();},
onLoad:function(){select();}
}
$(".p li a").colorbox(opts);
$('#cboxTitle').after('
');
highres();
if (window.location.hash != '' && window.location.hash != '#' && window.location.hash != '#_' && window.location.hash != null) {
var h = window.location.hash.substr(1);
$('li a').removeClass('s');
$('li a img[src$='+h+']').parent().addClass('s');
$('.s').click();
}
// launch/start/stop diapo
$(document).bind('keydown', 'd space', function(){
if ($("#colorbox").css("display") == "none") {
$('.s').click();
}
$('#cboxSlideshow').click();
return false;
});
$(document).bind('keydown', 'o return', function(){
if ($("#colorbox").css("display") == "none") {
if ($('.p .s').length != 0)
$('.s').click();
else
window.location.href=$('.s').attr('href');
} else {
$('#_cboxHighres').click();
}
});
//current pic is clicked pic
$('li a').click(function(){
$('li a').removeClass('s')
$(this).addClass('s');
});
//change current selected pic
$(document).bind('keydown', 'j left', function(){
if ($("#colorbox").css("display") == "none") {
prev();
}
});
$(document).bind('keydown', 'k right', function(){
if ($("#colorbox").css("display") == "none") {
next();
}
});
$(document).bind('keydown', 'j', function(){if ($("#colorbox").css("display") != "none") $('#cboxPrevious').click();});
$(document).bind('keydown', 'k', function(){if ($("#colorbox").css("display") != "none") $('#cboxNext').click();});
$(document).bind('keydown', 'esc u', function(){
if ($("#colorbox").css("display") == "none") {
//up one dir
window.location.href=$('#t a').eq($('#t a').length-2).attr('href');
} else {
$('#cboxClose').click();
}
});
$(document).keydown(function(e){
var k=(e.keyCode)?e.keyCode: ((e.charCode)?e.charCode:((e.which)?e.which:0));
if (k == 191) { // "/"
$('#q').focus();
return false;
}
});
$(document).bind('keydown', 'shift+e', function(){window.location.href='?edit/Famille/2010-06-13-Jules'});
$('#q').bind('keydown', 'esc', function(){$('#q').blur();});
$('#q').keyup(function(){
var links = $('li a');
links.parent().hide();
var m = $('li a img').filter(function() {// filter function to deal with case-sensitiveness
return (new RegExp(na($('#q').attr('value').toLowerCase()), "i")).test(na($(this).attr('title')));
});
$('li a img').parent().removeClass('s');
m.eq(0).parent().addClass('s');
m.parent().parent().show();
$(".p li a").removeClass('cboxElement').removeData('colorbox');
$(".p li:visible a").colorbox(opts);
});
function na(strAccents){ //strips out accents
strAccents = strAccents.split('');
strAccentsOut = new Array();
strAccentsLen = strAccents.length;
var accents = 'ÀÃÂÃÄÅà áâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÃÃŒÃÃŽÃìÃîïÙÚÛÜùúûüÑñŠšŸÿýŽž';
var accentsOut = ['A','A','A','A','A','A','a','a','a','a','a','a','O','O','O','O','O','O','O','o','o','o','o','o','o','E','E','E','E','e','e','e','e','e','C','c','D','I','I','I','I','i','i','i','i','U','U','U','U','u','u','u','u','N','n','S','s','Y','y','y','Z','z'];
for (var y = 0; y != strAccentsLen; y++) { // not less than operator!
if (accents.indexOf(strAccents[y]) != -1) {
strAccentsOut[y] = accentsOut[accents.indexOf(strAccents[y])];
}
else
strAccentsOut[y] = strAccents[y];
}
strAccentsOut = strAccentsOut.join('');
return strAccentsOut;
}
//select first pic (or folder)
$('li a:first').addClass('s');
//TODO
//full ajax?
// - get folders/pictures
// - generate page
// - on folder click, request folder content, wipe page, rebuild
});