﻿function Resize() {
    var content = document.getElementById('content');

    if (content) {
        var newHeight = document.body.offsetHeight;
       // alert(newHeight);
        newHeight = newHeight - 145 - 113;
        if (newHeight < 300) {
            newHeight = 300;
        }
        if (content.offsetHeight > newHeight) {
            // content.style.height = (content.offsetHeight + 60) + 'px';
            //content.style.height = (content.offsetHeight + 9) + 'px';
        } else {
           // content.style.height = newHeight + 'px';  // setAttribute('height', newHeight , 0);        
        }
    }

    var contentpanel = document.getElementById('contentpanel');
    if (contentpanel) {
        var contentpanelbottom = document.getElementById('contentpanelbottom');
        if (contentpanelbottom) {
           // alert(contentpanelbottom.outerHTML);
            contentpanelbottom.style.top = (contentpanel.offsetHeight - 10) + 'px';
        }
    }
}


function onMouseOverPortfolio() 
{
    
    var tbl = getPortfolioItemTable(this.event.srcElement);
    //alert(tbl.outerHTML);
}

function getPortfolioItemTable(element) 
{
    if (element.tagName == "TABLE") 
    {
        return element;
    } 
    else 
    {
        if (element.parentElement) 
        {
            return getPortfolioItemTable(element.parentElement);
        } 
        else 
        {
            return undefined;
        }
    }
}

function OpenPopup(bewerkId, backofficeType, parentId, width, height) {
    popupControl.SetWindowContentUrl(popupControl.GetWindowByName('MainWindow'), 'Bewerk.aspx?mt=' + backofficeType + '&id=' + bewerkId);
    popupControl.ShowWindow(popupControl.GetWindowByName('MainWindow'));
    popupControl.SetWindowSize(popupControl.GetWindowByName('MainWindow'), width, height);
    //popupControl.SetWindowWidth('MainWindow', 100);
    //popupControl.SetWindowHeight('MainWindow', 100);

}

function OnClosePopup(s, e) {
    if (e.window.name != 'EditWindow') {
        window.location.href = window.location.href;
    }
}

var defaultStep = 1;
var step = defaultStep;
var timerDown = "";
var maxTop = 0;

function moveNext(id) {
    maxTop = maxTop + 75;

    if (maxTop >= document.getElementById(id).scrollHeight) {
        maxTop = 0;
        document.getElementById(id).scrollTop = 0;
    }

    clearTimeout(timerDown);
    timerDown = setTimeout("scrollDivDown('" + id + "')", 10);
}

function scrollDivDown(id) {
    clearTimeout(timerDown);
    document.getElementById(id).scrollTop += step;
    if (document.getElementById(id).scrollTop < maxTop) {
        timerDown = setTimeout("scrollDivDown('" + id + "')", 10);
    } else {
        timerDown = setTimeout("moveNext('" + id + "')", 5000);
    }
}

Resize();
window.onresize = Resize;
