/* cache backgroundimages in IE */
try {
    document.execCommand("BackgroundImageCache", false, true);
}
catch (err) { }

function OnWidgetDrop(sender, e) {
    var container = e.get_container();
    var item = e.get_droppedItem();
    var position = e.get_position();

    var instanceId = item.getAttribute("InstanceId");
    var columnNo = parseInt(container.getAttribute("columnNo"));
    var row = position;
    if (item.getAttribute("IsTemplate") != null && item.getAttribute("IsTemplate") == "true") {
        var pageId = container.getAttribute("PageId");
        _4screen.CSB.WebServices.WidgetService.AddWidgetInstance(instanceId, pageId, columnNo, row, OnWidgetDropSuccess, OnWidgetDropFail);
    }
    else {
        _4screen.CSB.WebServices.WidgetService.MoveWidgetInstance(instanceId, columnNo, row, OnWidgetDropSuccess, OnWidgetDropFail);
    }
}

function OnWidgetDropSuccess(result) {
    __doPostBack(document.getElementById("ctl00$Cnt$WCUP"), '');
}

function OnWidgetDropFail(error) {
}

function $hide(id) {
    document.getElementById(id).style.display = "none";
}

function dump(arr, level) {
    var dumped_text = "";
    if (!level) level = 0;

    //The padding given at the beginning of the line.
    var level_padding = "";
    for (var j = 0; j < level + 1; j++) level_padding += "    ";

    if (typeof (arr) == 'object') { //Array/Hashes/Objects 
        for (var item in arr) {
            var value = arr[item];

            if (typeof (value) == 'object') { //If it is an array,
                dumped_text += level_padding + "'" + item + "' ...\n";
                dumped_text += dump(value, level + 1);
            } else {
                dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
            }
        }
    } else { //Stings/Chars/Numbers etc.
        dumped_text = "===>" + arr + "<===(" + typeof (arr) + ")";
    }
    return dumped_text;
}

var VideoDiv;
function DisableVideoDiv() {
    if (VideoDiv != undefined) {
        VideoDiv.style.visibility = 'hidden';
        VideoDiv.style.display = 'none';
    }
}
function EnableVideoDiv() {
    if (VideoDiv != 'undefined') {
        VideoDiv.style.visibility = 'visible';
        VideoDiv.style.display = 'inline';
    }
}

function DisableEnterKey(e) {
    var key;
    if (window.event)
        key = window.event.keyCode;
    else
        key = e.which;

    return (key != 13);
}

function RedirectOnClick(url, txtBoxId) {
    if (document.getElementById(txtBoxId).value.length > 0) {
        window.location = url + document.getElementById(txtBoxId).value;
    }
}

function RedirectOnEnterKey(e, url, txtBoxId) {
    if (!e) var e = window.event;
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
    if (parseInt(code) == 13 && document.getElementById(txtBoxId).value.length > 0) {
        window.location = url + document.getElementById(txtBoxId).value;
    }
}

function DoPostbackOnEnterKey(e, postbackId) {
    if (!e) var e = window.event;
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
    if (parseInt(code) == 13) {
        __doPostBack(postbackId, '');
        return false;
    }
}

function DoLoginOnEnterKey(e, postbackId) {
    if (!e) var e = window.event;
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
    if (parseInt(code) == 13) {
        if (document.getElementById('SecXmlToken') != null) {
            RemoveNodeByID('SecXmlToken');
        }
        __doPostBack(postbackId, '');
        return false;
    }
}

function HitTagFilter(e) {
    if (!e) var e = window.event;
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
    if (parseInt(code) == 13) {
        var obj = document.getElementById('txtTag');
        var hrf = document.getElementById('href1');
        window.location.href = hrf.href + '?mtag=' + obj.value;
        return true;
    }
}

function RemoveNodeByID(nodeID) {
    var node = document.getElementById(nodeID);
    if (node != null && node.parentNode != null) {
        node.parentNode.removeChild(node);
    }
}

function DeleteDataObject(url) {
    if (confirm(unescape("Soll dieser Inhalt wirklich gel%F6scht werden?"))) {
        radWinOpen(url, unescape("Inhalt l%F6schen"), 300, 150, false, 'SetTab')
    }

    return false;
}

function SelectTextBox(textboxId) {
    document.getElementById(textboxId).focus();
    document.getElementById(textboxId).select();
}

