var onBodyLoadRows = Array();

function onBodyLoad()
{
	while( onBodyLoadRows.length > 0 )
	{
		eval( onBodyLoadRows.pop() );
	}
}

function updateCartItems()
{
	var thisObject = this;
			
	req = new Ajax.Request( '/getItems.php', {
							 method    : 'get',
 							 parameters: {},
							 onSuccess : function(transport) 
						  				{
											var nr = parseInt( transport.responseText );
											if( nr == 1 )  nrString = nr + ' item';
											else		   nrString = nr + ' items';	
											$('cartItemsNr').update( nrString );
							  			}
							});
}


//payment
var currentOpenedTr = 0;
function showTr( id )
{
	if( currentOpenedTr != 0 && $( 'paymentInstructions' + currentOpenedTr ) != null ) $( 'paymentInstructions' + currentOpenedTr ).hide();
	currentOpenedTr = id;
	
	if( $( 'paymentInstructions' + currentOpenedTr ) != null )
		$( 'paymentInstructions' + currentOpenedTr ).show();
}

function keepAlive()
{
	setInterval( refreshSession, 1000 * 60 * 10 );
}

function refreshSession()
{
	$.post( "keepAlive.php" );
}

onBodyLoadRows.push( 'updateCartItems();' );
onBodyLoadRows.push( 'keepAlive();' );
