


   var esIE6 = (window.external && typeof window.XMLHttpRequest == "undefined");


    var cargando = false;

    this.historyListener = function(historyHash) {
		//stateVar = historyHash;
	   if (!cargando){
		   cargando = true;
		 if (historyHash == ''){
		   cargando = false;
		   location.href='index.php';
		 }
		 else{    
			 linkAjax2(historyHash,$('contenidoAjax'));
		 }
	   }
    };
                
// subscribe to unFocus.History
unFocus.History.addEventListener('historyChange', this.historyListener);



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



	   

	     function linkAjax(link, destino,tmpl,nohistorial){
		 
	       var linkoriginal = link;
               
               if(tmpl){
                  link = link + tmpl;
                }
                
                if((!nohistorial) && (!esIE6)){                    
                  //alert('antes');
	          unFocus.History.addHistory(link);

                  //$clear(periodicalFunctionVar);
                                  //CODIGO SEGUIMIENTO GOOGLE
			           //pageTracker._trackPageview(linkoriginal);

		
                }else{   
					
                         linkAjax2(link, destino);
                }

         }


function linkAjax2(link, destino){
			
			//var barra = new progressBar(destino);
				
				//barra.mostrar(); 
				
                                var scroller = new Fx.Scroll(document.body);
                			
				
				new Request.HTML({
					url:link,
					update:destino,
                                        useWaiter: true,
					evalScripts: true,
					onSuccess: function (responseTree, responseElements, responseHTML, responseJavaScript){
                                               // barra.ocultar();
						cargando = false;
						 
						scroller.scrollIntoView($('contendio-general'));
						
                        
						pageTracker._trackPageview(link);
					}		   
				}).post();
          }

         function FormAjax(formulario,destino,tmpl){
			//alert('aca2');
			//var barra = new progressBar(destino);
			//alert(barra);
				//barra.mostrar();  
			new Request.HTML({
			   url:formulario.action,
			   update:destino,
               useWaiter: true,
               waiterOptions:{
                    fxOptions:{duration: 500}
               },
			   evalScripts: true,
			   onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
						//	barra.ocultar();  	  
				}
			}).post(formulario);
		
			return false;
          }    
		
		
	
    
	  

