var conf_posun = 65; var conf_reflection_p = 0.5; var conf_focus = 4; var conf_images_cursor = 'pointer'; var conf_fotoflow = 'pasPortfolia'; var conf_loading = 'preloader'; var conf_images = 'fotkyPortfolia'; var conf_captions = 'titulekPortfolia'; var caption_id = 0; var new_caption_id = 0; var current = 0; var target = 0; var mem_target = 0; var timer = 0; var array_images = new Array(); var posx = 0; var new_posx = 0; var xstep = 150; function step()
{ switch (target < current-1 || target > current+1)
{ case true:
moveTo(current + (target-current)/3); window.setTimeout(step, 50); timer = 1; break; default:
timer = 0; break;}
}
function glideTo(x, new_caption_id)
{ target = x; mem_target = x; if (timer == 0)
{ window.setTimeout(step, 50); timer = 1;}
caption_id = "reference" + new_caption_id; caption = document.getElementById(caption_id).innerHTML; if (caption == '') caption = '&nbsp;'; caption_div.innerHTML = caption;}
function moveTo(x)
{ current = x; var zIndex = max; for (var index = 0; index < max; index++)
{ var image = image_array[index]; var current_image = index * -xstep; if ((current_image+max_conf_focus) < mem_target || (current_image-max_conf_focus) > mem_target)
{ image.style.visibility = 'hidden'; image.style.display = 'none';}
else
{ var z = Math.sqrt(10000 + x * x) + 100; var xs = x / z * size + size; image.style.display = 'block'; var new_img_h = (image.h / image.w * image.pc) / z * size; switch ( new_img_h > max_height )
{ case false:
var new_img_w = image.pc / z * size; break; default:
new_img_h = max_height; var new_img_w = image.w * new_img_h / image.h; break;}
var new_img_top = (images_width * 0.34 - new_img_h) + images_top + ((new_img_h / (conf_reflection_p + 1)) * conf_reflection_p); image.style.left = xs - (image.pc / 2) / z * size + images_left + 'px'; if(new_img_w && new_img_h)
{ image.style.height = new_img_h + 'px'; image.style.width = new_img_w + 'px'; image.style.top = (new_img_top-conf_posun) + 'px';}
image.style.visibility = 'visible'; switch ( x < 0 )
{ case true:
zIndex++; break; default:
zIndex = zIndex - 1; break;}
switch ( image.i == caption_id )
{ case false:
image.onclick = function() { glideTo(this.x_pos, this.i);}
break; default:
zIndex = zIndex + 1; if(image.url !== null && image.url !== '')
{ image.onclick = function() { document.location = this.url;}
}
break;}
image.style.zIndex = zIndex;}
x += xstep;}
}
function refresh(onload)
{ fotoflow_div = document.getElementById(conf_fotoflow); img_div = document.getElementById(conf_images); caption_div = document.getElementById(conf_captions); images_width = img_div.offsetWidth; images_top = fotoflow_div.offsetTop; images_left = fotoflow_div.offsetLeft; max_conf_focus = conf_focus * xstep; size = images_width * 0.5; max_height = images_width * 0.51; img_div.style.height = images_width * 0.338 + 'px'; image_array = img_div.getElementsByTagName('img'); max = image_array.length; var i = 0; for (var index = 0; index < max; index++)
{ var image = image_array[index]; array_images[i] = index; image.onclick = function() { glideTo(this.x_pos, this.i);}
image.x_pos = (-i * xstep); image.i = i; if(onload == true)
{ image.w = image.width; image.h = image.height;}
switch ((image.w + 1) > (image.h / (conf_reflection_p + 1)))
{ case true:
image.pc = 118; break; default:
image.pc = 100; break;}
image.style.cursor = conf_images_cursor; i++;}
max = array_images.length; moveTo(current); glideTo(current, caption_id);}
function show(id)
{ var element = document.getElementById(id); element.style.visibility = 'visible';}
function hide(id)
{ var element = document.getElementById(id); element.style.visibility = 'hidden'; element.style.display = 'none';}
window.onload = function()
{ if(document.getElementById(conf_fotoflow))
{ hide(conf_loading); refresh(true); show(conf_images); glideTo( -600, 4);}
}
window.onresize = function()
{ if(document.getElementById(conf_fotoflow)) refresh();}
window.onunload = function()
{ document = null;}