function SelectAll(checkbox, childName) {
    if (checkbox.checked == true) {
        var i;
        for (i = 0; i < document.forms[0].elements.length; i++)
            if ((document.forms[0].elements[i].type == 'checkbox') && (document.forms[0].elements[i].name.indexOf(childName) > -1))
            document.forms[0].elements[i].checked = true;
    }
    else {
        var i;
        for (i = 0; i < document.forms[0].elements.length; i++)
            if ((document.forms[0].elements[i].type == 'checkbox') && (document.forms[0].elements[i].name.indexOf(childName) > -1))
            document.forms[0].elements[i].checked = false;
    }
}

function SelectElement(newSelectedElementId, currentSelectedElementId) {
    var currentSelectedElement = document.getElementById(currentSelectedElementId);
    if (currentSelectedElement.value.length > 0 && document.getElementById(currentSelectedElement.value) != null)
        document.getElementById(currentSelectedElement.value).className = "CSB_wi_not_selected";

    currentSelectedElement.value = newSelectedElementId;
    document.getElementById(newSelectedElementId).className = "CSB_wi_selected";
}

Array.prototype.contains = function(element) {
    for (var i = 0; i < this.length; i++) {
        if (this[i].toLowerCase() == element.toLowerCase()) {
            return true;
        }
    }
    return false;
};

Array.prototype.remove = function(subject) {
    for (var i = 0; i < this.length; i++) {
        if (this[i].toLowerCase() == subject.toLowerCase())
            this.splice(i, 1);
    }
};

function UpdateTagsTextbox(checkbox, textboxId, tags) {
    var textbox = document.getElementById(textboxId);

    tags = tags.toLowerCase();
    var tagsToAddOrRemove = new Array();
    tagsToAddOrRemove = tags.split(";");
    var currentTags = new Array();
    if (textbox.value.length > 0) {
        currentTags = textbox.value.split(";");
    }

    for (var i = 0; i < tagsToAddOrRemove.length; i++) {
        if (checkbox.checked) {
            checkbox.parentNode.className = "CSB_cb_selected";
            if (!currentTags.contains(tagsToAddOrRemove[i])) {
                currentTags.push(tagsToAddOrRemove[i]);
            }
        }
        else {
            checkbox.parentNode.className = "CSB_cb_unselected";
            if (currentTags.contains(tagsToAddOrRemove[i])) {
                currentTags.remove(tagsToAddOrRemove[i]);
            }
        }
    }

    textbox.value = "";
    currentTags.sort();
    for (var i = 0; i < currentTags.length; i++) {
        textbox.value += currentTags[i];
        if (i < currentTags.length - 1)
            textbox.value += ";";
    }
}

function stopPropagation(e) {
    e.cancelBubble = true;
    if (e.stopPropagation) {
        e.stopPropagation();
    }
}

function setComboboxText(id) {
    var combobox = document.getElementById(id + "_Input");
    combobox.value = "";
    var checkboxIndex = 0;
    do {
        var checkbox = document.getElementById(id + "_i" + checkboxIndex + "_CheckBox");
        checkboxIndex++;
        if (checkbox != null) {
            if (checkbox.checked) {
                combobox.value += checkbox.nextSibling.firstChild.nodeValue + ",";
            }
        }
    } while (checkbox != null)
    combobox.value = combobox.value.replace(/,$/, "");
}

function LayoutChange(currentDropzones, newDropzones) {
    if (newDropzones < currentDropzones)
        alert('Das neue Layout hat weniger Spalten. Die Widgets werden automatisch verschoben.');
}

function ReloadPageWithTheme(theme) {
    var urlParts = window.location.href.split("?");
    if (urlParts.length == 2) {
        var queryStringParts = urlParts[1].split("&");
        var url = urlParts[0];
        var queryString = "";
        for (var i = 0; i < queryStringParts.length; i++) {
            if (queryStringParts[i].indexOf("Theme") != 0) {
                queryString += queryStringParts[i] + "&";
            }
        }
        window.location.href = url + "?" + queryString + "Theme=" + theme.value;
    }
}

