var t;
var opacity = 0;
var opacity_2 = 0;
var gal__img__id;

function gal__enlarge(id)
{
    gal__img__id = id;
    opacity = 50
    gal__light_down();
    
    setTimeout("gal__img_replace()", 500);
    
    opacity_2 = 0;
    setTimeout("gal__light_up()", 550);
}

function gal__enlarge__max(img__id)
{
    wname = 'advert_edit_window';
    w = screen.width;
    h = screen.height;
    st = 1;
    tool = 0;
    scrolll = 1;
    resize = 1;
    
    wd = window.open('image_max.php?f=' + img__id + '&sw=' + w + '&sh=' + h, wname, 'fullscreen=1, status=' + st + ', toolbar=' + tool + ', scrollbars=' + scrolll + ', resizable=' + resize);
}

function gal__enlarge__max_2(img__id)
{
    wname = 'advert_edit_window';
    w = screen.width;
    h = screen.height;
    st = 1;
    tool = 0;
    scrolll = 1;
    resize = 1;
    
    wd = window.open('image_max_2.php?f=' + img__id + '&sw=' + w + '&sh=' + h, wname, 'fullscreen=1, status=' + st + ', toolbar=' + tool + ', scrollbars=' + scrolll + ', resizable=' + resize);
}

function gal__img_replace()
{
    gal__enlarged.innerHTML = '<img id="gal__enl__img" src="http://marijasribna.com/upload/img/4/' + gal__img__id + '" style="filter:alpha(opacity=0); -moz-opacity:0" onClick="gal__enlarge__max()">';
}

function gal__light_up(){
    imageobject = fetch_object('gal__enl__img');
    
    if (is_nav || is_op){
        imageobject.style.MozOpacity = opacity_2/100;
    }
    else if (is_ie){
        imageobject.filters.alpha.opacity = opacity_2;
    }
    
    opacity_2 += 10;
    
    if (opacity_2 != 110){
        t2 = setTimeout("gal__light_up()", 50);
    } else {
        clearTimeout(t2);
        //opacity = 0;
    }
}

function gal__light_down(){
    imageobject = fetch_object('gal__enl__img');
    
    if (is_nav || is_op){
        imageobject.style.MozOpacity = opacity/100;
    }
    else if (is_ie){
        imageobject.filters.alpha.opacity = opacity
    }
    
    opacity -= 10;
    
    if (opacity != -10){
        t1 = setTimeout("gal__light_down()", 50);
    } else {
        clearTimeout(t1);
        //opacity = 0;
    }
}

function gal__fix__list__width()
{
    var w;
    h = fetch_object('gal_list_h');
    h2 = fetch_object('gal_list_h2');
    if (is_ie){
        w = 725;
    } else {
        w = 725;
    }
    
    h.style.width = w;
    h2.style.width = w;
    
    gal__list__fix__overflow('gal_list_h');
}

function gal__list__fix__overflow(hid)
{
    h = fetch_object(hid);

    if (is_op){
        h.style.overflow = 'auto';
    } else {
        h.style.overflowX = 'scroll';
    }
}

var gal_scroll_n = 0;
function gal__list__scroll(hid, t, max_n)
{
    var h = fetch_object(hid);
    
    max_n -= 5;
    
    if ((t == 1 && gal_scroll_n == max_n) || (t == -1 && gal_scroll_n == 0)){
        return;
    }
    
    gal_scroll_n += t;
    
    h.scrollLeft = 144 * gal_scroll_n;
}

function gal__list__fix__overflow_2(hid)
{
    h = fetch_object(hid);

    if (is_op){
        h.style.overflow = 'auto';
    } else {
        h.style.overflowX = 'hidden';
    }
}

// Blog
var blog_scroll_n = 0;
function blog__scroll(hid, t, max_n)
{
    var h = fetch_object(hid);
    var diff;
    
    max_n -= 19;
    
    if ((t == 1 && blog_scroll_n == max_n) || (t == -1 && blog_scroll_n == 0)){
        return;
    }
    
    blog_scroll_n += t;
    //alert(blog_scroll_n+'/'+max_n);
    if (is_ie){
        diff = 38 + Math.floor(blog_scroll_n / 3);
    } else {
        diff = 37;
    }
    
    h.scrollLeft = diff * blog_scroll_n;
}


