﻿// if(document.all&&!document.getElementById)
//    document.getElementById = function(id){return this.all[id]}
    
function changeCheckBoxState(controlID, state){var checkBox = document.getElementById(controlID);checkBox.checked = state;}

// Popup window functions
function showPopupWindow(url, windowName){var oWnd = window.radopen(url, windowName);}
function showPopupWindowOnParent(url, windowName){var oWnd = window.parent.radopen(url, windowName);}

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0
    
function resizeIframe(frameid)
{
    var currentfr = document.getElementById(frameid);
    
    if (currentfr && !window.opera)
    {
        currentfr.style.display = "block";
        
        if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
           currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
        else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
           currentfr.height = currentfr.Document.body.scrollHeight;
        
        if(currentfr.addEventListener)
           currentfr.addEventListener("load", readjustIframe, False)
        else if (currentfr.attachEvent)
        {
           currentfr.detachEvent("onload", readjustIframe) // Bug fix line
           currentfr.attachEvent("onload", readjustIframe)
        }
    }

}

function readjustIframe(loadevt)
{
    var crossevt=(window.event)? event : loadevt
    var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
    
    if(iframeroot)
        resizeIframe(iframeroot.id);
}

function EnlargePicture(pictureId)
{
    if(pictureId != null)
    {
        var url = '\ViewImage.aspx?ID=' + pictureId;
        window.open(url, null, 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=600,left = 240,top = 212');
    }
}

function textboxMultilineMaxNumber(txt,maxLen)
{
    try
    {
        if(txt.value.length > (maxLen -1))
        {
            return false;
        }
    }
    catch(e)
    {
    }
}

function noHtmlCharacters(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    // Check for bracket char codes
    if ((charCode == 60) || (charCode == 62)) {
        return false;
    }
    return true;
}
