function getOffsetLeft(element) {

	var ol = element.offsetLeft;

	while ((element = element.offsetParent) != null) {

		ol += element.offsetLeft;

	}

	return ol;

}



function getOffsetTop(element) {

	var ot = element.offsetTop;

	while ((element = element.offsetParent) != null) {

		ot += element.offsetTop;

	}

	return ot;

}


function BrowserName() {

	agent = navigator.userAgent.toLowerCase();

	if (agent.indexOf('opera') != -1) 

		return 'opera';

	else if (agent.indexOf('firefox') != -1) 

		return 'firefox';

	else if (agent.indexOf('gecko') != -1) 

		return 'mozilla';

	else if (agent.indexOf('msie') != -1)

		return 'ie';

}



var browser = BrowserName();

var documentBody = (document.compatMode == 'CSS1Compat')? document.documentElement : document.body;

var clientHeight;


//count the the new position for the cart
function CartFloat() {
	var cart_div = document.getElementById('cart');
	
	clientHeight = (browser == 'ie')? documentBody.clientHeight : window.innerHeight;
	
	var left = getOffsetLeft(document.getElementById('page'));
	left += 12;	//offset with 12 px from the page div's left side
	
	//alert(documentBody.scrollTop);
	
	var top = documentBody.scrollTop+(clientHeight/2)-(cart_div.clientHeight/2);
	
	cart_div.style.top = top+'px';
	cart_div.style.left = left+'px';
}


//setup the cartfloat()

function SetupCart() {
	setTimeout('CartFloat()',20);
}
