﻿function Resize(TagN, elementid, wid, hei, finalwid, finalhei, timeout, step, variant) {
    j = 0;
    var divs = document.getElementsByTagName(TagN);
    for (var i = 0; i < divs.length; i++) {
        var divname = divs[i].id;
        if (divname.indexOf(elementid) == 0) {
            if (variant == 'grow') {
                setTimeout("grow('" + TagN + "', '" + elementid + "', " + wid + ", " + hei + ", " + finalwid + ", " + finalhei + ", " + timeout + ", " + step + ", " + i + ")", (j + 1) * 500);
            }
            if (variant == 'shrink') {
                setTimeout("shrink('" + TagN + "', '" + elementid + "', " + wid + ", " + hei + ", " + finalwid + ", " + finalhei + ", " + timeout + ", " + step + ", " + i + ")", (j + 1) * 500);
            }
            j = j + 1;
        }
    }

    return;
}

function GraphicListResizeShow() {
    j = 0;
    var TagN = 'div';
    var elementid = 'PopUpBig';
    var divs = document.getElementsByTagName(TagN);

    for (var i = 0; i < divs.length; i++) {
        var divname = divs[i].id;
        if (divname.indexOf(elementid) > 0) {
            setTimeout("Resize('" + TagN + "', '" + elementid + "', 400, 0, 400, 50, 20, 8, 'grow')", (j + 1) * 2500);
            setTimeout("Resize('" + TagN + "', '" + elementid + "', 400, 50, 400, 0, 20, 8, 'shrink')", (j + 1) * 5000);
        }
        j = j + 1;
    }
}

function grow(TagN, elementid, wid, hei, finalwid, finalhei, timeout, step, i) {

    var divs = document.getElementsByTagName(TagN);

    var divname = divs[i].id;
    if (divname.indexOf(elementid) == 0) {
        divs[i].style.width = wid.toString() + 'px';
        divs[i].style.height = hei.toString() + 'px';
    }
    if (wid < finalwid) {
        wid = wid + step;
    }
    if (hei < finalhei) {
        hei = hei + step;
    }

    if (wid < finalwid) {

        setTimeout("grow('" + TagN + "', '" + elementid + "', " + wid + ", " + hei + ", " + finalwid + ", " + finalhei + ", " + timeout + ", " + step + ", " + i + ")", timeout);
    }
    else if (hei < finalhei) {
        setTimeout("grow('" + TagN + "', '" + elementid + "', " + wid + ", " + hei + ", " + finalwid + ", " + finalhei + ", " + timeout + ", " + step + ", " + i + ")", timeout);
    }
    return;
}

function shrink(TagN, elementid, wid, hei, finalwid, finalhei, timeout, step, i) {

    var divs = document.getElementsByTagName(TagN);

    var divname = divs[i].id;
    if (divname.indexOf(elementid) == 0) {
        divs[i].style.width = wid.toString() + 'px';
        divs[i].style.height = hei.toString() + 'px';
    }
    if (wid > finalwid) {
        wid = wid - step;
    }
    if (hei > finalhei) {
        hei = hei - step;
    }

    if (wid > finalwid) {

        setTimeout("shrink('" + TagN + "', '" + elementid + "', " + wid + ", " + hei + ", " + finalwid + ", " + finalhei + ", " + timeout + ", " + step + ", " + i + ")", timeout);
    }
    else if (hei > finalhei) {
        setTimeout("shrink('" + TagN + "', '" + elementid + "', " + wid + ", " + hei + ", " + finalwid + ", " + finalhei + ", " + timeout + ", " + step + ", " + i + ")", timeout);
    }
    return;
}

function PartialResize() {
    setTimeout("Resize('img', 'ExpandMe', 0, 0, 180, 150, 1, 15, 'grow')", 300);
}

