﻿var imgs1 = new Array(), current1=0;
        
        function rotate_borde()
        {
            var elementDIV = $('borde');
            imgs1 = elementDIV.getElements('img.slide');
            imgs1.each(function(el){
                el.setOpacity(0);
            })

            imgs1[current1].fade(1);
	        setTimeout(yfade,2000);
        }

        function yfade()
        {
	        nIndex = imgs1[current1+1]?current1+1:0;
	        imgs1[current1].fade(0);
	        imgs1[nIndex].set('tween', {transition: Fx.Transitions.Sine.easeOut,duration: 1000});
	        imgs1[nIndex].tween('opacity', 1);
	        current1 = nIndex;
	        setTimeout(yfade,2000);
        }
    
     var imgs2 = new Array(), current2=0;
        
        function rotate_servicios()
        {
            var elementDIV = $('content2');
            imgs2 = elementDIV.getElements('img.slide');
            imgs2.each(function(el){
                el.setOpacity(0);
            })

            imgs2[current2].fade(1);
	        setTimeout(zfade,4000);
        }

        function zfade()
        {
	        nIndex = imgs2[current2+1]?current2+1:0;
	        imgs2[current2].fade(0);
	        imgs2[nIndex].set('tween', {transition: Fx.Transitions.Sine.easeOut,duration: 2000});
	        imgs2[nIndex].tween('opacity', 1);
	        current2 = nIndex;
	        setTimeout(zfade,4000);
        }   
		
		var imgs2 = new Array(), current2=0;
        
        function rotate_empre()
        {
            var elementDIV = $('content4');
            imgs2 = elementDIV.getElements('img.slide');
            imgs2.each(function(el){
                el.setOpacity(0);
            })

            imgs2[current2].fade(1);
	        setTimeout(zfade,4000);
        }

        function zfade()
        {
	        nIndex = imgs2[current2+1]?current2+1:0;
	        imgs2[current2].fade(0);
	        imgs2[nIndex].set('tween', {transition: Fx.Transitions.Sine.easeOut,duration: 2000});
	        imgs2[nIndex].tween('opacity', 1);
	        current2 = nIndex;
	        setTimeout(zfade,4000);
        }   
        
        
    var scroll1 = new Scroller('drag', {area: 150, velocity: 1});
var scroll2 = new Scroller('mousemove', {area: 100, velocity: 1});
 
// Drag
$('drag').addEvent('mousedown', function() {
	this.setStyle('cursor', 'url(/demos/Scroller/closedhand.cur), move');
	scroll1.start();
});
$('drag').addEvent('mouseup', function() {
	this.setStyle('cursor', 'url(/demos/Scroller/openhand.cur), move');
	scroll1.stop();
});
 
 
// Mousemove
$('mousemove').addEvent('mouseover', scroll2.start.bind(scroll2));
$('mousemove').addEvent('mouseout', scroll2.stop.bind(scroll2));

// Documento JavaScript
// Esta función cargará las paginas
function llamarasincrono(url, id_contenedor){
var pagina_requerida = false
if (window.XMLHttpRequest) {// Si es Mozilla, Safari etc
pagina_requerida = new XMLHttpRequest()
} else if (window.ActiveXObject){ // pero si es IE
try {
pagina_requerida = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){ // en caso que sea una versión antigua
try{
pagina_requerida = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
pagina_requerida.onreadystatechange=function(){ // función de respuesta
cargarpagina(pagina_requerida, id_contenedor)
}
pagina_requerida.open('GET', url, true) // asignamos los métodos open y send
pagina_requerida.send(null)
}
// todo es correcto y ha llegado el momento de poner la información requerida
// en su sitio en la pagina xhtml
function cargarpagina(pagina_requerida, id_contenedor){
if (pagina_requerida.readyState == 4 && (pagina_requerida.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(id_contenedor).innerHTML=pagina_requerida.responseText
}
 var imgsf = new Array(), currentf=0, timer;
 function rotate_boligrafos()
         {
         $('grande').src = fotos[currentf];
        var preloadimage = new Image();
        preloadimage.src = fotos[currentf+1]; // Preload Next Image
        timer = setTimeout(ofade,4000);
         }
        function ofade()
       {
       var nIndex = fotos[currentf+1]?currentf+1:0;
       $('grande').setOpacity(0);
       $('grande').src = fotos[nIndex];
       var myFx = new Fx.Tween('grande', {property: 'opacity',transition: Fx.Transitions.Sine.easeOut,duration: 2000});
     myFx.start(1);
    currentf = nIndex;
    nIndex = fotos[currentf+1]?currentf+1:0;
   var preloadimage = new Image();
   preloadimage.src = fotos[nIndex]; // Preload Next Image
   timer = setTimeout(ofade,4000);
   }
   function cambiar(imagen){
  clearTimeout(timer);
  currentf = fotos[imagen-1]?imagen-1:fotos.length-1;
  var nIndex = fotos[currentf+1]?currentf+1:0;
  var myFx = new Fx.Tween('grande', {property: 'opacity'});
  $('grande').setOpacity(0);
  $('grande').src = fotos[nIndex];
  myFx.start(1);
  currentf = nIndex;
  nIndex = fotos[currentf+1]?currentf+1:0;
  var preloadimage = new Image();
  preloadimage.src = fotos[nIndex]; // Preload Next Image
  timer = setTimeout(ofade,4000);
  }
