	window.onresize = function() {
  		setFooter();
	}

	function getWindowHeight() {
		var windowHeight=0;
		
		
		if (typeof(window.innerHeight)=='number') {
			windowHeight=window.innerHeight;
		}
		else {
			if (document.documentElement&&document.documentElement.clientHeight) {
				windowHeight=document.documentElement.clientHeight;
			}
			else {
				if (document.body&&document.body.clientHeight) {
					windowHeight=document.body.clientHeight;
				}
			}
		}
		return windowHeight;
	}

	function setFooter() {
	//	$('debug').update('alabala1');					
		if (document.getElementById) {
			var windowHeight=getWindowHeight();

			if (windowHeight>0) {
				//debug (window.scrollbars)
				var contentHeight=document.getElementById('bd').offsetHeight;
				var footerElement=document.getElementById('foot');
				var footerHeight=footerElement.offsetHeight;
				//$('debug').update(windowHeight+","+contentHeight+","+footerHeight);
				//$('debug').update(document.body.clientHeight);
				if (windowHeight-(contentHeight+footerHeight)>=0) {
					//$('debug').update('1');					
					footerElement.style.position='absolute';
					footerElement.style.bottom='0px';//'(windowHeight-(contentHeight+footerHeight))+'px';
				}
				else {
					//$('debug').update('2');
					footerElement.style.position='static';
					//footerElement.style.bottom='0';
				}
			}
		}
	}
	
	function setFooterAndIndex() {
	//$('debug').update('alabala2');
		if (document.getElementById) {
			var windowHeight=getWindowHeight();

			if (windowHeight>0) {
				//debug (window.scrollbars)
				var contentHeight=document.getElementById('bd').offsetHeight;
				var footerElement=document.getElementById('foot');
				var indexElement=document.getElementById('footerIndex');
				var footerHeight=footerElement.offsetHeight;
				var indexHeight=indexElement.offsetHeight;
				//$('debug').update(windowHeight+","+contentHeight+","+footerHeight);
				//$('debug').update(document.body.clientHeight);
				if (windowHeight-(contentHeight+footerHeight)>=0) {
					//$('debug').update(windowHeight-(contentHeight+footerHeight));					
					footerElement.style.position='absolute';
					footerElement.style.bottom = '0px';
					//footerElement.style.top=(windowHeight-(contentHeight+footerHeight))+'px';
					indexElement.style.position = 'absolute';
					indexElement.style.bottom = (footerHeight+4) + 'px';
					//index.style.bottom=(windowHeight-(contentHeight+footerHeight))+20+'px';
				}
				else if ((windowHeight - contentHeight) < 0) {
					//$('debug').update('2');
					footerElement.style.position='static';
					indexElement.style.position='static';
					indexElement.style.bottom=(footerHeight+4)+'px';
					footerElement.style.bottom='0px';
				}
				else {
					//$('debug').update('2');
					footerElement.style.position='static';
					//footerElement.style.bottom='0';
				}
			}
		}
		//var footerElement=document.getElementById('foot');
	//	var index=document.getElementById("footerIndex");
	//	index.style.top = footerElement.style.top - 20;
	}