﻿var PreviousSize = 0;
var PreviewModeOn = false;

function resize() {
    if (document != null && document.body != null && document.documentElement != null) {
        var htmlheight = document.body.scrollHeight;
        var windowheight = document.documentElement.clientHeight;
        var correctiefactor = 30;
        var headerHeight = 206;

        var hoofdMenu = document.getElementById("hoofdMenu");
        var content = document.getElementById("content");
        var menuItem = document.getElementById("menuItem");
        
        var contentHeight = windowheight - headerHeight;
        if (contentHeight < 0) contentHeight = 0;
        var hoofdMenuHeight = windowheight - headerHeight;
        if (hoofdMenuHeight < 0) contentHeight = 0;
        var menuItemHeight = windowheight - headerHeight + correctiefactor;

        document.body.style.height = windowheight + "px";
        if (hoofdMenu != null) hoofdMenu.style.height = hoofdMenuHeight + "px";
        if (content != null) content.style.height = contentHeight + "px";
        if (menuItem != null) {
            menuItem.style.height = menuItemHeight + "px";

            if (content != null) content.style.width = 600 + "px";
        }
        else {
            if (content != null) content.style.width = 740 + "px";
        }
    }
}

function initLightbox(relAttribute) {

    // Use this example, or...
    $('a[@rel*=' + relAttribute + ']').lightBox(); // Select all links that contains lightbox in the attribute rel
    // This, or...
    //$('#gallery a').lightBox(); // Select all links in object with gallery ID
    // This, or...
    //$('a.lightbox').lightBox(); // Select all links with lightbox class
    // This, or...
    //$('a').lightBox(); // Select all links in the page
    // ... The possibility are many. Use your creative or choose one in the examples above

}

function resizeCms() {
    if (document != null && document.body != null && document.documentElement != null) {
        var htmlheight = document.body.scrollHeight;
        var windowheight = document.documentElement.clientHeight;
        var correctiefactor = 70;
        var headerHeight = 40;
        //alert("htmlheight: " + htmlheight + " windowheight: " + windowheight);

        var centerScreen = document.getElementById("cmsCenterScreen");
        var hoofdMenu = document.getElementById("ctl00_cmsHoofdMenu");
        var content = document.getElementById("ctl00_cmsInhoudHolder");
        var previewTab = document.getElementById("ctl00_ContentPlaceHolder1_tcMenu_tbPreview");
        //alert("centerscreen: " + centerScreen + " hoofdMenu: " + hoofdMenu + " content: " + content + " previewTab: " + previewTab);
        
        var centerScreenHeight = windowheight;
        if (centerScreenHeight < 0) centerScreenHeight = 0;
        var hoofdMenuHeight = windowheight - headerHeight;
        if (hoofdMenuHeight < 0) centerScreenHeight = 0;
        document.body.style.height = windowheight + "px";
        if (centerScreen != null) centerScreen.style.height = centerScreenHeight + "px";
        if (hoofdMenu != null) hoofdMenu.style.height = hoofdMenuHeight + "px";
        if (content != null) content.style.height = centerScreenHeight - headerHeight + "px";
        if (previewTab != null) {
            previewTab.style.height = centerScreenHeight - headerHeight - correctiefactor + "px";
        }
                
        //alert("centerScreenHeight: " + centerScreenHeight + " hoofdMenuHeight: " + hoofdMenuHeight);
        //alert("document.body.style.height: " + document.body.style.height + " content.style.height: " + content.style.height);
        //alert("centerScreen.style.height: " + centerScreen.style.height);
    }
}

function setPreviewMode(ModeOn) {
    PreviewModeOn = ModeOn;
}

function SelectDate() {
    var calendar = Sys.Application.findComponent("ctl00_ContentPlaceHolder1_tcNieuws_tbInstellingen_frmViewNieuwsInstellingen_calDatum");
    var input = document.getElementById("txtDatum");
    calendar.popupBeside(input, C1.Web.UI.PositioningMode.bottomLeft);
}

function CalendarClosed() {
    var calendar = Sys.Application.findComponent("ctl00_ContentPlaceHolder1_tcNieuws_tbInstellingen_frmViewNieuwsInstellingen_calDatum");
    var input = document.getElementById("txtDatum");
    input.value = calendar.get_selectedDate().toLocaleDateString();
}

function textboxMultilineMaxNumber(txt, maxLen) {
    try {
        if (txt.value.length > (maxLen - 1)) {
            if (window.event) {
                event.returnValue = false;
            }
            else {
                return false;
            }
        }
    } catch (e) {
    }
}   