/*---------------------------------------- APLICACION ----------------------------------------*/
//Placom.cargarJsg('placom/VentanaWC');

Aplicacion = Class.create({
	initialize:function() 
  {
  	if(typeof(Cargador) != 'undefined') 
  		this.cargador = new Cargador({anchoPag: 800});
  	if(typeof(Ventana) != 'undefined') 
  		ventana = new Ventana();
  	
  	document.observe('dom:loaded', function()
	{
		// Google Analytics
		var gaJsHost = ('https:' == document.location.protocol ? 'https://ssl.' : 'http://www.') + 'google-analytics.com/ga.js';
	    var script = new Element('script', {'src': gaJsHost});
	    var gaTrack = function() 
		{
	      if(!script.readyState || /loaded|complete/.test(script.readyState)) 
	      {
	      	_gaq.push(['_setAccount', 'UA-503372-19']);
			_gaq.push(['_setDomainName', 'none']);
			_gaq.push(['_setAllowLinker', true]);
			_gaq.push(['_trackPageview']);
	      }
	    };
	    script.observe('load', gaTrack);
	    script.observe('readystatechange', gaTrack);
	    document.body.appendChild(script);
	});  	
  },
  inicializarPaginado:function(ruta)
  {
	ruta = new Template(unescape(ruta));
	$$('select.selectorPaginas').each(function(select){
	select.observe('change', function(){
		Placom.irA(ruta.evaluate({pagina: select.getValue()}));
		});
	});
  },
  clickBannerSuscribete:function(tipo)
  {
	Placom.irA(Placom.getRutaIni()+'suscripcion/inicio/tipo/'+tipo);
  },
  onPagCargadaCrearEventoTipoSuscripcion:function(tipo)
  {
	  //Campos para el Email
	  this.checkEmail = $('formSuscripcion_via_email');
	  this.cuerpoTextoEmail = $('cuerpoTextoEmail');
	  //Campos para el Telefono
	  this.checkSms = $('formSuscripcion_via_sms');
	  this.cuerpoTextoTelefono = $('cuerpoTextoTelefono');
	  	  
	  if(tipo == 'email'){
		this.checkEmail.checked = true;
	  	this.cuerpoTextoEmail.removeClassName('oculto');
	  	this.cuerpoTextoTelefono.addClassName('oculto');
  	  }	
	  else if(tipo == 'sms'){
		this.checkSms.checked = true;
		this.cuerpoTextoTelefono.removeClassName('oculto');
		this.cuerpoTextoEmail.addClassName('oculto');
	  }

	  if(Prototype.Browser.IE)
		  this.checkEmail.observe('click', this.onChangeViaEmail.bind(this));
	  else
		  this.checkEmail.observe('change', this.onChangeViaEmail.bind(this));
	  
	  if(Prototype.Browser.IE)
		  this.checkSms.observe('click', this.onChangeViaSms.bind(this));
	  else
		  this.checkSms.observe('change', this.onChangeViaSms.bind(this));
  },
  onChangeViaEmail:function()
  {
	  if(this.checkEmail.checked){
		  this.cuerpoTextoEmail.removeClassName('oculto');
	  }
	  else{
		  this.cuerpoTextoEmail.addClassName('oculto');
	  }
  },
  onChangeViaSms:function()
  {
	  if(this.checkSms.checked){
		  this.cuerpoTextoTelefono.removeClassName('oculto');
	  }
	  else{
		  this.cuerpoTextoTelefono.addClassName('oculto');
	  }
  }
});
var app = new Aplicacion();

