prevision = Class.create();

prevision.prototype = {
	
	initialize: function(identificador, url) {
		this.Estado = 0;
		this.identificador = identificador;
		
		this.cValue=getCookie('pred_'+url);

		
		this.url = url;
		
		this.HacerConsulta();
	},

	HacerConsulta: function(){
		var url_consulta='';
		url_consulta = this.url+'/consulta';

		url_consulta+=( (this.cValue==null
)?'':'/'+this.cValue );

		this.cargando();

		var myAjax = new Ajax.Request(
				url_consulta,
				{
					method: 'get',
					onComplete: this.escribirConsulta.bind(this)

				});
		return;
	},

	cargando: function(){
		$(this.identificador).innerHTML = '<div align="center"><img src="/imag/ajax_active.gif" width="16" height="16" /></div>';

	},
	HacerAccion: function (accion, hour, minutes){
		var url_accion='';
		var strNextDay;
		var nextDay = new Date();
		var expires = new Date();
		var pars = '';


		nextDay.setDate
(nextDay.getDate()+1);
		nextDay.setHours(hour);
		nextDay.setMinutes(minutes);
	
		expires.setDate(nextDay.getDate()+365);
	
		strNextDay = nextDay.getFullYear()+'-'+(nextDay.getMonth()+1)+'-'+nextDay.getDate()+'-'+nextDay.getHours()+'-'+nextDay.getMinutes()+'-00';

	
	//	setCookie ( 'pred_'+url,  strNextDay , expires.toString());

		this.cargando();

		url_accion= this.url + '/'+accion+'/'+strNextDay;
		var myAjax = new Ajax.Request(

				url_accion, 
				{
					method: 'get', 
					onComplete: this.escribirConsulta.bind(this)
				});
		return;
	},


	escribirConsulta: function(originalRequest) {
		$(this.identificador
).innerHTML = originalRequest.responseText;
	},

	mostrar_ocultar: function() {
		if (this.Estado==0) {
			Element.show ('datos_para_hoy');
			$('link_mostrar_datos_hoy').innerHTML = 'Pron&oacute;stico para hoy (*)<img src="/imagenes/iconos/flecha2.gif" width="18" height="17" border="0" />';

			this.Estado = 1;
		}
		else {
			Element.hide('datos_para_hoy');
			$('link_mostrar_datos_hoy').innerHTML = 'Pron&oacute;stico para hoy (*)<img src="/imagenes/iconos/flecha1.gif" width="18" height="17" border="0" />'

			
			this.Estado = 0;
		}
		return false;
	}
}
