
/*
 * Course class, holds all the properties and methods of a course.
 *
 * @package classes
 * @copyright Copyright 2009, Lastbyte VOF
 * @version 1.0
 */
var Course = new Class(
{
	Implements: Options,

	options:
	{
		label: 'Course'
	},

  /*
   * Constructor
   *
   * @param string name
   */
	initialize: function (options)
	{
		this.setOptions(options);
		
		this.label = this.options.label;
		this.attributes = {};
	},

	/*
	 * Returns the course label
	 *
	 * @return string
	 */
	getLabel: function ()
	{
		return this.label;
	},
	
	/*
	 * Adds an attribute value to this product
	 *
	 * @param string attr
	 * @param string value
	 */
	addAttribute: function (attr, value)
	{
		if (!this.attributes[attr])
			this.attributes[attr] = [value];
		else if (this.attributes[attr].indexOf(value) == -1)
			this.attributes[attr].push(value);
	},
	
	/*
	 * Checks whether this product has a certain attribute
	 *
	 * @param string attr
	 * @return boolean
	 */
	hasAttribute: function (attr)
	{
		return (!!this.attributes[attr]);
	},
	
	/*
	 * Checks whether an attribute has a specified value
	 *
	 * @param string attr
	 * @param string value
	 * @return boolean
	 */
	hasValue: function (attr, value)
	{
		if (!this.hasAttribute(attr))
			return false;
		return (this.attributes[attr].indexOf(value) > -1)
	},
	
	/*
	 * Returns the values belonging to a certain attribute
	 *
	 * @param string attr
	 * @return mixed
	 */
	getAttribute: function (attr)
	{
		if (this.attributes[attr])
			if (this.attributes[attr].length == 1)
				return this.attributes[attr][0];
			else
				return this.attributes[attr];
	}

});
