﻿function EnableCheckedBodyType() {
    document.getElementById('limuzina').checked = 'checked';
    document.getElementById('kombilimuzina').checked = 'checked';
    document.getElementById('karavan').checked = 'checked';
    document.getElementById('enoprostorec').checked = 'checked';
    document.getElementById('terensko').checked = 'checked';
    document.getElementById('športni').checked = 'checked';
    document.getElementById('cabrio').checked = 'checked';
    document.getElementById('dostavno').checked = 'checked';
    document.getElementById('avtodom').checked = 'checked';
    document.getElementById('plovilo').checked = 'checked';
    document.getElementById('pocitniskaprikolica').checked = 'checked';
}

function DisableCheckedBodyType() {
    document.getElementById('limuzina').checked = '';
    document.getElementById('kombilimuzina').checked = '';
    document.getElementById('karavan').checked = '';
    document.getElementById('enoprostorec').checked = '';
    document.getElementById('terensko').checked = '';
    document.getElementById('športni').checked = '';
    document.getElementById('cabrio').checked = '';
    document.getElementById('dostavno').checked = '';
    document.getElementById('avtodom').checked = '';
    document.getElementById('plovilo').checked = '';
    document.getElementById('pocitniskaprikolica').checked = '';
}

function TabClick(td) {
    var i
    var tr
    var td_Content

    tr = td.parentNode

    for (i = 0; i < tr.cells.length - 1; i++) {
        td_Content = document.getElementById('table_Tab_Content').rows[0].cells[i];
        td_Tab = document.getElementById('table_Tab').rows[0].cells[i];
        tr.cells[i].className = 'TabFrame';

        if (td != td_Tab) {
            td_Content.style.display = 'none';
        } else {
            td_Content.style.display = 'inline';
        }
    }
    tr.cells[td.cellIndex].className = 'TabSelFrame';

    if (document.getElementById('ForResize').scrollHeight > '650') {
        document.getElementById('layout_td_Main').style.height = parseInt(document.getElementById('ForResize').scrollHeight + 20) + 'px';
        document.getElementById('HiddenOverflow_Main').style.height = parseInt(document.getElementById('ForResize').scrollHeight + 20) + 'px';
    }
    else {
        document.getElementById('layout_td_Main').style.height = '660px';
        document.getElementById('HiddenOverflow_Main').style.height = '660px';
    }
}

function TabOver(td) {
    if (td.className != 'TabSelFrame') {
        td.className = 'TabFrameOver';
    }
}
function TabOut(td) {
    if (td.className != 'TabSelFrame') {
        td.className = 'TabFrame';
    }
}

function setRefreshClock() {
    document.getElementById("ConsoleRefreshClock").innerHTML = '60';

    var chkbox = document.createElement('input');
    chkbox.type = "checkbox";
    chkbox.id = 'RefreshCheckBox';
    chkbox.checked = 'checked';

    chkbox.onclick = function() {
        if (chkbox.checked) {
            document.getElementById("ConsoleRefreshClock").innerHTML = '60';
            interval = window.setInterval('document.getElementById("ConsoleRefreshClock").innerHTML=parseInt(document.getElementById("ConsoleRefreshClock").innerHTML) - 1;', 1000);
            timeout = window.setTimeout('clearTimeout(timeout); clearInterval(interval); document.form_Page.submit();', 60000);
        } else {
            window.clearInterval(interval); window.clearTimeout(timeout);
        }
    }

    document.getElementById('ConsoleRefreshText').appendChild(chkbox);
    document.getElementById('RefreshCheckBox').checked = 'checked';

    if (document.getElementById('RefreshCheckBox').checked) {
        interval = window.setInterval('document.getElementById("ConsoleRefreshClock").innerHTML=parseInt(document.getElementById("ConsoleRefreshClock").innerHTML) - 1;', 1000);
        timeout = window.setTimeout('clearTimeout(timeout); clearInterval(interval); document.form_Page.submit();', 60000);
    }
}

function cdtime(container, targetdate, currentdate) {
    if (!document.getElementById || !document.getElementById(container)) return
    this.container = document.getElementById(container)
    this.currentTime = new Date(currentdate)
    this.targetdate = new Date(targetdate)
    this.timesup = false
    this.updateTime()
}

cdtime.prototype.updateTime = function() {
    var thisobj = this
    this.currentTime.setSeconds(this.currentTime.getSeconds() + 1)
    setTimeout(function() { thisobj.updateTime() }, 1000) //update time every second
}

cdtime.prototype.displaycountdown = function(baseunit, functionref) {
    this.baseunit = baseunit
    this.formatresults = functionref
    this.showresults()
}

cdtime.prototype.showresults = function() {
    var thisobj = this


    var timediff = (this.targetdate - this.currentTime) / 1000 //difference btw target date and current date, in seconds
    if (timediff < 0) { //if time is up
        this.timesup = true
        this.container.innerHTML = this.formatresults()
        return
    }
    var oneMinute = 60 //minute unit in seconds
    var oneHour = 60 * 60 //hour unit in seconds
    var oneDay = 60 * 60 * 24 //day unit in seconds
    var dayfield = Math.floor(timediff / oneDay)
    var hourfield = Math.floor((timediff - dayfield * oneDay) / oneHour)
    var minutefield = Math.floor((timediff - dayfield * oneDay - hourfield * oneHour) / oneMinute)
    var secondfield = Math.floor((timediff - dayfield * oneDay - hourfield * oneHour - minutefield * oneMinute))
    if (this.baseunit == "hours") { //if base unit is hours, set "hourfield" to be topmost level
        hourfield = dayfield * 24 + hourfield
        dayfield = "n/a"
    }
    else if (this.baseunit == "minutes") { //if base unit is minutes, set "minutefield" to be topmost level
        minutefield = dayfield * 24 * 60 + hourfield * 60 + minutefield
        dayfield = hourfield = "n/a"
    }
    else if (this.baseunit == "seconds") { //if base unit is seconds, set "secondfield" to be topmost level
        var secondfield = timediff
        dayfield = hourfield = minutefield = "n/a"
    }
    this.container.innerHTML = this.formatresults(dayfield, hourfield, minutefield, secondfield)
    setTimeout(function() { thisobj.showresults() }, 1000) //update results every second
}

function formatresults() {
    if (this.timesup == false) { //if target date/time not yet met
        var displaystring = "<span class='lcdstyle'>" + arguments[0] + " <sup>dni</sup> " + arguments[1] + " <sup>ur</sup> " + arguments[2] + " <sup>minut</sup> " + arguments[3] + " <sup>sekund</sup></span>"
    }
    else { //else if target date/time met
        var displaystring = "" //Don't display any text
        //alert("Konec avkcije.") //Instead, perform a custom alert
        document.form_Page.submit(); //samo refreshamo stran
    }
    return displaystring
}