function StyleSwitchMode(previewElementID, rbNewID, rbColorID, rbImageID, tbColorID, tbImageID, pnlColorolorID, pnlImagemageID, cbRepeatHID, cbRepeatVID) {
    var previewElement = document.getElementById(previewElementID);
    var rbColor = document.getElementById(rbColorID);
    var rbImage = document.getElementById(rbImageID);
    var tbColor = document.getElementById(tbColorID);
    var tbImage = document.getElementById(tbImageID);
    var pnlColor = document.getElementById(pnlColorolorID);
    var pnlImage = document.getElementById(pnlImagemageID);

    previewElement.style.backgroundImage = "none";
    previewElement.style.backgroundRepeat = "no-repeat";
    previewElement.style.backgroundColor = "transparent";

    if (rbNewID == rbColorID) // Switch to color mode
    {
        pnlColor.style.display = "inline";
        pnlImage.style.display = "none";

        if (tbColor.value.indexOf('#') != -1) {
            try { previewElement.style.backgroundColor = tbColor.value; }
            catch (error) { }
        }
    }
    else // Switch to image mode
    {
        pnlImage.style.display = "inline";
        pnlColor.style.display = "none";

        var imageLarge = tbImage.value.replace(/BG\/S/i, "BG/L");
        previewElement.style.backgroundImage = "url(" + imageLarge + ")";

        StyleSetRepeating(previewElementID, cbRepeatHID, cbRepeatVID);
    }
}

function StyleColorChange(previewElementID, colorBoxID, tbColorID) {
    var previewElement = document.getElementById(previewElementID);
    var colorBox = document.getElementById(colorBoxID);
    var tbColor = document.getElementById(tbColorID);

    try {
        previewElement.style.backgroundColor = tbColor.value;
        colorBox.style.backgroundColor = tbColor.value;
    }
    catch (error) {
        previewElement.style.backgroundColor = "transparent";
        colorBox.style.backgroundColor = "transparent";
        tbColor.value = "Keine Farbe ausgewählt";
    }
}

function StyleSetRepeating(previewElementID, cbRepeatHID, cbRepeatVID) {
    var previewElement = document.getElementById(previewElementID);
    var cbRepeatH = document.getElementById(cbRepeatHID);
    var cbRepeatV = document.getElementById(cbRepeatVID);

    previewElement.style.backgroundRepeat = "no-repeat";
    if (cbRepeatH.checked)
        previewElement.style.backgroundRepeat = "repeat-x";
    if (cbRepeatV.checked)
        previewElement.style.backgroundRepeat = "repeat-y";
    if (cbRepeatH.checked && cbRepeatV.checked)
        previewElement.style.backgroundRepeat = "repeat";
}

function StyleSetFooterHeight(previewElementID, tbFooterHeightID) {
    var previewElement = document.getElementById(previewElementID);
    var tbFooterHeight = document.getElementById(tbFooterHeightID);
    var validChars = "0123456789";
    var isNumber = true;
    var character;

    for (var i = 0; i < tbFooterHeight.value.length && isNumber == true; i++) {
        character = tbFooterHeight.value.charAt(i);
        if (validChars.indexOf(character) == -1) {
            isNumber = false;
        }
    }
    if (isNumber) {
        if (tbFooterHeight.value > 500)
            tbFooterHeight.value = 500;
        previewElement.style.height = tbFooterHeight.value + "px";
    }
}

function ChangeRatingImg(clientId, i) {
    for (var x = 1; x <= i; x++) {
        var img = document.getElementById(clientId + '_RAT' + x);
        img.src = img.getAttribute('nsrc');
    }
}

function RestoreRatingImg(clientId, i) {
    for (var x = 1; x <= i; x++) {
        var img = document.getElementById(clientId + '_RAT' + x);
        img.src = img.getAttribute('ssrc');
    }
}

function OnTextboxFocus(textbox, defaultValue) {
    if (textbox.value == (defaultValue)) {
        textbox.value = "";
    }
}

function AttachEvent(parentObject, eventName, eventHandler) {
    eventName = GetEventName(eventName);
    if (parentObject.addEventListener) {
        parentObject.addEventListener(eventName, eventHandler, false);
    }
    else {
        if (parentObject.attachEvent) {
            parentObject.attachEvent(eventName, eventHandler);
        }
    }
}

function DetachEvent(parentObject, eventName, eventHandler) {
    eventName = GetEventName(eventName);
    if (parentObject.addEventListener) {
        parentObject.removeEventListener(eventName, eventHandler, false);
    }
    else {
        if (parentObject.detachEvent) {
            parentObject.detachEvent(eventName, eventHandler);
        }
    }
}

