// Ajax.js

function add_to_watch_list(auction_id)
{
	$.get("/api_for_ajax/add-to-watch-list.php?au_id=" + auction_id + "&now=" + new Date().getTime(), function(data) {
		//alert(data);		
		switch(Number(data))
		{
			case 0:	alert('Failed. Please Retry.');break;
			case -1: alert('You have already added this item.');break;
			case -2: alert('Please Login First');break;
			case 1:	alert('Add Success!');break;
		}
	});
}

function delete_from_watch_list(auction_id, row_id)
{
	$.get("/api_for_ajax/delete-from-watch-list.php?au_id=" + auction_id + "&now=" + new Date().getTime(), function(data) {
		//alert(data);		
		switch(Number(data))
		{
			case 0:	alert('Failed. Please Retry.');break;
			//case 1:	alert('Delete Success!');break;
			case 1: $('#' + row_id).fadeOut(1000);
		}
	});
}

function email_a_friend(form_data)
{
	$.post("/api_for_ajax/email-a-friend.php?now=" + new Date().getTime(), form_data, function(data) {
		if(data == 1)
		{
			$('#error_box').css('color', '#009900');
			$('#error_box').css('font-size', '24px');
			$('#error_box').html('<center>Email sending Success!</center>');
			$('#main_form').hide();
			
		}
		else
		{
			$('#error_box').css('padding-left', '10px');
			$('#error_box').css('color', '#FF0000');
			$('#error_box').html(data);
		}
		$('#error_box').show();
	});
}
