var posic;
var cuenta=0;
var navegador=navigator.appName;
var apa=1;
var desa=0;
var registro=0;
var pagina;
function animacion(){
//de izquierda a derecha
//	var largoTot=0;
//	for(i=0; i<5; i++){
//	largoTot+=imgs[i].offsetWidth;
//	};
//var posInicial=largoTot-imgs[0].offsetWidth;
//document.getElementById("tira").style.left=-posInicial+"px";
pagina="home";
espera();
};
function espera(){
	var veces=imgs.length;
	cuenta+=1;
	if(cuenta<veces){
		setTimeout(movi,4000);
	}else{
		cuenta=1;
		document.getElementById("tira").style.left=0+"px";
		setTimeout(movi,4000);
	};

};

function transicion(curva,ms,callback){
    this.ant=0.01;
    this.done_=false;
    var _this=this;
    this.start=new Date().getTime();
    this.init=function(){
        setTimeout(function(){
                if(!_this.next()){
                    callback(1);
                    _this.done_=true;
                    window.globalIntervalo=0;
                    if(pagina=="home"){
                    espera();
                	}
                	if(pagina=="rotacion"){
                    preEsfuma();
                	}              
                    return;
                }
                callback(_this.next());
                _this.init();
            },13);
    }
    this.next=function(){
        var now=new Date().getTime();
        if((now-this.start)>ms)
            return false;
        return this.ant=curva((now-this.start+.001)/ms,this.ant);
    }
}
function movi(){
	
    var inicio=document.getElementById("tira").offsetLeft,fin=document.getElementById("tira").offsetLeft-750;
    var t=new transicion(senoidal,6000,function(p){
        document.getElementById("tira").style.left=(inicio+((fin-inicio)*p))+'px';
    });
    t.init();
    t=null;
}
function senoidal(p,a){
    return (1 - Math.cos(p * Math.PI)) / 2;
} 


//rotacionnnnnnnnnnnnnnnnnnnnnnnn

function rotacion(){
	pagina="rotacion";
	var cantImg=imgs2.length;
	var cont=cantImg;
		for(x=0; x<cantImg; x++){
			imgs2[x].style.zIndex=cont;
			if(x>0){	
		     	if(navegador =="Microsoft Internet Explorer"){	    
                	imgs2[x].style.filter="alpha(opacity=0)";
    			}else{
	   			    imgs2[x].style.opacity=0;
        		}
			}
			cont-=1;
			};
	preEsfuma();	
};
	
function preEsfuma(){
	if(registro<((imgs2.length)-1)){
		desa=imgs2[registro];
		sig=registro+1;
		apa=imgs2[sig];		
		registro+=1;
		setTimeout("esfumar()",2000);
	}else{
		desa=imgs2[registro];
		apa=imgs2[0];
		registro=0;
		setTimeout("esfumar()",2000);
		};	
};


function esfumar(){
	if(navegador =="Microsoft Internet Explorer"){
		 //desaparece
		var inicio=100,fin=0;
	    //aparece
	    var inicio2=0,fin2=100;	
	}else{
	    //desaparece
		var inicio=1,fin=0;
	    //aparece
	    var inicio2=0,fin2=1;
	}
    var t=new transicion(linear,500,function(p){
      if(navegador =="Microsoft Internet Explorer"){
	     var uno=(inicio+((fin-inicio)*p));
         var dos=(inicio2+((fin2-inicio2)*p));
         desa.style.filter="alpha(opacity="+uno+")";
         apa.style.filter="alpha(opacity="+dos+")";
    }else{
	   
        apa.style.opacity=(inicio2+((fin2-inicio2)*p));
	     desa.style.opacity=(inicio+((fin-inicio)*p));
        }
    });
    t.init();
    t=null;
}
function linear(p,a){
    return p;
} 


//para el cambio de colores 
var guarda="";
function mchic(nombre){
	if(guarda !=""){
		document.getElementById(guarda).src="images/"+guarda+"/"+guarda+".jpg";
		};
	document.getElementById(nombre).src="images/"+nombre+"/"+nombre+"h.jpg";
	guarda=nombre;
};
function hoover(nombre){
	document.getElementById(nombre).src="images/"+nombre+"/"+nombre+"h.jpg";
	};
function blurr(nombre){
	if(guarda !=nombre){
	document.getElementById(nombre).src="images/"+nombre+"/"+nombre+".jpg";
	};
};	
function subMenu(muestra){
	if(muestra){
		document.getElementById("subMenu").style.display="block";
	}else{
		document.getElementById("subMenu").style.display="none";
	};
};	