function _(div_id)
{
return document.getElementById(div_id);
}
// read
function R(func_name, args)
{
return "/" + app_id + "-0-ds2d_svc-galeriav2-" + func_name + "-" + (args === undefined? '': args) + ".htm";
}
// write
function W(func_name, args)
{
return "/" + app_id + "-post-ds2d_svc-galeriav2-" + func_name + "-" + (args === undefined? '': args) + ".htm";
}
// write, bypass proxy
function W0(func_name, args)
{
return request_url + app_id + "/" + func_name + "/" + args;
}
function ARG(table, escaping)
{
if(escaping === undefined)
escaping = false;
var request = "";
for(key in table)
request += (escaping? escapeURIComponent(key): key) + "=" + (escaping? escapeURIComponent(table[key]): table[key]) + "&";
return request.substring(0, request.length - 1);
}
function bind_callback(obj, func)
{
obj.onreadystatechange = function() {
if(obj.readyState == 4 && obj.status == 200)
func(obj);
}
}
// ]]>
// ' +
'
' +
//'' +
' ' + //src="' + loading_image + '" />' +
//'' +
'' +
'' +
'' +
'' +
'',
html_code_post = "";
var current_caption;
function set_opacity(obj, opacity) {
if(obj != null) {
obj.style.filter = 'alpha(opacity=' + opacity + ')';
obj.style.opacity = opacity / 100;
obj.style.KhtmlOpacity = opacity / 100;
obj.style.MozOpacity = opacity / 100;
}
}
function set_size(obj, x, y) {
obj.style.height = y + "px";
obj.style.width = x + "px";
}
function get_post_url()
{
return W("post_action", "");
}
//max
function page(obj){
var post_data = "action=next_page&id_obrazka=" + obj,
url = get_post_url(),
request = xhr_init("POST", url, true);
alert(url);
bind_callback(request, function(obj) {
var response = obj.responseText;
if(response == "ok")
{
alert(response);
}
else
{
document.getElementById('id49ec6d133a527').innerHTML=response;
}
});
request.send(post_data);
}
//max
function set_position(obj, x, y) {
obj.style.left = x + "px";
obj.style.top = y + "px";
}
function create_workspace() {
var el;
if(!workspace) {
el = document.createElement("div");
el.id = 'imagespace';
if(is_ie())
el.style.position = 'absolute';
else
el.style.position = 'fixed';
el.style.left = "0px";
el.style.top = "0px";
el.style.width = "0px";
el.style.height = "0px";
el.style.visibility = 'visible';
el.style.background = 'white';
el.style.border = '1px solid #9a9a9a';
el.style.zIndex = 9999;
el.onclick = back_to_page;
set_opacity(el, 0);
el.innerHTML = ' ';// src="' + loading_image + '" />';
return el;
}
else
return null;
}
function create_backdrop() {
var b_height, b_width;
if(!is_ie()) {
b_height = parseInt(window.screen.height);
b_width = parseInt(window.screen.width);
} else {
b_height = parseInt(document.body.clientHeight);
b_width = parseInt(document.body.clientWidth);
}
if(!backdrop) {
var el = document.createElement('div');
el.id = 'backdrop';
if(is_ie())
el.style.position = 'absolute';
else
el.style.position = 'fixed';
el.style.left = "0px";
el.style.top = "0px";
el.style.width = (b_width) + "px";
el.style.height = (b_height) + "px";
el.style.visibility = 'visible';
el.style.background = 'white';
el.onclick = back_to_page;
el.style.zIndex = 1000;
set_opacity(el, 100);
return el;
} else
return null;
}
function append_to_workspace(element) {
document.body.appendChild(element);
}
function remove_from_workspace(element) {
document.body.removeChild(element);
}
var state = 0;
var stop_animation = false;
var backdrop_opacity = 0, workspace_opacity = 0, image_opacity = 0;
var creation_finished = false;
var acceleration;
var image_obj;
var caption_request_pending = false;
var y_ofs = -80, h_ofs = 30;
var animation_id = 0;
// c'mon kage, now it's time to blow doors down
// ooh, i hear you jb, now it's time to blow doors down
function start_animation() {
stop_animation = false;
if(animation_id == 0)
animation_id = setInterval("start_animation()", 15);
switch(state) {
case 0:
set_opacity(backdrop, backdrop_opacity);
backdrop_opacity += 20;
if(backdrop_opacity >= 80) {
backdrop_opacity = 80;
set_opacity(backdrop, backdrop_opacity);
state = 1;
}
break;
case 1:
var x, y, w = 100, h = 100, iw, ih;
if(is_ie()) {
iw = window.screen.width;
ih = window.screen.height;
} else {
iw = window.innerWidth;
ih = window.innerHeight;
}
x = Math.floor(parseInt(iw) / 2 - w / 2);
y = Math.floor(parseInt(ih) / 2 - (h + h_ofs) / 2);
if(is_ie()) {
y += (parseInt(document.documentElement.scrollTop) - 50);
}
set_position(workspace, x, y);
set_size(workspace, w, 100);
state = 2;
break;
case 2:
set_opacity(workspace, workspace_opacity);
workspace_opacity += 28;
if(workspace_opacity >= 100) {
workspace_opacity = 100;
set_opacity(workspace, workspace_opacity);
state = 3;
}
break;
case 3:
if(!already_loading)
setTimeout('load_image_async()', 10);
break;
case 4:
var width = parseInt(workspace.style.width), height = parseInt(workspace.style.height) - h_ofs,
x = parseInt(workspace.style.left), y = parseInt(workspace.style.top),
changed = false, img_width = parseInt(global_img_obj.width), img_height = parseInt(global_img_obj.height);
if(img_width === 0)
return;
if(width < img_width && first_time) {
width += 10 + (acceleration * 3);
x -= parseInt((10 + (acceleration * 3))/2);
var delta = width - img_width;
if(delta > 0) {
width -= delta / 2;
x -= delta / 2;
}
changed = true;
}
else if(width != img_width)
width = img_width;
if(height < img_height && first_time) {
height += 10 + (acceleration * 3);
y -= parseInt((10 + (acceleration * 3))/2);
changed = true;
var delta = height - img_height;
if(delta > 0) {
height -= delta / 2;
y -= delta / 2;
}
} else if(height != img_height)
height = img_height;
set_position(workspace, x, y);
set_size(workspace, width, height + h_ofs);
valid_width = width;
valid_height = height + h_ofs;
if(acceleration > 0)
acceleration ;
if(!changed) {
state = 5;
var iw, ih, w = parseInt(valid_width), h = parseInt(valid_height);
// na koniec napraw pozycje
if(is_ie()) {
iw = window.screen.width;
ih = window.screen.height;
} else {
iw = window.innerWidth;
ih = window.innerHeight;
}
x = Math.floor(parseInt(iw) / 2 - w / 2);
y = Math.floor(parseInt(ih) / 2 - (h + h_ofs) / 2);
if(is_ie()) {
y += (parseInt(document.documentElement.scrollTop) - 50);
}
set_position(workspace, x, y);
set_size(workspace, img_width, img_height + h_ofs);
}
break;
case 5:
workspace.innerHTML = html_code_pre + current_caption + html_code_post;
image_obj = document.getElementById('a1image');
image_obj.src = global_img_obj.src;
set_size(workspace, valid_width, valid_height);
set_opacity(image_obj, 0);
image_opacity = 0;
image_obj.style.visibility = 'visible';
state++;
break;
case 6:
set_opacity(image_obj, image_opacity);
image_opacity += 10;
if(image_opacity >= 100) {
set_opacity(image_obj, 100);
image_opacity = 0;
state++;
}
break;
default:
var fixup;
if((fixup = get_fixup()) != 0) {
document.getElementById("imagespace").style.height = (parseInt(document.getElementById("imagespace").style.height) + fixup) + "px";
document.getElementById("imagespace").style.top = (parseInt(document.getElementById("imagespace").style.top) - (fixup / 2)) + "px";
}
caption_obj = document.getElementById('caption');
caption_obj.style.visibility = 'visible';
stop_animation = true;
creation_finished = true;
clearInterval(animation_id);
animation_id = 0;
create_navigation();
first_time = false;
break;
}
}
function get_fixup() {
var arr = document.getElementById("mini_" + requested_id).className.split(" ");
for(var i = 0, len = arr.length; i < len; i++) {
if(arr[i].substring(0, 3) == "bc_") {
var t = arr[i].split("_");
var pixlen = t[1];
return parseInt(pixlen);
}
}
return 0;
}
function prev_image() {
var img = lookup_prev(requested_id);
remove_navigation();
requested_id = img;
state = 3;
document.getElementById("caption").style.visibility = "hidden";
current_caption = captions[img];
start_animation();
}
function prev_image_over() {
var obj = document.getElementById('btn_back');
if(obj) set_opacity(obj, 30);
}
function prev_image_out() {
var obj = document.getElementById('btn_back');
if(obj) set_opacity(obj, 0);
}
function next_image() {
workspace.style.visibility = "hidden";
var img = lookup_next(requested_id);
remove_navigation();
requested_id = img;
state = 3;
document.getElementById("caption").style.visibility = "hidden";
current_caption = captions[img];
start_animation();
workspace.style.visibility = "visible";
}
function next_image_over() {
var obj = document.getElementById('btn_fwd');
if(obj) set_opacity(obj, 30);
}
function next_image_out() {
var obj = document.getElementById('btn_fwd');
if(obj) set_opacity(obj, 0);
}
function lookup_next(id) {
for(var i = 0; i < sequence.length; i++)
if(sequence[i] == id && sequence[i+1] != 0)
return sequence[i+1];
return null;
}
function lookup_prev(id) {
for(var i = 0; i < sequence.length; i++)
if(sequence[i] == id && i > 0)
return sequence[i-1];
return null;
}
function create_navigation() {
var t, btn_back, btn_fwd, btn_save;
btn_save = document.getElementById("btn_save");
if(!btn_save) {
var x_width = 23;
var x_height = 22;
btn_save = document.createElement("div");
btn_save.style.visibility = "visible";
btn_save.id = "btn_save";
btn_save.style.position = (is_ie()? "absolute": "fixed");
btn_save.style.width = x_width + "px";
btn_save.style.height = x_height + "px";
btn_save.style.backgroundColor = "red";
btn_save.style.zIndex = 10001;
btn_save.style.cursor = "pointer";
//btn_save.style.backgroundImage = "url(/cms/images/disk.png)";
var this_image_url = global_img_obj.src;
btn_save.innerHTML = " ";
var left_pos = (parseInt(workspace.style.left) + (parseInt(workspace.style.width) - x_width) + 1);
btn_save.style.left = left_pos + "px";
btn_save.style.top = (parseInt(workspace.style.top) + 1) + "px";
document.body.appendChild(btn_save);
}
if((t = lookup_prev(requested_id)) !== undefined && t !== null) {
btn_back = document.getElementById("btn_back");
if(!btn_back) {
btn_back = document.createElement("div");
btn_back.style.visibility = "hidden";
btn_back.id = "btn_back";
btn_back.style.position = (is_ie()? "absolute": "fixed");
btn_back.style.width = parseInt(image_obj.width)/2 + "px";
btn_back.style.height = parseInt(image_obj.height) + "px";
btn_back.style.backgroundColor = "black";
btn_back.style.backgroundImage = "url(" + res_left_arrow + ")";
btn_back.style.backgroundRepeat = "no-repeat";
btn_back.style.backgroundPosition = "center";
btn_back.style.zIndex = 10000;
btn_back.onclick = function() { prev_image(); };
btn_back.onmouseover = function() { prev_image_over(); };
btn_back.onmouseout = function() { prev_image_out(); };
btn_back.style.cursor = "pointer";
document.body.appendChild(btn_back);
}
btn_back.style.left = (parseInt(workspace.style.left)+1) + "px";
btn_back.style.top = (parseInt(workspace.style.top)+1) + "px";
set_opacity(btn_back, 0);
show_prev_button();
}
if((t = lookup_next(requested_id)) !== undefined && t !== null) {
btn_fwd = document.getElementById("btn_fwd");
if(!btn_fwd) {
btn_fwd = document.createElement("div");
btn_fwd.style.visibility = "hidden";
btn_fwd.id = "btn_fwd";
btn_fwd.style.position = (is_ie()? "absolute": "fixed");
btn_fwd.style.width = Math.ceil(parseInt(image_obj.width) / 2) + "px";
btn_fwd.style.height = parseInt(image_obj.height) + "px";
btn_fwd.style.backgroundColor = "black";
btn_fwd.style.backgroundImage = "url(" + res_right_arrow + ")";
btn_fwd.style.backgroundRepeat = "no-repeat";
btn_fwd.style.backgroundPosition = "center";
btn_fwd.style.zIndex = 10000;
btn_fwd.onclick = function() { next_image(); };
btn_fwd.onmouseover = function() { next_image_over(); };
btn_fwd.onmouseout = function() { next_image_out(); };
btn_fwd.style.cursor = "pointer";
document.body.appendChild(btn_fwd);
}
var left_pos = (parseInt(workspace.style.left) + (parseInt(workspace.style.width) / 2) + 1);
btn_fwd.style.left = left_pos + "px";
btn_fwd.style.top = (parseInt(workspace.style.top)+1) + "px";
set_opacity(btn_fwd, 0);
show_next_button();
}
}
function show_prev_button() {
btn_prev = document.getElementById('btn_back');
if(btn_prev)
btn_prev.style.visibility = 'visible';
else
setTimeout("show_prev_button()", 10);
}
function show_next_button() {
btn_next = document.getElementById('btn_fwd');
if(btn_next)
btn_next.style.visibility = 'visible';
else
setTimeout("show_next_button()", 10);
}
function remove_navigation() {
var o = document.getElementById("btn_back");
if(o) document.body.removeChild(o);
o = document.getElementById("btn_fwd");
if(o) document.body.removeChild(o);
o = document.getElementById("btn_save");
if(o) document.body.removeChild(o);
}
function setup_state_4(current_img_obj) {
already_loading = false;
current_img_obj.style.visibility = 'hidden';
global_img_obj = img_obj;
acceleration = 10;
state = 4; // powiekszanie
}
function is_ie() {
if(navigator.appVersion && navigator.appVersion.indexOf("MSIE") != -1)
return true;
else
return false;
}
function is_opera() {
return navigator.userAgent.indexOf("Opera") != -1;
}
var image_cache = new Array();
function is_cached(url) {
for(var i = 0, len = image_cache.length; i < len; i++)
if(image_cache[i].src === url)
return true;
return false;
}
function add_to_cache(obj) {
image_cache.push(obj);
}
function load_image_async() {
already_loading = true;
var current_img_obj = document.getElementById('a1image');
if(!current_img_obj) {
already_loading = false;
return;
}
img_obj = new Image();
img_obj.src = request_url + app_id + "/pokaz_zdjecie/" + requested_id;
if((is_opera() || is_ie()) && is_cached(img_obj.src)) {
set_opacity(img_obj, 0);
setup_state_4(current_img_obj);
} else {
img_obj.onload = function()
{
if(is_opera() || is_ie())
add_to_cache(img_obj);
set_opacity(img_obj, 0);
setup_state_4(current_img_obj);
}
}
}
function start_finishing_animation() {
stop_animation = false;
if(animation_id == 0)
animation_id = setInterval("start_finishing_animation()", 15);
switch(state) {
case 0:
set_opacity(workspace, workspace_opacity);
workspace_opacity -= 35;
if(workspace_opacity <= 10) {
workspace_opacity = 0;
set_opacity(workspace, workspace_opacity);
state++;
}
break;
case 1:
set_opacity(backdrop, backdrop_opacity);
backdrop_opacity -= 35;
if(backdrop_opacity <= 0) {
backdrop_opacity = 0;
set_opacity(backdrop, backdrop_opacity);
state++;
}
break;
case 2:
workspace = remove_object(workspace);
backdrop = remove_object(backdrop);
state++;
break;
default:
stop_animation = true;
creation_finished = false;
clearInterval(animation_id);
animation_id = 0;
first_time = true;
show_embeds();
break;
}
}
function remove_object(obj) {
if(obj != null)
remove_from_workspace(obj);
return null;
}
function back_to_page() {
remove_navigation();
if(creation_finished && stop_animation) {
state = 0;
stop_animation = false;
workspace_opacity = 80;
start_finishing_animation();
}
}
function preload_navigation() {
var img = new Image(), img2 = new Image();
img.src = res_left_arrow;
img2.src = res_right_arrow;
}
function show_embeds() {
manipulate_embeds("EMBED", true);
manipulate_embeds("OBJECT", true);
manipulate_embeds("INPUT", true);
manipulate_embeds("SELECT", true);
}
function hide_embeds() {
manipulate_embeds("EMBED", false);
manipulate_embeds("OBJECT", false);
manipulate_embeds("INPUT", false);
manipulate_embeds("SELECT", false);
}
function manipulate_embeds(tagname, flag) {
var embeds = document.getElementsByTagName(tagname);
if(embeds && embeds.length > 0) {
for(var i = 0, l = embeds.length; i < l; i++) {
var el = embeds[i];
el.style.visibility = flag == true? 'visible': 'hidden';
}
}
}
var secondtime = false;
function pokaz(id) {
hide_embeds();
preload_navigation();
caption = captions[id];
if(!workspace || workspace == undefined) {
requested_id = id;
current_caption = caption;
if(!backdrop) {
backdrop = create_backdrop();
append_to_workspace(backdrop);
}
if(!workspace) {
workspace = create_workspace();
append_to_workspace(workspace);
}
state = 0;
stop_animation = false;
start_animation();
}
}
// ]]>
/*
*/
UM Ostrów Mazowiecka, Źródło artykułu: www.ostrowmaz.pl, Autor zdjęć: UM Ostrów Mazowiecka
Brak komentarzy, Twój może być pierwszy!
| |