function screenDynamics() {
	
    var mytable = document.getElementById("mainTable");
        
    var screenWidth				= window.screen.width;
    var screenHeight			= window.screen.height;
    var screenColorDepth		= window.screen.colorDepth;
    var windowWidth				= window.innerWidth;
    var windowHeight			= window.innerHeight;
    //var windowWidthPercentage	= (windowWidth / (parseInt(mytable.getAttribute("fixedWidth")) + parseInt(mytable.getAttribute("dynamicBorder")))) * 100;	
    var browserOrientation		= (typeof window.orientation == "undefined") ? 0 : window.orientation;
    var touchDevice				= ('ontouchstart' in document.documentElement) ? 1 : 0;
	
    /* define ajax module and function */
    ajaxdata  = "ajaxModule="			+ "screen";
    ajaxdata += "&ajaxFunction="		+ "screenDynamics"
	
    /* define variables */
    ajaxdata += "&screenWidth="			+ screenWidth;
    ajaxdata += "&screenHeight="			+ screenHeight;
    ajaxdata += "&screenColorDepth="		+ screenColorDepth;
    ajaxdata += "&windowWidth="			+ windowWidth;
    ajaxdata += "&windowHeight="			+ windowHeight;
    ajaxdata += "&windowWidthPercentage="           + 100; //windowWidthPercentage.toFixed(2);	
    ajaxdata += "&browserOrientation="		+ browserOrientation;
    ajaxdata += "&touchDevice="			+ touchDevice;
    ajaxdata += "&tableWidth="			+ 100; //mytable.width;
	
    /**
     * TODO: 
     * fixedWidth and dynamicBorder do not exist anymore
     * fix scaling problem
     * 
	if(windowWidth < (parseInt(mytable.getAttribute("fixedWidth")) + parseInt(mytable.getAttribute("dynamicBorder"))) ) {
		mytable.width = windowWidth - parseInt(mytable.getAttribute("dynamicBorder")) - 17;
	}
	else {
		mytable.width = mytable.getAttribute("fixedWidth") - 17;
	} */
	
    $.ajax({
        type: "POST",
        url: "/ajax.php",
        data: ajaxdata,
        cache: false,
        success: function (response){
            $("#variablesScreen").html(response);	
        }
    });
    return 100; //windowWidthPercentage;
}

function resizeByID(id, percentage) {	
    var object = document.getElementById(id);
    if(percentage <= 100) {
        object.style.width = percentage + '%';
    } else {
        object.style.width = '100%';
    }
}

function resizeByClassName(className, percentage) {
    var objects = document.getElementsByClassName(className);
    for (var i = 0; i < objects.length; i++) {
        if(percentage <= 100) {
            objects[i].style.width = percentage + '%';
        } else {
            objects[i].style.width = '100%';
        }
    }
}


function functionLoader() {
    var percentage = screenDynamics();
    resizeByClassName('dynamic', percentage);
}

var timeout;
function functionLoaderOnTimeout () {
    clearTimeout(window.timeout);
    window.timeout = setTimeout('functionLoader()', 2000);
}

window.onload	= functionLoader;
window.onresize = functionLoaderOnTimeout;
