arr=[];
indice=0;
function loadBlock(place,addr){
	if(xmlhttp){
		document.getElementById(place).style['display']= 'block';
//		document.getElementById(place).innerHTML = '<span id="carregando" align=center><img src="imagens/carregando.gif" border="0" /></span>';
		document.getElementById(place).innerHTML = '<span id="carregando" onClick="javascript: this.style[\'display\']=\'none\';" style="position: absolute; display: block; padding-left:40px; padding-right:10px; width: auto; line-height: 40px; border: 1px solid #000; font-weight: bold; background:#FFF url(\'http://www.tendabar.com.br/novo/img/loading.gif\') no-repeat 5px center;">Carregando...</span>';
		blockUPDATE(place,addr);
	}
}

function blockUPDATE(place,addr){
	if(xmlhttp){
//tenta criar um objeto XMLHttpRequest
	  //  if(document.getElementById(place)) document.getElementById(place).innerHTML="<span class='carregando'>"+"Carregando...</span>";
    	//Adiciona à fila
	    arr[arr.length]=[place,addr];
	    if((indice+1)== arr.length) RunExecute();
	}
}

function RunExecute(){
	if(!xmlhttp){
//CRIA UM OBJETO XHR
	try{
		    xmlhttp = new XMLHttpRequest();
		}catch(xmlhttp){
	    	try{
    		    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		    }catch(xmlhttp){
	    	    try{
    		        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	        	}catch(xmlhttp){
            		xmlhttp = false;
	    	    }
    		}
		}
	}

	if(xmlhttp){
    	xmlhttp.open("GET",arr[indice][1],true); 
	//	xmlhttp.setRequestHeader("Content-type", "charset=utf-8")
		xmlhttp.setRequestHeader('content-type', 'text/html');
		xmlhttp.setRequestHeader('Content-Type','charset=iso-8859-1');
		xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	    xmlhttp.onreadystatechange=function() {
			//alert(xmlhttp.status+" - "+xmlhttp.readyState);
	        if (xmlhttp.readyState==4){
    	        //EXIBE o HTML recebido
        	    consulta=unescape(xmlhttp.responseText); //.replace(/\+/g," "));
				//alert(consulta);
				if(document.getElementById(arr[indice][0])){
					 document.getElementById(arr[indice][0]).innerHTML=consulta;
				 }
	            //Roda o próximo
    	        indice++;
        	    if(indice<arr.length) setTimeout("RunExecute()",20);
	        }
    	}
	    //Executa
	    xmlhttp.send(null);
	}
}

	//PARA EXIBIR E OCULTAR BLOCOS
	function ShowHide(obj,s){
		if(obj && s) obj.style.display = s;
		else if(!s) obj.style.display = (obj.style.display=='none') ? 'block' : 'none';
	}

	//4 PARAMETROS QUE FAZEM A INTERCALAÇÃO DE CONTEÚDO
	function MinimizeMaximize(obj1,obj2,i1,i2){
		ShowHide(obj1);
		obj2.innerHTML = (obj1.style.display=='none') ? i1 : i2;
	}
	//mostra blocos e e aplica transparencia a botao
	function ChangeBlock(esconde,mostra,botao1,botao2){
		ShowHide(esconde,"none");
		ShowHide(mostra,"block");
		makeFade(botao2,'DescOp1');
		makeFade(botao1,'DescOp');
	}



//---------------AJAX COM POST -- //

Ap=[]; inp=0; frm=[];
function postValores(formulario,act,id,url,texto){
//	alert(formulario.name+" - "+act+" - "+id+" - "+url+" - "+texto);
var	valores = "act="+act;
	for (i=0; i < formulario.elements.length; i++){
		if ((formulario.elements[i].value && formulario.elements[i].type != 'button' && formulario.elements[i].type != 'submit' )){
			if(formulario.elements[i].type == 'checkbox' && formulario.elements[i].checked == true){
				valores += "&"+formulario.elements[i].name+"="+formulario.elements[i].value;
			}else if(formulario.elements[i].type == 'select-multiple'){	//PARA SELECTS MULTIPLOS
				var mult = formulario.elements[i];
				for(a=0;a<mult.length;a++){
					if(mult.options[a].selected){
						valores += "&"+formulario.elements[i].name+"="+mult.options[a].value;
					}
				}
			}else if(formulario.elements[i].type == 'radio' && formulario.elements[i].checked == true){ //PARA RADIOBUTTON
					valores += "&"+formulario.elements[i].name+"="+formulario.elements[i].value;
			}else if((formulario.elements[i].type == 'text' || formulario.elements[i].type == 'select-one' || formulario.elements[i].type == 'textarea' || formulario.elements[i].type == 'hidden') && (formulario.elements[i].type != 'checkbox' && formulario.elements[i].type != 'select-multiple')){
					nVal = "";
					nVal = escape(formulario.elements[i].value);
				valores += "&"+formulario.elements[i].name+"="+nVal;
				}
		}
	}
	if(document.getElementById(id)){
		document.getElementById(id).style['display']= 'block';
		document.getElementById(id).innerHTML = (texto) ? '<span id="carregando" align=center> '+texto+'</span>' : '<span id="carregando" align=center><img src="img/loading.gif" border="0" /> Aguarde, carregando dados...</span>';
	}
	frm[Ap.length]=valores.toString();
    Ap[Ap.length]=[id,url];
//	alert(Ap.length+" - "+inp);
    if((inp+1)==Ap.length) RunPost();
}

