function slideSwitch() {
    var $active = $('#slideshow IMG.active');
    var $active2 = $('#slideshow2 IMG.active');
    var $active3 = $('#slideshow3 IMG.active');
    var $active4 = $('#slideshow4 IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');
    if ( $active2.length == 0 ) $active2 = $('#slideshow2 IMG:last');
    if ( $active3.length == 0 ) $active3 = $('#slideshow3 IMG:last');
    if ( $active4.length == 0 ) $active4 = $('#slideshow4 IMG:last');
    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    var $next2 =  $active2.next().length ? $active2.next()
        : $('#slideshow2 IMG:first');

    var $next3 =  $active3.next().length ? $active3.next()
        : $('#slideshow3 IMG:first');

    var $next4 =  $active4.next().length ? $active4.next()
        : $('#slideshow4 IMG:first');


    // uncomment the 3 lines below to pull the images in random order

    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');
    $active2.addClass('last-active');
    $active3.addClass('last-active');
    $active4.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
    $next2.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active2.removeClass('active last-active');
        });
    $next3.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active3.removeClass('active last-active');
        });
    $next4.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active4.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});

function menu(id)
{
if(id==1){
document.location.href="index.php";
}



if(id==2){
document.getElementById('menu1').style.color = "#ffffff";
document.getElementById('menu1').style.fontWeight = "normal";

document.getElementById('menu2').style.color = "#666666";
document.getElementById('menu2').style.fontWeight = "bold";

document.getElementById('menu3').style.color = "#ffffff";
document.getElementById('menu3').style.fontWeight = "normal";
document.getElementById('menu4').style.color = "#ffffff";
document.getElementById('menu4').style.fontWeight = "normal";
document.getElementById('menu5').style.color = "#ffffff";
document.getElementById('menu5').style.fontWeight = "normal";
}
if(id==3){
document.getElementById('menu1').style.color = "#ffffff";
document.getElementById('menu1').style.fontWeight = "normal";
document.getElementById('menu2').style.color = "#ffffff";
document.getElementById('menu2').style.fontWeight = "normal";

document.getElementById('menu3').style.color = "#666666";
document.getElementById('menu3').style.fontWeight = "bold";

document.getElementById('menu4').style.color = "#ffffff";
document.getElementById('menu4').style.fontWeight = "normal";
document.getElementById('menu5').style.color = "#ffffff";
document.getElementById('menu5').style.fontWeight = "normal";
}
if(id==4){
document.getElementById('menu1').style.color = "#ffffff";
document.getElementById('menu1').style.fontWeight = "normal";
document.getElementById('menu2').style.color = "#ffffff";
document.getElementById('menu2').style.fontWeight = "normal";
document.getElementById('menu3').style.color = "#ffffff";
document.getElementById('menu3').style.fontWeight = "normal";

document.getElementById('menu4').style.color = "#666666";
document.getElementById('menu4').style.fontWeight = "bold";

document.getElementById('menu5').style.color = "#ffffff";
document.getElementById('menu5').style.fontWeight = "normal";
}
if(id==5){
document.getElementById('menu1').style.color = "#ffffff";
document.getElementById('menu1').style.fontWeight = "normal";
document.getElementById('menu2').style.color = "#ffffff";
document.getElementById('menu2').style.fontWeight = "normal";
document.getElementById('menu3').style.color = "#ffffff";
document.getElementById('menu3').style.fontWeight = "normal";
document.getElementById('menu4').style.color = "#ffffff";
document.getElementById('menu4').style.fontWeight = "normal";

document.getElementById('menu5').style.color = "#666666";
document.getElementById('menu5').style.fontWeight = "bold";
}





}




