﻿var checkBrowser = document.appendChild
&& navigator.userAgent.toLowerCase().indexOf("opera") == -1
&& navigator.userAgent.toLowerCase().indexOf("netscape") == -1
&& navigator.userAgent.toLowerCase().indexOf("msie") == -1
&& navigator.userAgent.toLowerCase().indexOf("chrome") == -1
&& navigator.userAgent.toLowerCase().indexOf("firefox") == -1
&& navigator.userAgent.toLowerCase().indexOf("omniweb") == -1
&& navigator.userAgent.toLowerCase().indexOf("apple") == -1
&& navigator.userAgent.toLowerCase().indexOf("msie") == -1
&& navigator.userAgent.toLowerCase().indexOf("icab") == -1
&& navigator.userAgent.toLowerCase().indexOf("kde") == -1
&& navigator.userAgent.toLowerCase().indexOf("camino") == -1
&& navigator.userAgent.toLowerCase().indexOf("gecko") == -1;

function SetElementDisplay(cont_ID, Display, cont_ID2, Display2) {
    if (Display == "true") {
        document.getElementById(cont_ID).style.display = "block";
    }
    else {
        document.getElementById(cont_ID).style.display = "none";
    }
    if (Display2 == "true") {
        document.getElementById(cont_ID2).style.display = "block";
    }
    else {
        document.getElementById(cont_ID2).style.display = "none";
    }
}

function OpenNewWindow(p_url) {
    window.open(p_url, '', config = 'toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no')
    return false;
}

function OpenFullScreenWindow(p_url) {
    window.open(p_url, '', config = 'toolbar=no, menubar=no, fullscreen=yes, scrollbars=yes, resizable=yes, location=no, directories=no, status=no')
    return false;
}

function OpenSizeWindow(p_url, Width, Height) {
    window.open(p_url, '', config = 'toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no, width=' + Width + ', height=' + Height)
    return false;
}

function ShowPopUp(p_url) {
    javascript: window.open(p_url);
}

function ValidateAttachment(oSrc, args) {
    args.IsValid = (oSrc.length > 0);
}

function CategoriesCheck(CategoriesSearchCheckBox1, CategoriesSearchCheckBox2, CategoriesSearchTR) {
    document.getElementById(CategoriesSearchCheckBox2).checked = document.getElementById(CategoriesSearchCheckBox1).checked;
    if (document.getElementById(CategoriesSearchCheckBox1).checked == true) {
        document.getElementById(CategoriesSearchTR).className = 'acr_sel';
    }
    else {
        document.getElementById(CategoriesSearchTR).className = 'acr_off';
    }
}

function CSTRMouseOver(CategoriesSearchTR) {
    if (document.getElementById(CategoriesSearchTR).className != 'acr_sel') {
        document.getElementById(CategoriesSearchTR).className = 'acr_on';
    }
}

function CSTRMouseOut(CategoriesSearchTR) {
    if (document.getElementById(CategoriesSearchTR).className != 'acr_sel') {
        document.getElementById(CategoriesSearchTR).className = 'acr_off';
    }
}

function toggle(id) {
    if (document.getElementById) {
        var el = document.getElementById(id);
        el.style.display = (el.style.display == 'none') ? 'block' : 'none';
        var lnk_el = document.getElementById('lnk_' + id);
        lnk_el.className = (lnk_el.className == 'toggle_title') ? 'tt_alt' : 'toggle_title';
    }
}

function ShowElement(con_id) {
    if (document.getElementById(con_id)) {
        if (document.getElementById(con_id).style.display == 'block' || document.getElementById(con_id).style.display == '') {
            document.getElementById(con_id).style.display = 'none';
        }
        else {
            document.getElementById(con_id).style.display = 'block';
        }
    }
}

function HideElement(con_id) {
    if (document.getElementById(con_id)) {
        document.getElementById(con_id).style.display = 'none';
    }
}

function RedirectPage(url) {
    document.location.href = url;
}

function PopUpOn(con_id) {
    if (document.getElementById(con_id)) {
        document.getElementById(con_id).style.display = 'block';
        document.getElementById(con_id).style.visibility = 'visible';
    }
}

