﻿function Blind(expandElementId, minValue, maxValue, flowVertical, shrinkElementId) {
    var targetValue;
    
    if (typeof(flowVertical) == 'undefined')
        flowVertical = true;
    
    var expandElement = document.getElementById(expandElementId);
    
    if (flowVertical) {
        if (expandElement.offsetHeight < maxValue)
            targetValue = maxValue;
        else
            targetValue = minValue;
    }
    else {
        if (expandElement.offsetWidth < maxValue)
            targetValue = maxValue;
        else
            targetValue = minValue;
    }
    
    AdjustSize(expandElementId, targetValue, flowVertical, shrinkElementId)
}

function AdjustSize(expandElementId, targetValue, flowVertical, shrinkElementId) {
    if (typeof(flowVertical) == undefined)
        flowVertical = true;
        
    var expandElement = document.getElementById(expandElementId);
    var shrinkElement;
    if (typeof(shrinkElementId) != undefined)
        shrinkElement = document.getElementById(shrinkElementId);
    
    var doExpand = false;
    if (flowVertical)
        doExpand = expandElement.offsetHeight < targetValue;
    else
        doExpand = expandElement.offsetWidth < targetValue;
    
    var step = -2;
    if (doExpand)
        step = 2;
        
    if (flowVertical) {
        expandElement.style.height = (expandElement.offsetHeight + step) + 'px';
        expandElement.style.display = '';
        
        if (shrinkElement) {
            shrinkElement.style.height = (shrinkElement.offsetHeight + (step * -1)) + 'px';
            if (shrinkElement.style.height == '0px')
                shrinkElement.style.display = 'none';
        }
        
        if ((doExpand && expandElement.offsetHeight < targetValue) || (!doExpand && expandElement.offsetHeight > targetValue))
            window.setTimeout("AdjustSize('" + expandElementId + "', " + targetValue + ", " + flowVertical + ", '" + shrinkElementId + "')", 1);
    }
    else {
        expandElement.style.width = (expandElement.offsetWidth + step) + 'px';
        expandElement.style.display = '';
        
        if (shrinkElement) {
            shrinkElement.style.width = (shrinkElement.offsetWidth + (step * -1)) + 'px';
            if (shrinkElement.style.width == '0px')
                shrinkElement.style.display = 'none';
        }
        
        if ((doExpand && expandElement.offsetHeight < targetValue) || (!doExpand && expandElement.offsetHeight > targetValue))
            window.setTimeout("AdjustSize('" + expandElementId + "', " + targetValue + ", " + flowVertical + ", '" + shrinkElementId + "')", 1);
    }
}
function blaetternButtonPress() {
    //alert("Klick");
    if (document.getElementById('Start-News') && document.getElementById('Start-Data')) {
        document.getElementById('Start-News').style.display = 'none';
        document.getElementById('Start-Data').style.display = 'block';
    }
}
function InitStartpage() {
    if (document.getElementById('Start-Data')) {
        document.getElementById('Start-Data').style.display = 'none';
        document.getElementById('Start-News').style.display = 'block';
    }
    if (HTTP_GET_VARS['showMandala']=='true') {
        document.getElementById('Start-News').style.display = 'none';
        document.getElementById('Start-Data').style.display = 'block';
    }
}
HTTP_GET_VARS = new Array();
strGET = document.location.search.substr(1, document.location.search.length);
if (strGET != '') {
    gArr = strGET.split('&');
    for (i = 0; i < gArr.length; ++i) {
        v = ''; vArr = gArr[i].split('=');
        if (vArr.length > 1) { v = vArr[1]; }
        HTTP_GET_VARS[unescape(vArr[0])] = unescape(v);
    }
}
$(document).ready(function() {
    var tables = $('#ContentArea table');
    $(tables).each(function(index, value) {
        var table = $(tables[index]);
        if (table.attr('border') == 1) {
            table.find('td').css('border', '1px solid #999');
            table.css('border', '1px solid #999');
        }
    });
});
