var TimeToFade = 1000;
var TimeToChange = 5000;
var totalSlides = 1;
var topValue = '90px';

first = 1;
last = 1;
current = 1;
used = 0;

var in2;
var out2;
var flag1 = 0;
var flag2 = 0;

var color1 = 0;
var color2 = 0;
var suma = 10;

function fadein2(idobj){
  var obj = document.getElementById(idobj);
  var objText = document.getElementById(idobj + "t");
  obj.style.display = "block";
  color1 += suma;
  
  obj.style.zIndex = 100;
  
  //alert(obj.style.zIndex);
  
  if (!(color1>=110)){
	//obj.style.top = '340px';
    obj.style.filter = 'alpha(opacity='+color1+')';
    obj.style.opacity = color1 /100;
    obj.style.MozOpacity = color1 /100;
    obj.style.KHTMLOpacity = color1 /100;
	//objText.style.zIndex = "100";
    //window.setTimeout ("fadein2('" + idobj + "');", 100);
    if(flag1 == 0) {
      in2 = setInterval("fadein2('" + idobj + "');", 100);
    }
    flag1 = 1
  } else {
    flag1 = 0;
    clearInterval(in2);
  }
}


function fadeout2(idobj) {
  var obj2 = document.getElementById(idobj);
  var objText = document.getElementById(idobj + "t");
  color2 -= suma;
  
  obj2.style.zIndex = "-1";
  
  if (!(color2 <=-10)){
    obj2.style.filter = 'alpha(opacity='+color2+')';
    obj2.style.opacity = color2 /100;
    obj2.style.MozOpacity = color2 /100;
    obj2.style.KHTMLOpacity = color2 /100;
	//objText.style.zIndex = "-1";
    //window.setTimeout ("fadeout2('" + idobj + "');", 100);
    if(flag2 == 0) {
      out2 = setInterval("fadeout2('" + idobj + "');", 100);
    }
    flag2 = 1;
  } else {
   //obj.style.top = '-500px';
    flag2 = 0;
    clearInterval(out2);
  }
}


function startSlide() {
	color1 = 0;
	color2 = 110;
    if(current > last) {
      current = 1;
      fadeout2("slide" + last);      
    } else {
      fadeout2("slide" + (current - 1));
    }

    fadein2("slide" + current);
    current = current + 1;
}