function AutoSuggest(elem, suggestions) {

    //The 'me' variable allow you to access the AutoSuggest object
    //from the elem's event handlers defined below.
    var me = this;

    //A reference to the element we're binding the list to.
    this.elem = elem;

    this.suggestions = suggestions;

    //Arrow to store a subset of eligible suggestions that match the user's input
    this.eligible = new Array();

    //The text input by the user.
    this.inputText = null;

    //A pointer to the index of the highlighted eligible item. -1 means nothing highlighted.
    this.highlighted = -1;

    //A div to use to create the dropdown.
    this.div = document.getElementById("autosuggest");


    //Do you want to remember what keycode means what? Me neither.
    var TAB = 9;
    var ESC = 27;
    var KEYUP = 38;
    var KEYDN = 40;


    //The browsers' own autocomplete feature can be problematic, since it will 
    //be making suggestions from the users' past input.
    //Setting this attribute should turn it off.
    elem.setAttribute("autocomplete", "off");

    //We need to be able to reference the elem by id. If it doesn't have an id, set one.
    if (!elem.id) {
        var id = "autosuggest" + idCounter;
        idCounter++;

        elem.id = id;
    }


    /********************************************************
    onkeydown event handler for the input elem.
    Tab key = use the highlighted suggestion, if there is one.
    Esc key = get rid of the autosuggest dropdown
    Up/down arrows = Move the highlight up and down in the suggestions.
    ********************************************************/
    elem.onkeydown = function(ev) {
        var key = me.getKeyCode(ev);

        switch (key) {
            case TAB:
                me.useSuggestion();
                break;

            case ESC:
                me.hideDiv();
                break;

            case KEYUP:
                if (me.highlighted > 0) {
                    me.highlighted--;
                }
                me.changeHighlight(key);
                break;

            case KEYDN:
                if (me.highlighted < (me.eligible.length - 1)) {
                    me.highlighted++;
                }
                me.changeHighlight(key);
                break;
        }
    };

    /********************************************************
    onkeyup handler for the elem
    If the text is of sufficient length, and has been changed, 
    then display a list of eligible suggestions.
    ********************************************************/
    elem.onkeyup = function(ev) {
        var key = me.getKeyCode(ev);
        switch (key) {
            //The control keys were already handled by onkeydown, so do nothing.    
            case TAB:
            case ESC:
            case KEYUP:
            case KEYDN:
                return;
            default:

                if (this.value != me.inputText && this.value.length > 1) {
                    me.inputText = this.value;
                    me.getEligible();
                    me.createDiv();
                    me.positionDiv();
                    me.hideDiv();

                    //If we find any suggesting item then we dislay it
                    if (document.getElementById('autosuggest').innerHTML.toUpperCase() != "<UL></UL>") {
                        me.showDiv();
                    }
                }
                else {
                    me.hideDiv();
                }
        }
    };


    /********************************************************
    Insert the highlighted suggestion into the input box, and 
    remove the suggestion dropdown.
    ********************************************************/
    this.useSuggestion = function() {
        if (this.highlighted > -1) {
            this.elem.value = this.eligible[this.highlighted];
            this.hideDiv();
            //It's impossible to cancel the Tab key's default behavior. 
            //So this undoes it by moving the focus back to our field right after
            //the event completes.
            setTimeout("document.getElementById('" + this.elem.id + "').focus()", 0);
        }
    };

    /********************************************************
    Display the dropdown. Pretty straightforward.
    ********************************************************/
    this.showDiv = function() {
        this.div.style.display = 'block';
    };

    /********************************************************
    Hide the dropdown and clear any highlight.
    ********************************************************/
    this.hideDiv = function() {
        this.div.style.display = 'none';
        this.highlighted = -1;
    };

    /********************************************************
    Modify the HTML in the dropdown to move the highlight.
    ********************************************************/
    this.changeHighlight = function() {
        var lis = this.div.getElementsByTagName('LI');
        for (i in lis) {
            var li = lis[i];

            if (this.highlighted == i) {
                li.className = "selected";
            }
            else {
                li.className = "";
            }
        }
    };

    /********************************************************
    Position the dropdown div below the input text field.
    ********************************************************/
    this.positionDiv = function() {
        var el = this.elem;
        var x = 0;
        var y = el.offsetHeight;

        //Walk up the DOM and add up all of the offset positions.
        while (el.offsetParent && el.tagName.toUpperCase() != 'BODY') {
            x += el.offsetLeft;
            y += el.offsetTop;
            el = el.offsetParent;
        }

        x += el.offsetLeft;
        y += el.offsetTop;

        this.div.style.left = x + 'px';
        this.div.style.top = y + 'px';
    };

    /********************************************************
    Build the HTML for the dropdown div
    ********************************************************/
    this.createDiv = function() {
        var ul = document.createElement('ul');

        //Create an array of LI's for the words.
        for (i in this.eligible) {
            var word = this.eligible[i];

            var li = document.createElement('li');
            var a = document.createElement('a');
            a.href = "javascript:false";
            a.innerHTML = word;
            li.appendChild(a);

            if (me.highlighted == i) {
                li.className = "selected";
            }

            ul.appendChild(li);
        }

        this.div.replaceChild(ul, this.div.childNodes[0]);


        /********************************************************
        mouseover handler for the dropdown ul
        move the highlighted suggestion with the mouse
        ********************************************************/
        ul.onmouseover = function(ev) {
            //Walk up from target until you find the LI.
            var target = me.getEventSource(ev);
            while (target.parentNode && target.tagName.toUpperCase() != 'LI') {
                target = target.parentNode;
            }

            var lis = me.div.getElementsByTagName('LI');


            for (i in lis) {
                var li = lis[i];
                if (li == target) {
                    me.highlighted = i;
                    break;
                }
            }
            me.changeHighlight();
        };

        /********************************************************
        click handler for the dropdown ul
        insert the clicked suggestion into the input
        ********************************************************/
        ul.onclick = function(ev) {
            me.useSuggestion();
            me.hideDiv();
            me.cancelEvent(ev);
            return false;
        };

        this.div.className = "suggestion_list";
        this.div.style.position = 'absolute';

    };

    /********************************************************
    determine which of the suggestions matches the input
    ********************************************************/
    this.getEligible = function() {
        this.eligible = new Array();
        for (i in this.suggestions) {
            var suggestion = this.suggestions[i];

            if (suggestion.toLowerCase().indexOf(this.inputText.toLowerCase()) == "0") {
                this.eligible[this.eligible.length] = suggestion;
            }
        }
    };

    /********************************************************
    Helper function to determine the keycode pressed in a 
    browser-independent manner.
    ********************************************************/
    this.getKeyCode = function(ev) {
        if (ev)			//Moz
        {
            return ev.keyCode;
        }
        if (window.event)	//IE
        {
            return window.event.keyCode;
        }
    };

    /********************************************************
    Helper function to determine the event source element in a 
    browser-independent manner.
    ********************************************************/
    this.getEventSource = function(ev) {
        if (ev)			//Moz
        {
            return ev.target;
        }

        if (window.event)	//IE
        {
            return window.event.srcElement;
        }
    };

    /********************************************************
    Helper function to cancel an event in a 
    browser-independent manner.
    (Returning false helps too).
    ********************************************************/
    this.cancelEvent = function(ev) {
        if (ev)			//Moz
        {
            ev.preventDefault();
            ev.stopPropagation();
        }
        if (window.event)	//IE
        {
            window.event.returnValue = false;
        }
    }
}

