﻿function GetFrame() {
    return lsFrame;
}

function SetElementText(elemId, txtValue) {
    var oElem = document.getElementById(elemId);
    if (oElem.firstChild) {
        oElem.firstChild.nodeValue = txtValue;
    }
    else {
        oElem.appendChild(document.createTextNode(txtValue));
    }
}

function SetElementHTML(elemId, htmlValue) {
    var oElem = document.getElementById(elemId);
    oElem.innerHTML = htmlValue;
}

function SetFocus(vsFieldId) {
    var oField = document.getElementById(vsFieldId);
    var iCaretPos = oField.value.length;

    // IE Support
    if (document.selection) {

        // Set focus on the element
        oField.focus();

        // Create empty selection range
        var oSel = document.selection.createRange();

        // Move selection start and end to 0 position
        oSel.moveStart('character', -oField.value.length);

        // Move selection start and end to desired position
        oSel.moveStart('character', iCaretPos);
        oSel.moveEnd('character', 0);
        oSel.select();
    }

    // Firefox support
    else if (oField.selectionStart || oField.selectionStart == '0') {
        oField.selectionStart = iCaretPos;
        oField.selectionEnd = iCaretPos;
        oField.focus();
    }
}

function TZCorrection(vsDate, viTZ) {
    var dtz = new Date();
    var tz = (dtz.getTimezoneOffset() / 60) + viTZ;
    var dt = new Date(vsDate);
    dt.setHours(dt.getHours() + tz);
    return dt;
}

