//Chama flash no site (correção do IE)
function exibeFash(swf, width, height, wmode, cache){
noCache = cache || cache == undefined ? "" : "?" + new Date();
wmode = wmode || wmode == undefined ? "opaque" : "transparent";

monta_swf = "";
monta_swf += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\""+ width +"\" height=\""+ height +"\" title=\"\">";
monta_swf += "<param name=\"movie\" value=\""+ swf + noCache +"\" />";
monta_swf += "<param name=\"quality\" value=\"high\" />";
monta_swf += "<param name=\"menu\" value=\"0\" />";
monta_swf += "<param name=\"wmode\" value=\""+ wmode +"\" />";
monta_swf += "<embed src=\""+ swf + noCache +"\" quality=\"high\" wmode=\""+ wmode +"\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+ width +"\" height=\""+ height +"\"></embed>";
monta_swf += "</object>";

document.write(monta_swf);
}


function MSN(URL) {
  var width = 400;
  var height = 280;
  var left = 50;
  var top = 10
  window.open(URL, 'MSN', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

function Enviar(URL) {
  var width = 450;
  var height = 300;
  var left = 50;
  var top = 10
  window.open(URL, 'Enviar', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

function Comprar(url) {
  window.open(url,'comprar','width=535, height=230, top=12, left=15, scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

function cores(url) {
  window.open(url,'cores','width=225, height=169, top=10, left=10, scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

function AbreFotoAgenda(url) {
  window.open(url,'fotoagenda','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150');
}

function AbreAudio(URL) {
  var width = 300;
  var height = 195;
  var left = 50;
  var top = 10
  window.open(URL, 'audio', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

function confirmaExclusao(aURL) {
	if(confirm('Você tem certeza que deseja excluir?')) {
	location.href = aURL;
	}
}

function confirmaPedido(aURL) {
	if(confirm('Você tem certeza que deseja confirmar este pedido?')) {
	location.href = aURL;
	}
}

function mudaPedido(aURL) {
	if(confirm('Você tem certeza que deseja mudar este pedido p/ orçamento?')) {
	location.href = aURL;
	}
}


function AbreListaProdutos(URL) {
  var width = 675;
  var height = 450;
  var left = 50;
  var top = 10
  window.open(URL, 'AbreListaProdutos', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

function AtualizaValores(aURL) {
	if(confirm('Você tem certeza que deseja atualizar os valores deste orçamento?')) {
	location.href = aURL;
	}
}


function confirmaEntrega(aURL) {
	if(confirm('Você tem certeza que deseja confirmar a entrega deste pedido?')) {
	location.href = aURL;
	}
}

function mudaEntrega(aURL) {
	if(confirm('Você tem certeza que deseja mudar este pedido p/ nao entregue?')) {
	location.href = aURL;
	}
}

// FUNCAO SELEIONA TODOS REGISTROS PRA EXCLUIR
cont321 = 0;
function SelectAll() { 
   for (var i=0;i<document.FORMLISTA.elements.length;i++) {
     var x = document.FORMLISTA.elements[i];
     if (x.id == 'check_sel') { 
	   if (cont321 == 0)
         x.checked = true;
       else
         x.checked = false;	   
     } 
   }
   if (cont321 == 0)
   {    
     var elem = document.getElementById("sel_todos");
     elem.value = "Desmarcar todos";
     cont321 = 1;
   } 
   else 
   {
     var elem = document.getElementById("sel_todos");
     elem.value = "Selecionar todos";
     cont321 = 0;
   }  
}

// FUNCAO SELEIONA TODOS REGISTROS PRA EXCLUIR
function checkdeletetion(){
   if (!confirm("Você realmente deseja deletar este registro.") == false )
   FORMLISTA.submit();
}

function confirmaBloqueio(aURL) {
	if(confirm('Você tem certeza disso?')) {
	location.href = aURL;
	}
}

// FORMATAR CAMPO COM MASCARA
function FormatarCampo(src, mask) 
{
  var i = src.value.length;
  var saida = mask.substring(0,1);
  var texto = mask.substring(i)
if (texto.substring(0,1) != saida) 
  {
        src.value += texto.substring(0,1);
  }
}


// FUNCAO DE IMPRIMIR
function Imprimir(URL) {
  var width = 650;
  var height = 500;
  var left = 50;
  var top = 10
  window.open(URL, 'imprimir', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

// FUNCAO DE EFEITO NAS FOTOS
function makevisible(cur,which){
if (which==0)
cur.filters.alpha.opacity=60
else
cur.filters.alpha.opacity=100
}


// FUNCAO AJAX PRA ABRIR PAGINAS
try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}

function FotoG(url, id, page){
	var loading = "<div align='center'></br><img src='images/layout/loading.gif'></br>Aguarde Carregando...</div>";
	var div_itens = document.getElementById("FotoG");
	div_itens.innerHTML = loading;
	if(xmlhttp){
		xmlhttp.open("POST", url, id, page, true);
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
		var exibi = "url="+url+"?id="+id+"&page="+page;
		xmlhttp.send(exibi);
		xmlhttp.onreadystatechange=function(){
			if (xmlhttp.readyState==4){
				var texto=xmlhttp.responseText;
				texto=texto.replace(/\+/g," ");
				texto=unescape(texto);
				div_itens.innerHTML = texto;
			}
		}
	}
}


function Url(pg){
	var loading = "<div align='center'></br><img src='images/layout/loading.gif'></br>Aguarde Carregando...</div>";
	var div_itens = document.getElementById("miolo");
	div_itens.innerHTML = loading;
	if(xmlhttp){
		xmlhttp.open("POST", "estrutura/"+pg+".php", true);
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
		var exibi = "pg="+pg;
		xmlhttp.send(exibi);
		xmlhttp.onreadystatechange=function(){
			if (xmlhttp.readyState==4){
				var texto=xmlhttp.responseText;
				texto=texto.replace(/\+/g," ");
				texto=unescape(texto); 
				div_itens.innerHTML = texto;
			}
		}
	}
}