//counter to help create unique ID's
var idCounter = 0;

var iNterval1;
var iNterval2;
var imgobj;

function ShowBlog() {
    document.getElementById('PopUpDivBlog').innerHTML = document.getElementById('HiddenBlogData').innerHTML;
    document.getElementById('PopUpDivBlog').style.overflow = 'auto';
    document.getElementById('PopUpDivBlog').style.height = '600px';
    document.getElementById('PopUpDivBlog').height = '600px';
    document.getElementById('PopUpDivBlog').style.width = '800px';
    document.getElementById('PopUpDivBlog').width = '800px';
    document.getElementById('PopUpDivBlog').style.visibility = 'visible';
    document.getElementById('OpacityDiv').style.visibility = 'visible';
    iNterval1 = setInterval("document.getElementById('PopUpDiv').style.top=document.documentElement.scrollTop + 'px';", 10);
    iNterval2 = setInterval("document.getElementById('OpacityDiv').style.top=document.documentElement.scrollTop + 'px';", 10);
}

function HideBlog() {
    document.getElementById('PopUpDivBlog').innerHTML = '';
    document.getElementById('PopUpDivBlog').style.overflow = 'hidden';
    document.getElementById('PopUpDivBlog').style.visibility = 'hidden';
    document.getElementById('OpacityDiv').style.visibility = 'hidden';
    window.clearInterval(iNterval1);
    window.clearInterval(iNterval2);
}


function OpenPopUPDiv(Src, ImageName, PhotoGalleryName, Id) {
    var GalleryID
    var NextImage
    var NextImageId
    var PrevImage
    var PrevImageId

    if (!Id) {
        document.getElementById('PopUpDivBlog').style.display = 'none';
        document.getElementById('PopUpDivImage').innerHTML = '<img title="Click to close" CurId="' + Id + '" id="CurImage" style="cursor:pointer;" src="' + Src + '" onclick="window.clearInterval(iNterval1); window.clearInterval(iNterval2); document.getElementById(&#39;PopUpDiv&#39;).style.visibility=&#39;hidden&#39;; document.getElementById(&#39;OpacityDiv&#39;).style.visibility=&#39;hidden&#39;; document.getElementById(&#39;PrevImageImg&#39;).style.visibility=&#39;hidden&#39;; document.getElementById(&#39;NextImageImg&#39;).style.visibility=&#39;hidden&#39;;"" />';
        document.getElementById('PrevImageImg').style.visibility = 'hidden';
        document.getElementById('NextImageImg').style.visibility = 'hidden';
        document.getElementById('OpacityDiv').style.visibility = 'visible';
        if (navigator.appVersion.indexOf("MSIE") == -1) {
            document.getElementById('PopUpDiv').style.position = 'fixed';
            document.getElementById('OpacityDiv').style.position = 'fixed';
        }
        else {
            iNterval1 = setInterval("document.getElementById('PopUpDiv').style.top=document.documentElement.scrollTop + 'px';", 10);
            iNterval2 = setInterval("document.getElementById('OpacityDiv').style.top=document.documentElement.scrollTop  + 'px';", 10);
        }
        setTimeout("document.getElementById('PopUpDiv').style.visibility='visible'", 10);
    }
    else {

        GalleryID = Id.split("_");
        NextImageId = parseInt(GalleryID[2]) + 1;
        PrevImageId = parseInt(GalleryID[2]) - 1;

        NextImage = GalleryID[0] + '_' + GalleryID[1] + '_' + NextImageId
        PrevImage = GalleryID[0] + '_' + GalleryID[1] + '_' + PrevImageId

        document.getElementById('PopUpDivBlog').style.display = 'none';
        document.getElementById('PopUpDivImage').innerHTML = '<img title="Click to close" CurId="' + Id + '" id="CurImage" style="cursor:pointer;" src="' + Src + '" onclick="window.clearInterval(iNterval1); window.clearInterval(iNterval2); document.getElementById(&#39;PopUpDiv&#39;).style.visibility=&#39;hidden&#39;; document.getElementById(&#39;OpacityDiv&#39;).style.visibility=&#39;hidden&#39;; document.getElementById(&#39;PrevImageImg&#39;).style.visibility=&#39;hidden&#39;; document.getElementById(&#39;NextImageImg&#39;).style.visibility=&#39;hidden&#39;;"" />';

        if (navigator.appVersion.indexOf("MSIE") == -1) {
            document.getElementById('PopUpDiv').style.position = 'fixed';
            document.getElementById('OpacityDiv').style.position = 'fixed';
        }
        else {
            iNterval1 = setInterval("document.getElementById('PopUpDiv').style.top=document.documentElement.scrollTop + 'px';", 10);
            iNterval2 = setInterval("document.getElementById('OpacityDiv').style.top=document.documentElement.scrollTop  + 'px';", 10);
        }

        document.getElementById('OpacityDiv').style.visibility = 'visible';
        setTimeout("document.getElementById('PopUpDiv').style.visibility='visible'", 10);
        document.getElementById('PrevImageImg').style.visibility = 'visible';
        document.getElementById('NextImageImg').style.visibility = 'visible';

        if (!document.getElementById(NextImage)) {
            document.getElementById('NextImageImg').style.visibility = 'hidden';
        }
        if (!document.getElementById(PrevImage)) {
            document.getElementById('PrevImageImg').style.visibility = 'hidden';
        }
    }
}

