﻿setInterval(
	function() {
		var bg = document.getElementById('_Background');
		var footer = document.getElementById('_Footer');
		var content = document.getElementById('_Content');
		var html = document.getElementsByTagName('HTML')[0];
		var body = document.getElementsByTagName('BODY')[0]

		if (bg && footer && content && html && body) {
			var fudge = 165;
			var bodyHeight = html.offsetHeight;
			var contentHeight = content.offsetHeight;
			var marginTop = parseInt(bodyHeight - contentHeight - fudge);
			var siteHeight = parseInt(contentHeight + fudge + 30);

			if (siteHeight < bodyHeight) siteHeight = bodyHeight
			if (marginTop < 20) marginTop = 20;
			if (jQuery.browser.msie && jQuery.browser.version == "6.0") siteHeight -= 4;
			
			footer.style.marginTop = marginTop + 'px';
			bg.style.height = siteHeight + 'px';
		}
	}
, 250);


function getServerData(page, bCacheConnection) {
	var _this = this;
	var _path = String(window.location);
	this.GenerateRandomString = function(len) {
		var _str = '';
		var arrKeyStr = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
		for (var i = 1; i <= len; i++) {
			var iRndNum = Math.ceil((Math.random() * 100) / 2.8) - 1; //Generates a random number from 0-35
			_str += arrKeyStr[iRndNum];
		}
		return _str;
	}
	this.GetTimeMod = function() {
		var _str = date.getMinutes();
		if (_str < 15) {
			_str = 15;
		} else if (_str < 30) {
			_str = 30;
		} else if (_str < 45) {
			_str = 45;
		} else {
			_str = 60;
		}
		return _str;
	}
	try {
		var _path = String(window.location);
		if (_path.substring(_path.length - 1) != '/') {
			_path = _path.substring(0, _path.lastIndexOf('/') + 1);
		}
		_path += page;

		if (_path.indexOf('?') != -1) {
			_path += '&';
		} else {
			_path += '?';
		}
		var date = new Date()
		if (typeof (bCacheConnection) == 'undefined' || bCacheConnection == true) {
			_path += 'z=' + date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + '-' + date.getHours() + '-' + _this.GetTimeMod();
		} else {
			_path += 'z=' + _this.GenerateRandomString(6);
		}
		var oRequest = new XMLHttpRequest();
		oRequest.open("get", _path, false);
		oRequest.send(null);
		return oRequest.responseText;
	} catch (e) {
		//alert('There was an error in the request:' + e.message)
	} finally {
	}
}

