/*
script desenvolvido por Luis Carlos de Brito - luis.carlos@linuxmail.org - e Anderson Julio de Souza - anderson.julio@ibest.com.br - 45 3038-2976 | 45 3037-3004 - Cascavel - PR

caso venha adquirir este script por outro meio senão através dos autores, favor manter os créditos dos criadores
este script pode ser utilizado, modificado, publicado, utilizado sem restricoes desde que mantido os crédidos dos criadores

##########------- tivemos muito trabalho para fazer este funcionar, respeite nosso trabalho e conhecimento -------##########

*/
var conexoes = new Array();
function openAjax() {
	try	{
		xmlhttp= new ActiveXObject("Msxml2.XMLHTTP");
	}catch (e) {
		try 		{
			xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
		}catch (Ex) {
			xmlhttp= false;
		}
	}
	if(!xmlhttp && typeof XMLHttpRequest!='undefined') {
	   xmlhttp= new XMLHttpRequest();
	}
	return xmlhttp;
}

function ReqHeader(method, index){
	conexoes[index].open(method, URL, true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); 
    xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate"); 
    xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0"); 
    xmlhttp.setRequestHeader("Pragma", "no-cache"); 
}

function Response(dv,index){
   conexoes[index].onreadystatechange=function() {
      if(conexoes[index].readyState==4) {
	     if(conexoes[index].status==200) {
		    resp=conexoes[index].responseText;
		    switch(dv) {
		    	case "alert":
		    		alert(resp);
		    		break;
		    	default:
		    		 getElmt(dv).innerHTML=resp;
		    }
	     }
      }
   }
}


function showHide(id,param) {
	getElmt(id).style.display=param;
}

function buscarConteudo(dv,dst,param1,param2) {	
	idx = conexoes.push(openAjax());
	idx-=1;
	URL="conteudo.php";
	ReqHeader('post', idx); 
	if(dv!='alert' && dv!=null && dv!=undefined)
		getElmt(dv).innerHTML='<b>Aguarde, carregando...<img src="imagens/atualiza.gif" border="0"></b>'; 
	conexoes[idx].send("acao=" + escape(dst)+"&param1="+escape(param1)+"&param2="+escape(param2));
	Response(dv,idx);
}

function buscarURL(dv,dst,param) {
	idx = conexoes.push(openAjax());
	idx-=1;
	URL=dst;
	if(dst=='')
		URL='conteudo.php';
	ReqHeader('post', idx); 
	if(dv!='alert' && dv!=null && dv!=undefined)
		getElmt(dv).innerHTML='<b>Aguarde, carregando...<img src="imagens/atualiza.gif" border="0"></b>'; 
	conexoes[idx].send(param);
	Response(dv,idx);
}

function enviarEmail() {
	nome = getElmt('nome').value;
	email = getElmt('mail').value;
	fone = getElmt('fone').value;	
	mensagem = getElmt('mensagem').value;
	params = nome+'$@$,'+email+'$@$,'+fone+'$@$,'+mensagem;

	buscarConteudo('alert','enviarEmail',params,'');
}

function votarEnquete(resposta) {
	buscarConteudo('dvEnquete','votarEnquete',resposta,'');
}

function getElmt(id) { 	return document.getElementById(id); }

function $(id) { return document.getElementById(id); }

function insertSWF(file, w, h) {
	insert = new Flash(file, "", w, h);
	insert.addParameter("wmode", "transparent"); 
	insert.addParameter("showMenu", "false"); 
	return insert.toString();
}
 
function showDvAlert(msg) {
	getElmt('contentDvAlert').innerHTML=msg;
	showHide('dvAlert','block');
	
	if(window.navigator.appName=="Microsoft Internet Explorer") {
		getElmt('dvAlert').style.filter='alpha(opacity=10)';
		
		var intervalo = window.setInterval(function() {		
			getElmt('dvAlert').style.filter='alpha(opacity='+(eval(getElmt('dvAlert').style.filter.substr(14,2))+10)+')';
		}, 100);
		window.setTimeout(function() {
		clearInterval(intervalo);
		}, 900);
	}
	else {
		getElmt('dvAlert').style.opacity='0.1';
		
		var intervalo = window.setInterval(function() {		
			getElmt('dvAlert').style.opacity=eval(getElmt('dvAlert').style.opacity)+0.1;
		}, 100);
		window.setTimeout(function() {
		clearInterval(intervalo);
		}, 900);
	}
	window.setTimeout(function(){showHide('dvAlert','none');},4000);
}