function NextImage(Id) {
    var GalleryID
    var NextImage
    var NextImageId
    var NextImageIdHide

    GalleryID = Id.split("_");
    NextImageId = parseInt(GalleryID[2]) + 1;
    NextImageIdHide = parseInt(GalleryID[2]) + 2;

    NextImage = GalleryID[0] + '_' + GalleryID[1] + '_' + NextImageId

    if (document.getElementById(NextImage)) {
        document.getElementById('CurImage').src = document.getElementById(NextImage).getAttribute('imagesrc');
        document.getElementById('CurImage').setAttribute('CurId', NextImage);
        document.getElementById('PrevImageImg').style.visibility = 'visible';
    }

    if (!document.getElementById(GalleryID[0] + '_' + GalleryID[1] + '_' + NextImageIdHide)) {
        document.getElementById('NextImageImg').style.visibility = 'hidden';
    }
}

function PrevImage(Id) {
    var GalleryID
    var PrevImage
    var PrevImageId
    var PrevImageIdHide

    GalleryID = Id.split("_");
    PrevImageId = parseInt(GalleryID[2]) - 1;
    PrevImageIdHide = parseInt(GalleryID[2]) - 2;

    PrevImage = GalleryID[0] + '_' + GalleryID[1] + '_' + PrevImageId

    if (document.getElementById(PrevImage)) {
        document.getElementById('CurImage').src = document.getElementById(PrevImage).getAttribute('imagesrc');
        document.getElementById('CurImage').setAttribute('CurId', PrevImage);
        document.getElementById('NextImageImg').style.visibility = 'visible';
    }

    if (!document.getElementById(GalleryID[0] + '_' + GalleryID[1] + '_' + PrevImageIdHide)) {
        document.getElementById('PrevImageImg').style.visibility = 'hidden';
    }
}

var baseopacity = 10

function slowhigh(which2) {
    imgobj = document.getElementById(which2)
    browserdetect = imgobj.filters ? "ie" : typeof imgobj.style.opacity == "string" ? "mozilla" : ""
    slowlow(imgobj)
    instantset(baseopacity)
    highlighting = setInterval("gradualfade(imgobj)", 40)
}

function slowlow(which2) {
    cleartimer()
    instantset(baseopacity)
}

function instantset(degree) {
    if (browserdetect == "mozilla")
        imgobj.style.opacity = degree / 100
    else if (browserdetect == "ie") {
        if (imgobj.filters.alpha) {
            imgobj.filters.alpha.opacity = degree
        }
    }
}

function cleartimer() {
    if (window.highlighting) clearInterval(highlighting)
}

function gradualfade(cur2) {
    if (browserdetect == "mozilla") {
        if (cur2.style.opacity < 1)
            cur2.style.opacity = Math.min(parseFloat(cur2.style.opacity) + 0.1, 0.99)
        else if (window.highlighting)
            clearInterval(highlighting)
    }
    if (browserdetect == "ie") {
        if (cur2.filters.alpha) {
            if (cur2.filters.alpha.opacity < 100)
                cur2.filters.alpha.opacity += 10
        }
    }
}

function copyToClipboard() {
    var vsebina = '';
    vsebina = layout_td_Main.innerText
    window.clipboardData.setData("Text", vsebina);
    alert("Text copied to clipboard!");
}

function PrintME(Value) {
    var skupno = '';
    style = document.getElementsByTagName("style");
    skupno = "<style>" + style[1].innerHTML + "</style>"
    skupno += document.getElementById("div_Content_0").innerHTML;
    document.write(skupno);
    printpr(Value);
}

function printpr(OLECMDID) {
    /* OLECMDID values:
    * 6 - print
    * 7 - print preview
    * 1 - open window
    * 4 - Save As
    */
    var PROMPT = 1; // 2 DONTPROMPTUSER
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
    document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(OLECMDID, PROMPT);
    WebBrowser1.outerHTML = "";
}

function GetClientVariable(Name) {
    return document.getElementById('hdn_var_' + Name)
}

/* Cascade menu */
function calculatePos(id, Level) {
    var Level2
    var i
    i = Level - 2
    Level2 = Level - 1;

    tObj_child = document.getElementById('CascadeLevel' + Level + '_' + id);
    tObj_parent = document.getElementById('CascadeDivLevel' + Level2 + '_' + id);

    tObj_child.style.width = tObj_parent.offsetWidth + 'px';
    tObj_child.style.marginTop = 5;
    if (i == 1) {
        tObj_child.style.marginLeft = tObj_parent.offsetWidth - 5 + 'px';
    }
    else {
        tObj_child.style.marginLeft = tObj_parent.offsetWidth + tObj_parent.style.marginLeft - 5 + 'px';
    }
}

function setOpacity(value, tObj) {
    var element
    element = document.getElementById(tObj);

    if (value == '0') {
        element.style.visibility = 'hidden';
    }
    else {
        element.style.visibility = 'visible';
    }
}
/* Cascade menu */


function PageLoaded() {
    var tbl_Layout
    var LayoutIndex, RegionIndex, RowIndex;

    tbllist = document.getElementsByTagName('TABLE')
    for (i = 0; i < tbllist.length; i++) {
        if (tbllist[i].id.substr(0, 7) == 'tbl_CB_') {
            tbl_CB = tbllist[i]

            ped_Content = document.getElementById('ped_td_Content_' + tbl_CB.id.substr(7));

            if (tbl_CB.parentNode.getAttribute("IsFullHeight") == "1") {
                tbl_CB.style.height = '100%';
            }
            else {
                if (Number(ped_Content.getAttribute('MinHeightContent')) > Number(ped_Content.scrollHeight)) {
                    //kle je problem
                    ped_Content.style.height = Number(ped_Content.getAttribute('MinHeightContent')) + 'px';
                }
                else {
                    ped_Content.style.height = 'auto';
                }
            }
        }
    }


    for (LayoutIndex = 0; LayoutIndex < document.getElementById("form_Page").childNodes.length; LayoutIndex++) {
        tbl_Layout = document.getElementById("form_Page").childNodes[LayoutIndex]
        if (tbl_Layout.nodeType == 1 && tbl_Layout.id.substr(0, 11) == "layout_tbl_") {
            for (RowIndex = 0; RowIndex < tbl_Layout.rows.length; RowIndex++) {
                for (RegionIndex = 0; RegionIndex < tbl_Layout.rows[RowIndex].cells.length; RegionIndex++) {
                    // Popravimo višine regij.
                    SetRegionHeight(tbl_Layout.rows[RowIndex].cells[RegionIndex])

                    // Popravimo odmike elementov.
                    RegionResized(tbl_Layout.rows[RowIndex].cells[RegionIndex])
                }
            }
        }
    }

    ChangeOverflow()
}