function GetEventName(eventName) {
    eventName = eventName.toLowerCase();
    if (document.addEventListener) {
        if (0 == eventName.indexOf('on')) {
            return eventName.substr(2);
        }
        else {
            return eventName;
        }
    }
    else {
        if (document.attachEvent && !(0 == eventName.indexOf('on'))) {
            return 'on' + eventName;
        }
        else {
            return eventName;
        }
    }
}

function GetModalOverlayImage() {
    var imageElement = document.createElement('IMG');
    imageElement.src = VRoot + '/Library/Images/transp.gif';
    imageElement.style.position = 'absolute';
    imageElement.style.zIndex = '5000';
    imageElement.className = 'RadWModalImage';
    return imageElement;
}

function SetModalBackgroundSize(imageElement) {
    var _3 = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
    var _4 = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
    var _5;
    if (window.innerWidth) {
        _5 = Math.min(window.innerWidth, document.documentElement.clientWidth);
    }
    else {
        _5 = Math.max(document.body.clientWidth, document.documentElement.clientWidth);
    }
    var _6;
    if (window.innerHeight) {
        _6 = Math.max(window.innerHeight, document.documentElement.clientHeight);
    }
    else {
        if (document.documentElement.clientHeight > 0) {
            _6 = document.documentElement.clientHeight;
        }
        else {
            _6 = document.body.clientHeight;
        }
    }
    imageElement.style.left = _3 + 'px';
    imageElement.style.top = _4 + 'px';
    imageElement.style.width = _5 + 'px';
    imageElement.style.height = _6 + 'px';
    imageElement.style.display = '';
}

var modalBackgroundImage = null;

function SetModalBackground() {
    if (modalBackgroundImage == null) {
        modalBackgroundImage = GetModalOverlayImage();
        AttachEvent(window, 'resize', SetModalBackground);
        AttachEvent(window, 'scroll', SetModalBackground);
    }

    SetModalBackgroundSize(modalBackgroundImage);

    if (null != document.readyState) {
        if ('complete' == document.readyState)
            document.body.appendChild(modalBackgroundImage);
        else
            window.setTimeout(SetModalBackground, 100);
    }
    else {
        document.body.appendChild(modalBackgroundImage);
    }
}

function HideModalBackground() {
    if (modalBackgroundImage != null) {
        modalBackgroundImage.style.display = 'none';
        DetachEvent(window, 'resize', SetModalBackground);
        DetachEvent(window, 'scroll', SetModalBackground);
    }
}

var popupWindowDiv = null;
var popupElementId = null;
var popupWidth = null;
var popupLeft = null;
var popupTop = null;
var popupTitle = null;
var popupContent = null;
var popupIsModal = null;

function SetPopupWindow(elementId, width, left, top, title, content, isModal) {
    popupElementId = elementId;
    popupWidth = width;
    popupLeft = left;
    popupTop = top;
    popupTitle = title;
    popupContent = content;
    popupIsModal = isModal;
    SetPopupWindowReady();
}

