/*
Gridmedia Slider Polish Gallery 0.5

author: Łukasz Różewicz
company: GRIDMEDIA
website: www.gridmedia.pl

more information about this script: http://gridmedia.pl/aktualnosc,21

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License (LGPL) as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

*/

function parseUri(str){
    var o = parseUri.options, m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), uri = {}, i = 14;
    
    while (i--) 
        uri[o.key[i]] = m[i] || "";
    
    uri[o.q.name] = {};
    uri[o.key[12]].replace(o.q.parser, function($0, $1, $2){
        if ($1) 
            uri[o.q.name][$1] = $2;
    });
    
    return uri;
};

parseUri.options = {
    strictMode: false,
    key: ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"],
    q: {
        name: "queryKey",
        parser: /(?:^|&)([^&=]*)=?([^&]*)/g
    },
    parser: {
        strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
        loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
    }
};


var gridmediaGlobalObj = new Object();
gridmediaGlobalObj.timer = null;
gridmediaGlobalObj.left = 0;
gridmediaGlobalObj.right = 0;
gridmediaGlobalObj.width = 0;
gridmediaGlobalObj.min_photo_width = 0;
gridmediaGlobalObj.photo_count = 0;
gridmediaGlobalObj.current_photo = 0;
gridmediaGlobalObj.photoOpacity = 0;
gridmediaGlobalObj.timerPhoto = null;
gridmediaGlobalObj.interval_autoplay = null;
gridmediaGlobalObj.options = null;
gridmediaGlobalObj.speed = 4000;

