function Auction()
{

}
Auction.auctions = [];
Auction.costs = [];
Auction.add = function(id, time_div_id)
{
	this.auctions[this.auctions.length] = [id, time_div_id];
}
Auction.addCost = function(time_div_id, cost_div_id)
{
   this.costs[time_div_id] = cost_div_id;
}
Auction.update_times = function()
{
	auction_string = '';
   var costs = this.costs;
	for(auction in this.auctions)
	{
		auction_string += this.auctions[auction][0] + '%' + this.auctions[auction][1] + ';';
	}
	$.post
	(
		'auction,getTimes',
		{'data': auction_string},
		function(data)
		{
			setTimeout('Auction.update_times();', '1000');
			times = eval('(' + data + ')');
			for(i in times)
			{
				$('#' + times[i][1]).text(times[i][2]);
				//$('#winner_'+times[i][1]).html(times[i][4]);
	            if(costs[times[i][1]] != undefined)
	            {
	               // alert('#' + costs[times[i][1]]);
	               // alert($('#' + costs[times[i][1]]).text());
	               $('#' + costs[times[i][1]]).text(times[i][3]);
	               $('#p' + costs[times[i][1]]).text(times[i][3]);
	               //$('#' + costs[times[i][1]]).text(times[i][3]);
	               if( times[i][4] != null )
	               {
	            	   $('#winner_'+times[i][0]).text('wygrywa: '+times[i][4]);
	            	   $('#pwinner_'+times[i][0]).text('wygrywa: '+times[i][4]);
	               }
	               else
	               {
	            	   $('#winner_'+times[i][0]).text('nikt nie prowadzi');
	            	   $('#pwinner_'+times[i][0]).text('nikt nie prowadzi');
	               }
	            }
			}
			
		}
	);
}
Auction.update_times();
//setInterval(function(){Auction.update_times()}, 1000)

$
(
	function()
	{
		$('.thumb').click
		(
			function()
			{
				$('#photo').attr('src', $(this).attr('src').replace('/sh__', '/sh_'));
				$('#photo').parent().attr('href', $(this).attr('src').replace('/sh__', '/'));
			}
		);
		
		$('#add_auto input[type=text]').blur( function() {
			var v = new Number( $(this).val() );
			v = parseInt(v);
			if( typeof(v) != 'number' )
				v = 0;
			$(this).val( v );		
		} );
	}
)

		$(document).ready(function(){
															 $('#payform .submit-nice-black').click(function(){
																																							 
																																							 $.post('index.php?page=user&action=addPayment', {sess:$(this).siblings('#session_id').val(), amount:$(this).siblings('#amount').val()});
																																							 
																																							 });
															 });


