﻿Globals = function() {
}

Globals.getBrowserMeasurements = function() {
    var measurements = new Object();
	
	measurements.page = new Object();
	measurements.window = new Object();
	
	// Window Scroll
	if (window.innerHeight && window.scrollMaxY)
	{
		measurements.window.scrollWidth = document.body.scrollWidth;
		measurements.window.scrollHeight = window.innerHeight + window.scrollMaxY;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{
		measurements.window.scrollWidth = document.body.scrollWidth;
		measurements.window.scrollHeight = document.body.scrollHeight;
	}
	else
	{
		measurements.window.scrollWidth = document.body.offsetWidth;
		measurements.window.scrollHeight = document.body.offsetHeight;
	}
	
	// Window Size
	if (self.innerHeight)
	{
		measurements.window.width = self.innerWidth;
		measurements.window.height = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		measurements.window.width = document.documentElement.clientWidth;
		measurements.window.height = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		measurements.window.width = document.body.clientWidth;
		measurements.window.height = document.body.clientHeight;
	}	
	
	// Page Size
	if (measurements.window.scrollHeight < measurements.window.height)
		measurements.page.height = measurements.window.height;
	else
		measurements.page.height = measurements.window.scrollHeight;

	if (measurements.window.scrollWidth < measurements.window.width)
		measurements.page.width = measurements.window.width;
	else
		measurements.page.width = measurements.window.scrollWidth;
    
    return measurements;
}

Globals.getElementSize = function(element) {
    var size = new Object();
    
    if (element.offsetHeight)
        size.height = element.offsetHeight;
    else if (element.clientHeight)
        size.height = element.clientHeight;
    if (element.offsetWidth)
        size.width = element.offsetWidth;
    else if (element.clientWidth)
        size.width = element.clientWidth;
    
    return size;
}

String.isNullOrEmpty = function(value) {
    return value == null || value == ''
}

