// ===================================================================== //
// PATICKA                                                               //
// ===================================================================== //

var U = {

	'getFncName' : function(fnc)
	{
		var fncString = fnc.toString();
		var match = /^function ([^\(]+)\(/.exec(fncString);

		if(typeof(match[1]) != 'undefined')
		   return match[1];
		else
		   return '';
	},

	'getInt' : function(val)
	{
 		try {
			val = parseInt(val.toString().replace(/^0*/, ''));
		} catch(e) {
			val = 0;
		}

		return isNaN(val) ? 0 : val;
	},

	'setEvent' : function(obj, event, fnc)
	{
		try {
			return obj.attachEvent(event, fnc);
		} catch (e) {
			return obj.setAttribute(event, this.getFncName(fnc)+'(event)');
		}
	},

	'resetEvent' : function(obj, event, fnc)
	{
	   try {
	      obj.detachEvent(event, fnc);
	   } catch (e) {
	      obj.setAttribute(event, '');
	   }
	},

	// ziska sirku elementu
	'getWidth' : function(elm)
	{
	   try {
      	var w = document.defaultView.getComputedStyle(elm, '').getPropertyValue('width');
		}
	   catch(e) {
	   	var w = elm.offsetWidth;
		}

		return this.getInt(w);
	},

	// ziska vysku elementu
	'getHeight' : function(elm)
	{
	   try {
      	var h = document.defaultView.getComputedStyle(elm, '').getPropertyValue('height');
		}
	   catch(e) {
	   	var h = elm.offsetHeight;
		}

		return this.getInt(h);
	},

	'getWindowWidth' : function()
	{
		if(window.innerWidth)    /* NN4 a kompatibilni prohlizece */
	      return window.innerWidth;
	   else if(document.documentElement && document.documentElement.clientWidth) /* >= MSIE6 v std. rezimu */
	      return document.documentElement.clientWidth;
	   else if(document.body && document.body.clientWidth) /* starsi MSIE + MSIE6 v quirk rezimu */
	      return document.body.clientWidth;
	   else
	      return 0;
	},

	'getWindowHeight' : function()
	{
		if(window.innerHeight)    /* NN4 a kompatibilni prohlizece */
	      return window.innerHeight;
	   else if(document.documentElement && document.documentElement.clientHeight) /* >= MSIE6 v std. rezimu */
	      return document.documentElement.clientHeight;
	   else if(document.body && document.body.clientHeight) /* starsi MSIE + MSIE6 v quirk rezimu */
	      return document.body.clientHeight;
	   else
	      return 0;
	}
}

var divMain = _$('Main');
var divFoot = _$('Footer');

function UpdateFooterPosition()
{
	var h = U.getHeight(divMain);
	divFoot.style.top = (h - 30) + 'px';
}

if(navigator.userAgent.match(/MSIE/gi))
{
	U.setEvent(window, 'onresize', UpdateFooterPosition);
	U.setEvent(window, 'onresizeend', UpdateFooterPosition);
	U.setEvent(window, 'onload', UpdateFooterPosition);
}
else
{
	U.setEvent(document.body, 'onresize', UpdateFooterPosition);
	U.setEvent(document.body, 'onresizeend', UpdateFooterPosition);
	U.setEvent(window, 'onload', UpdateFooterPosition);
}


