// Juan Matias de la Camara Beovide
// TJF - Tiger JavaScrip Framework
// Abril 2008

// Objeto para tomar tiempos entre paginas. Tiene la capacidad 
// transmitirse en cookies o por post.

// Modos de instanciar el objeto:
// var o = new TJF_Timer({name : 'nombre'});
// var o = new TJF_Timer({name : 'nombre', method : TJFCTES_TBP.METHOD.COOKIES });
//
// Metodos:

//Variables globales del timer Between Pages
var TJFCTES_TBP = {
	METHOD : {	COOKIES : 0,
				POST : 1 }
}

// Lo creo como clase
var TJF_TimerBP = Class.create();

// Especifico los defaults
TJF_TimerBP.DEFAULTS = {
	name : "TJF_TimerBP",
	method : TJFCTES_TBP.METHOD.COOKIES
};

// Armo la clase con el prototype
TJF_TimerBP.prototype = {
	// variables
		method : "",
		timer : new TJF_Timer({name : name}),
	
	//metodos
		// constructor
		initialize : function (options){
			this.options = Extend(options, TJF_TimerBP.DEFAULTS );
			this.name = this.options.name;
			this.method = this.options.method;
		},

		start : function() { this.timer.start(); },
		stop : function() { this.timer.stop(); },
		getTime : function() { return(this.timer.getTime()); },
		prepare : function(formId){
			if (this.method == TJFCTES_TBP.METHOD.COOKIES){
				var myCook = new TJF_Cookie("galleta"+this.timer.getName(),"","");
				myCook.setValue(this.timer.serialize());
				myCook.setCookie();
			}else if(this.method == TJFCTES_TBP.METHOD.POST){
				// hacer el metodo para hacer el post
				
			}
		},
		retrieve : function(name) {
			if (this.method == TJFCTES_TBP.METHOD.COOKIES){
				var myCook = new TJF_Cookie("galleta"+this.timer.getName(),"","");
				if(myCook.getCookie() != -1){
					this.timer.unserialize(myCook.getValue());
				} 
				
			}else if(this.method == TJFCTES_TBP.METHOD.POST){
				// hacer el metodo para hacer el post
			}
		}
}