function startDrag(id) {
	dv2drag = id;
	document.onmousemove = mouseMove;
}

function stopDrag(){
	document.onmousemove = null;
}

function mouseMove(ev){
	ev = ev || window.event;
	if(ev.clientX) {
		getElmt(dv2drag).style.left=ev.clientX - 150;
		getElmt(dv2drag).style.top=ev.clientY-10;
	}else {
		getElmt(dv2drag).style.left=ev.pageX - 150;
		getElmt(dv2drag).style.top=ev.pageY-10;
	}
}

function showHideResultados(min,max,id,prefix) {
	for(i=min;i<max;i++){
		getElmt(i).style.display='none';
		getElmt(prefix+i).style.display='block';
	}
	getElmt(prefix+id).style.display='none';
	getElmt(id).style.display='block';
}

function animarNoticias(n1,n2,n3,n4) {
	//cache das imagens
	img1 = new Image();
	img1.src='upload/'+n2;
	img2 = new Image();
	img2.src='upload/'+n3;
	img3 = new Image();
	img3.src='upload/'+n4;
	
	img = new Array(n1,n2,n3,n4);
	idx=0;
	window.setTimeout(function(){
		if(window.navigator.appName=="Microsoft Internet Explorer") {
			var bint = window.setInterval(function() {
				if(getElmt('bigFotoNoticia')!=null) {
					idx==3 ? idx=0 : idx++;
					if(img[idx]=='') idx=0;
					
					getElmt('bigFotoNoticia').style.filter='alpha(opacity=10)';
					getElmt('legendaBigFotoNoticia').innerHTML=getElmt('legenda'+idx).value;
					
					getElmt('bigFotoNoticia').innerHTML='<img onload="if(isIE){addIECorners(); }else {addCorners();}" class="corner iradius16" style="max-height:350px; max-width:476" src="upload/'+img[idx]+'"><input type="hidden" name="id_not" id="id_not" value="'+legend[idx]+'">';
					var intervalo = window.setInterval(function() {		
						getElmt('bigFotoNoticia').style.filter='alpha(opacity='+(eval(getElmt('bigFotoNoticia').style.filter.substr(14,2))+10)+')';
					}, 100);
					window.setTimeout(function() {
						clearInterval(intervalo);
						getElmt('bigFotoNoticia').style.filter='alpha(opacity=100)';
					}, 900);
				  }
				},5000);
		}
		else {
			var bint = window.setInterval(function() {	
				if(getElmt('bigFotoNoticia')!=null) {
					idx==3 ? idx=0 : idx++;
					if(img[idx]=='') idx=0;
					
					getElmt('bigFotoNoticia').style.opacity='0.1';
					getElmt('legendaBigFotoNoticia').innerHTML=getElmt('legenda'+idx).value;
					
					getElmt('bigFotoNoticia').innerHTML='<img onload="if(isIE){addIECorners(); }else {addCorners();}" class="corner iradius16" style="max-height:350px; max-width:476px" src="upload/'+img[idx]+'"><input type="hidden" name="id_not" id="id_not" value="'+legend[idx]+'">';
					var intervalo = window.setInterval(function() {		
						getElmt('bigFotoNoticia').style.opacity=eval(getElmt('bigFotoNoticia').style.opacity)+0.1;
					}, 100);
					window.setTimeout(function() {
						clearInterval(intervalo);
						getElmt('bigFotoNoticia').style.opacity='1';
					}, 900);
				}
			},5000);
		}
	},1000);
}

function menuOverIE(dv,onOff) {
	getElmt(dv).style.display=onOff;
}

function trocarFoto(src, id) {
	getElmt('bigFotoNoticia').innerHTML='<img onload="if(isIE){addIECorners(); }else {addCorners();}" class="corner iradius16" style="width:476px; height:350px" src="upload/'+src+'">';
	getElmt('legendaBigFotoNoticia').innerHTML=getElmt('legenda'+id).value;
}