window.defaultStatus='<%=siteBarStatus%>';

function resizeImgInit(img,z){
	var limite = z;
	if(img.width>limite || img.height>limite){
			if(img.width>img.height){
				img.width=limite ;
			}else{
				img.height=limite ;
			}
	}	
}


function addbookmark(){
	if (document.all){	window.external.AddFavorite(document.location,document.title);  }
}



function fadeTo(el,from,to,steps,curr){
    var to    = to;
    var stps  = steps || 5;
    var from  = from  || (to/stps);
    var curr  = curr  || from;
        curr  = curr  + ((to-from)/stps);

    el.style.opacity = Number( curr / 100 );
    el.style.filter  = 'alpha(opacity=' + Number( curr ) + ')';
    if(Math.round(curr) != to){        
        setTimeout(function(){
                fadeTo(el,from,to,steps,curr);
            },
            100
        );
    }
}

function tempo_decorrido(){
	now = new Date();
	the_timer = new Date(now.getTime());
	hora = the_timer.getHours();
	minutos = the_timer.getMinutes();
	segundos = the_timer.getSeconds();
	if ( minutos <= 9 ) minutos = "0" + minutos;
	if ( segundos <= 9 ) segundos = "0" + segundos;
	display_timer = hora + ":" + minutos + ":" + segundos;
	document.getElementById("timeClock").innerHTML = display_timer;
	var temp = setTimeout( "tempo_decorrido()", 1000);
}
/**************************** imagem destaque ****************************/
var SlideShowSpeed = 5000;
var CrossFadeDuration = 3;
var SS_count=0;

var Picture = new Array(); 
var Caption = new Array(); 
var Description = new Array();
var Link = new Array(); 
<%
if isarray(destaqueList) then
	for i=0 to ubound(destaqueList)
		link=destaqueList(i,3) : if link="" then link="destaque.asp?idDestaque="&destaqueList(i,0) end if
		response.write "Picture["&i&"]  = ""noticias/destaque/"&destaqueList(i,0)&"/capa.jpg"";"
		response.write "Caption["&i&"]  = ""<a href='"&link&"' style='color:#ffffff;'>"&replacetext(destaqueList(i,2))&"</a>"";"
		response.write "Description["&i&"]  = ""<a href='"&link&"' style='color:#ffffff;font-weight:bold;'>"&replacetext(destaqueList(i,1))&"</a>"";"
		response.write "Link["&i&"]  = """&link&""";"
	next
end if
%>

var tss;
var iss;
var jss = 0;
var jssCurrent=jss;
var pss = Picture.length-1;
var checkRun=0;


var preLoad = new Array();
function runPreLoad(){
	for (iss = 0; iss < pss+1; iss++){
		preLoad[iss] = new Image();
		preLoad[iss].src = Picture[iss];
	}
	
	if (document.getElementById){ // IE5 NN6
		runSS();
		if(pss>0){shL('idSToolbar','show');}
	}else if (document.layers){ // NN4
		runSS();
		if(pss>0){shL('idSToolbar','show');}
	}else if (document.all){ // IE4
		runSS();
		if(pss>0){shL('idSToolbar','show');}
	}	
}

function runSlideShow_MZ(strObj){//mozila
	var increment = 5;
	var obj = eval(strObj);
	var n = parseFloat(obj.style.opacity);
	if(n<1){
		obj.style.opacity=n+(increment/100);
		setTimeout("runSlideShow_MZ('"+strObj+"')",50);
	}
}
function runSlideShow(){
	var totalDestaque=10
	if (document.all){
		document.images.PictureBox.style.filter="blendTrans(duration=2)";
		document.images.PictureBox.style.filter="blendTrans(duration=CrossFadeDuration)";
		document.images.PictureBox.filters.blendTrans.Apply();
	}else{
		//alert(1)
		document.images.PictureBox.style.opacity=0;
		runSlideShow_MZ( 'document.images.PictureBox' )
	}
	document.images.PictureBox.src = preLoad[jss].src;
	
	document.getElementById("LinkPictureBox").href=Link[jss];
	if (document.getElementById) document.getElementById("CaptionBox3").innerHTML= Caption[jss];// + " </a>";
	
	if(Description[jss]!=''){
		shL('DescriptionBox2','show','no');
		if (document.getElementById) document.getElementById("DescriptionBox").innerHTML= Description[jss];
	}else{
		shL('DescriptionBox2','hide','no');
	}
	if (document.all) document.images.PictureBox.filters.blendTrans.Play();
	if(pss>totalDestaque){
		pss=totalDestaque-1
	}
	for (i=0;i<pss+1;i++){ document.getElementById("idSN_"+i).className='destaqueBtOut';}
	document.getElementById("idSN_"+jss).className='destaqueBtOver';

	
	jssCurrent=jss;
	jss = jss + 1;if (jss > (pss)) jss=0;
	
}
function shL(layer,s,p){
	var obj = document.getElementById(layer);
	if (s=='auto'){
		if (obj.style.visibility=='hidden'){
			obj.style.visibility='visible';
			obj.style.display='block';
			if(p!='no'){obj.style.position='static';}
		}else{
			obj.style.visibility='hidden';
			obj.style.display='none';
			if(p!='no'){obj.style.position='absolute';}
		}
	}else{
		if (s=='show' || s==1){
			obj.style.visibility='visible';
			obj.style.display='block';
			if(p!='no'){obj.style.position='static';}
		}else if (s=='hide' || s==0){
			obj.style.visibility='hidden';
			obj.style.display='none';
			if(p!='no'){obj.style.position='absolute';}
		}
	}
}
function runSS(){
	n_check=100;

	if(SS_count==0){
		if(checkRun==0){//-> play
			runSlideShow();
		}//else -> pause
	}

	if(checkRun==0){SS_count++;}//conta somente se não estiver pausado
	if( (SS_count*n_check)>=SlideShowSpeed ){ 
		SS_count=0; 
	}else{
		var n = ((SS_count*n_check)/SlideShowSpeed)*100; n = parseInt(n);
		document.getElementById("idSSBar").style.width =  n+'%';
	}
	setTimeout('runSS()',n_check);
}


function runSS_setImg(set){
	var i;
	if(set=='+'){ 
		SS_count=0;//para mudar a imagem
	}else if(set=='-'){ 
		jssCurrent--; 
		if(jssCurrent<0){jssCurrent=pss;}
		jss=jssCurrent;
		SS_count=0;//para mudar a imagem
	}else{//é passado um numero/posição
		jssCurrent=parseInt(set);
		jss=jssCurrent;
		SS_count=0;//para mudar a imagem
	}
	
	if(checkRun==1){ runSS_playPause(); }//tira do pause
}

function runSS_playPause(){
	if(checkRun==0){ //pause
		checkRun=1;
		document.getElementById("labelBt1").innerHTML='||';
	}else{ //play
		checkRun=0;
		document.getElementById("labelBt1").innerHTML='....';
	}
}
/**************************** imagem destaque ****************************/
//-->
function loading(destaque){
	tempo_decorrido();
	<%if layoutTopoRefreh>0 then%>
	//loadTopo();
	//setTimeout('loadTopo();',<%=layoutTopoRefreh*1000%>);
	<%end if%>
	//indica que a pagina já foi carregada
	if(destaque=='1'){
		if (document.getElementById){ // IE5 NN6
			runPreLoad();
		}else if (document.layers){ // NN4
			runPreLoad();
		}else if (document.all){ // IE4
			runPreLoad();
		}
	}
}