function ShowGallery() {
    StopShow();
    setTimeout("ShowThem('div', 'GalleryPanel')", 200);
    setTimeout("ShowThem('img', 'ZoomInButton')", 200);
    //    setTimeout("HideThem('div', 'ShowPanel')", 200);
    //    setTimeout("HideThem('div', 'GmapPanel')", 200);
    setTimeout("Resize('img', 'ExpandMe', 0, 0, 180, 150, 1, 10, 'grow')", 300);
    document.getElementById(GalleryImageButton).src = CloseGalleryImageUrl;
    document.getElementById(GalleryImageButton).onclick = function() { ShowShow() };
    //    document.getElementById(GmapBtn).src = GmapBtnImageUrl;
    //    document.getElementById(GmapBtn).onclick = function() { ShowGmap() };
    return;
}
function ShowShow() {
    setTimeout("HideThem('div', 'GalleryPanel')", 200);
    //    setTimeout("HideThem('div', 'GmapPanel')", 200);
    //    setTimeout("ShowThem('div', 'ShowPanel')", 200);
    Resize('img', 'ExpandMe', 180, 150, 0, 0, 1, 10, 'shrink');
    //    setTimeout("ShowThem(" + StartItemTagN + ", " + StartItemelementid + ")", 10);
    setTimeout("Show(StartItemdirection, StartItemTagN, StartItemelementid, StartItemposition, StartItemstep, StartItemtimeout, StartItemlength)", 1500);
    document.getElementById(GalleryImageButton).onclick = function() { ShowGallery() };
    document.getElementById(GalleryImageButton).src = StartGalleryImageUrl;
    //    document.getElementById(GmapBtn).src = GmapBtnImageUrl;
    //    document.getElementById(GmapBtn).onclick = function() { ShowGmap() };
    return;
}

//function ShowGmap() {
//    StopShow();
////    setTimeout("HideThem('div', 'ShowPanel')", 200);
//    setTimeout("HideThem('div', 'GalleryPanel')", 200);
//    setTimeout("ShowThem('div', 'GmapPanel')", 200);
//    Resize('img', 'ExpandMe', 180, 150, 0, 0, 1, 10, 'shrink');
//    document.getElementById(GmapBtn).src = CloseGalleryImageUrl;
//    document.getElementById(GmapBtn).onclick = function() { ShowShow() };
//    document.getElementById(GalleryImageButton).onclick = function() { ShowGallery() };
//    document.getElementById(GalleryImageButton).src = StartGalleryImageUrl;
//    document.getElementById('GMap').height = '340px';
//    initializeG();
//}


function OpenReservationForm() {
    var ReservationForm = document.getElementById('ReservationForm');
    ReservationForm.style.display = 'block';
    Resize('div', 'ReservationForm', 0, 0, 380, 500, 30, 20, 'grow');
}

function HideThem(TagN, elementid) {

    var divs = document.getElementsByTagName(TagN);

    for (var i = 0; i < divs.length; i++) {
        var divname = divs[i].id;
        if (divname.indexOf(elementid) == 0) {
            divs[i].style.display = 'none';
        }
    }
}

function ShowThem(TagN, elementid) {

    var divs = document.getElementsByTagName(TagN);

    for (var i = 0; i < divs.length; i++) {
        var divname = divs[i].id;
        if (divname.indexOf(elementid) == 0) {
            divs[i].style.display = 'block';
        }
    }
}

movingtimer = new Array();
hidingtimer = new Array();
var ShowPlayInterval;
var StartItemdirection;
var StartItemTagN;
var StartItemelementid;
var StartItemposition;
var StartItemstep;
var StartItemtimeout;
var StartItemlength;

function Show(direction, TagN, elementid, position, step, timeout, length) {

    StartItemdirection = direction;
    StartItemTagN = TagN;
    StartItemelementid = elementid;
    StartItemposition = position;
    StartItemstep = step;
    StartItemtimeout = timeout;
    StartItemlength = length;

    var delay = ((length - position) / step) * timeout;
    if (delay < 0) {
        delay = delay - delay - delay;
    }
    var divs = document.getElementsByTagName(TagN);
    var totaltime = 0;
    var NofElem = 0;

    for (var i = 0; i < divs.length; i++) {
        var divname = divs[i].id;
        if (divname.indexOf(elementid) == 0) {
            totaltime = totaltime + delay;
            NofElem = NofElem + 1;
        }
    }

    totaltime = totaltime + NofElem * 2000 - 1000;
    ShowPlay(direction, TagN, elementid, position, step, timeout, length, delay);
    ShowPlayInterval = setInterval("ShowPlay('" + direction + "', '" + TagN + "', '" + elementid + "', " + position + ", " + step + ", " + timeout + ", " + length + ", " + delay + ")", totaltime);
}