var gridmedia_gallery = new Class({
    initialize: function(options){
        gridmediaGlobalObj.options = options;
        this.width = options.width;
        gridmediaGlobalObj.width = options.width;
        gridmediaGlobalObj.min_photo_width = options.min_photo_width;
        if (options.speed != null) 
            gridmediaGlobalObj.speed = options.speed;
        this.height = options.height;
        this.left = 0;
        this.right = 0;
        this.timer = 2;
        if (options.autoPlay == true) 
            this.autoPlay(options);
        if (options.tooltips == true) 
            this.tooltips(options);
        this.setStyles(options);
        this.hideLeftScroll(options);
        this.hideRightScroll(options);
        this.hideCenterScroll(options);
    },
    setStyles: function(options){
        var id_list = options.id_list;
        var id_main = options.id_main;
        var width = options.width;
        var height = options.height;
        var min_photo_width = options.min_photo_width;
        var min_photo_height = options.min_photo_height;
        var image_url = options.image_url;
        var images = $$('#' + id_list + ' img');
        var links = $$('#' + id_list + ' a');
        
        // ---------------------------- stylowanie miniaturek ----------------
        $(id_list).setStyle('width', width);
        $(id_list).setStyle('height', min_photo_height);
        $(id_list).setStyle('overflow', 'hidden');
        $(id_list).setStyle('position', 'relative');
        
        $$('#' + id_list + ' div')[0].setStyle('width', '2000px');
        $$('#' + id_list + ' div')[0].setStyle('height', min_photo_height);
        $$('#' + id_list + ' div')[0].setStyle('position', 'absolute');
        $$('#' + id_list + ' div')[0].setProperty('id', "id_silder_123456789");
        
        
        var slider_left = document.createElement("div");
        slider_left.id = 'slider_left_gridmedia';
        var height_sl = Math.ceil((width / 3) - 1);
        slider_left.style.width = height_sl + 'px';
        slider_left.style.height = min_photo_height + 'px';
        slider_left.style.position = 'absolute';
        slider_left.style.top = 0;
        slider_left.style.left = 0;
        slider_left.style.backgroundColor = 'red';
        slider_left.style.opacity = 0;
        slider_left.style.MozOpacity = 0;
        slider_left.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)";
        slider_left.style.zIndex = 100;
        document.getElementById(id_list).appendChild(slider_left);
        
        
        var slider_right = document.createElement("div");
        slider_right.id = 'slider_right_gridmedia';
        var width_sl = Math.ceil((width / 3) - 1);
        slider_right.style.width = width_sl + 'px';
        slider_right.style.height = min_photo_height + 'px';
        slider_right.style.position = 'absolute';
        slider_right.style.backgroundColor = 'red';
        slider_right.style.opacity = 0;
        slider_right.style.MozOpacity = 0;
        slider_right.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)";
        slider_right.style.left = (width_sl * 2) + 'px';
        document.getElementById(id_list).appendChild(slider_right);
        
        var slider_center = document.createElement("div");
        slider_center.id = 'slider_center_gridmedia';
        var width_sl = Math.ceil((width / 3) - 1);
        slider_center.style.width = width_sl + 'px';
        slider_center.style.height = min_photo_height + 'px';
        slider_center.style.position = 'absolute';
        slider_center.style.backgroundColor = 'red';
        slider_center.style.opacity = 0;
        slider_center.style.MozOpacity = 0;
        slider_center.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)";
        slider_center.style.left = (width_sl * 1) + 'px';
        document.getElementById(id_list).appendChild(slider_center);
        
        
        $(id_list).addEvent('mouseleave', function(){
            $('slider_left_gridmedia').setStyle('display', 'block');
            $('slider_center_gridmedia').setStyle('display', 'block');
            $('slider_right_gridmedia').setStyle('display', 'block');
            
            // zatrzymaj przewijanie
            clearInterval(gridmediaGlobalObj.timer);
        });
        
        document.getElementById(id_list).onmouseover = function(){
            clearInterval(gridmediaGlobalObj.interval_autoplay);
        }
        
        document.getElementById(id_main).onmouseover = function(){
            clearInterval(gridmediaGlobalObj.interval_autoplay);
        }
        
        document.getElementById(id_list).onmouseout = function(){
            var autoPlay = options.autoPlay;
            if (autoPlay == true) {
                gridmediaGlobalObj.interval_autoplay = setInterval(function(){
                
                    var getA = document.getElementById(id_list).getElementsByTagName('a');
                    $each(getA, function(htmlElement, key){
                        htmlElement.style.opacity = 0.5;
                        htmlElement.style.MozOpacity = 0.5;
                        htmlElement.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)";
                    });
                    
                    
                    var current_photo = gridmediaGlobalObj.current_photo;
                    var photo_count = gridmediaGlobalObj.photo_count;
                    
                    if (current_photo + 1 != gridmediaGlobalObj.photo_count) {
                        document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo + 1].style.opacity = 1;
                        document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo + 1].style.MozOpacity = 1;
                        document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo + 1].style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
                    }
                    else {
                        document.getElementById(id_list).getElementsByTagName('a')[0].style.opacity = 1;
                        document.getElementById(id_list).getElementsByTagName('a')[0].style.MozOpacity = 1;
                        document.getElementById(id_list).getElementsByTagName('a')[0].style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
                    }
                    
                    if (current_photo + 1 != gridmediaGlobalObj.photo_count) {
                        $('divBorderGridmedia' + (current_photo + 1)).fade(1);
                        $('divBorderGridmedia' + current_photo).fade(0);
                        gridmediaGlobalObj.current_photo = gridmediaGlobalObj.current_photo + 1;
                    }
                    else {
                        $('divBorderGridmedia' + (0)).fade(1);
                        $('divBorderGridmedia' + current_photo).fade(0);
                        gridmediaGlobalObj.current_photo = 0;
                    }
                    
                    // -------- przesuwanie paska -----------------------------------
                    
                    
                    // jeśli miaturki nie mieszczą się w pasku i cześć jest schowana
                    if (Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width) < gridmediaGlobalObj.photo_count) {
                        if (gridmediaGlobalObj.current_photo < Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width)) {
                            gridmediaGlobalObj.left = 0;
                            $('id_silder_123456789').tween('left', 0);
                        }
                        if ((gridmediaGlobalObj.current_photo + 1) > Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width)) {
                        
                            gridmediaGlobalObj.left = -(gridmediaGlobalObj.min_photo_width * (gridmediaGlobalObj.current_photo - Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width) + 1));
                            $('id_silder_123456789').tween('left', -(gridmediaGlobalObj.min_photo_width * (gridmediaGlobalObj.current_photo - Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width) + 1)));
                            
                        }
                    }
                    
                }, gridmediaGlobalObj.speed);
            }
        }
        
        document.getElementById(id_main).onmouseout = function(){
            var autoPlay = options.autoPlay;
            if (autoPlay == true) {
                gridmediaGlobalObj.interval_autoplay = setInterval(function(){
                
                    var getA = document.getElementById(id_list).getElementsByTagName('a');
                    $each(getA, function(htmlElement, key){
                        htmlElement.style.opacity = 0.5;
                        htmlElement.style.MozOpacity = 0.5;
                        htmlElement.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)";
                    });
                    
                    
                    var current_photo = gridmediaGlobalObj.current_photo;
                    var photo_count = gridmediaGlobalObj.photo_count;
                    
                    if (current_photo + 1 != gridmediaGlobalObj.photo_count) {
                        document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo + 1].style.opacity = 1;
                        document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo + 1].style.MozOpacity = 1;
                        document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo + 1].style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
                    }
                    else {
                        document.getElementById(id_list).getElementsByTagName('a')[0].style.opacity = 1;
                        document.getElementById(id_list).getElementsByTagName('a')[0].style.MozOpacity = 1;
                        document.getElementById(id_list).getElementsByTagName('a')[0].style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
                    }
                    
                    if (current_photo + 1 != gridmediaGlobalObj.photo_count) {
                        $('divBorderGridmedia' + (current_photo + 1)).fade(1);
                        $('divBorderGridmedia' + current_photo).fade(0);
                        gridmediaGlobalObj.current_photo = gridmediaGlobalObj.current_photo + 1;
                    }
                    else {
                        $('divBorderGridmedia' + (0)).fade(1);
                        $('divBorderGridmedia' + current_photo).fade(0);
                        gridmediaGlobalObj.current_photo = 0;
                    }
                    
                    // -------- przesuwanie paska -----------------------------------
                    
                    
                    // jeśli miaturki nie mieszczą się w pasku i cześć jest schowana
                    if (Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width) < gridmediaGlobalObj.photo_count) {
                        if (gridmediaGlobalObj.current_photo < Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width)) {
                            gridmediaGlobalObj.left = 0;
                            $('id_silder_123456789').tween('left', 0);
                        }
                        if ((gridmediaGlobalObj.current_photo + 1) > Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width)) {
                        
                            gridmediaGlobalObj.left = -(gridmediaGlobalObj.min_photo_width * (gridmediaGlobalObj.current_photo - Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width) + 1));
                            $('id_silder_123456789').tween('left', -(gridmediaGlobalObj.min_photo_width * (gridmediaGlobalObj.current_photo - Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width) + 1)));
                            
                        }
                    }
                    
                }, gridmediaGlobalObj.speed);
            }
        }
        
        
        // -------------------------------------------------------------------
        
        // ---------------------------- stylowanie panelu --------------------
        $(id_main).setStyle('width', width);
        $(id_main).setStyle('height', height);
        $(id_main).setStyle('overflow', 'hidden');
        $(id_main).setStyle('position', 'relative');
        // -------------------------------------------------------------------
        
        
        $each(links, function(htmlElement, key){
            htmlElement.setStyle('float', 'left');
            htmlElement.setStyle('display', 'block');
            htmlElement.setStyle('width', min_photo_width);
            htmlElement.setStyle('height', min_photo_height);
            htmlElement.addClass('gridmediaLinksMinPhoto');
            htmlElement.onclick = function(){
            
                $('divBorderGridmedia' + gridmediaGlobalObj.current_photo).fade(0);
                $('divBorderGridmedia' + key).fade(1);
                gridmediaGlobalObj.current_photo = key;
                
                var getA = document.getElementById(id_list).getElementsByTagName('a');
                $each(getA, function(htmlElement, key){
                    htmlElement.style.opacity = 0.5;
                    htmlElement.style.MozOpacity = 0.5;
                    htmlElement.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)";
                });
                document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo].style.opacity = 1;
                document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo].style.MozOpacity = 1;
                document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo].style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
                
                return false;
            }
            
            
            
        });
        var ii = 900;
        $each(images, function(htmlElement, key){
            gridmediaGlobalObj.photo_count = gridmediaGlobalObj.photo_count + 1;
            
            var fileName = parseUri(htmlElement.src).file;
            var bigImage = fileName.substr(4, fileName.length - 4);
            if (key == 0) {
                var divBorder = document.createElement("div");
                divBorder.id = 'divBorderGridmedia' + key;
                divBorder.style.position = 'absolute';
                divBorder.style.zIndex = 901;
                document.getElementById(id_main).appendChild(divBorder);
                
                var author = document.createElement("a");
                author.href = "http://www.gridmedia.pl";
                author.id = 'link_to_author_site';
                author.style.xIndex = 0;
                author.style.position = 'absolute';
                author.style.height = 0;
                author.style.overflow = 'hidden';
                document.getElementById(id_main).appendChild(author);
                document.getElementById('link_to_author_site').innerHTML = 'Projektowanie i tworzenie stron www Warszawa';
                
                
                var bigImageMain = document.createElement("img");
                bigImageMain.id = 'bigImageGridmedia' + key;
                bigImageMain.src = image_url + '/' + bigImage;
                document.getElementById('divBorderGridmedia' + key).appendChild(bigImageMain);
                
            }
            else {
                var divBorder = document.createElement("div");
                divBorder.id = 'divBorderGridmedia' + key;
                divBorder.style.position = 'absolute';
                divBorder.style.zIndex = ii;
                document.getElementById(id_main).appendChild(divBorder);
                $('divBorderGridmedia' + key).fade(0);
                
                var bigImageMain = document.createElement("img");
                bigImageMain.id = 'bigImageGridmedia' + key;
                bigImageMain.src = image_url + '/' + bigImage;
                document.getElementById('divBorderGridmedia' + key).appendChild(bigImageMain);
                ii = ii - 1;
            }
            // ------------------- tworzenie strzałek -----------------------------------------
            
            var left_arrow = document.createElement("div");
            left_arrow.id = 'left_arrow_gridmedia';
            var width_left = Math.ceil((width / 2) - 1);
            left_arrow.style.top = 0;
            left_arrow.style.left = 0;
            left_arrow.onclick = function(){
            
            
                var current_photo = gridmediaGlobalObj.current_photo;
                if (current_photo != 0) {
                    $('divBorderGridmedia' + (current_photo - 1)).fade(1);
                    $('divBorderGridmedia' + current_photo).fade(0);
                    
                    gridmediaGlobalObj.current_photo = gridmediaGlobalObj.current_photo - 1;
                    
                    if (gridmediaGlobalObj.current_photo == 0) {
                        $('left_arrow_gridmedia').setStyle('background', 'transparent url(images/transparent.gif) no-repeat center left');
                    }
                    else {
                        $('left_arrow_gridmedia').setStyle('background', 'transparent url(images/arrow_left_bg2-trans.png) no-repeat center left');
                        
                    }
                    
                    var getA = document.getElementById(id_list).getElementsByTagName('a');
                    $each(getA, function(htmlElement, key){
                        htmlElement.style.opacity = 0.5;
                        htmlElement.style.MozOpacity = 0.5;
                        htmlElement.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)";
                    });
                    document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo].style.opacity = 1;
                    document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo].style.MozOpacity = 1;
                    document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo].style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
                }
                if (gridmediaGlobalObj.current_photo < Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width)) {
                    gridmediaGlobalObj.left = 0;
                    $('id_silder_123456789').tween('left', 0);
                }
                if ((gridmediaGlobalObj.current_photo + 1) > Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width)) {
                    gridmediaGlobalObj.left = -(gridmediaGlobalObj.min_photo_width * (gridmediaGlobalObj.current_photo - Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width) + 1));
                    $('id_silder_123456789').tween('left', -(gridmediaGlobalObj.min_photo_width * (gridmediaGlobalObj.current_photo - Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width) + 1)));
                    
                }
            }
            
            document.getElementById(id_main).appendChild(left_arrow);
            $('left_arrow_gridmedia').setStyle('position', 'absolute');
            $('left_arrow_gridmedia').setStyle('width', width_left + 'px');
            $('left_arrow_gridmedia').setStyle('height', height + 'px');
            $('left_arrow_gridmedia').setStyle('z-Index', 1000);
            $('left_arrow_gridmedia').setStyle('background', 'transparent url(images/transparent.gif) no-repeat center left');
            
            $('left_arrow_gridmedia').addEvent('mouseover', function(){
                $('left_arrow_gridmedia').setStyle('background', 'transparent url(images/arrow_left_bg2-trans.png) no-repeat center left');
                $('left_arrow_gridmedia').setStyle('opacity', 0.5);
                $('left_arrow_gridmedia').setStyle('cursor', 'pointer');
                
                if (gridmediaGlobalObj.current_photo == 0) {
                    $('left_arrow_gridmedia').setStyle('background', 'transparent url(images/transparent.gif) no-repeat center left');
                }
                else {
                    $('left_arrow_gridmedia').setStyle('background', 'transparent url(images/arrow_left_bg2-trans.png) no-repeat center left');
                    
                }
                
                
            });
            $('left_arrow_gridmedia').addEvent('mouseout', function(){
                $('left_arrow_gridmedia').setStyle('background', 'transparent url(images/transparent.gif) no-repeat center left');
            });
            
            
            var right_arrow = document.createElement("div");
            right_arrow.id = 'right_arrow_gridmedia';
            var width_right = width - width_left;
            right_arrow.style.top = 0;
            right_arrow.style.left = width_left + 'px';
            right_arrow.onclick = function(){
                var current_photo = gridmediaGlobalObj.current_photo;
                if (current_photo + 1 != gridmediaGlobalObj.photo_count) {
                    $('divBorderGridmedia' + (current_photo + 1)).fade(1);
                    $('divBorderGridmedia' + current_photo).fade(0);
                    
                    gridmediaGlobalObj.current_photo = gridmediaGlobalObj.current_photo + 1;
                    
                    if (gridmediaGlobalObj.current_photo + 1 == gridmediaGlobalObj.photo_count) {
                        $('right_arrow_gridmedia').setStyle('background', 'transparent url(images/transparent.gif) no-repeat center right');
                    }
                    else {
                        $('right_arrow_gridmedia').setStyle('background', 'transparent url(images/arrow_right_bg2-trans.png) no-repeat center right');
                        
                    }
                    
                    var getA = document.getElementById(id_list).getElementsByTagName('a');
                    $each(getA, function(htmlElement, key){
                        htmlElement.style.opacity = 0.5;
                        htmlElement.style.MozOpacity = 0.5;
                        htmlElement.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)";
                    });
                    document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo].style.opacity = 1;
                    document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo].style.MozOpacity = 1;
                    document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo].style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
                }
                if (gridmediaGlobalObj.current_photo < Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width)) {
                    gridmediaGlobalObj.left = 0;
                    $('id_silder_123456789').tween('left', 0);
                }
                if ((gridmediaGlobalObj.current_photo + 1) > Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width)) {
                    gridmediaGlobalObj.left = -(gridmediaGlobalObj.min_photo_width * (gridmediaGlobalObj.current_photo - Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width) + 1));
                    $('id_silder_123456789').tween('left', -(gridmediaGlobalObj.min_photo_width * (gridmediaGlobalObj.current_photo - Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width) + 1)));
                    
                }
            }
            
            document.getElementById(id_main).appendChild(right_arrow);
            $('right_arrow_gridmedia').setStyle('position', 'absolute');
            $('right_arrow_gridmedia').setStyle('width', width_right + 'px');
            $('right_arrow_gridmedia').setStyle('height', height + 'px');
            $('right_arrow_gridmedia').setStyle('z-Index', 1000);
            $('right_arrow_gridmedia').setStyle('background', 'transparent url(images/transparent.gif) no-repeat center left');
            
            $('right_arrow_gridmedia').addEvent('mouseover', function(){
                $('right_arrow_gridmedia').setStyle('background', 'transparent url(images/arrow_right_bg2-trans.png) no-repeat center right');
                $('right_arrow_gridmedia').setStyle('opacity', 0.5);
                $('right_arrow_gridmedia').setStyle('cursor', 'pointer');
                
                if (gridmediaGlobalObj.current_photo + 1 == gridmediaGlobalObj.photo_count) {
                    $('right_arrow_gridmedia').setStyle('background', 'transparent url(images/transparent.gif) no-repeat center right');
                }
                else {
                    $('right_arrow_gridmedia').setStyle('background', 'transparent url(images/arrow_right_bg2-trans.png) no-repeat center right');
                    
                }
                
            });
            $('right_arrow_gridmedia').addEvent('mouseout', function(){
                $('right_arrow_gridmedia').setStyle('background', 'transparent url(images/transparent.gif) no-repeat center left');
            });
            
            
            // --------------------------------------------------------------------------------
            
            location.href.substring(location.href.lastIndexOf('/') + 1)
            htmlElement.setStyle('width', min_photo_width);
            htmlElement.setStyle('height', min_photo_height);
            htmlElement.setStyle('border', 0);
        });
        
        
    },
    hideLeftScroll: function(options){
        $('slider_left_gridmedia').addEvent('mouseover', function(options){
            this.style.display = 'none';
            $('slider_center_gridmedia').setStyle('display', 'block');
            $('slider_right_gridmedia').setStyle('display', 'block');
            
            // przewijanie w lewo	   
            gridmediaGlobalObj.timer = setInterval(function(){
                $('id_silder_123456789').setStyle('left', gridmediaGlobalObj.left);
                
                if (gridmediaGlobalObj.left == 0) {
                    clearInterval(gridmediaGlobalObj.timer);
                    
                }
                else {
                    gridmediaGlobalObj.left = gridmediaGlobalObj.left + 2;
                }
            }, 10);
        });
        
        
    },
    hideRightScroll: function(options){
        $('slider_right_gridmedia').addEvent('mouseover', function(){
            this.style.display = 'none';
            $('slider_center_gridmedia').setStyle('display', 'block');
            $('slider_left_gridmedia').setStyle('display', 'block');
            
            // przewijanie w prawo
            gridmediaGlobalObj.timer = setInterval(function(){
                $('id_silder_123456789').setStyle('left', gridmediaGlobalObj.left);
                
                
                if (-((gridmediaGlobalObj.photo_count * gridmediaGlobalObj.min_photo_width) - gridmediaGlobalObj.width) == gridmediaGlobalObj.left) {
                    clearInterval(gridmediaGlobalObj.timer);
                    
                }
                else {
                    if (Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width) < gridmediaGlobalObj.photo_count) {
                        gridmediaGlobalObj.left = gridmediaGlobalObj.left - 2;
                    }
                }
            }, 10);
        });
        
    },
    hideCenterScroll: function(options){
        $('slider_center_gridmedia').addEvent('mouseover', function(){
            this.style.display = 'none';
            $('slider_right_gridmedia').setStyle('display', 'block');
            $('slider_left_gridmedia').setStyle('display', 'block');
            
            // zatrzymaj przewijanie
            clearInterval(gridmediaGlobalObj.timer);
        });
        
    },
    autoPlay: function(options){
        var id_list = options.id_list;
        document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo].style.opacity = 1;
        document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo].style.MozOpacity = 1;
        document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo].style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
        
        gridmediaGlobalObj.interval_autoplay = setInterval(function(){
        
            var getA = document.getElementById(id_list).getElementsByTagName('a');
            $each(getA, function(htmlElement, key){
                htmlElement.style.opacity = 0.5;
                htmlElement.style.MozOpacity = 0.5;
                htmlElement.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)";
            });
            
            
            var current_photo = gridmediaGlobalObj.current_photo;
            var photo_count = gridmediaGlobalObj.photo_count;
            
            if (current_photo + 1 != gridmediaGlobalObj.photo_count) {
                document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo + 1].style.opacity = 1;
                document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo + 1].style.MozOpacity = 1;
                document.getElementById(id_list).getElementsByTagName('a')[gridmediaGlobalObj.current_photo + 1].style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
            }
            else {
                document.getElementById(id_list).getElementsByTagName('a')[0].style.opacity = 1;
                document.getElementById(id_list).getElementsByTagName('a')[0].style.MozOpacity = 1;
                document.getElementById(id_list).getElementsByTagName('a')[0].style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
            }
            
            if (current_photo + 1 != gridmediaGlobalObj.photo_count) {
                $('divBorderGridmedia' + (current_photo + 1)).fade(1);
                $('divBorderGridmedia' + current_photo).fade(0);
                gridmediaGlobalObj.current_photo = gridmediaGlobalObj.current_photo + 1;
            }
            else {
                $('divBorderGridmedia' + (0)).fade(1);
                $('divBorderGridmedia' + current_photo).fade(0);
                gridmediaGlobalObj.current_photo = 0;
            }
            
            // -------- przesuwanie paska -----------------------------------
            
            
            // jeśli miaturki nie mieszczą się w pasku i cześć jest schowana
            if (Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width) < gridmediaGlobalObj.photo_count) {
                if (gridmediaGlobalObj.current_photo < Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width)) {
                    gridmediaGlobalObj.left = 0;
                    $('id_silder_123456789').tween('left', 0);
                }
                if ((gridmediaGlobalObj.current_photo + 1) > Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width)) {
                
                    gridmediaGlobalObj.left = -(gridmediaGlobalObj.min_photo_width * (gridmediaGlobalObj.current_photo - Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width) + 1));
                    $('id_silder_123456789').tween('left', -(gridmediaGlobalObj.min_photo_width * (gridmediaGlobalObj.current_photo - Math.ceil(gridmediaGlobalObj.width / gridmediaGlobalObj.min_photo_width) + 1)));
                    
                }
            }
            
        }, gridmediaGlobalObj.speed);
    },
    tooltips: function(options) {
    window.addEvent('domready', function() {
      var id_list = options.id_list;
      var myTips = new Tips(document.getElementById(id_list).getElementsByTagName('a'), {
    	timeOut: 700,
    	text: 'rel',
    	maxTitleChars: 50,
    	maxOpacity: .9 
    	});
    });
    
    }
});
