//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 = 406;
  var height = 286;
  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 = 460; 
  var height = 228;
  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=85;
	} else {
	cur.filters.alpha.opacity=100;
	}
}


function ValidaEmail(email) {
	return email.search(/(\w[\w[\w\.\+]+)@(.+)\.(\w+)$/)==0; 
}

function gE(ID) {
	return document.getElementById(ID);
}

function gEs(tag) {
	return document.getElementsByTagName(tag);
}


// PESQUISA QUAL É O BROWSER
function Pesquisa(){
var Dados = null;
	try {
	// Firefox, Opera 8.0+, Safari
	Dados = new XMLHttpRequest();
	} catch (e) {
	//Internet Explorer
		try {
		Dados = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		Dados = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
return Dados;
}


// FUNCAO MOSTRA DADOS
var Dados
function MostrarDados(arquivo, id, campo) {
Dados = Pesquisa();

var url = arquivo+id;

Dados.open("GET", url, true)
Dados.onreadystatechange = function(){
	if (Dados.readyState==1) { // Cria o efeito de loading
	loading(true, campo);
	}
	if (Dados.readyState==4 || Dados.readyState=="complete") {// Remove o efeito de loading
	//loading(false, campo);
	gE(campo).innerHTML = Dados.responseText;
	}
}
Dados.send(null)
}
	

// FUNCAO MOSTRA ID
function MostraID(id, campo){
gE(campo).value = id;
}


// CRIA EFEITO LOADING
function loading(act, campo) {
	if(act == true){
	var loading = "<div align='center' style='background-color:#FFFFFF;'><img src='http://www.paratotal.com.br/images/layout/img_carregando.gif'></div>"; 
	gE(campo).innerHTML = loading;
	}
	if(act == false){
	//FechaDIV('Carregando');
	var bgBody = gE(campo);
	bgBody.parentNode.removeChild(bgBody);
	}
}


// FUNCAO FECHA DIV
function FechaDIV(campo){
//gE(campo).style.visibility = 'hidden';
gE(campo).style.display = 'none';
}

// FUNCAO AUMENTA E DIMINUI FONTE DAS NOTICIAS
function aumentar(campo){
fontSize += 3;
gE(campo).style.fontSize = fontSize + "px";
}
  
function diminuir(campo){
fontSize -= 3;
gE(campo).style.fontSize = fontSize + "px";
}

// FUNCAO QUE EXIBE MENSAGEM NA BARRA DE STATUS
function ExibeMensagem(){ 
window.status = mensagem_status;
timerID= setTimeout("ExibeMensagem()", 0);
}