function ShowPlay(direction, TagN, elementid, position, step, timeout, length, delay) {
    j = 0;
    var divs = document.getElementsByTagName(TagN);
    if (divs.length < 2) {
        divs[0].style.display = 'block';
    }
    else {
        for (var z = 0; z < divs.length; z++) {
            var divn = divs[z].id;

            if (divn.indexOf(elementid) == 0) {
                divs[z].style.display = 'block';
                movingtimer[z] = setTimeout("moveObj" + direction + "('" + TagN + "', '" + elementid + "', " + position + ", " + step + ", " + timeout + ", " + length + ", " + z + ")", j * delay + j * 1000);
                hidingtimer[z] = setTimeout("FadeObject('" + TagN + "', '" + elementid + "', " + z + ", 1, 'out')", (j + 1) * delay + (j + 1) * 1000);
                j = j + 1;
            }

        }
    }
}

function StopShow() {
    clearInterval(ShowPlayInterval);
    for (var i = 0; i < movingtimer.length; i++) {
        clearTimeout(movingtimer[i]);
    }
    for (var j = 0; j < hidingtimer.length; j++) {
        clearTimeout(hidingtimer[j]);
    }
    for (var k = 0; k < doingmovingtimer.length; k++) {
        clearTimeout(doingmovingtimer[k]);
    }
    for (var m = 0; m < fadeout.length; m++) {
        clearTimeout(fadeout[m]);
    }
    for (var n = 0; n < fadein.length; n++) {
        clearTimeout(fadein[n]);
    }

}
var fadeout = new Array();
var fadein = new Array();
function FadeObject(TagN, elementid, i, opac, inout) {
    var divs = document.getElementsByTagName(TagN);

    if (inout == 'out') {
        opac = opac - 0.1;
    }
    else {
        opac = opac + 0.1;
    }

    var divname = divs[i].id;
    if (divname.indexOf(elementid) == 0) {

        divs[i].style.opacity = "." + opac.toString().substring(2, 3);
        divs[i].style.filter = 'alpha(opacity=' + opac * 100 + ')';
    }

    if (inout == 'out') {
        if (opac > 0.1) {
            fadeout[i] = setTimeout("FadeObject('" + TagN + "', '" + elementid + "', " + i + ", " + opac + ", '" + inout + "')", 100);
        }
        else {
            divs[i].style.opacity = 1;
            divs[i].style.filter = 'alpha(opacity=100)';
            divs[i].style.display = 'none';
        }
    }

    if (inout == 'in') {
        if (opac == 0.1) {
            divs[i].style.display = 'block';
        }
        if (opac > 0.8) {
            fadein[i] = setTimeout("FadeObject('" + TagN + "', '" + elementid + "', " + i + ", " + opac + ", '" + inout + "')", 100);
        }
        else {
            divs[i].style.opacity = 1;
            divs[i].style.filter = 'alpha(opacity=100)';
        }
    }
    return;
}
var doingmovingtimer = new Array();

function moveObjRight(TagN, obj, position, step, timeout, length, i) {

    var divs = document.getElementsByTagName(TagN);

    var divname = divs[i].id;
    if (divname.indexOf(obj) == 0) {
        divs[i].style.top = position + 'px';
    }

    position = position + step;
    if (position > length)
        doingmovingtimer[i] = setTimeout("moveObjRight('" + TagN + "', '" + obj + "', " + position + ", " + step + ", " + timeout + ", " + length + ", " + i + ");", timeout);


}
function moveObjLeft(TagN, obj, position, step, timeout, length, i) {

    var divs = document.getElementsByTagName(TagN);

    var divname = divs[i].id;
    if (divname.indexOf(obj) == 0) {
        divs[i].style.top = position + 'px';
    }

    position = position - step;
    if (position > length)
        doingmovingtimer[i] = setTimeout("moveObjLeft('" + TagN + "', '" + obj + "', " + position + ", " + step + ", " + timeout + ", " + length + ", " + i + ");", timeout);


}
function moveObjUp(TagN, obj, position, step, timeout, length, i) {

    var divs = document.getElementsByTagName(TagN);

    var divname = divs[i].id;
    if (divname.indexOf(obj) == 0) {
        divs[i].style.top = position + 'px';
    }

    position = position - step;
    if (position > length)
        doingmovingtimer[i] = setTimeout("moveObjUp('" + TagN + "', '" + obj + "', " + position + ", " + step + ", " + timeout + ", " + length + ", " + i + ");", timeout);


}
function moveObjDown(TagN, obj, position, step, timeout, length, i) {

    var divs = document.getElementsByTagName(TagN);

    var divname = divs[i].id;
    if (divname.indexOf(obj) == 0) {
        divs[i].style.top = position + 'px';
    }

    position = position + step;
    if (position < length)
        doingmovingtimer[i] = setTimeout("moveObjDown('" + TagN + "', '" + obj + "', " + position + ", " + step + ", " + timeout + ", " + length + ", " + i + ");", timeout);


}

