/**
 * @author Administrador
 */
/*Request de modelos de uma determinada marca */

function CarregarConteudo() {
if (document.getElementById) {  // DOM3 = IE5, NS6
document.getElementById('hidepage').style.visibility = 'hidden';
}
else {
if (document.layers) {  // Netscape 4
document.hidepage.visibility = 'hidden';
}
else {  // IE 4
document.all.hidepage.style.visibility = 'hidden';
      }
   }
}

   function Verifica_Browser( ) {       
      //verifica se o browser tem suporte a ajax
      try {
         ajax = new ActiveXObject("Microsoft.XMLHTTP");
      } 
      catch( e ) {
         try {
            ajax = new ActiveXObject("Msxml2.XMLHTTP");
         }
         catch( ex ) {
            try {
               ajax = new XMLHttpRequest();
            } catch( exc ) {
               	alert("Este browser não tem recursos para uso do Ajax");
               	ajax = null;
        		}
    		}
    	}
		return ajax;
	}
	
	function Simple_request( div, path ) {          
        //se tiver suporte ajax     
        if( ( ajax = Verifica_Browser( ) ) != null ) {      
            idOpcao  = document.getElementById( div );          
            ajax.open("POST", path , true );
            ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            ajax.onreadystatechange = function() {
                //enquanto estiver processando...emite a msg de carregando
                if(ajax.readyState == 1) {
                    idOpcao.innerHTML = "<h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A efectuar pedido. Aguarde por favor...<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img align='middle' src='AplicacaoEmail/Media/AguardarResposta.gif'></h3>";
                }
                if(ajax.readyState == 4 ) {
                    if( ajax.responseText ) {                       
                        idOpcao.innerHTML = ajax.responseText;
                    } else {
                        idOpcao.innerHTML = "O ficheiro nao foi encontrado";
                    }                   
                }
             }
             ajax.send(1);
          }       
       }
       
	function PedidoSimplesComCabecalho( div, path, cabecalho ) {          
        //se tiver suporte ajax     
        if( ( ajax = Verifica_Browser( ) ) != null ) {      
            idOpcao  = document.getElementById( div );          
            ajax.open("POST", path , true );
            ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            ajax.onreadystatechange = function() {
                //enquanto estiver processando...emite a msg de carregando
                if(ajax.readyState == 1) {
                    idOpcao.innerHTML = "<h2>" + cabecalho + "</h2><hr><h3>A efectuar pedido. Aguarde por favor...<br><br><img align='middle' src='AplicacaoEmail/Media/AguardarResposta.gif'></h3>";
                }
                if(ajax.readyState == 4 ) {
                    if( ajax.responseText ) {                       
                        idOpcao.innerHTML = ajax.responseText;
                    } else {
                        idOpcao.innerHTML = "O ficheiro nao foi encontrado";
                    }                   
                }
             }
             ajax.send(1);
          }       
       }
       
       
       
function MostraResposta(id) 
{
  var itm = null;
  if (document.getElementById) {
	itm = document.getElementById(id);
  } else if (document.all){
	itm = document.all[id];
  } else if (document.layers){
	itm = document.layers[id];
  }
  if (!itm) {
  }
  else if (itm.style) {
	if (itm.style.display == "none") {
	  itm.style.display = "";
	}
	else {
	  itm.style.display = "none";
	}
  }
  else {
	itm.visibility = "show";
  }
}

