/*
	Sistema de notícias HOTLink
	------------------------------------------------------

	Autor		: Eduardo Bello
	Data		: 04/10/2007
	Descrição	: Realiza troca das notícias secundárias.


	Log de atualizações:
	-------------------

	Data		-	Autor				-	Descrição
	----------		-------------------		------------------------------------------------------

*/

// Declaração das variáveis globais


// Set the slideshow speed (in milliseconds)
var slideShowSpeed = 5000;

// Set the duration of crossfade (in seconds)
var crossFadeDuration = 3;

var tss;
var iss;
var jss = 0;
var pss = hnImgs.length-1;

var hnPreLoad = new Array();
for (iss = 0; iss < pss; iss++){
	hnPreLoad[iss] = new Image();
	hnPreLoad[iss].src = hnImgs[iss];
}

function hnNext() {
	//jss++;
	//if (jss > (pss-1)) jss=0;	
	clearTimeout(tss);
	runSlideShow();
}

function hnPrevious() {
	jss-=2;
	if (jss < 0 ) jss=pss-1;	
	clearTimeout(tss);
	runSlideShow();
}

function runSlideShow(){
	var speed=25;
	var timer=0;
	if (document.all && navigator.userAgent.indexOf('Opera')==-1) {
		try {
			document.images.nSecundariaImg.style.filter="blendTrans(duration=crossFadeDuration)";
			document.images.nSecundariaImg.filters.blendTrans.Apply();
		} catch(e) { };
	};/* else {
		//for(i=100;i>0;i-=2) setTimeout('changeOpac('+i+')', timer++ * speed);
		//hnBlend();	
	}*/
	document.images.nSecundariaImg.src = hnPreLoad[jss].src;
	if (document.getElementById) { 
		document.getElementById("nSecundariaTitulo").innerHTML= hnTitulos[jss];
		document.getElementById("nSecundariaTexto").innerHTML = hnTextos[jss];
		document.getElementById("nSecundariaLink").href       = hnLinks[jss];
	}
	if (document.all && navigator.userAgent.indexOf('Opera')==-1) {
		document.images.nSecundariaImg.filters.blendTrans.Play();
	} else {
		for(i=0;i<=100;i+=2) setTimeout('changeOpac('+i+')', timer++ * speed);	
	}
	jss++;
	if (jss > (pss-1)) jss=0;
	clearTimeout(tss);
	tss = setTimeout('runSlideShow()', slideShowSpeed);
}


function changeOpac(opacity){
	var obj = document.getElementById("nSecundariaImg").style;
	obj.opacity=(opacity/101);
	obj.MozOpacity=(opacity/101);
	obj.KhtmlOpacity=(opacity/101);
}

function findLinkByHref(href) {
  for (var i=0; i<document.links.length; i++) {
    if (document.links[i].href == href) return i;
  }
  return -1;
}

function changeLinkHref(id,newHref) {
  if (document.links.length > 0) {
    if (document.getElementById) {
      document.getElementById(id).href = newHref;
    }
    else if (document.all) {
      document.all[id].href = newHref;
    }
  }
}