function ChangeOverflow() {
    // Spremeni overflow regij da se lahko prekrivajo
    var divs = document.getElementsByTagName("div");
    for (var i = 0; i < divs.length; i++)
        if (divs[i].id.indexOf("HiddenOverflow") == 0) {
        divs[i].style.overflow = "visible";

        //Opera problem
        if (navigator.userAgent.substring(0, 5) == 'Opera') {
            divs[i].style.height = divs[i].parentNode.offsetHeight + 'px';
        }
        else {
            divs[i].style.height = divs[i].parentNode.offsetHeight + 'px';
        }

        // Ie fix
        if (navigator.appName == 'Microsoft Internet Explorer') {
            divs[i].style.position = "static";

            for (var j = 0; j < divs[i].childNodes.length; j++) {
                if (divs[i].childNodes[j].getAttribute("IsFullHeight") == "1") {
                    divs[i].style.position = "relative";
                }
            }
        }
    }
}

function RegionResized(td_Region) {
    var ElmIndex, div_Elm
    var ElementWidth, RegionWidth
    var new_Left
    // FFfix je fix za firefox in opero ker se začne childNodes[1] in ne childNodes[0]
    var FFfix

    if (navigator.product == 'Gecko') {
        FFfix = 1
    }
    else {
        FFfix = 0
    }

    if (navigator.userAgent.substring(0, 5) == 'Opera') {
        FFfix = 1
    }


    // Popravimo odmike elementov.
    if (td_Region.childNodes[FFfix] != undefined) {
        for (ElmIndex = FFfix; ElmIndex < td_Region.childNodes[FFfix].childNodes.length; ElmIndex++) {

            div_Elm = td_Region.childNodes[FFfix].childNodes[ElmIndex]

            // če ni div_Elm object type text nadaljujemo (Samo za Firefox in opero)
            if (div_Elm.innerHTML != undefined) {
                if (div_Elm.getAttribute("IsFullWidth") == "0") {
                    if (div_Elm.getAttribute("HAlign") == 2) {			// Center
                        ElementWidth = div_Elm.offsetWidth
                        RegionWidth = td_Region.offsetWidth
                        div_Elm.style.marginLeft = div_Elm.getAttribute("PELeft") - (ElementWidth / 2) + (RegionWidth / 2) + 'px';
                    }
                    else if (div_Elm.getAttribute("HAlign") == 3) {		// Right
                        ElementWidth = div_Elm.offsetWidth
                        RegionWidth = td_Region.offsetWidth
                        div_Elm.style.marginLeft = div_Elm.getAttribute("PELeft") - ElementWidth + RegionWidth + 'px';
                    }
                }
            }
        }
    }
}

function SetRegionHeight(td_Region) {
    var div_Region

    if (navigator.product == 'Gecko') {
        div_Region = td_Region.childNodes[1]
    }
    else {
        div_Region = td_Region.childNodes[0]
    }

    if (navigator.userAgent.substring(0, 5) == 'Opera') {
        div_Region = td_Region.childNodes[1]
    }

    if (div_Region != undefined) {
        if (div_Region.offsetHeight < div_Region.scrollHeight) {
            td_Region.style.height = div_Region.scrollHeight + 'px';
        }
    }
}

function GetElementLeft(elm) {
    var Left = 0

    while (elm != null) {
        Left = Left + elm.offsetLeft
        elm = elm.offsetParent
    }

    return Left
}

function GetElementTop(elm) {
    var Top = 0

    while (elm != null) {
        Top = Top + elm.offsetTop
        elm = elm.offsetParent
    }

    return Top
}

function GetElementWidth(elm) {
    return elm.offsetWidth
}

function GetElementHeight(elm) {
    return elm.offsetHeight
}

// FormatInteger
function FormatInteger(Value, Digits) {
    var i, StrLen
    var sOutput

    sOutput = ""
    StrLen = Value.toString().length
    for (i = 0; i < Digits - StrLen; i++) {
        sOutput += "0"
    }

    return sOutput + Value.toString()
}

// Popravi visino iframe elementa glede na vsebino in regijo v kateri se nahaja.
function FixIframeHeight(oIframe) {
    try {
        var iFrame = document.getElementById('IframeHeightForFix');
        if (iFrame.contentWindow.document.body.scrollHeight) {
            var layoutTable = iFrame.parentNode.ownerDocument.getElementById("layout_tbl_0");
            var divs = layoutTable.getElementsByTagName("div");

            iFrame.height = "1px";

            //popravimo regijo in overflowe
            for (var i = 0; i < divs.length; i++)
                if (divs[i].id.indexOf("HiddenOverflow") == 0) {
                divs[i].style.position = "relative";
                divs[i].style.overflow = "visible";
                divs[i].style.height = '1px';
                divs[i].parentNode.style.height = '1px';
            }

            iFrame.height = parseInt(iFrame.contentWindow.document.body.scrollHeight) + 30 + 'px';
            iFrame.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.overflow = 'auto';

            for (var i = 0; i < divs.length; i++)
                if (divs[i].id.indexOf("HiddenOverflow") == 0) {
                divs[i].style.overflow = "auto";
                divs[i].style.height = 'auto';
                divs[i].parentNode.style.height = 'auto';
            }

            PageLoaded();
        }
    }
    catch (err) {
        //alert(err.description)
    }
}

// TRV
function NAV_TRV_Navigate(tbl_Navigation) {
    var SiteLongCode
    var sURL
    var NavigationID
    var LinkURL

    SiteLongCode = document.getElementById("hdn_var_SiteLanguageCode").value + '/' + document.getElementById("hdn_var_SiteCode").value
    sURL = tbl_Navigation.getAttribute('URL')
    LinkURL = tbl_Navigation.getAttribute('LinkURL')
    // Ce je obstaja Outer link, potem se odpre novo okno, ce ne se odpre v istem
    if (LinkURL != '') {
        window.open(LinkURL, 'OuterLink')
    }
    else {
        document.form_Page.action = sURL
        document.form_Page.target = "_top"
        document.form_Page.submit()
    }
}