function SetPopupWindowReady() {
    popupContent = popupContent.replace(/&lt;/g, "<");
    popupContent = popupContent.replace(/&gt;/g, ">");

    if (popupWindowDiv == null) {
        popupWindowDiv = document.createElement('DIV');
        popupWindowDiv.style.position = 'absolute';
        popupWindowDiv.style.zIndex = '10000';
        popupWindowDiv.style.top = popupTop + 'px';
        var innerWidth;
        if (window.innerWidth)
            innerWidth = Math.min(window.innerWidth, document.documentElement.clientWidth);
        else
            innerWidth = Math.max(document.body.clientWidth, document.documentElement.clientWidth);
        if (popupLeft == null || popupLeft == 0)
            popupWindowDiv.style.left = (innerWidth / 2 - popupWidth / 2) + 'px';
        else
            popupWindowDiv.style.left = popupLeft + 'px';
    }

    popupWindowDiv.style.display = '';
    popupWindowDiv.innerHTML = "<div style='position:absolute; z-index:10000;' unselectable='on' class='RadToolTip_Custom rtVisibleCallout' id='" + popupElementId + "'><table class='rtWrapper' width='" + popupWidth + "'><tbody><tr><td class='rtWrapperTopLeft'>&nbsp;</td><td class='rtWrapperTopCenter'><div class='rtTitlebar'>" + popupTitle + "</div><a title='Schliessen' class='CloseButton' onClick=\"HidePopupWindow('" + popupElementId + "')\" href='javascript:void(0);'><span>Close</span></a></td></td><td class='rtWrapperTopRight'>&nbsp;</td></tr><tr><td class='rtWrapperLeftMiddle'>&nbsp;</td><td class='rtWrapperContent' valign='top'><div>" + popupContent + "</div></td><td class='rtWrapperRightMiddle'>&nbsp;</td></tr><tr><td class='rtWrapperBottomLeft'>&nbsp;</td><td class='rtWrapperBottomCenter'>&nbsp;</td><td class='rtWrapperBottomRight'>&nbsp;</td></tr></tbody></table></div>";

    if (document.readyState != null && navigator.userAgent != null && navigator.userAgent.toString().indexOf("MSIE") != -1) {
        if ('complete' == document.readyState) {
            document.body.appendChild(popupWindowDiv);
        }
        else {
            window.setTimeout(SetPopupWindowReady, 100);
        }
    }
    else {
        document.body.appendChild(popupWindowDiv);
    }

    if (popupIsModal)
        SetModalBackground();
}

function HidePopupWindow(elementId) {
    document.getElementById(elementId).style.display = 'none';
    HideModalBackground();
}

function GetRadWindow() {
    var oWindow = null;
    if (window.radWindow)
        oWindow = window.radWindow;
    else if (window.frameElement != null && window.frameElement.radWindow)
        oWindow = window.frameElement.radWindow;
    return oWindow;
}

function CloseWindow(CWParams) {
    if (CWParams == 'undefined' || CWParams == null) {
        GetRadWindow().Close();
    }
    else {
        GetRadWindow().Close(CWParams);
    }
}

function GeoInfoCB(sender, geoInfo) {
    var manager = GetRadWindowManager();
    var wizardWin = manager.GetWindowByName("wizardWin");
    var currentDocument = null;
    if (wizardWin != null && wizardWin.get_contentFrame() != null && wizardWin.get_contentFrame().contentWindow != null) {
        currentDocument = wizardWin.get_contentFrame().contentWindow.document;
    }
    else {
        currentDocument = window.document;
    }
    var geoInfoArray = geoInfo.toString().split(",");
    if (geoInfoArray.length == 7) {
        var controlId = geoInfoArray[0];
        var txtLong = currentDocument.getElementById(controlId + '_TxtGeoLong');
        var txtLat = currentDocument.getElementById(controlId + '_TxtGeoLat');
        var txtZip = currentDocument.getElementById(controlId + '_HFZip');
        var txtCity = currentDocument.getElementById(controlId + '_HFCity');
        var txtRegion = currentDocument.getElementById(controlId + '_HFRegion');
        var txtCountry = currentDocument.getElementById(controlId + '_HFCountry');
        txtLat.value = geoInfoArray[1];
        txtLong.value = geoInfoArray[2];
        txtZip.value = geoInfoArray[3];
        txtCity.value = geoInfoArray[4];
        txtRegion.value = geoInfoArray[5];
        txtCountry.value = geoInfoArray[6];
    }
}

function RefreshRadWindow(radWindowId) {
    var radWin = null;
    var currentRadWin = GetRadWindow();
    if (currentRadWin != null) {
        var manager = currentRadWin.get_windowManager();
        if (manager != null)
            var radWin = manager.GetWindowByName(radWindowId);
    }
    if (radWin != null) {
        radWin.reload();
    }
    else {
        RefreshParentPage();
    }
}

function RefreshParentPage(ignoreCache) {
    if (ignoreCache != null)
        GetRadWindow().BrowserWindow.location.reload(ignoreCache);
    else
        GetRadWindow().BrowserWindow.location = GetRadWindow().BrowserWindow.location;
}

function RedirectParentPage(newUrl) {
    GetRadWindow().BrowserWindow.document.location.href = newUrl;
}

function CallFunctionOnParentPage(fnName) {
    var oWindow = GetRadWindow();
    if (oWindow.BrowserWindow[fnName] && typeof (oWindow.BrowserWindow[fnName]) == "function") {
        oWindow.BrowserWindow[fnName](oWindow);
    }
}

