/*********************************
* 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;
}

/*********************************
* Tab container
**********************************/

TabContainer = 
{
	init: function()
	{
		var containers = $$('.tabcontainer');
		
		for(var i = 0; i < containers.length;i++)
		{
			TabContainer.initContainer(containers[i]);
		}
	},
	initContainer: function(container)
	{
		TabContainer.initTabs($$('#'+container.id + ' .tab'),container.id);
		//TabContainer.initContent($$('#'+container.id + ' .tabcontent'),container.id);
	},
	initTabs: function(tabs,containerId)
	{
		for(var i = 0; i < tabs.length; i++)
		{
			tabs[i].containerId = containerId;
			tabs[i].tabId = i;
			tabs[i].addEvent('click',TabContainer.onTabClick);
		}
	},
	onTabClick: function(e)
	{
		TabContainer.setTab(this.tabId,this.containerId);
		return false;
	},
	setTab: function(tabId,containerId)
	{
		var tabs 		= $$('#'+containerId + ' .tab');
		var contents 	= $$('#'+containerId + ' .tabcontent');
		var targetTab = null;
		
		for(var i = 0; i < tabs.length; i++)
		{
			tabs[i].removeClass('active');
			contents[i].removeClass('active');
			if(tabs[i].tabId == tabId)
			{
				tabs[i].addClass('active');
				contents[i].addClass('active');
			}
		}
	}
}

window.addEvent('domready',TabContainer.init);

//TabContainer.init();











