window.addEvent('domready',function() {positionFooter();});
window.addEvent('resize',function() {positionFooter();});

function positionFooter()
{
	var resizewrapper 	= $('wrapper');
	var footer  		= $('footer');

	if(resizewrapper && footer)
	{
		resizewrapper.style.height = 'auto';
		
		// resize if
		if((resizewrapper.clientHeight + footer.clientHeight) < getWindowHeight() - 40)
		{
			//alert(footer.clientHeight);
			resizewrapper.style.height = (getWindowHeight() - footer.clientHeight - 80) + 'px';
		}
	}
}

function positionWrapperHome()
{
	var wrapper = $('wrapper');
	wrapper.style.height = getWindowHeight() + 'px';
}

/*********************************
* Returns value of querystring variable
**********************************/
function getQueryVariable(variable) 
{ 
  var query = window.location.search.substring(1); 
  var vars = query.split("&");
   
  for (var i=0;i<vars.length;i++) 
  { 
    var pair = vars[i].split("=");
    if (pair[0] == variable) 
	{ 
      return pair[1]; 
    }
	else
	{
		return null;
	}
  } 
} 

/*********************************
* Returns height of window in pixels
**********************************/
function getWindowHeight()
{
	// calculate windowheight 
	var height = 0;
	
	if( typeof(window.innerHeight ) == 'number' )
	{
		//Non-IE
		height = window.innerHeight;
	}
	else if( document.documentElement && document.documentElement.clientHeight )
	{
		//IE 6+ in 'standards compliant mode'
		height = document.documentElement.clientHeight;
	}
	else if( document.body && document.body.clientHeight )
	{
		//IE 4 compatible
		height = document.body.clientHeight;
	}
	return height;
}

/*********************************
* Returns width of window in pixels
**********************************/
function getWindowWidth()
{
	// calculate windowheight 
	var width = 0;
	
	if( typeof(window.innerWidth ) == 'number' )
	{
		//Non-IE
		width = window.innerWidth;
	}
	else if( document.documentElement && document.documentElement.clientWidth )
	{
		//IE 6+ in 'standards compliant mode'
		width = document.documentElement.clientWidth;
	}
	else if( document.body && document.body.clientWidth )
	{
		//IE 4 compatible
		width = document.body.clientWidth;
	}
	return width;
}

/*********************************
* Returns height of body in pixels
**********************************/
function getBodyHeight()
{
	return document.getElementsByTagName('body')[0].clientHeight;
}

/*********************************
* Returns width of body in pixels
**********************************/
function getBodyWidth()
{
	return document.getElementsByTagName('body')[0].clientWidth;
}