function NAV_TRV_NavigationMouseOver(tbl_Navigation) {
    var NormalClass, MouseOverClass

    // Expander
    NormalClass = tbl_Navigation.rows[0].cells[0].className
    MouseOverClass = tbl_Navigation.rows[0].cells[0].getAttribute('MOClass')
    tbl_Navigation.rows[0].cells[0].className = NormalClass + ' ' + MouseOverClass
    tbl_Navigation.rows[0].cells[0].setAttribute('NormalClass', NormalClass)

    // Text
    NormalClass = tbl_Navigation.rows[0].cells[1].className
    MouseOverClass = tbl_Navigation.rows[0].cells[1].getAttribute('MOClass')
    tbl_Navigation.rows[0].cells[1].className = NormalClass + ' ' + MouseOverClass
    tbl_Navigation.rows[0].cells[1].setAttribute('NormalClass', NormalClass)
}

function NAV_TRV_NavigationMouseOut(tbl_Navigation) {
    var NormalClass, MouseOverClass

    // Expander
    NormalClass = tbl_Navigation.rows[0].cells[0].getAttribute('NormalClass')
    tbl_Navigation.rows[0].cells[0].className = NormalClass

    // Text
    NormalClass = tbl_Navigation.rows[0].cells[1].getAttribute('NormalClass')
    tbl_Navigation.rows[0].cells[1].className = NormalClass
}


// HRZ
function NAV_HRZ_NavigationMouseOver(tbl_Navigation) {
    var NormalClass, MouseOverClass

    // LeftCell
    NormalClass = tbl_Navigation.rows[0].cells[0].className
    MouseOverClass = tbl_Navigation.rows[0].cells[0].getAttribute('MOClass')
    tbl_Navigation.rows[0].cells[0].className = NormalClass + ' ' + MouseOverClass
    tbl_Navigation.rows[0].cells[0].setAttribute('NormalClass', NormalClass)

    // Text
    NormalClass = tbl_Navigation.rows[0].cells[1].className
    MouseOverClass = tbl_Navigation.rows[0].cells[1].getAttribute('MOClass')
    tbl_Navigation.rows[0].cells[1].className = NormalClass + ' ' + MouseOverClass
    tbl_Navigation.rows[0].cells[1].setAttribute('NormalClass', NormalClass)

    // RightCell
    NormalClass = tbl_Navigation.rows[0].cells[2].className
    MouseOverClass = tbl_Navigation.rows[0].cells[2].getAttribute('MOClass')
    tbl_Navigation.rows[0].cells[2].className = NormalClass + ' ' + MouseOverClass
    tbl_Navigation.rows[0].cells[2].setAttribute('NormalClass', NormalClass)
}

function NAV_HRZ_NavigationMouseOut(tbl_Navigation) {
    var NormalClass, MouseOverClass

    // LeftCell
    NormalClass = tbl_Navigation.rows[0].cells[0].getAttribute('NormalClass')
    tbl_Navigation.rows[0].cells[0].className = NormalClass

    // Text
    NormalClass = tbl_Navigation.rows[0].cells[1].getAttribute('NormalClass')
    tbl_Navigation.rows[0].cells[1].className = NormalClass

    // RightCell
    NormalClass = tbl_Navigation.rows[0].cells[2].getAttribute('NormalClass')
    tbl_Navigation.rows[0].cells[2].className = NormalClass
}


// VRT
function NAV_VRT_Navigate(evt) {
    var SiteLongCode
    var CodePath
    var NavigationID

    // Kompatibilnost z 'Mozillo'.
    if (window.event) evt = window.event

    // Kompatibilnost z 'Mozillo'.
    if (evt.srcElement)
        elm = evt.srcElement
    else
        elm = evt.target

    // NavigationID
    NavigationID = elm.id.substr(elm.id.length - 8, 8)
    // SiteName
    //SiteName = 'PortalGenerator/slo/produkti'
    SiteLongCode = document.getElementById("hdn_var_SiteLanguageCode").value + '/' + document.getElementById("hdn_var_SiteCode").value
    // CodePath
    CodePath = elm.getAttribute('CodePath')
    document.form_Page.action = '/PortalGenerator/' + SiteLongCode + '/' + CodePath + NavigationID + '.aspx'
    //document.form_Page.action = "Main.aspx?NAV=" + NavigationID	???????????? STARO ????????????????????
    document.form_Page.submit()
}

function NAV_ShowNextLevel(evt) {
    var elm
    var tbl_NextLevel
    var tbl, row, sNodeID
    var sCtrlIndex

    // Kompatibilnost z 'Mozillo'.
    if (window.event) evt = window.event

    // Kompatibilnost z 'Mozillo'.
    if (evt.srcElement)
        elm = evt.srcElement
    else
        elm = evt.target

    // Samo 'nav_XXX_td_'.
    if (!(elm.id.substr(0, 4) == "nav_" && elm.id.substr(8, 3) == "td_")) return 0
    sCtrlIndex = elm.id.substr(4, 3)

    // Zapremo vse druge.
    tbl = elm.parentNode.parentNode.parentNode.parentNode.parentNode		// TD/TR/TBODY/TABLE
    for (i = 0; i < tbl.rows.length; i++) {
        row = tbl.rows[i]
        sNodeID = row.cells[0].childNodes[0].childNodes[1].id.substr(row.cells[0].childNodes[0].childNodes[1].id.length - 8, 8)
        tbl_NextLevel = document.getElementById('nav_' + sCtrlIndex + '_tbl_' + sNodeID)
        if (!(tbl_NextLevel == null)) {
            tbl_NextLevel.setAttribute('IsClosing', '1')
            setTimeout('NAV_CloseChildNodesTablesRecursively(document.getElementById("' + tbl_NextLevel.id + '"))', 50)
        }
    }

    NAV_CancelParentTableClosing(tbl)

    // Vklopimo 'MouseOver' efekt.
    tbl_NextLevel = document.getElementById("nav_" + sCtrlIndex + "_tbl_" + elm.id.substr(elm.id.length - 8, 8))
    if (tbl_NextLevel == null) return 0
    tbl_NextLevel.setAttribute('IsClosing', 0)

    // Kompatibilnost z 'Mozillo'.
    if (elm.getClientRects) {
        tbl_NextLevel.style.left = elm.getClientRects()[0].right + document.body.scrollLeft
        tbl_NextLevel.style.top = elm.getClientRects()[0].top + document.body.scrollTop
    }
    else {
        tbl_NextLevel.style.left = GetElementLeft(elm) + GetElementWidth(elm)
        tbl_NextLevel.style.top = GetElementTop(elm)
    }
    tbl_NextLevel.style.visibility = "visible"
    tbl_NextLevel.setActive
}

