var dashboard = new Object();
dashboard.extract = new Object();

dashboard.load = function() {
	// place holder for future content
}

/* Definitions for data
 * --------------------
 * { beanName : "Use this parameter to reference a bean in the session",
 *   className : "Use this parameter to create an instance of a class" };
 *
 */
dashboard.action = function(data, callback) {
    $.post("/action",
        data,
        callback
    );
}

dashboard.json = function(data, callback) {
    $.post("/action",
        data,
        callback,
        "json"
    );
}

/* extract.obj
 * param: options.obj(1,2,3,4...) - jQuery Object
 *        options.selector(1,2,3,4...) - jQuery selector
 *        increment - obj/selector number
 * returns jQuery Object
 */
dashboard.extract.obj = function(options, increment) {
    var increment = increment !== undefined ? increment : "";
    
    if (("obj" + increment) in options)   
        return options["obj" + increment];
    if (("selector" + increment) in options)
        return $(options["selector" + increment]);
    return null;
}

dashboard.call = function(options, data, state) {
    var state = state !== undefined ? state : "callback";
    if (state in options)
        options[state](data);
}


dashboard.createCookie = function (name,value,minutes) {
    if (minutes) {
    	var date = new Date();
    	date.setTime(date.getTime()+(minutes*60*1000));
    	var expires = "; expires="+date.toGMTString();
    }
    else {
    	var expires = "";
    }
    document.cookie = name+"="+value+expires+"; path=/";
}

