      var esIE6 = (

          window.external &&

          typeof window.XMLHttpRequest == "undefined"

      );


           var cargando = false;

           this.historyListener = function(historyHash) {
                       if (!cargando){
                           cargando = true;
                         if (historyHash == ''){
                           cargando = false;
                           location.href='index.php';
                         }else{
                             linkAjax2(historyHash,$('capaAjax'));
                         }
                       }

            };
                // subscribe to unFocus.History
            unFocus.History.addEventListener('historyChange', this.historyListener);



         function botonVolver(){
             if(!esIE6){
               window.history.back();
             }
         }

		 var progressBar = new Class({
		 	initialize: function(destino){
			  this.destino = destino;
			  var tam = this.destino.getSize().size;
			  this.MyBarra=new Element('div',{
					'styles':{
						width: tam.x,
						height:tam.y,
						background: 'url(./templates/copbad9/img/carga.gif) center no-repeat #FFFFFF',
						position:'absolute',
						opacity : 0
					}
				}).setHTML('&nbsp;');
		    },

			mostrar: function(){
				$$('body').adopt(this.MyBarra);
				var pos = this.destino.getPosition();
				this.MyBarra.setStyle('z-index','99');
				this.MyBarra.setStyles({
					top: pos.y,
					left: pos.x,
					opacity: 0.6
				});
			},

			ocultar: function(){
				this.MyBarra.setStyle('opacity','0');
				this.MyBarra.remove();
			}
		})



	      function linkAjax(link, destino,nohistorial)
		  {
               /* if((!nohistorial) && (!esIE6)){
                  unFocus.History.addHistory(link);
                }else{*/
                    linkAjax2(link, destino);
           //     }

         }

   	      function linkAjax2(link, destino)
		  {

				new Request.HTML({
						   url:link,
						   update:destino,
                           useWaiter: true,
                           waiterOptions: {
                                fxOptions: {duration: 500}
                              },
						   evalScripts: true,
						   onSuccess: function (responseTree, responseElements, responseHTML, responseJavaScript){
                           
                           //  pageTracker._trackPageview(link);
                               //var scroller = new Fx.Scroll(document.body);
                               //scroller.scrollIntoView($('capaAjax'));
                              
                             cargando = false;
						   }


						  }).post();
         }


          function FormAjax(formulario,destino) {

						new Request.HTML({
							   url:formulario.action,
							   update:destino,
                               useWaiter: true,
                               waiterOptions: {
                                    fxOptions: {duration: 500}
                                  },
							   evalScripts: true,
							   onSuccess: function (responseTree, responseElements, responseHTML, responseJavaScript){

									/*barra.ocultar();
									barra = null;*/
							   }
							  }).post(formulario);




				/*
				formulario.send({
					update: destino,
					evalScripts: false,
					onComplete: function(xml) {

						//alert(xml);

					//	$('barraPrecarga').setStyle('display','none');
					//	$('capaAjax').setStyle('display','block');
						//destino.removeClass('ajax-loading');
						//pageTracker._trackPageview(form.action );
						this.evalScripts();
						//barra.ocultar();
						//barra = null;
					}
				});
               */

				return false;
           }

		
		
      function abrirImagenes(destino){
          Mediabox.open('index.php?option=com_media&view=images&tmpl=component&origen='+destino, 'Seleccione una imagen - luego CLOSE para cerrar', 'mediabox[1000 430]')
      }		
	  
     function dialogoModal(link,vuelta,texto,alto,ancho){
          Mediabox.open(link+'&vuelta='+vuelta, texto, 'mediabox['+alto +' ' +ancho +']');
      }		
	  
	  