function PopUpOff(con_id) {
    if (document.getElementById(con_id)) {
        document.getElementById(con_id).style.display = 'none';
        document.getElementById(con_id).style.visibility = 'hidden';
    }
}

function PopUpOnMouseOut(element, event, con_id) {
    var current_mouse_target = null;
    if (event.toElement) {
        current_mouse_target = event.toElement;
    } else if (event.relatedTarget) {
        current_mouse_target = event.relatedTarget;
    }
    if (!Ischild(element, current_mouse_target) && element != current_mouse_target) {
        fadeOut(con_id);
    }
}

function Ischild(parent, child) {
    if (child != null) {
        while (child.parentNode) {
            if ((child = child.parentNode) == parent) {
                return true;
            }
        }
    }
    return false;
}

function fadeOut(con_id) {
    if (document.getElementById(con_id)) {
        oDiv = document.getElementById(con_id);
        oDiv.style.filter = "blendTrans(duration=1)";
        if (oDiv.filters != null) {
            // Make sure the filter is not playing.
            if (oDiv.filters.blendTrans.status != 1) {
                oDiv.filters.blendTrans.apply();
                oDiv.style.visibility = 'hidden';
                oDiv.filters.blendTrans.play();
            }
        }
        else {
            setTimeout("ElementVisibilityHidden('" + con_id + "')", 500);
        }
    }
}

function ElementVisibilityHidden(con_id) {
    if (document.getElementById(con_id)) {
        document.getElementById(con_id).style.visibility = 'hidden';
    }
}

function ChechMaxLength(txtbox, MaxLength) {
    if (txtbox.value.length > MaxLength) {
        txtbox.value = txtbox.value.substring(0, MaxLength);
    }
}

function PosljiPosto(StringWEB) {
    eval(unescape(StringWEB));
}

function resizeMe(obj) {
    obj.style.height = (obj.contentWindow.document.body.scrollHeight - 1) + "px";
}

function pageLoad(sender, args) {
    if (args.get_isPartialLoad()) {
        if (typeof (fb) != "undefined") {
            if (fb != null) {
                fb.anchors.length = 0;
                fdiv = document.getElementById('FLOATBOXDIV');
                if (fdiv != null) {
                    fb.tagAnchors(fdiv);
                }
            }
        }
    }
}

function RedirectParentURL(ic_href) {
    if (window.parent)
    { window.parent.location.href = ic_href; }
    else
    { window.location.href = ic_href; }
}

function RedirectURL(ic_href) {
    window.location.href = ic_href;}

function ReloadParentURL() {
    if (window.parent)
    { window.parent.location.reload(); }
    else
    { window.location.reload(); }
}

function ResizeFloatBox(w, h) {
    if (window.parent && window.parent.fb)
    { window.parent.fb.resize(w, h); }
}

function HideWT(wtdiv, contr) {
    if (document.getElementById(contr + '_WTM')) {
        document.getElementById(contr + '_WTM').style.display = 'none';
    }
    if (document.getElementById(contr + '_WTT')) {
        document.getElementById(contr + '_WTT').style.display = 'none';
    }
    if (document.getElementById(contr + '_WTW')) {
        document.getElementById(contr + '_WTW').style.display = 'none';
    }
    if (document.getElementById(contr + '_WTTH')) {
        document.getElementById(contr + '_WTTH').style.display = 'none';
    }
    if (document.getElementById(contr + '_WTF')) {
        document.getElementById(contr + '_WTF').style.display = 'none';
    }
    if (document.getElementById(contr + '_WTSA')) {
        document.getElementById(contr + '_WTSA').style.display = 'none';
    }
    if (document.getElementById(contr + '_WTSU')) {
        document.getElementById(contr + '_WTSU').style.display = 'none';
    }
    if (document.getElementById(contr + '_' + wtdiv)) {
        document.getElementById(contr + '_' + wtdiv).style.display = 'block';
    }
}

function setHomepage(_url) {
    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage(_url);
    }
}