var rS = {
	
	init: function() {
		
		var iWinWidth = 0, iWinHeight = 0;
		
		if( typeof( window.innerWidth ) == 'number' ) {
			
			//Non-IE
			iWinWidth = window.innerWidth;
			iWinHeight = window.innerHeight;
			
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			
			//IE 6+ in 'standards compliant mode'
			iWinWidth = document.documentElement.clientWidth;
			iWinHeight = document.documentElement.clientHeight;
			
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			
			//IE 4 compatible
			iWinWidth = document.body.clientWidth;
			iWinHeight = document.body.clientHeight;
			
		}
		
		rS.resizeMain(iWinHeight);
	},

	resizeMain: function(iWinHeight) {
		var windowHeight=iWinHeight;
		
		//var windowHeight=getWindowHeight();
		if (windowHeight>0) {
			var wrapper = document.getElementById('wrapper');
			if(wrapper)
			{
				var contentHeight = document.getElementById('wrapper').offsetHeight;
				var footerElement = document.getElementById('footer');
				var footerHeight = footerElement.offsetHeight;
				if (windowHeight-(contentHeight+footerHeight)>=0) {
					footerElement.style.position='relative';
					footerElement.style.top=(windowHeight-
					(contentHeight+footerHeight))+'px';
				}
				else {
					footerElement.style.position='static';
				}
			}
		}
	},

	addEvent: function(elm, evType, fn, useCapture) {

		// cross-browser event handling for IE5+, NS6 and Mozilla
		// By Scott Andrew
		if (elm.addEventListener) {
			elm.addEventListener(evType, fn, useCapture);
			return true;
		} else if (elm.attachEvent) {
			var r = elm.attachEvent('on' + evType, fn);
			return r;
		} else {
			elm['on' + evType] = fn;
		}
	}
}

rS.addEvent(window, 'load', rS.init, false);
rS.addEvent(window, 'resize', rS.init, false);