function NAV_CancelParentTableClosing(tbl) {
    var td_Parent

    sCtrlIndex = tbl.id.substr(4, 3)

    while (tbl.id.substr(0, 4) == 'nav_') {
        tbl.setAttribute('IsClosing', '0')
        td_Parent = document.getElementById('nav_' + sCtrlIndex + '_td_' + tbl.id.substr(tbl.id.length - 8, 8))
        if (!td_Parent) return 0
        tbl = td_Parent.parentNode.parentNode.parentNode.parentNode.parentNode
    }
}

function NAV_CloseChildNodesTablesRecursively(tbl) {
    var tbl_NextLevel
    var sCtrlIndex
    var i, row

    // Preverimo atribut 'IsClosing'. Korenska tabela tega parametra nima.
    if (!(tbl.getAttribute("IsClosing") == null)) {
        if (tbl.getAttribute("IsClosing") == '0') return 0
    }

    sCtrlIndex = tbl.id.substr(4, 3)

    tbl.setAttribute('IsClosing', 1)
    tbl.style.visibility = 'hidden'

    for (i = 0; i < tbl.rows.length; i++) {
        row = tbl.rows[i]
        sNodeID = row.cells[0].childNodes[0].childNodes[1].id.substr(row.cells[0].childNodes[0].childNodes[1].id.length - 8, 8)
        tbl_NextLevel = document.getElementById('nav_' + sCtrlIndex + '_tbl_' + sNodeID)
        if (!(tbl_NextLevel == null)) {
            tbl_NextLevel.setAttribute('IsClosing', 1)
            NAV_CloseChildNodesTablesRecursively(tbl_NextLevel)
        }
    }

    tbl.setAttribute('IsClosing', '0')
}

function NAV_MouseOut(evt) {
    var elm
    var tbl, tbl_NextLevel, row, sNode

    // Kompatibilnost z 'Mozillo'.
    if (window.event) evt = window.event

    // Kompatibilnost z 'Mozillo'.
    if (evt.srcElement)
        elm = evt.srcElement
    else
        elm = evt.target

    // Samo 'nav_XXX_td_'.
    if (!(elm.id.substr(0, 4) == 'nav_' && elm.id.substr(8, 3) == 'td_')) return 0

    //		elm.parentNode.childNodes[0].runtimeStyle.cssText = ''

    sCtrlIndex = elm.id.substr(4, 3)

    // Zapremo vse druge.
    tbl = document.getElementById('nav_' + sCtrlIndex + '_tbl_00000000') //elm.parentNode.parentNode.parentNode.parentNode.parentNode
    for (i = 0; i < tbl.rows.length; i++) {
        row = tbl.rows[i]
        sNodeID = row.cells[0].childNodes[0].childNodes[1].id.substr(row.cells[0].childNodes[0].childNodes[1].id.length - 8, 8)
        tbl_NextLevel = document.getElementById('nav_' + sCtrlIndex + '_tbl_' + sNodeID)
        if (!(tbl_NextLevel == null)) {
            tbl_NextLevel.setAttribute('IsClosing', '1')
            setTimeout('NAV_CloseChildNodesTablesRecursively(document.getElementById("' + tbl_NextLevel.id + '"))', 1000)
        }
    }
}


function NAV_AddChildNodesTable(CtrlIndex, NodeID, Width, NavigationHeight, SelectorWidth, ExpanderWidth,
							    SelectorImageSrc, TextImageSrc, ExpanderImageSrc,
							    SelectorMOImageSrc, TextMOImageSrc, ExpanderMOImageSrc, TextStyle, TextMOStyle) {
    var tbl
    var sHTML
    var CtrlID

    CtrlID = 'nav_' + FormatInteger(CtrlIndex, 3) + '_tbl_' + FormatInteger(NodeID, 8)
    tbl = document.createElement('TABLE')
    tbl.id = CtrlID
    tbl.cellSpacing = 0
    tbl.cellPadding = 0
    tbl.style.position = 'absolute'
    tbl.style.visibility = 'hidden'
    tbl.style.width = Width
    tbl.style.tableLayout = 'fixed'
    tbl.zIndex = 40
    // Custom Attributes.
    tbl.setAttribute('IsClosing', '0')
    tbl.setAttribute('NavigationHeight', NavigationHeight)
    tbl.setAttribute('SelectorWidth', SelectorWidth)
    tbl.setAttribute('ExpanderWidth', ExpanderWidth)
    tbl.setAttribute('SelectorImageSrc', SelectorImageSrc)
    tbl.setAttribute('TextImageSrc', TextImageSrc)
    tbl.setAttribute('ExpanderImageSrc', ExpanderImageSrc)
    tbl.setAttribute('SelectorMOImageSrc', SelectorMOImageSrc)
    tbl.setAttribute('TextMOImageSrc', TextMOImageSrc)
    tbl.setAttribute('ExpanderMOImageSrc', ExpanderMOImageSrc)
    tbl.setAttribute('TextStyle', TextStyle)
    tbl.setAttribute('TextMOStyle', TextMOStyle)

    document.getElementById('div_TopContainer').insertBefore(tbl, null)

    return tbl
}

