/**
 * @author bjackson
 */
function API()
{
	this.getArticle = function(category, id, notify)
	{
		var article = new Article(category, id);
		var url = 'http://www.clanspring.com/site/clanspring/index.php?page=api&method=getArticle';
		if (category)
		{
			url += '&category=' + category;
		}
		url += '&id=' + id;
		var ajax = new Ajax(url, "GET", true);
		ajax.getXMLObject(article, notify);
	}

	this.getArticleXML = function(category, id, notify)
	{
		var article = new Article(category, id);
		var url = 'http://www.clanspring.com/site/clanspring/index.php?page=api&method=getArticle';
		if (category)
		{
			url += '&category=' + category;
		}
		url += '&id=' + id;
		var ajax = new Ajax(url, "GET", true);
		ajax.onLoad = function()
		{
			notify(ajax.getResponseXML());
		};
		ajax.send();
	}

	this.getArticleHTML = function(category, id, notify)
	{
		var url = 'http://www.clanspring.com/site/clanspring/index.php?page=api&method=getArticle&html=1';
		if (category)
		{
			url += '&category=' + category;
		}
		url += '&id=' + id;
		var ajax = new Ajax(url, "GET", true);
		ajax.onLoad = function()
		{
			notify(ajax.getResponseText());
		};
		ajax.send();
	}

	this.getProperties = function(url, notify)
	{
		var properties = new PropertiesXML(null);
		var ajax = new Ajax(url, "GET", true);
		ajax.getXMLObject(properties, notify);
	}

	this.getCategories = function(notify)
	{
		var url = 'http://www.clanspring.com/site/clanspring/index.php?page=api&method=getCategories';
		var properties = new PropertiesXML(null);
		var ajax = new Ajax(url, "GET", true);
		ajax.getXMLObject(properties, notify);
	}

	this.setProperties = function(url, propertiesXML, notify)
	{
		var ajax = new Ajax(url, "POST", true);
		ajax.xml = propertiesXML.getXML();
		ajax.getXMLObject(propertiesXML, notify);
	}
}