function RunPost(){
	if(xmlhttp){
		//Abre a conexão
		xmlhttp.open("POST", Ap[inp][1], true);
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded;'); 
		//Função para tratamento do retorno
	    xmlhttp.onreadystatechange=function() {
			//alert(xmlhttp.status+" - "+xmlhttp.readyState);
	        if (xmlhttp.readyState==4){
    	        //Mostra o HTML recebido
	            retorno=unescape(xmlhttp.responseText); //.replace(/\+/g," "));
				//document.getElementById(Ap[inp][0]).scrollIntoView();
				//alert(retorno);
				if(document.getElementById(Ap[inp][0])){
					 document.getElementById(Ap[inp][0]).innerHTML=retorno;
					// if(document.getElementById('globalSource')) reDimensiona();
				 }
	            //Roda o próximo
            	inp++;
        	    if(inp<Ap.length) setTimeout("RunPost()",20);
    	    }
	    }
    	//Executa	
	    xmlhttp.send(frm[inp]);
	}
}

//slideshow imagens

//PARA EFETUAR FADE EM OUTROS NAVEGADORES
function Fade(){
		var opacs = ["0",".1",".2",".3",".4",".5",".6",".7",".8",".9","1"];
		for (var i=0;i<11;i++){
			  setTimeout('document.getElementById(\'SlideShow\').style.opacity = "'+opacs[i]+'";', ((i==0) ? i : (i*80)));
		}
}

function SlideShow(){
	var obj = document.images.SlideShow;
	if(ns6 || (navigator.userAgent.indexOf("Opera") != -1)){
		j = j + 1;
		if (j > (p - 1)) j = 0;
		t2 = setTimeout('Fade()', (velocidade-100));
		t = setTimeout('SlideShow()', velocidade);	
	}
	if(ie && (navigator.userAgent.indexOf("Opera") == -1)) {
			obj.style.filter="blendTrans(duration=2)";
			obj.style.filter="blendTrans(duration=tempoFade)";
			obj.filters.blendTrans.Apply();
		}
	obj.src = ArrF[j].src;
//	obj.width = 100;
//	obj.height = 75;
	document.getElementById("textoP").innerHTML = fotoTexto[j]+((fotoVideo[j]!="") ? '<br /><a href="'+fotoVideo[j]+'" style="padding-left:13px; background:url(\'img/bt_seta.gif\') no-repeat left center;" class="azul"> ver o vídeo</a>':"");
	document.getElementById("linkfoto").href = fotoLinks[j];
	document.getElementById("link_Azul").style.display = "block";
	document.getElementById("link_Azul").href = fotoLinks[j];
	if(ArrF.length > 1) document.getElementById('controle').style.display = "block";
		if(ie && (navigator.userAgent.indexOf("Opera") == -1)) {
			obj.filters.blendTrans.Play();
			j = j + 1;
			if (j > (p - 1)) j = 0;
			t = setTimeout('SlideShow()', velocidade);
			t2 = setTimeout('');	
		}
}



function Control(a){
	clearTimeout(t);
	if(t2) clearTimeout(t2);
	if(a=="menos"){
		j = (j==0) ? (p-2) : ((j==1) ? (p-1) : (parseInt(j)-2));
	}
	SlideShow();
}

function abreVideo(a){
return void(window.open(a,'','width=500,height=450,scrolling=no,status=no,menubar=no,toolbar=no'));
}

//LIMPA CAMPO FORMULARIO OU DEIXA O MESMO VALOR
function padrao(i,input,valor){
    var obj = document.forms[i].elements[input]; 
	var str = obj.value 
    if(str != valor && str.length != 0){
		valor = obj.value;
	}  
	obj.value=valor;
} 

function limpapadrao(i,input,valor){
    var obj = document.forms[i].elements[input]; 
	var str = obj.value 
	if(str != valor){
		valor = obj.value;
	}else{
		valor = "";
	}
	obj.value=valor;
}

function makeFade(Oid,c){
		Oid.className=c;
}

function fechaAviso(){
	ShowHide(document.getElementById("_aviso"),"none");
}


/*var pos = 0;
var place = 1;
var Ar_ = Array();
function changeV(v,place){
		document.getElementById('prods').innerHTML = Message.substring(0, place);
}

   function scrollIn(Ar_) {
//	for(a=0;a<Ar.length;$a++){
		for($a=0;$a<Ar_.length;$a++){
			Message = Ar_[pos];
			if (place >= Message.length) {
				place=1;
				window.setTimeout("scrollOut()",300); 
			 } else {
				place++;
				window.setTimeout("scrollIn()",50); 
			 }
		}
//	}
   }

   function scrollOut() {
		document.getElementById('prods').innerHTML = "";
		pos++;		
	}
*/

