/**
 * Class for creating plans section.
 * @class This is the Plans class.  
 *
 * @param {Array} conf
 *
 * @param {String} conf.id The id div of plans element
 * @param {Function} conf.callback The callback function on click event
 *
 */
intelli.plans = function(conf)
{
	var id = conf.id;
	var callback = (typeof conf.callback == 'function') ? conf.callback : function(){};
	var idPlan = (typeof conf.idPlan == 'undefined') ? false : conf.idPlan;

	this.init = function()
	{
		if(idPlan)
		{
			setPlan();
		}

		$("#" + id + " input[type=radio]").click(callback);
	};

	/**
	 * Return id current plan
	 *
	 * @return {Integer}
	 */
	this.getPlanCost = function()
	{
		if($('#plans').length > 0)
		{
			var id_plan = $("#plans input[type='radio']:checked").val();
			var plan_cost = $("#planCost_" + id_plan).val();
			
			return plan_cost;
		}

		return false;
	};

	var setPlan = function()
	{
		$("#" + id + "> p > input[type=radio]").each(function()
		{
			if($(this).val() == idPlan)
			{
				$(this).attr('checked', 'checked');
			}
		});
	};
};

