// JavaScript Document
function cambioImagen(id,srcImg) {
		document.getElementById(id).src = '../img/'+ srcImg;
}

function Reloj_es(){ 

var mes2 = new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
var dia2 = new Array("Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado");


fecha = new Date() ;
Hora = fecha.getHours() ;
Minutos = fecha.getMinutes() ;
Segundos = fecha.getSeconds();
dia = fecha.getDate();
diaSem = dia2[fecha.getDay()];
mes = mes2[fecha.getMonth()];
anio = fecha.getFullYear();


if (Hora<=9)
Hora = "0" + Hora

if (Minutos<=9)
Minutos = "0" + Minutos

if (Segundos<=9)
Segundos = "0" + Segundos

hor =  diaSem+", "+Hora + ":" + Minutos + ":" + Segundos
dias = dia+" "+mes+" "+anio;

document.getElementById('fec').innerHTML = dias
document.getElementById('rel').innerHTML = hor


setTimeout("Reloj_es()",1000) 
}

function Reloj_en(){ 

var mes2 = new Array("January","Februry","March","April","May","June","July","August","September","October","November","Dicember");
var dia2 = new Array("Sunday","Monday","Tuesday","Wendsday","Thursday","Friday","Saturday");

fecha = new Date() ;
Hora = fecha.getHours() ;
Minutos = fecha.getMinutes() ;
Segundos = fecha.getSeconds();
dia = fecha.getDate();
diaSem = dia2[fecha.getDay()];
mes = mes2[fecha.getMonth()];
anio = fecha.getFullYear();


if (Hora<=9)
Hora = "0" + Hora

if (Minutos<=9)
Minutos = "0" + Minutos

if (Segundos<=9)
Segundos = "0" + Segundos

hor =  diaSem+", "+Hora + ":" + Minutos + ":" + Segundos
dias = dia+" "+mes+" "+anio;

document.getElementById('fec').innerHTML = dias
document.getElementById('rel').innerHTML = hor


setTimeout("Reloj_en()",1000) 
}


function ScrollUp(speed){
    	if(document.getElementById){
    		if(parseInt(obj[active].style.top) < 0){
    			obj[active].style.top = parseInt(obj[active].style.top) + speed + "px";
		}
    		timerID = setTimeout("ScrollUp("+speed+")",10);
    	}
}

function ScrollDown(speed){
    	if(document.getElementById){                        
    		if(parseInt(obj[active].style.top) > document.getElementById('cont').offsetHeight - obj[active].offsetHeight){ 
    			obj[active].style.top = parseInt(obj[active].style.top) - speed + "px";
		}
    		timerID = setTimeout("ScrollDown("+speed+")",10);
    	}
}

function ScrollStop(){
    	if(document.getElementById){
    		clearTimeout(timerID);
    	}
}

function ScrollPageInit(numero) {
    	if(document.getElementById){
		
		    active = numero;

    		obj = document.getElementById("cont").getElementsByTagName("div");
    		obj['page'+(numero+1)].style.visibility = "visible";
    		obj['page'+(numero+1)].style.top = 0;				
    	}	    	
}


var eActivo=null;

function cambiar(id)
{
	if(eActivo!=null)
	{
		document.getElementById(eActivo).style.display="none";
		document.getElementById(id).style.display="block";
		
	}
	else
		document.getElementById(id).style.display="block";
		
	eActivo=id;
}

function ver(id)
{
	document.getElementById(id).style.display="block";
}

function ocultar(id)
{
	document.getElementById(id).style.display="none";
}

//**OPACIDAD**//
function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

function validar() {
    // Array con todos los elementos del formulario
    camposTexto = form.elements;

    for (x=0; x < camposTexto.length; x++) {
      if (camposTexto[x].value == '' && camposTexto[x].type=='text') {
       alert("El campo " + camposTexto[x].name + " está vacio y es OBLIGATORIO");
       return false;
      }
    }
    <!--alert("Todo está correctamente");-->
    return validarEmail(this.form.email.value);
  }
  
function validarEmail(valor) {
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
      <!--alert("La dirección de email " + valor + " es correcta.") -->
      return true;
    } else {
      alert("La dirección de email es incorrecta.");
      return false;
    }
  }
  
function irA(menu) {
	window.location.href = menu.options[menu.selectedIndex].value;
	}