function NAV_AddChildNodeCell(CtrlIndex, ParentID, NodeID, CodePath, Text, ChildNodesCount) {
    var tbl, tr, td
    var sCtrlIndex
    var tbl_Nav, tr_Nav, td_Nav
    var div_Navi, div_Cover
    var NavigationHeight
    var SelectorImageSrc, TextImageSrc, ExpanderImageSrc, SelectorMOImageSrc, TextMOImageSrc, ExpanderMOImageSrc
    var TextStyle, TextMOStyle

    sCtrlIndex = FormatInteger(CtrlIndex, 3)
    tbl = document.getElementById('nav_' + FormatInteger(CtrlIndex, 3) + '_tbl_' + FormatInteger(ParentID, 8))

    // Preberemo atribute iz pripadajoce tabele.
    NavigationHeight = tbl.getAttribute('NavigationHeight')
    SelectorImageSrc = tbl.getAttribute('SelectorImageSrc')
    TextImageSrc = tbl.getAttribute('TextImageSrc')
    ExpanderImageSrc = tbl.getAttribute('ExpanderImageSrc')
    TextStyle = tbl.getAttribute('TextStyle')
    TextMOStyle = tbl.getAttribute('TextMOStyle')

    tr = tbl.insertRow(tbl.rows.length)
    tr.style.height = NavigationHeight
    tr.id = 'nav_' + FormatInteger(CtrlIndex, 3) + '_tr_' + FormatInteger(NodeID, 8)

    td = tr.insertCell(tr.cells.length)
    td.style.position = 'relative'

    // V vsako celico damo še <DIV> element z relativnim pozicioniranjem (zaradi kompatibilnosti z Mozillo).
    div_Navi = document.createElement('DIV')
    td.appendChild(div_Navi)
    div_Navi.style.position = 'relative'
    div_Navi.style.overflow = 'hidden'
    div_Navi.style.width = '100%'
    div_Navi.style.height = td.offsetHeight //'100%' (na NN ne dela!)

    // Celice
    tbl_Nav = document.createElement('TABLE')
    div_Navi.appendChild(tbl_Nav)				// Dodamo tabelo v vrstico 'td'.
    //tbl_Nav.style.position = 'absolute'
    tbl_Nav.border = 0
    tbl_Nav.cellSpacing = 0
    tbl_Nav.cellPadding = 0
    tbl_Nav.style.left = 0
    tbl_Nav.style.top = 0
    tbl_Nav.width = '100%'
    tbl_Nav.height = '100%'
    // Style


    tr_Nav = tbl_Nav.insertRow(tbl_Nav.rows.length)
    // Selector
    if (SelectorImageSrc != '') {
        td_Nav = tr_Nav.insertCell(tr_Nav.cells.length)
        td_Nav.style.width = '1'
        td_Nav.style.verticalAlign = 'top'
        td_Nav.innerHTML = '<img src="' + SelectorImageSrc + '">'
    }

    // Text
    td_Nav = tr_Nav.insertCell(tr_Nav.cells.length)
    td_Nav.style.cssText = TextStyle
    if (TextImageSrc != '') td_Nav.style.background = 'url("' + TextImageSrc + '")'
    td_Nav.innerHTML = Text

    // Expander
    if (ExpanderImageSrc != '' && ChildNodesCount > 0) {
        td_Nav = tr_Nav.insertCell(tr_Nav.cells.length)
        td_Nav.style.width = '1'
        td_Nav.style.verticalAlign = 'top'
        td_Nav.innerHTML = '<img src="' + ExpanderImageSrc + '">'
    }

    // Šipa
    div_Cover = document.createElement('DIV')
    div_Navi.appendChild(div_Cover)
    div_Cover.id = 'nav_' + FormatInteger(CtrlIndex, 3) + '_td_' + FormatInteger(NodeID, 8)
    div_Cover.style.position = 'absolute'
    div_Cover.style.overflow = 'hidden'
    div_Cover.style.left = 0
    div_Cover.style.top = 0
    div_Cover.style.width = '100%'
    div_Cover.style.height = NavigationHeight
    div_Cover.style.background = 'url("javascript:void(0);")'
    div_Cover.onmouseover = NAV_ShowNextLevel
    div_Cover.onmouseout = NAV_MouseOut
    div_Cover.onclick = NAV_VRT_Navigate
    // Temu 'DIV' objektu nastavimo atribut 'CodePath', ki je potreben za navigacijski 'URL'.
    div_Cover.setAttribute('CodePath', CodePath)

    return td
}



//FrontEnd FCKeditor
function EditContent(id, index, ElementId) {
    var div = document.getElementById(id);
    var childID = "EditElementId_" + index
    var elementID = "pe_div_" + ElementId

    //odstranimo Edit href
    div.removeChild(document.getElementById(childID));

    //zapomnimo id in vsebino
    document.getElementById("hdn_var_EditPageElementID").value = ElementId;
    document.getElementById("hdn_var_EditPageElementContent").value = div.innerHTML;

    var fck = new FCKeditor("FCKeditor");
    fck.Height = "600px";
    fck.Width = "100%";
    document.getElementById(elementID).style.zIndex = '999';
    div.innerHTML = fck.CreateHtml();

    // ie 6.0 fix
    if (navigator.appVersion.indexOf("4.0 (compatible; MSIE 6.0") == 0) alert("Loaded...");
}


//onComplete load
function FCKeditor_OnComplete(editorInstance) {
    editorInstance.LinkedField.form.onsubmit = doSave;
    editorInstance.LinkedField.form.action = top.location;
    //editorInstance.Commands.GetCommand('FitWindow').Execute();

    oXgetHTML(editorInstance);
    editorInstance.Events.AttachEvent('OnAfterSetHTML', SetCssStyles);
}


// From hdn_var_EditPageElementContent to FckEditor
function oXgetHTML(editorInstance) {
    document.getElementById("hdn_var_EditPageElementContentOld").value = document.getElementById("hdn_var_EditPageElementContent").value;
    editorInstance.SetHTML(document.getElementById("hdn_var_EditPageElementContent").value);
}


function SetCssStyles() {
    var oEditor = FCKeditorAPI.GetInstance('FCKeditor');

    if (oEditor.EditorDocument) {
        var oElement = oEditor.EditorDocument.getElementsByTagName('head')[0];
        var oStyle = oEditor.EditorDocument.createElement("style");

        oStyle.setAttribute("type", "text/css");

        if (oStyle.styleSheet) {
            //  Ie 7 kkuracc čist nč ne dela po standardu
            oStyle.styleSheet.cssText = document.getElementById("Page_Style").styleSheet.cssText + " .EditorBody {background-color:white;}";
            oElement.appendChild(oStyle);
        }
        else {
            //Firefox
            oStyle.innerHTML = document.getElementById("Page_Style").innerHTML;
            oElement.appendChild(oStyle);
        }
    }
}

// called on save
function doSave() {
    var oEditor = FCKeditorAPI.GetInstance('FCKeditor');
    document.getElementById("hdn_var_EditPageElementContent").value = oEditor.GetHTML();
}

// Za iframe popup ki gre lahko žez celotno vsebino   
function makeFrame(x, y, width, height, src) {


    if (document.getElementById('IdCheck')) {
        removeElement();
        return;

    }
    ifrm = document.createElement("IFRAME");

    ifrm.setAttribute("frameBorder", "0");
    ifrm.setAttribute("id", "IdCheck");
    ifrm.setAttribute("position", "absolute");
    ifrm.setAttribute("width", width + "px");
    ifrm.setAttribute("height", height + "px");
    ifrm.setAttribute("z-index", "1000");
    ifrm.setAttribute("src", src);

    var div = document.getElementById('autosuggest');
    div.style.left = x + "px";
    div.style.top = y + "px";
    div.setAttribute("width", width + "px");
    div.setAttribute("height", height + "px");

    div.appendChild(ifrm);


}

function removeElement() {
    var d = document.getElementById('IdCheck');
    d.parentNode.removeChild(d);
}