
function trackSchool(id, a, b, c, d)
{
	// Show loading indicator
	if ($('loading'))
	{
		$('loading').appear({duration: .75});
	}
	
	new Ajax.Request('/ajax.utilities.php', {
		parameters: 'trackschool='+id+'&a='+a+'&b='+b+'&c='+c+'&d='+d,

		onSuccess: function(resp) 
		{
			if (resp.responseText.indexOf('success') == 0)
			{
				ajax_showSuccess(resp.responseText.indexOf(':') > 0 ? resp.responseText.replace('success:', '') : 'You are now tracking this school.');

				// Swap the track/untrack links
				if ($('trackschool'))
				{
					$('trackschool').hide();
				}
				if ($('untrackschool'))
				{
					$('untrackschool').show();
				}
			}else if(resp.responseText.indexOf('notice') == 0)
			{
				ajax_showNotice(resp.responseText.indexOf(':') > 0 ? resp.responseText.replace('notice:', '') : 'Cannot track this school.');
			}else if(resp.responseText.indexOf('error') == 0)
			{
				ajax_showError(resp.responseText.indexOf(':') > 0 ? resp.responseText.replace('error:', '') : 'There was an error attempting to track this school. #tkbe7');
			}else{
				ajax_showNotice('That\'s weird... something unexplanable has just happened. Please try again.', false);
			}

			// Hide the loading indicator
			if ($('loading'))
			{
				$('loading').fade({duration: .25, from: 1, to: 0});
			}
		},

		onFailure: function(resp) 
		{
			ajax_showError('There was a network error while attempting to track this school. Please try again.');

			// Hide the loading indicator
			if ($('loading'))
			{
				$('loading').fade({duration: .25, from: 1, to: 0});
			}
		}

	});
}

function untrackSchool(id, a, b, c, d)
{
	// Show loading indicator
	if ($('loading'))
	{
		$('loading').appear({duration: .75});
	}

	new Ajax.Request('/ajax.utilities.php', {
		parameters: 'untrackschool='+id+'&a='+a+'&b='+b+'&c='+c+'&d='+d,

		onSuccess: function(resp) 
		{
			if (resp.responseText.indexOf('success') == 0)
			{
				ajax_showSuccess(resp.responseText.indexOf(':') > 0 ? resp.responseText.replace('success:', '') : 'You are no longer tracking this school.');

				// Swap the track/untrack links
				if ($('untrackschool'))
				{
					$('untrackschool').hide();
				}
				if ($('trackschool'))
				{
					$('trackschool').show();
				}
			}else if(resp.responseText.indexOf('error') == 0)
			{
				ajax_showError(resp.responseText.indexOf(':') > 0 ? resp.responseText.replace('error:', '') : 'There was an error attempting to stop tracking this school. #tkbe9');
			}else{
				ajax_showNotice('That\'s weird... something unexplanable has just happened. Please try again.', false);
			}

			// Hide the loading indicator
			if ($('loading'))
			{
				$('loading').fade({duration: .25, from: 1, to: 0});
			}
		},

		onFailure: function(resp) 
		{
			ajax_showError('There was a network error while attempting to stop tracking this school. Please try again.');

			// Hide the loading indicator
			if ($('loading'))
			{
				$('loading').fade({duration: .25, from: 1, to: 0});
			}
		}

	});
}
