//muestra u oculta el texto "why" en la página de portada
function visible(option, id_left, id_right) {
    if (option == 1) {
      changeOpac(0, id_left);
      document.getElementById(id_left).style.visibility="visible";
      opacity(id_left, 10, 90, 1000)
      document.getElementById(id_right).style.backgroundColor="#eed794";
      document.getElementById(id_right).style.color="#6b6e3a";
    }
    if (option == 0) {
      opacity(id_left, 100, 0, 1000)
      document.getElementById(id_right).style.backgroundColor="#6b6e3a";
      document.getElementById(id_right).style.color="#eed794";
      //document.getElementById(id).style.visibility="hidden";
    }
}
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 + ")";
}



//NO USADAS

//para la función rotateImg(),descomentar
//var imgdir = "img/";
//var imgcount = 0;
//var home_img1 = new Array;
//home_img1[0] = imgdir+"home-img1-1.jpg";
//home_img1[1] = imgdir+"home-img1-2.jpg";
//home_img1[2] = imgdir+"home-img1-3.jpg";

//rotate imgs
function rotateImg(id,img) {
  idimg = id;
  max = img.length;
  if (imgcount == max) { imgcount = 0 };
  image = img[imgcount];
  setTimeout("_rotateImg(idimg,image)",4000);
  imgcount++;
}
function _rotateImg(id,image) {
  document.getElementById(id).src = image;
}

var menu=new Array("menu1","menu2","menu3","menu4","menu5","menu6","menu7","menu8","menu9");

function fadeMenu(id) {
  for (var i in menu) {
    if (menu[i] != id) {
      opacity(menu[i],100,50,100);
	}
  }
}

function unfadeMenu() {
  for (var i in menu) {
    opacity(menu[i],50,100,100);
  }
}


//reubica el logo a la izquierda cuando el usuario hace "scroll"
function moveLogo() {
  if(window.pageYOffset){
	y = window.pageYOffset;
  } else {
    y = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
  }

  if (y >= 100) {
    var logo = imgdir+"logo2.png";
    document.getElementById("logo").style.position="fixed";
    document.getElementById("logo").style.top="15px";
    document.getElementById("logo").style.left="15px";
    document.getElementById("imglogo").style.width="215px";
	document.getElementById("imglogo").src=logo;
    document.getElementById("menu").style.top="120px";
  } else {
    var logo = imgdir+"logo.png";
    document.getElementById("logo").style.position="absolute";
    document.getElementById("logo").style.top="45px";
    document.getElementById("logo").style.left="250px";
    document.getElementById("imglogo").style.width="263px";
	document.getElementById("imglogo").src=logo;
    document.getElementById("menu").style.top="180px";
  }
}

