/*********************************
* trackPage
**********************************/

function trackOutgoingLink(key,href)
{
	pageTracker._trackPageview(key);
	window.open(href);
	return false;
}

/*********************************
* product scrolling
**********************************/

var productScrollIndex = 0;
var productScrollIncrement = 222;

function doScrollLeft()
{
	if(productScrollIndex > 0)
	{
		productScrollIndex--;
		updateScroller();
	}
}

function doScrollRight()
{
	if(productScrollIndex < (productCount - 4))
	{
		productScrollIndex++;
		updateScroller();
	}
}

function updateScroller()
{
	//alert(productScrollIndex);
	var el			= $('products');
	var currOffset  = el.scrollLeft;
	var myFx = new Fx.Scroll(el);
	myFx.start(productScrollIndex * productScrollIncrement, 0);
	
	if(productScrollIndex == 0)
	{
		doDisableLeft();
	}
	else
	{
		doEnableLeft();
	}
	if(productScrollIndex == (productCount - 4))
	{
		doDisableRight();
	}
	else
	{
		doEnableRight();
	}
}

function doEnableLeft()
{
	$('previous').tween('opacity', 1);
}
function doEnableRight()
{
	$('next').tween('opacity', 1);
}

function doDisableLeft()
{
	$('previous').tween('opacity', 0);
}
function doDisableRight()
{
	$('next').tween('opacity', 0);
}

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