function valida(){




var mensaje = "";

        if(document.getElementById('nombre').value==""){
        mensaje= mensaje+"Debe llenar el campo nombre.\n";
        }
        if(document.getElementById('consulta').value==""){
        mensaje= mensaje+"Debe llenar el campo Consulta.\n";
        }
        if(document.getElementById('telefono').value==""   ){
        mensaje= mensaje+"Debe llenar el campo Telefono.\n";
        }
        if(document.getElementById('mail').value==""   ){
        mensaje= mensaje+"Debe llenar el campo E-mail.\n";
        }

        if (mensaje != ""){
        alert(mensaje);
        return false;
        }
        else{
        document.getElementById('enviado').value=1;
        return true;
        }

}
var aphrq=false;
var aphrq2=false;
var aphrq3=false;
//Empresa-----------------------------------------------------------------------
    function empresa(){



        if(window.XMLHttpRequest){
             aphrq = new XMLHttpRequest();
        } else {
             aphrq = new ActiveXObject("Microsoft.XMLHTTP");
        }

        var url="empresa.php";
        aphrq.onreadystatechange = procesa_empresa;
        aphrq.open("GET",url,true);
        aphrq.send(null);
   }

    function procesa_empresa(){
       if(aphrq.readyState==1){
          document.getElementById("principal").innerHTML = "<img style='text-align: center;' src='images/cargando.gif' alg='Loading...'>";
          //document.getElementById("div3").innerHTML = "<img align='center' src='images/lightbox-ico-loading.gif' alg='Loading...'>";
      }
       if(aphrq.readyState==4){
           if(aphrq.status == 200){
                document.getElementById("principal").innerHTML=aphrq.responseText;

           }
       }
    }
//sucursales

 function sucursales(){



        if(window.XMLHttpRequest){
             aphrq = new XMLHttpRequest();
        } else {
             aphrq = new ActiveXObject("Microsoft.XMLHTTP");
        }

        var url="sucursales.php";
        aphrq.onreadystatechange = procesa_sucursal;
        aphrq.open("GET",url,true);
        aphrq.send(null);
   }

    function procesa_sucursal(){
       if(aphrq.readyState==1){
          document.getElementById("principal").innerHTML = "<img style='text-align: center;' src='images/cargando.gif' alg='Loading...'>";

      }
       if(aphrq.readyState==4){
           if(aphrq.status == 200){
                document.getElementById("principal").innerHTML=aphrq.responseText;

           }
       }
    }

//Servicios---------------------------------------------------------------------

function servicios(){



        if(window.XMLHttpRequest){
             aphrq = new XMLHttpRequest();
        } else {
             aphrq = new ActiveXObject("Microsoft.XMLHTTP");
        }

        var url="servicios.php";
        aphrq.onreadystatechange = procesa_servicios;
        aphrq.open("GET",url,true);
        aphrq.send(null);
   }

    function procesa_servicios(){
       if(aphrq.readyState==1){
          document.getElementById("principal").innerHTML = "<img style='text-align: center;' src='images/cargando.gif' alg='Loading...'>";

      }
       if(aphrq.readyState==4){
           if(aphrq.status == 200){
                document.getElementById("principal").innerHTML=aphrq.responseText;

           }
       }
    }


//Contacto----------------------------------------------------------------------
 function contacto(){


        if(window.XMLHttpRequest){
             aphrq = new XMLHttpRequest();
        } else {
             aphrq = new ActiveXObject("Microsoft.XMLHTTP");
        }

        var url="contacto.php";
        aphrq.onreadystatechange = procesa_contacto;
        aphrq.open("GET",url,true);
        aphrq.send(null);
   }

    function procesa_contacto(){
       if(aphrq.readyState==1){
          document.getElementById("principal").innerHTML = "<img style='text-align: center;' src='images/cargando.gif' alg='Loading...'>";
          //document.getElementById("div3").innerHTML = "<img align='center' src='images/lightbox-ico-loading.gif' alg='Loading...'>";
      }
       if(aphrq.readyState==4){
           if(aphrq.status == 200){
                document.getElementById("principal").innerHTML=aphrq.responseText;

           }
       }
    }
