// JavaScript Document
//
//FADE INTRO
//
var fadestart1=100;
var iMax1=0;
var timer1int=30;
var timerhint=5000;
var timer1on=0;
var timerhid=0;
var timer1id=0;
var timer2id=0;
var iTitCnt=0;
var iTxtCnt=0;
var DivTit=0;
var DivTxt=0;
var ie5=(document.all && document.getElementById);

function fadetxt() {
  DivTit=document.getElementById('imageClaim');
  //DivTxt=document.getElementById('div_texto');
  iTitCnt=fadestart1;
  //iTxtCnt=fadestart2;
  setTimer1();
  //setTimer2();
  //timerhid=setTimeout('gohome()',timerhint);
}

function gohome() {
document.location="home.php?lng=es";
}

function setTimer1() {
  if (timer1on) {
          clearTimeout(timer1id);
          timer1on=0;
  } else {
	  timer1id=setTimeout('fadefnc1()',timer1int);
          timer1on=1;
  }
}
function clrTimer() {
  if (timer1on) {
          clearTimeout(timer1id);
          timer1on=0;
  }
}
function fadefnc1() {
  if (ie5) {
	DivTit.style.filter="alpha(opacity=" + iTitCnt + ")"; 
  }
  else {
	DivTit.style.MozOpacity = iTitCnt / 100.0;
  }
  iTitCnt=iTitCnt-3;
  if (iTitCnt>iMax1-1) { 
  	timer1id=setTimeout('fadefnc1()',timer1int); 
  } else { 
  	clearTimeout(timer1id);
	//DivTit.style.visibility="hidden";
	hide(DivTit);
	show("MenuMask");
	show("Menu");
	showMenu();
  }

}

//
//SHOW MENU
//
function showMenu() {
	//
	initSLAnime("Menu", 191, 547, 191, 435, 2, 1);
	
}

//
//ANIMATION MENU
// animation object holds numerous properties related to motion
var anime = new Array();

// initialize default anime object
function initAnime(num) {
    anime[num] = {elemID:"", 
             xCurr:0, 
             yCurr:0, 
             xTarg:0, 
             yTarg:0, 
             xStep:0, 
             yStep:0,
             xDelta:0,
             yDelta:0,
             xTravel:0,
             yTravel:0,
             vel:1, 
             pathLen:1, 
             interval:null
            };
}

// stuff animation object with necessary explicit and calculated values
function initSLAnime(elemID, startX, startY, endX, endY, speed, num) {
    initAnime(num);
    anime[num].elemID = elemID;
    anime[num].xCurr = startX;
    anime[num].yCurr = startY;
    anime[num].xTarg = endX;
    anime[num].yTarg = endY;
    anime[num].xDelta = Math.abs(endX - startX);
    anime[num].yDelta = Math.abs(endY - startY);
    anime[num].vel = (speed) ? speed : 1;
    // set element's start position
    //document.getElementById(elemID).style.left = startX + "px";
    //document.getElementById(elemID).style.top = startY + "px";
	shiftTo(anime[num].elemID, startX, startY);
    // the length of the line between start and end points
    anime[num].pathLen = Math.sqrt((Math.pow((startX - endX), 2)) + (Math.pow((startY - endY), 2)));
    // how big the pixel steps are along each axis
    anime[num].xStep = parseInt(((anime[num].xTarg - anime[num].xCurr) / anime[num].pathLen) * anime[num].vel);
    anime[num].yStep = parseInt(((anime[num].yTarg - anime[num].yCurr) / anime[num].pathLen) * anime[num].vel);
    // start the repeated invocation of the animation
    anime[num].interval = setInterval("doSLAnimation("+num+")", 10);
}

// calculate next steps and assign to style properties
function doSLAnimation(num) {
    if ( ((anime[num].xTravel + anime[num].xStep) <= anime[num].xDelta) && ((anime[num].yTravel + anime[num].yStep) <= anime[num].yDelta) ) {
        var x = anime[num].xCurr + anime[num].xStep;
        var y = anime[num].yCurr + anime[num].yStep;
        //document.getElementById(anime[num].elemID).style.left = x + "px";
        //document.getElementById(anime[num].elemID).style.top = y + "px";
		shiftTo(anime[num].elemID, x, y);
        anime[num].xTravel += Math.abs(anime[num].xStep);
        anime[num].yTravel += Math.abs(anime[num].yStep);
        anime[num].xCurr = x;
        anime[num].yCurr = y;
    } else {
        //document.getElementById(anime[num].elemID).style.left = anime[num].xTarg + "px";
        //document.getElementById(anime[num].elemID).style.top = anime[num].yTarg + "px";
		shiftTo(anime[num].elemID, anime[num].xTarg, anime[num].yTarg);
        clearInterval(anime[num].interval);
		//if (num==20) { running=false; }
		//if (closing==2) { animMenu(1); } else if (closing==1) { animMenu(2); };
    }
}