function Slide(obj, Length, timer, direction) {

    var CurrentMargin = document.getElementById(obj).style.marginLeft.replace("px", "");
    MoveInterval = setInterval("MoveObject('" + obj + "', " + CurrentMargin + ", " + Length + ", '" + direction + "')", timer);

}

position = 0;
itteration = 0;
movesize = 1;

function MoveObject(obj, CurrentMargin, Length, direction) {

    document.getElementById(obj).style.marginLeft = CurrentMargin + position + "px";

    if (direction == 'left') {
        position = position + movesize;

        itteration = itteration + 1;

        if (Length < position) {
            clearInterval(MoveInterval);
            position = 0;
        }
    }

    else {
        position = position - movesize;

        itteration = itteration + 1;

        if (-Length > position) {
            clearInterval(MoveInterval);
            position = 0;
        }
    }
}

function getSize(what) {
    var myWidth = 0, myHeight = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    if (what == "width") {
        return myWidth;
    }
    if (what == "Height") {
        return myHeight;
    }
}

function getSizeParentWindow(what) {
    var myWidth = 0, myHeight = 0;
    if (typeof (window.parent.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.parent.innerWidth;
        myHeight = window.parent.innerHeight;
    } else if (document.documentElement && (document.parent.documentElement.clientWidth || document.parent.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.parent.documentElement.clientWidth;
        myHeight = document.parent.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.parent.body.clientWidth;
        myHeight = document.parent.body.clientHeight;
    }
    if (what == "width") {
        return myWidth;
    }
    if (what == "Height") {
        return myHeight;
    }
}

function LoadScroll(divid) {
    //    GraphicListResizeShow();
    height = getSize('Height');
    if (height > 1000) {
        document.getElementById(divid).style.height = height - 430 + 'px';
        document.getElementById('MainDiv').style.height = height - 430 + 'px';
        CSBfleXcroll(divid);
    }
    else {
        document.getElementById(divid).style.height = 'auto';
        document.getElementById(divid).style.position = 'static';
        document.getElementById(divid).style.overflow = 'visible';
        document.getElementById('MainDiv').style.height = 'auto';
        document.getElementById('MainDiv').style.width = '950px';
        document.getElementById('HeaderDiv').style.width = '960px';
        document.getElementById('SurroundDiv').style.width = '980px';
        //        document.getElementById('ContentLeftCell').style.width = '365px';
        //        document.getElementById('ContentRightCell').style.width = '595px';
        document.getElementById('NavigationMenu').style.width = '565px';
        document.getElementById('HeaderMenu').style.width = '570px';
        document.getElementById('LanguageDiv').style.float = 'left';
    }
}

function refreshcomments() {
    document.getElementById('ctl00_ContentPlaceHolder1_CommentsShow1_CommentsUpdateButton').click();
}
function InsertComment() {
    document.getElementById(InsertImage).style.display = 'none';
    __doPostBack(CommentsInsertButton, '');
    setTimeout("refreshcomments()", 3000);
}

function OdpriObrazecKomentarji() {
    document.getElementById('KomentirajObrazec').style.display = 'block';
    document.getElementById('Zapri').style.display = 'block';
    document.getElementById('Komentiraj').style.display = 'none';
    document.getElementById('MainPhotoDiv').style.display = 'none';
}
function ZapriObrazecKomentarji() {
    document.getElementById('KomentirajObrazec').style.display = 'none';
    document.getElementById('Zapri').style.display = 'none';
    document.getElementById('Komentiraj').style.display = 'block';
    document.getElementById('MainPhotoDiv').style.display = 'block';
}


function SendPrijava() {
    document.getElementById(InsertImage).style.display = 'none';
    __doPostBack(CommentsInsertButton, '');
}

function OdpriObrazecIzobrazevanja() {
    document.getElementById('KomentirajObrazec').style.display = 'block';
    document.getElementById('Zapri').style.display = 'block';
    document.getElementById('Komentiraj').style.display = 'none';
    document.getElementById('MainPhotoDiv').style.display = 'none';
}
function ZapriObrazecIzobrazevanja() {
    document.getElementById('KomentirajObrazec').style.display = 'none';
    document.getElementById('Zapri').style.display = 'none';
    document.getElementById('Komentiraj').style.display = 'block';
    document.getElementById('MainPhotoDiv').style.display = 'block';
}
