/* 
* Session cookie prototype 
* ver 0.2
*
* History:
*	0.2	10.11.08/goshi	remove bug with initial setting for session cookie
*	0.1	10.11.08/goshi
*/
function pphpSession(){
	this._init();
}

pphpSession.prototype = {

	// because session data is dynamic - we must not set _values for long time - only for temporary cache for updating
	_values: new Object(),
	
	_init: function(){
		this._values = portal.storage.get(session_name, 'object');//getCookieArr(session_name);
		
		if (this._values == undefined || this._values == false){
			
			this._values = new Object();
			portal.storage.set(session_name, this._values, 'object');
			/*var expires = new Date();
			expires.setTime(expires.getTime() + max_cookie_life);
			
			setCookieArr(session_name, this._values, expires, "/");*/
					
		}
		
		// setting up switchers
		
		if (this._values['switchers'] == undefined){
		
			this._values['switchers'] = new Object();
			this.set('switchers', this._values['switchers']);
			
		}
	},
	
	get: function(valueName){
		this._values = portal.storage.get(session_name, 'object');
		//this._values = getCookieArr(session_name);
		if (this._values[valueName] != undefined && this._values[valueName] != ''){
			return this._values[valueName];
		}
	},
	
	set: function(valueName, value){

		this._values = portal.storage.get(session_name, 'object');//getCookieArr(session_name);

		this._values[valueName] = value;

		/*var expires = new Date();
		expires.setTime(expires.getTime() + max_cookie_life);
		setCookieArr(session_name, this._values, expires, "/");*/
		portal.storage.set(session_name, this._values, 'object');
	}

};

portal.session = new pphpSession();