﻿function getNavigatorAgent(){
    return navigator.userAgent;
}

function is_ie(){
    var agent = getNavigatorAgent();
    var msieShift = agent.indexOf("MSIE");
    var msie = agent.indexOf("msie");
    return (( msieShift != -1 ) || ( msie != -1));
}

function is_ie8() {
    var agent = getNavigatorAgent();
    var msieShift = agent.indexOf("MSIE 8.0");
    var msie = agent.indexOf("msie 8.0");
    return ((msieShift != -1) || (msie != -1));
}

function is_mozilla(){
    var agent = getNavigatorAgent();
    return (agent.indexOf("Mozilla") != -1);
}

function showtable(controlId)
    {
        var tabla = document.getElementById("tblContent_"+controlId);
        if( tabla ){
            tabla.style.display = "";
            var toolTipImage = document.getElementById("tooltip_image_"+controlId);
            var toolTipSpan = document.getElementById("tooltip_span_"+controlId);
            if(is_ie()){
                if(toolTipImage){
                    toolTipImage.style.display = "none";
                }
            }
            else{
                if(toolTipSpan){
                    toolTipSpan.style.display = "none";
                }
            }
        }
    }
function FCKUpdateLinkedField(id)
{
    try
    {
        if(typeof(FCKeditorAPI) == "object")
        {
            FCKeditorAPI.GetInstance(id).UpdateLinkedField();
        }
    }
    catch(err)
    {
    }
}
function openSendMessageWindow(root, idReceiver){
    window.open(root + 'users/sendmessage/' + idReceiver, 'sendMail', 'status=Yes,toolbar=No,resizable=Disallow, width=560, height=355, scrollbars=No');
}
function ShowHideElement(divId,hiddenFieldId){
    var div = document.getElementById(divId);
    var hiddenField = document.getElementById(hiddenFieldId);
    
    if(div && hiddenField)
    {
        if (div.style.display == "")
        {
            div.style.display = "none";
            hiddenField.value = "display:none;";
        }
        else
        {
            if (div.style.display == "none")
            {
                div.style.display = "";
                hiddenField.value = "display:";
            }
        }
    }
}
function ShowHideElement(divId) {
    var div = document.getElementById(divId);

    if (div) {
        if (div.style.display == "") {
            div.style.display = "none";
        }
        else {
            if (div.style.display == "none") {
                div.style.display = "";
            }
        }
    }
}
function changeClass(element, className){
    element.className = className;
}
function ValidateDocumentExtension(fileUploadId, notValidExtensions, validatorTextContainerId) {
    var fileupload = document.getElementById(fileUploadId);
    var validatorTextContainer = document.getElementById(validatorTextContainerId);
    if (fileupload && fileupload.value != "") {
        var splitedName = fileupload.value.split(".");
        var extension = splitedName[splitedName.length - 1];
        if (notValidExtensions.indexOf(extension) != -1) {
            Page_IsValid = false;
            validatorTextContainer.style.display = "";
            return false;
        } else {
            validatorTextContainer.style.display = "none";
            return true;
        }
    }
}
function ValidateDocumentExtensionForConversion(fileUploadId, popupId, hidpopupId, validExtensions, okButtonUniqueId, isVirtualRoomEnabled) {
    var fileupload = document.getElementById(fileUploadId);
    var popup = $find(popupId);
    var hidpopup = $find(hidpopupId);
    if (Page_IsValid == true && fileupload && fileupload.value != "") {
        if (isVirtualRoomEnabled == "True") {
            var splitedName = fileupload.value.split(".");
            var extension = splitedName[splitedName.length - 1];
            if (extension && extension != "") {
                if (validExtensions.indexOf(extension) != -1) {
                    __doPostBack(okButtonUniqueId, '')
                    return true;
                } else {
                    if (hidpopup && hidpopup != null) {
                        hidpopup.hide();
                    }
                    if (popup && popup != null) {
                        popup.show();
                    }
                    return false;
                }
            }
        } else {
            __doPostBack(okButtonUniqueId, '')
            return true;
        }
    }
}

Sys.Browser.WebKit = {};
if (navigator.userAgent.indexOf('WebKit/') > -1) {
    Sys.Browser.agent = Sys.Browser.WebKit;
    Sys.Browser.version = parseFloat(navigator.userAgent.match(/WebKit\/(\d+(\.\d+)?)/)[1]);
    Sys.Browser.name = 'WebKit';
}