/* Constants
*/
var UNDEF='undefined';
var C = {
THMB:'#thumbs',
THMBC:'#cont',
THMC:'#cont>ul.thmb',
SCRL:'#scroll-left',
SCRR:'#scroll-right',
CLOS:'#close',
IMGS:'#images',
HEAD:'#header',
FOOT:'#footer',
UPBTN:'#up',
PRVBTN:'#prev',
NXTBTN:'#next'
};
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,'');
};
String.prototype.cleanupHTML = function() {
return this.replace(/
/g,'\n').replace(/\&/g,'&').replace(/\</g,'<').replace(/\>/g,'>').replace(/\&(m|n)dash;/g,'-').replace(/\'/g,'\'').replace(/\"/g,'"');
};
String.prototype.appendSep = function(s,sep) {
if(typeof sep=='undefined') sep=' · ';
return (this.length?(this+sep):'')+s;
};
/* Easing by George Smith
*/
jQuery.extend(jQuery.easing, {
easeOutBack: function (x, t, b, c, d, s) {
if(s==undefined) s=1.70158;
return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b;
},
easeOutSine: function (x, t, b, c, d) {
return c * Math.sin(t/d * (Math.PI/2)) + b;
}
});
/* Cookie handling from http://www.quirksmode.org/js/cookies.html
*/
var Cookie = {
put: function(name,value,hours){
if(typeof hours==UNDEF) hours=1;
var expires='';
if(hours){
var date=new Date();
date.setTime(date.getTime()+(hours*60*60*1000));
expires='; expires='+date.toGMTString();
}
document.cookie=name+"="+value+expires+"; path=/";
},
get: function(name){
var nm=name+'=';
var ca=document.cookie.split(';');
for(var i in ca) {
var c=ca[i].replace(/^\s*/,'');
if(c.indexOf(nm)==0)
return c.substring(nm.length);
}
return null;
},
getBoolean: function(name){
var c=Cookie.get(name);
return c!=null&&c!='false';
},
clear: function(name){
Cookie.put(name,'',-1);
}
};
/* Skin code
*/
var Ctrl = {
top:null,
bottom:null,
topOn:captionsOn,
bottomOn:thumbsOn,
init:function(){
Ctrl.top=$('#top');
Ctrl.bottom=$('#bottom');
Ctrl.center();
$('#toptab').click(Ctrl.toggleTop);
$('#bottomtab').click(Ctrl.toggleBottom);
var c=Cookie.get('_cs_top');
if(c) this.topOn=(c!='false');
else this.topOn|=Thumbs.folders.length;
if(!this.topOn)
Ctrl.top.css({top:-Ctrl.top.height()});
c=Cookie.get('_cs_bottom');
if(c) this.bottomOn=(c!='false');
else this.bottomOn|=Thumbs.folders.length;
if(!this.bottomOn)
Ctrl.bottom.css({bottom:-Ctrl.bottom.height()+25});
},
center:function(){
var wh=$('#images').height();
var bh=$('#prev').height();
$('#prev,#next').css({top:Math.round((wh-bh)/2)});
},
toggleTop:function(){
var ch=Ctrl.top.height();
Ctrl.top.stop(true,false);
if(Ctrl.topOn)
Ctrl.top.animate({top:-ch},500,'easeOutSine');
else
Ctrl.top.animate({top:0},500,'easeOutSine');
Ctrl.topOn=!Ctrl.topOn;
Cookie.put('_cs_top',Ctrl.topOn);
},
toggleBottom:function(){
var ch=Ctrl.bottom.height();
Ctrl.bottom.stop(true,false);
if(Ctrl.bottomOn)
Ctrl.bottom.animate({bottom:-ch+25},500,'easeOutSine');
else
Ctrl.bottom.animate({bottom:0},500,'easeOutSine');
Ctrl.bottomOn=!Ctrl.bottomOn;
Cookie.put('_cs_bottom',Ctrl.bottomOn);
},
goUp:function(){
window.location=(typeof parentIndexPage=='undefined' || !parentIndexPage.length)?'../':parentIndexPage;
}
};
var Imgs = {
div:null,
curr:-1,
width:0,
height:0,
left:0,
ul:null,
anim:0,
fit:true,
init:function(){
Imgs.ul=$('#images>ul');
if(images.length>0){
l=Imgs.getImg(0);
Imgs.curr=0;
Imgs.width=Imgs.div.width();
Imgs.height=Imgs.div.height();
Imgs.left=Imgs.ul.offset().left;
var c=Cookie.get('_cs_fit');
Imgs.fit=(c)?(c==='true'):fitImages;
Imgs.setImg(1,0);
Imgs.setImg(2,1);
Imgs.preload(2);
$('#prev').click(Imgs.prev);
$('#next').click(Imgs.next);
Imgs.setCaption();
Thumbs.setactive();
}
},
preload:function(n){
if(n<(images.length)&&n>=0){
var img=new Image();
img.src=decodeURIComponent(images[n].file);
}
},
next:function(){
if(Imgs.curr==(images.length-1)){
if(slideshowLoop)
Imgs.goto(0);
else {
Imgs.stop();
Alert.show('
'+text.atLastPageQuestion+'
', new Array({t:text.startOver,h:function(){Imgs.goto(0);}}, {t:text.up,h:function(){Ctrl.goUp();}}, {t:text.stop,h:null})); } } else Imgs.goto(Imgs.curr+1); }, prev:function(){ Imgs.goto((Imgs.curr==0)?(images.length-1):Imgs.curr-1); }, getImg:function(pos){ return Imgs.ul.find('li').eq(pos); }, setImg:function(pos,n){ if(n<0||n>=images.length) return; var l=Imgs.getImg(pos); l.empty().append(''); Imgs.fitWindow(pos,n); }, fitWindow:function(pos,n){ if(n<0||n>=images.length) return; var iw=parseInt(images[n].width), ih=parseInt(images[n].height); var l=Imgs.getImg(pos); if(Imgs.fit){ if(Imgs.width/iw<=Imgs.height/ih){ih=Math.round(ih*Imgs.width/iw);iw=Imgs.width;} else{iw=Math.round(iw*Imgs.height/ih);ih=Imgs.height;} } l.find('img').css({width:iw,height:ih,top:Math.round((Imgs.height-ih)/2),left:Math.round((Imgs.width-iw)/2)}).dblclick(Imgs.toggleFit); }, toggleFit:function(){ var iw=parseInt(images[Imgs.curr].width), ih=parseInt(images[Imgs.curr].height); var ww=Imgs.width, wh=Imgs.height; var l=(ww-iw)/2, t=(wh-ih)/2; if(!Imgs.fit){ if(ww/iw<=wh/ih) {ih=Math.round(ih*ww/iw);iw=ww;} else {iw=Math.round(iw*wh/ih);ih=wh;} l=(ww-iw)/2; t=(wh-ih)/2; }else{ if(typeof c!=UNDEF && (iw>ww&&ih>wh)){ l=Math.round(ww/2-c.x*iw); t=Math.round(wh/2-c.y*ih); if(l>0) l=0; else if(l<(ww-iw)) l=ww-iw; if(t>0) t=0; else if(t<(wh-ih)) t=wh-ih; }else{ l=(ww-iw)/2; t=(wh-ih)/2; } } Imgs.fit=!Imgs.fit; Cookie.put('_cs_fit',Imgs.fit); Imgs.getImg(1,Imgs.curr).find('img').animate({width:iw,height:ih,left:l,top:t},500); Imgs.fitWindow(0,Imgs.curr-1); Imgs.fitWindow(2,Imgs.curr+1); }, stopRight:function(){ Imgs.getImg(3).remove(); Imgs.anim=0; }, moveRight:function(n){ Imgs.ul.prepend('').appendTo($('body')); h.html(to.data('hint')); var o=to.offset(); var t=o.top-h.outerHeight()-10; var l=Math.round(o.left+(to.outerWidth()-h.outerWidth())/2); if(t<0){ t=o.top+to.outerHeight()+10; if((t+to.outerHeight())>$(window).height()) t=$(window).height()-h.outerHeight(); } if(l<0){ l=o.left+to.outerWidth()+10; t=o.top+(to.outerHeight()-h.outerHeight())/2; } else if((l+h.outerWidth())>$(window).width()) { l=o.left-10-h.outerWidth(); t=o.top+(to.outerHeight()-h.outerHeight())/2; } h.css({left:l,top:t}).fadeIn(); },function(){$('#hint').remove()}); } } }; var Alert = { show:function(text,buttons){ $('#modal').remove(); $('body').append('
'+text.upgradeBrowserExplain+'
',new Array(text.contin))},2000); } });