jQuery(document).ready(function($) {
  $('a[rel*=facebox]').facebox()
})
function addclass(id1, id2) {
	$('#' + id1).addClass(id2);
}
function removeclass(id1, id2) {
	$('#' + id1).removeClass(id2);
}
function showhide(id1, id2) { 
	$('#' + id1).show();
	$('#' + id2).hide();
}
function login(error) {
	$.post('/index.php/do_login/', {
		email: 		$('#email').val(),
		password:	$('#password').val()
	}, function (data) {
		if (data == 'false') {
			alert(error);
		} else {
			document.location = '/';
		}
	});
}
function switchTab(id) {
	$('#tabs').val(id);
	$('#loading').show();
	$('#auctions').hide();
	$('#tabs li').removeClass('selected');
	$('#' + id).addClass('selected');
	$.ajax({
		type: 		'GET',
		url:		'/index.php/auctions/' + id,
		success: 	function(data) {
			$('#loading').hide();
			$('#auctions').show();
			$('#auctions').html(data);
		}
	});
}
function placeBid(id, text, error) {
	if (confirm(text) == true) {
		$.post('/index.php/place_bid/',  {
			auctionID:	id,
			amount: 	$('#amount_' + id).val()
		}, function(data) {
			if (data == 'false') {
				alert(error);
			} else {
				var tab = $('#tabs').val();
				switchTab(tab);
				$('#showbalance').load('/index.php/balance/');
			}
		});
	}
}
function showInfo(id) {
	$('#image_' + id).hide(); 
	$('#info_' + id).fadeIn();
	$('#infobutton_' + id).hide();
	$('#imagebutton_' + id).show();
}
function showImage(id) {
	$('#info_' + id).hide(); 
	$('#image_' + id).fadeIn();
	$('#imagebutton_' + id).hide();
	$('#infobutton_' + id).show();
}