/**
 * @module co2calc
 * @requires jQuery, tbelt, json
*/

(function($j, $tb) {

    /**
    * A Widget extension allowing the user to manage their current and previous calculator results.
    * @class Actions
    * @namespace co2calc.widget
    * @extends co2calc.widget.Widget
    */
    co2calc.widget.Actions = (function() {

        /**
        * Employs the Widget constructor.
        * @constructor
        * @param {Object} opts An object whose properties are copied to the Household instance.
        */
        function Actions(opts) {
            var I = this;
            co2calc.widget.Widget.apply(I, arguments);

        }

        $j.extend(Actions.prototype, co2calc.widget.Widget.prototype,
        {
            /**
             * The name of this Actions widget instance.
             * @property name
             * @type String
             * @default "Actions"
             */
			name: "Actions",
			/**
			 * Returns an empty object, because nothing in this Widget needs to be saved.
			 * @method toJSON
			 */
			toJSON:function(){return {}},
			fromJSON:function(){return this;}

        });

        return Actions;

    })();


    /**
    * ActionsView Class Description
    * @namespace co2calc.widget
    * @class ActionsView
    * @extends co2calc.widget.WidgetView
    */
    co2calc.widget.ActionsView = (function() {

        /**
        * Employs WidgetView constructor;
        * @constructor
        * @param {Object} opts An object whose properties are copied to the ActionsView instance.
        */
        function ActionsView(opts) {
            var I = this;
            co2calc.widget.WidgetView.apply(I, arguments);
            //console.log(I.calculate);
			
        }

        $j.extend(true, ActionsView.prototype, co2calc.widget.WidgetView.prototype,
        {
			/**
			 * The name of the ActionsView instance.
			 * @property name
			 * @type String
			 * @default "View"
			 */
			name: "View",
			
			/**
			 * The data for this ActionsView.
			 * @property data
			 * @type Object
			 * @default {}
			 */
			data:{},
			
			/**
            * Employs WidgetView.init();
            * @method init
            * @return {ActionsView} This ActionsView instance.
            */
			init:function(){
				var I = this;
				co2calc.widget.WidgetView.prototype.init.apply(I, arguments);
				
				
				return I;
				
			},
			
			/**
			* Sends the user to the balance page with the appropriate CO2 totals.
			* @method actNow
			*/
			actNow:function(forceNewWindow){
				var baseUrl = "/Calculator/Balance.aspx?",
				parms=[];
				if(co2calc.widgets["Household"]) parms.push("home="+co2calc.widgets["Household"].total());
				if(co2calc.widgets["Driving"]) parms.push("car="+co2calc.widgets["Driving"].total());
				if(co2calc.widgets["AirTravel"]) parms.push("travel="+co2calc.widgets["AirTravel"].total());
				
				co2calc.gotoUrl(baseUrl+parms.join("&"), forceNewWindow);
			}
			

        });

        return ActionsView;

    })();




})(jQuery, tbelt);





