var numbr=1;
var tipo="Appear";
var randDest;
var Dest=new Array();
function random_dest(){


randDest = self.setInterval(function (){

if(numbr!=Dest.length-1){
  numbr++;
}else{
  numbr=1;
}
//alert(numbr);


//Effect.BlindDown("not_dest", { duration: 1.0,from:0,to:1,afterFinishInternal:function (){Effect.Appear("not_dest", { duration: 14.0,from:1,to:1});}});
Effect.Appear("flash_home", { duration: 5.0,from:1,to:1,afterFinishInternal:function (){Effect.Fade("flash_home", { duration: 5.0,from:1,to:1});}});




muda_img(Dest[numbr]);
},"10000");
}

function muda_img(id){


var obj = document.getElementById("flash_home");

var serverPage ="random_img.php";
var params = "id="+id;


xmlhttp.open("GET",serverPage+"?"+params);
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 1 ) {
//obj.innerHTML="<img src='./sysimages/loader2.gif' border='0' class='border_img'>";
}else if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  obj.innerHTML = xmlhttp.responseText;
  
  /*var nr = document.getElementById("nr_" + id);
  var seta = document.getElementById("seta" + id);
  var td = document.getElementsByTagName("td");
  
  for(i = 0; i <td.length; i++){
    	
        	if(td[i].className=="nr_sel"){
    				  
              td[i].className="nr";
      				
          }
          if(td[i].className=="seta_sel"){
    				  
              td[i].className="seta";
      				
          }
    	}
  
  if(nr!=null){
    nr.className='nr_sel';
  }
  if(seta!=null){
    seta.className='seta_sel';
  }*/
  
}
}
xmlhttp.send(null);
}

var OBJ;
var total;
var elem = new Array();
 function formErros(obj)
{
OBJ=obj;
total=obj.length;

var frmObj=OBJ.form;
objID=obj.id;

  
 elem = frmObj.elements;
 
  for(i = 0; i < elem.length; i++){
  
  if(elem[i].id==objID){
    document.getElementById(objID).style.borderColor="#FF0000";
    
    var lbl=document.getElementById("lbl_" + objID);
    
    if(lbl!=null){
       //lbl.style.color="#FF0000";
    }
    
  }
  
  }
}
// SUBMENU
function showSub(id)
{ 
  
  document.getElementById("subp_" + id).style.display = "block";
  var mnT= document.getElementById("mnT" + id);
  
  var mnW = mnT.clientWidth;
  //alert(mnW);
  var sub_tbl= document.getElementById("tbl_subp_" + id);
  var stW = sub_tbl.clientWidth;
 
  if(sub_tbl!=null){
    if(stW<mnW){
      sub_tbl.style.width=mnW+'px';
    }
    //alert((mnW+28));
    if(mnW<stW){
      //alert(mnW+""+stW);
      sub_tbl.style.width=(mnW+52)+'px';
    }
    
  }
  
}

function hideSub(id){
  document.getElementById(id).style.display = "none";
}

var jpesq;

function verifica_pesq(form) {

var formulario = document.getElementById(form)
var txt=formulario.valor_pesq;
var texto = txt.value;

var error;

  if((txt.value=="") || (txt.value==unescape(jpesq[1]))){
      alert(unescape(jpesq[2]));
      error=1;
  }else if(txt.value!="" &&  texto.length<5){
      alert(unescape(jpesq[3]));
      error=2;
      
  }

  if((txt.value!=unescape(jpesq[1])) && (texto.value!="") && (texto.length>=5)){
     error=0;
  }
  
  if(error>0){
    return false;
  }else {
    return document.getElementById(form).submit();
  }
  
  
}

/* IFRAME POP-UP */
var _xpannel;

function ModalIframePopUp(phpfile, _title, _mensagem, _height, _width)
{
  _xpannel = new YAHOO.widget.Panel("xpannel", 
      {  
      width:_width, 
      fixedcenter:true, 
      close:false, 
      draggable:true, 
      zindex:32200, 
      modal:true, 
      visible:false
      } );

    var HTML_BODY = '<iframe src="'+ phpfile +'" style="width:100%;height:' + _height + ';background-color:transparent;margin: 0px !important; padding: 0px !important;" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="100%" height="100%" hspace="0"></iframe>';
    /*_xpannel.setHeader(_title);*/
    _xpannel.setBody(HTML_BODY);
    _xpannel.render(document.body);
    _xpannel.show();
}

function ModalPopUp(phpfile, _title, _mensagem, _width)
{
  _xpannel = new YAHOO.widget.Panel("xpannel", 
      {  
      width:_width, 
      fixedcenter:true, 
      close:false, 
      draggable:true, 
      zindex:32200, 
      modal:true, 
      visible:false
      } );

  var abrejanela = {
          success: function(oResponse) {
          var oResults = oResponse.responseText;
          _xpannel.setHeader(_title);
          _xpannel.setBody(oResults);
          _xpannel.render(document.body);
          _xpannel.show();
          },
          
          failure: function(oResponse) {
            alert('(1) Erro ao carregar informação. Por favor volte a tentar!');
          },
          timeout: 20000
  };

  YAHOO.util.Connect.asyncRequest('GET', phpfile, abrejanela);
}