function radWinOpen(url, title, width, height, isCentered, CallBackFunc, windowId) {
    var oWindow;

    if (GetRadWindow() == null) {
        oWindow = window.radopen(url, windowId);
    }
    else {
        var oBrowserWnd = GetRadWindow().BrowserWindow;
        oWindow = oBrowserWnd.radopen(url, windowId);
    }
    oWindow.set_modal(true);
    oWindow.SetSize(width, height);
    oWindow.SetTitle(title);
    oWindow.Center();

    if (CallBackFunc != 'undefined' && CallBackFunc != null) {
        oWindow.set_clientCallBackFunction(CallBackFunc);
    }
}

function GetXmlHttp() {
    http_request = false;

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
			{ }
        }
    }

    if (!http_request) {
        return null;
    }
    else {
        return http_request;
    }
}

function GetXmlHttp_Old() {
    var x = null;
    try {
        x = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
        try {
            x = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e) {
            x = null;
        }
    }

    if (!x && typeof XMLHttpRequest != "undefined") {
        x = new XMLHttpRequest();
    }

    return x;
}

function DateAdd(date, interval, value) {

    if (interval == "Y")
        return new Date(date.getFullYear() - 0 + value, date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds());
    else if (interval == "M")
        return new Date(date.getFullYear(), date.getMonth() - 0 + value, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds());
    else if (interval == "D")
        return new Date(date.getFullYear(), date.getMonth(), date.getDate() - 0 + value, date.getHours(), date.getMinutes(), date.getSeconds());
    else
        return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds());
}

function ReturnOptionAuswahl(id, anzahl) {
    for (i = 0; i < anzahl; ++i) {
        var opt = document.getElementById(id + "_" + i);
        if (opt.checked == true) {
            return (opt.value);
        }
    }
    return 0;
}

function formatParaDate(date) {
    return date.getFullYear() + "." + (date.getMonth() + 1) + "." + date.getDate();
}

var xmlHttp = null;

function GetJson(urlBase, fromId, toId) {
    var url = buildDataUrl(urlBase, fromId, toId);

    xmlHttp = GetXmlHttp();
    xmlHttp.onreadystatechange = ProcessRequest;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
}

function buildDataUrl(urlBase, fromId, toId) {
    var url = urlBase;

    var ctrl = $find(fromId);
    if (ctrl != null) {
        var value = ctrl.get_selectedDate();
        url += "&DateFrom=" + formatParaDate(value);
    }

    ctrl = $find(toId);
    if (ctrl != null) {
        value = ctrl.get_selectedDate();
        url += "&DateTo=" + formatParaDate(value);
    }

    return url;
}

function ProcessRequest() {
    if (xmlHttp.readyState == 4) {
        var ids = xmlHttp.getResponseHeader("IDS").split("|");
        if (xmlHttp.status == 200) {
            var info = xmlHttp.responseText;
            var tmp = $get(ids[0]);
            x = tmp.load(info);
            hideErrorMessage(ids[1]);
        }
        else if (xmlHttp.status == 501) {
            showErrorMessage(ids[1], xmlHttp.responseText);
        }
        else {
            showErrorMessage(ids[1], xmlHttp.status);
        }
    }
}

function hideErrorMessage(errorId) {
    var ctrl = document.getElementById(errorId);
    ctrl.innerHTML = "";
}

function showErrorMessage(errorId, message) {
    var ctrl = document.getElementById(errorId);
    ctrl.innerHTML = message;
}

function showMore(hideElementId, showElementId) {
    var hideElement = document.getElementById(hideElementId);
    var showElement = document.getElementById(showElementId);
    hideElement.style.display = "none";
    showElement.style.display = "block";
}

function setFromToDate(dataRange, fromId, toId) {
    var to = new Date();
    var from = new Date();

    if (dataRange == 1) {
        from.setDate(1);
    }
    else if (dataRange == 2) {
        to.setDate(1);
        to = DateAdd(to, "D", -1);
        from = DateAdd(to, "Copy", 0);
        from.setDate(1);
    }
    else if (dataRange == 3) {
        from.setDate(1);
        from = DateAdd(from, "M", -1);
    }

    var ctrlFrom = $find(fromId);
    var ctrlTo = $find(toId);

    ctrlFrom.set_selectedDate(from);
    ctrlTo.set_selectedDate(to);
}