'
o+=T('left - zoom in')+' '
o+=T('right - zoom out')+' '
o+=remotekeys()
output('hiddenlayer',font(o))
var x=divWidth('hiddenlayer')+2*fontsize
var y=divHeight('hiddenlayer')+2*fontsize
if (options&HELP && (!HELPER || HELPER.closed)) {
HELPER=window.open('','JShelp','height='+y+',width='+x+',toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,screenX='+(screen.availWidth-x-10)+',left='+(screen.availWidth-x-10))
if (HELPER) {
HELPER.document.clear()
HELPER.document.writeln(font(o))
HELPER.document.close()
inheritColors(document,HELPER.document)
HELPER.document.onkeypress=HELPER.getKey
}
} else {
if (HELPER && !HELPER.closed) HELPER.close()
HELPER=0
}
}
//
// Construct object prototypes
//
function JSImage() {
this.image=0
this.left=0
this.fixed=0
this.status=0
this.top=0
this.zoom=0
}
//
// Browser specific DHTML functions
//
function getElement(name) {
if (isIE5) return document.all[name]
if (document.getElementById) return document.getElementById(name)
if (document.all) return document.all[name]
if (document.layers) return document[name]
}
function getDoc(name) {
if (isIE5) return document.all[name].document
if (document.getElementById) return document.getElementById(name).ownerDocument
if (document.all) return document.all[name].document
if (document.layers) return document[name].document
}
function divWidth(name) {
if (isIE5) return document.all[name].offsetWidth
if (document.getElementById) return document.getElementById(name).offsetWidth
if (document.all) return document.all[name].offsetWidth
if (document.layers) return document[name].document.width
}
function divHeight(name) {
if (isIE5) return document.all[name].offsetHeight
if (document.getElementById) return document.getElementById(name).offsetHeight
if (document.all) return document.all[name].offsetHeight
if (document.layers) return document[name].document.height
}
function getLayer(name) {
if (isIE5) return document.all[name].style
if (document.getElementById) return document.getElementById(name).style
if (document.all) return document.all[name].style
if (document.layers) return document[name]
}
function getX(layer) {
layer=getLayer(layer)
if (isIE5) return layer.pixelLeft
if (document.getElementById) return parseInt(layer.left)
if (document.all) return layer.pixelLeft
if (document.layers) return layer.x
}
function getY(layer) {
layer=getLayer(layer)
if (isIE5) return layer.pixelTop
if (document.getElementById) return parseInt(layer.top)
if (document.all) return layer.pixelTop
if (document.layers) return layer.y
}
function getLanguage() {
var lang=navigator.userLanguage?navigator.userLanguage:navigator.language
return lang.substr(0,2)
}
function setClip(layer,x,y,t,r,b,l) {
debug(); layer=getLayer(layer)
if (isIE5) {
layer.clip='rect('+t+'px '+r+'px '+b+'px '+l+'px)'
layer.pixelLeft=x
layer.pixelTop=y
} else if (document.getElementById) {
layer.left=x
layer.top=y
layer.clip='rect('+t+' '+r+' '+b+' '+l+')'
} else if (document.all) {
layer.clip='rect('+t+'px '+r+'px '+b+'px '+l+'px)'
layer.pixelLeft=x
layer.pixelTop=y
layer.overflow='hidden'
} else if (document.layers) {
layer.clip.top=t
layer.clip.right=r
layer.clip.bottom=b
layer.clip.left=l
layer.moveTo(x,y)
}
}
function setWidth(layer,w) {
layer=getLayer(layer)
if (isIE5)
layer.posWidth=w
else if (document.getElementById)
layer.width=w
else if (document.all)
layer.posWidth=w
else if (layer.clip)
layer.clip.width=w
}
function output(layer,html) {
if (isIE5) {
layer=eval(layer)
layer.innerHTML=html
} else if (document.getElementById)
document.getElementById(layer).innerHTML=html
else if (document.all) {
layer=eval(layer)
layer.innerHTML=html
} else if (document.layers) {
var doc=getDoc(layer)
doc.open()
doc.writeln(html)
doc.close()
}
}
function setXY(layer,x,y) {
debug(); layer=getLayer(layer)
if (isIE5) {
layer.pixelLeft=x
layer.pixelTop=y
} else if (document.getElementById) {
layer.left=x
layer.top=y
} else if (document.all) {
layer.pixelLeft=x
layer.pixelTop=y
} else if (document.layers)
layer.moveTo(x,y)
}
function center(layer,y) { setXY(layer,Math.round((width-divWidth(layer)-leftMargin-rightMargin)/2)+leftMargin,y) }
function setCursor(curtype) { if (document.all) document.body.style.cursor=curtype }
function setVisibility(layer,vis) {
debug()
layer=getLayer(layer)
layer.visibility=(vis?'visible':'hidden')
}
function remotekeys() {
return ''
}
function getKey(evt) {
var key=document.all?event.keyCode:
evt.keyCode?evt.keyCode:
evt.charCode?evt.charCode:
evt.which?evt.which:void 0
dokey(String.fromCharCode(key).toLowerCase())
return false
}
function dokey(key) {
switch(key) {
case '!': toggleOption(DEBUGMODE); break
case '+': case '=': nextImage(); break
case '-': previousImage(); break
case '<': case ',': slower(); break
case '>': case '.': faster(); break
case '^': toggleOption(CONTROLTOP); break
case 'a': toggleOption(ADVANCED); break
case 'c': toggleOption(CONTROLS); break
case 'd': toggleOption(CAPTIONS); break
case 'e': toggleOption(EFFECTS); break
case 'f': gofullScreen(); break
case 'h': toggleOption(HELP); break
case 'l': toggleOption(LANGUAGES); break
case 'm': toggleOption(MAXSIZE); break
case 'o': alert('options='+options); break
case 'p': toggleOption(PRECACHE); break
case 'r': toggleOption(RANDOM); break
case 's': slideshow(); break
case 't': toggleOption(THUMBS); break
case 'x': exitfullScreen(); break
case 'z': toggleOption(ZOOM); break
case '?': alert(about()); break
case '\r': if (kpic && kpic<=pics) { displayImage(save(kpic-1)) }
kpic=0
break
default: if (!isNaN(key)) {
kpic=kpic*10+parseInt(key)
} else {
debug(T('You typed')+': '+key)
}
}
}
//
// Debug functions
//
function startDebug() {
DEBUG=window.open()
if (DEBUG) {
DEBUG.document.clear()
DEBUG.document.writeln('
JSviewer Debugger
')
DEBUG.document.writeln(remotekeys()+'
'+about())
DEBUG.document.onkeypress=DEBUG.getKey
log(navigator.userAgent)
log(document.URL)
window.focus()
}
}
function log(s) {
if (DEBUG && !DEBUG.closed) {
var localtime=new Date()
DEBUG.document.writeln(localtime+' '+s)
DEBUG.scrollTo(0,99999999)
} else DEBUG=0
}
function stopDebug() {
log(T('End debug')+'.
')
if (DEBUG && !DEBUG.closed) DEBUG.document.close()
DEBUG=0
}
function funcall(caller) {
if (caller) {
var s=caller.toString()
var results=s.match(/function\s+([^\(]+)\(([^\)]*)\)\s.+/)
var func=results?results[1]:''
var args=results?results[2]:''
args=args.split(',')
for (var i=0;i'
document.writeln(o)
}
function T(s) {
if (words && words[language] && !words[language][s]) debug(s)
return (words && words[language] && words[language][s])?words[language][s]:s
}
function Tr(s) {
s=T(s)
var result
while (result=s.match(/\(\d+);/))
s=s.replace(result[0],String.fromCharCode(RegExp.$1))
return s
}
function randomPick() {
return randomPick.arguments[Math.floor(Math.random()*randomPick.arguments.length)]
}
function pick(n,c) {
var i=n
if (c>1) while (i==n) {
i=Math.floor(n+Math.random()*c)%c
if (c>12) for (var p=-10; p<=0; p++)
if (History[(History.length+index+p)%History.length]==i) i=n
}
return i
}
function isImage(i) {
var name=imageFile(i)
if (name=='') return 0
name=name.toLowerCase()
var dot=name.lastIndexOf('.')
var imagetypes='.gif.jpg.jpeg.png'
return imagetypes.indexOf(name.substr(dot))>=0
}
function save(image) {
index=(index+1)%History.length
History[index]=image
History[(index+1)%History.length]=-1
return image
}
function redraw() {
saveState()
if (DEBUG && !DEBUG.closed) DEBUG.close()
window.location.reload()
return false
}
function inheritColors(source,dest) {
dest.bgColor=source.bgColor
dest.fgColor=source.fgColor
dest.linkColor=source.linkColor
dest.alinkColor=source.alinkColor
dest.vlinkColor=source.vlinkColor
}
function font(s,c) { return ''+s+'' }
function small(s) { return ''+s+'' }
function form(s) { return '' }
function vstat(s) {
return 'onmouseover="window.status='+s+'; return true" onmouseout="window.status=\'\'; return true"'
}
function stat(s) { return vstat("'"+s+"'") }
function link(func,extra,text) {
return ''+text+' '
}
function button(value,func,extra) {
return ' '
}
function checkbox(opt,extra,text) {
return ' '+text+' '
}
function notify(s,c) {
debug()
setClip('picture',leftOffset,topOffset,0,width-leftOffset-rightOffset,height-topOffset-bottomOffset-captionOffset,0)
output('picture',font(s,c))
output('hiddenlayer',font(s,c))
var w=width-leftOffset-rightOffset
if (w>divWidth('hiddenlayer')) w=divWidth('hiddenlayer')
setWidth('picture',w)
W=divWidth('picture')
H=divHeight('picture')
if ((width-W)/2<=leftOffset || (width-W)/2<=rightOffset)
X=Math.floor((width-leftOffset-rightOffset-W)/2)+leftOffset
else
X=Math.floor((width-leftMargin-rightMargin-W)/2)+leftMargin
if ((height-H-captionOffset)/2<=topOffset || (height-H-captionOffset)/2<=bottomOffset)
Y=Math.floor((height-topOffset-bottomOffset-captionOffset-H)/2)+topOffset
else
Y=Math.floor((height-topMargin-bottomMargin-captionOffset-H)/2)+topMargin
setXY('picture',X,Y)
}
function error(s) { notify(s,'red') }
function gofullScreen() {
// Stop slide show
window.clearTimeout(redisp)
saveState()
window.open(document.URL,'JSfull','fullscreen=1,height='+(screen.availHeight-10)+',width='+(screen.availWidth-10)+',screenX=0,screenY=0,left=0,top=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0')
}
function exitfullScreen() {
if (window.opener && window.opener.toggleVisibility) {
saveState()
window.opener.location.reload()
}
if (parent) parent.window.close(); else window.close()
}
//
// Image caching functions
//
function imageFile(i) {
var img=escape(images.options[i].value.split(';')[0])
return img.replace('http%3A//','http://')
}
function imageCaption(i) {
var caption=images.options[i].value.split(';')[1]
return caption?caption:''
}
function preFetch(i) {
if (isImage(i) && !Images[i].status) {
debug()
Images[i].status=2
Images[i].image=new Image()
Images[i].image.onload=function() { Images[i].status=1; cacheImage(i) }
Images[i].image.onabort=function() { Images[i].status=0 }
Images[i].image.onerror=function() { Images[i].status=3; postFetch() }
Images[i].image.src=imageFile(i)
}
}
function flushCache(i) {
memory=0
clearOption(PRECACHE)
while (cache.length>10) {
var p=cache[0]
cache=cache.slice(1)
if (i!=p && Images[p].status==1) {
debug(T('Flushing image')+' '+p+' '+T('from cache'))
Images[p].image=Images[p].status=0
Thumbs[p].image=Thumbs[p].status=0
}
}
}
function cacheImage(i) {
// Track browser cache memory usage
if (Images[i].image.fileSize) memory+=Images[i].image.fileSize*1
else memory+=Math.round(Images[i].image.width*Images[i].image.height/2)
cache[cache.length]=i
// Clear memory cache if needed
if (memory>16777216) flushCache(i)
postFetch()
}
function postFetch() {
debug()
// Always pre-cache next image if not loaded
if (isImage(lookahead) && !Images[lookahead].status) return preFetch(lookahead)
// Only pre-cache first 16 MB of images
if (options&PRECACHE && memory<16777216) for (var i=(pic+1)%pics;i!=pic;i=(i+1)%pics)
if (isImage(i) && !Images[i].status)
// Use window.setTimeout to prevent stack overflow
return window.setTimeout('preFetch('+i+')',50);
}
function thumbFile(i) {
var thumb=imageFile(i)
var path=thumb.split('/')
var l=path.length
path[l]=path[l-1]; path[l-1]=thumbdir
return path.join('/')
}
function fetchThumb(i) {
if (isImage(i) && !Thumbs[i].status) {
debug(thumbFile(i))
Thumbs[i].status=2
Thumbs[i].image=new Image()
Thumbs[i].image.onload=function() { Thumbs[i].status=1 }
Thumbs[i].image.onabort=function() { Thumbs[i].status=0 }
Thumbs[i].image.onerror=function() { Thumbs[i].status=3 }
Thumbs[i].image.src=thumbFile(i)
}
}
//
// Image rendering functions
//
function IEtransition(d) {
var trans=transitiontype
d='duration='+d
if (trans===void 0) switch (Math.floor(Math.random()*17)) {
case 0: trans='Barn('+d+',motion='+randomPick('in','out')+',orientation=',randomPick('horizontal','vertical')+')'
break;
case 1: trans='Blinds('+d+',bands='+randomPick(2,4,6,8)+',direction='+randomPick('up','down','right','left')+')'
break;
case 2: trans='CheckerBoard('+d+',squaresX='+randomPick(2,4,8,12)+',squaresY='+randomPick(2,4,8,12)+',direction='+randomPick('up','down','right','left')+')'
break;
case 3: trans='Fade('+d+',overlap='+randomPick(0.25,0.5,0.75,1)+')'
break;
case 4: trans='GradientWipe('+d+',gradientSize='+randomPick(0,0.1,0.3,0.5,0.7,0.9,1)+',wipeStyle='+randomPick(0,1)+',motion='+randomPick('forward','reverse')+')'
break;
case 5: trans='Inset('+d+')'
break;
case 6: trans='Iris('+d+',irisStyle='+randomPick('DIAMOND','CIRCLE','CROSS','PLUS','SQUARE','STAR')+',motion='+randomPick('in','out')+')'
break;
case 7: trans='Pixelate('+d+',maxSquare='+randomPick(5,10,20,30,40,50)+')'
break;
case 8: trans='RadialWipe('+d+',wipeStyle='+randomPick('CLOCK','WEDGE','RADIAL')+')'
break;
case 9: trans='RandomBars('+d+',orientation='+randomPick('horizontal','vertical')+')'
break;
case 10: trans='RandomDissolve('+d+')'
break;
case 11: trans='Slide('+d+',pushStyle='+randomPick('HIDE','PUSH','SWAP')+',bands='+randomPick(1,2,3,4,5,6,7)+')'
break;
case 12: trans='Spiral('+d+',gridSizeX='+randomPick(8,16,32,64)+',gridSizeY='+randomPick(8,16,32,64)+')'
break;
case 13: trans='Stretch('+d+',stretchStyle='+randomPick('HIDE','PUSH','SPIN')+')'
break;
case 14: trans='Strips('+d+',motion='+randomPick('leftdown','leftup','rightdown','rightup')+')'
break;
case 15: trans='Wheel('+d+',spokes='+randomPick(2,4,10,16,20)+')'
break;
case 16: trans='Zigzag('+d+',gridSizeX='+randomPick(8,16,32,64)+',gridSizeY='+randomPick(8,16,32,64)+')'
break;
}
document.body.style.filter='progid:DXImageTransform.Microsoft.'+trans
if (navigator.appVersion.indexOf('MSIE 5.0')!=-1)
document.body.style.filter='revealTrans('+d+',transition='+Math.floor(Math.random()*23)+')'
document.body.filters[0].Apply()
}
function maxSize() {
renderCaption(width-leftOffset-rightOffset)
var x=(width-leftOffset-rightOffset)/Images[pic].image.width
var y=(height-topOffset-bottomOffset-captionOffset)/Images[pic].image.height
// Scale using smaller zoom value
var z=(x1) z=1
Images[pic].zoom=z
debug('zoom='+z)
}
function renderCaption(w) {
var caption=imageCaption(pic)
setVisibility('caption',0)
if (caption!='' && options&CAPTIONS) {
output('hiddenlayer',font(caption))
output('caption',font(caption))
if (w>width-leftOffset-rightOffset) w=width-leftOffset-rightOffset
if (w>divWidth('hiddenlayer') || divWidth('hiddenlayer')width-leftOffset-rightOffset) W=width-leftOffset-rightOffset
renderCaption(W)
if (H>height-topOffset-bottomOffset-captionOffset) H=height-topOffset-bottomOffset-captionOffset
if (Images[pic].top>Math.floor(Images[pic].image.height-H/Images[pic].zoom))
Images[pic].top=Math.floor(Images[pic].image.height-H/Images[pic].zoom)
if (Images[pic].left>Math.floor(Images[pic].image.width-W/Images[pic].zoom))
Images[pic].left=Math.floor(Images[pic].image.width-W/Images[pic].zoom)
if (Images[pic].top<0) Images[pic].top=0
if (Images[pic].left<0) Images[pic].left=0
var x=Images[pic].left
var y=Images[pic].top
var z=Images[pic].zoom
var t=Math.floor(y*z)
var r=Math.floor(x*z+W)
var b=Math.floor(y*z+H)
var l=Math.floor(x*z)
if ((width-leftMargin-rightMargin-W)/2<=leftOffset || (width-leftMargin-rightMargin-W)/2<=rightOffset)
X=Math.floor((width-leftOffset-rightOffset-W)/2)-l+leftOffset
else
X=Math.floor((width-leftMargin-rightMargin-W)/2)-l+leftMargin
if ((height-topMargin-bottomMargin-H-captionOffset)/2<=topOffset || (height-topMargin-bottomMargin-H-captionOffset)/2<=bottomOffset)
Y=Math.floor((height-topOffset-bottomOffset-captionOffset-H)/2)-t+topOffset
else
Y=Math.floor((height-topMargin-bottomMargin-H-captionOffset)/2)-t+topMargin
output('picture','')
if (Y+t')
if (captionOffset) {
setXY('caption',X+Math.floor((W-divWidth('caption'))/2),Y+H+12)
setVisibility('caption',1)
}
} else {
captionOffset=0
notify(imageCaption(pic))
}
}
window.status=images.options[pic].text
displayThumbs()
}
function displayImage(i) {
// Turn off scroll bars in IE
if (document.all) document.body.scroll='no'
// Make sure image is cached before displaying it
if (isImage(i) && !Images[i].status) {
preFetch(i)
setCursor('Wait')
}
if (Images[i].status==2) return recheck=window.setTimeout('displayImage('+i+')',125)
setCursor('Default')
// Setup IE transition
if (document.all && document.body.filters && options&EFFECTS) IEtransition(timer/6000)
// Track current picture on screen menu and in global variable
pic=images.selectedIndex=i; debug(imageFile(pic))
// Pre-cache next image if current image is cached
if (Images[pic].status==1) preFetch(lookahead)
// Queue up next image for slide show
if (options&SLIDESHOW) {
window.clearTimeout(redisp)
redisp=window.setTimeout('nextSlide()',timer)
}
// Render images on screen
drawScreen()
// Play IE transition
if (document.all && document.body.filters && options&EFFECTS) document.body.filters[0].Play()
}
function scaleImage(Image,file,size,buffer,image,alt) {
var z=(Image.image.width>Image.image.height?Image.image.width:Image.image.height)/size
var x=Math.round(Image.image.width/z)
var y=Math.round(Image.image.height/z)
return ''
}
function moreThumbs() { if (across*down0) { across--; renderThumbs() } return false }
function displayThumbs() {
if (options&THUMBS && across>0) {
var border=Math.round(3.49*fontsize/maxfont)
var t='thumb'+pic
var match=0
var doc=getDoc('thumbnails')
for (var i=0; doc.images[i]; i++)
doc.images[i].border=doc.images[i].name==t?match=border:0
for (var i=0; doc.links[i]; i++)
doc.links[i].style.textDecoration=doc.links[i].name==t?match='underline':'none'
if (!match) renderThumbs()
}
setXY('lessthumbs',leftMargin+5,height-bottomMargin-divHeight('lessthumbs'))
setXY('morethumbs',leftMargin+divWidth('thumbnails')+(across?-15:5),height-bottomMargin-divHeight('morethumbs'))
}
function renderThumbs() {
debug()
var THUMBSIZE=Math.round(thumbsize*fontsize/maxfont)
var border=Math.round(3.49*fontsize/maxfont)
var bufspace=Math.round(7.49*fontsize/maxfont)
down=Math.floor((height-topMargin-bottomMargin-border)/(THUMBSIZE+2*bufspace))
var maxacross=Math.floor((width-leftMargin-rightMargin-border-5)/(THUMBSIZE+2*bufspace))
if (across>maxacross) across=maxacross
var thumbs=down*across
if (thumbs>pics) { across=Math.ceil(pics/down); thumbs=pics }
var o='