// JavaScript Document

function validar_busca(){

			if(document.getElementById("search").value == "") {
				 alert('Busque com uma palavra!');
				 document.getElementById("search").focus();
				 return false;
			}
}



function ExcluiRelatFunc(nome, id){
if (confirm("Você tem certeza que deseja excluír o Relatório do dia -- " + nome + " ") ){
 
carregaPag("exemplo_" + id + "", "php", "detal_relat_agenda", "?sta=1&id_relatorio="+ id +"");

}
}

function ExcluiUser(nome, id){
if (confirm("Você tem certeza que deseja excluír o Usuário // " + nome + " ") ){
  window.location.href="?now=drop_user&alt=1&id_user="+ id +"";
}
}
function fnExcluiIng(nome, id){
if (confirm("Você tem certeza que deseja excluír o Produto // " + nome + " ") ){
  window.location.href="?now=drop_produto&cadastra_prod=2&idalter="+ id +"";
}
}
function fnExcluicatmae(nome, id){
if (confirm("Você tem certeza que deseja excluír Categoria Mãe \\\\\\ " + nome + " \\\\\\ 'Atenção você poderá perder todos os produtods cadastrados com essa categoria'") ){
  window.location.href="?now=drop_mae&cadastra_prod=2&idalter="+ id +"";
}
}
function fnExcluicatpai(nome, id){
if (confirm("Você tem certeza que deseja excluír Categoria Pai \\\\\\ " + nome + " \\\\\\ 'Atenção você poderá perder todas categorias Mães cadastradas com essa categoria Pai'") ){
  window.location.href="?now=drop_pai&cadastra_prod=2&idalter="+ id +"";
}
}
function ConfPag(nome, id){
if (confirm("Você tem certeza que deseja Confirmar que o pedido foi Lido do(a) \\\\\\ " + nome + " ") ){
  window.location.href="?now=ver_ped&cadastra_pago=2&idpag="+ id +"";
}
}
function Conf1(nome, id){
if (confirm("Você tem certeza que deseja Confirmar a conclusão do pedido de \\\\\\ " + nome + " ") ){
  window.location.href="?now=ver_pag&cadastra_pago=2&idconclui="+ id +"";
}
}
function Conf1funcionario(nome, id){
if (confirm("Você tem certeza que deseja Confirmar a conclusão do pedido de \\\\\\ " + nome + " ") ){
  window.location.href="?now=funcionarios&now_funcionario=ver_pag_funcionario&cadastra_pago=2&idconclui="+ id +"";
}
}
function ConfPagfuncionario(nome, id){
if (confirm("Você tem certeza que deseja Confirmar que o pedido foi Lido do(a) \\\\\\ " + nome + " ") ){
  window.location.href="?now=funcionarios&now_funcionario=ver_ped_funcionario&cadastra_pago=2&idpag="+ id +"";
}
}
function ConfVip(nome, id){
if (confirm("Você tem certeza que deseja Confirmar que o pedido foi Lido do(a) \\\\\\ " + nome + " ") ){
  window.location.href="?now=cliente_vip&now_vip=ver_ped_vip&cadastra_pago=2&idpag="+ id +"";
}
}

function Conf1Vip(nome, id){
if (confirm("Você tem certeza que deseja Confirmar a conclusão do pedido de \\\\\\ " + nome + " ") ){
  window.location.href="?now=cliente_vip&now_vip=ver_pag_vip&cadastra_pago=2&idconclui="+ id +"";
}
}
//Pedido Funcionario
function ExcluiPedido(nome, id, cod){
if (confirm("Você tem certeza que deseja Excluir pedido de \\\\\\ " + nome + " ") ){
  window.location.href="?now=funcionarios&now_funcionario=ver_ped_funcionario&exclui_pedido=3&idexclui="+ id +"&cod="+ cod +"";
}
}
function ExcluiPedido1(nome, id, cod){
if (confirm("Você tem certeza que deseja Excluir pedido de \\\\\\ " + nome + " ") ){
  window.location.href="?now=funcionarios&now_funcionario=ver_pag_funcionario&exclui_pedido=3&idexclui="+ id +"&cod="+ cod +"";
}
}
function ExcluiPedido2(nome, id, cod){
if (confirm("Você tem certeza que deseja Excluir pedido de \\\\\\ " + nome + " ") ){
  window.location.href="?now=funcionarios&now_funcionario=ver_conclui_funcionario&exclui_pedido=3&idexclui="+ id +"&cod="+ cod +"";
}
}
// Pedido Loja
function ExcluiPedido3(nome, id, cod){
if (confirm("Você tem certeza que deseja Excluir pedido de \\\\\\ " + nome + " ") ){
  window.location.href="?now=ver_ped&exclui_pedido=3&idexclui="+ id +"&cod="+ cod +"";
}
}
function ExcluiPedido4(nome, id, cod){
if (confirm("Você tem certeza que deseja Excluir pedido de \\\\\\ " + nome + " ") ){
  window.location.href="?now=ver_pag&exclui_pedido=3&idexclui="+ id +"&cod="+ cod +"";
}
}
//Pedido Cliente VIP
function ExcluiPedido5(nome, id, cod){
if (confirm("Você tem certeza que deseja Excluir pedido de \\\\\\ " + nome + " ") ){
  window.location.href="?now=cliente_vip&now_vip=ver_conclui_vip&exclui_pedido=3&idexclui="+ id +"&cod="+ cod +"";
}
}
function ExcluiPedido6(nome, id, cod){
if (confirm("Você tem certeza que deseja Excluir pedido de \\\\\\ " + nome + " ") ){
  window.location.href="?now=cliente_vip&now_vip=ver_ped_vip&exclui_pedido=3&idexclui="+ id +"&cod="+ cod +"";
}
}
function ExcluiPedido7(nome, id, cod){
if (confirm("Você tem certeza que deseja Excluir pedido de \\\\\\ " + nome + " ") ){
  window.location.href="?now=cliente_vip&now_vip=ver_pag_vip&exclui_pedido=3&idexclui="+ id +"&cod="+ cod +"";
}
}
<!--
   function finaliza() {
	   if(confirm('Deseja mesmo efetivar esse pedido ?')){
	   return true;
	} 
   
   }//FECHA FUNCTION
//-->

function atalho() {
     //F2
	if(navigator.appName == "Microsoft Internet Explorer") { 
		if (event.keyCode==113) {
			location='/admin/';
			
			event.keyCode=0;
			return false;
		}
	}
}
document.onkeydown=atalho;

function checaCampos()
{
	 	var form = document.form;

	 if(form.listar.value == "")
	  {
			 alert('Você deve escolher um dos Produtos para passar para o próximo passo !!!');
			 form.listar.focus();
			 return false;
		}
	 
	return true;
}


<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->


<!-- 
function MaskedTextBox_IE_addEvent(id) {
	document.getElementById(id).onkeypress = MaskedTextBox_IE_VerifyMask;
}

function MaskedTextBox_IE_FocusMask(e) {
	if(event.srcElement.value == '') {
		var i=1;
		var mask = event.srcElement.mask;
		if(mask == null)
			mask = event.target.attributes[event.target.attributes.length - 1].value;
		var maskChar = mask.substr(0, 1);
		var charCode = maskChar.toLowerCase().charCodeAt(0);
		while((charCode != 57) && ((charCode < 48) || (charCode > 57)) && (charCode != 99)) {
			event.srcElement.value = event.srcElement.value + maskChar;
			maskChar = mask.substr(i, 1);
			charCode = maskChar.toLowerCase().charCodeAt(0);
			i++;
		}
		if(event.srcElement.createTextRange) {
			var range = event.srcElement.createTextRange();
			
			range.moveStart('character', event.srcElement.value.length);
			range.collapse();
			range.select();
		}
	}
}

function MaskedTextBox_IE_VerifyMask(e) {
	if(document.selection != null) {
		if(document.selection.createRange().text != '')
			document.selection.clear();
	}
	var keyCode = event.keyCode;
	var autoFill = event.srcElement.autofill;
	if(autoFill == null)
		autoFill = event.target.attributes[event.target.attributes.length - 2].value;
	var mask = event.srcElement.mask;
	if(mask == null)
		mask = event.target.attributes[event.target.attributes.length - 1].value;
	var val = event.srcElement.value;
	var retValue = false;
	
	if(mask.length == 0 || keyCode == 13 || keyCode == 8 || keyCode == 0) {
		retValue = true;
	} else {
	
		var maskChar = mask.substr(val.length, 1);
		var nextMaskChar = '';
		if((val.length + 1) <= mask.length)
			nextMaskChar = mask.substr(val.length + 1, 1);
	
		if ((maskChar.charCodeAt(0) == 57) && (keyCode >= 48) && (keyCode <= 57)) // digit
			retValue = true;
		else if((maskChar.toLowerCase().charCodeAt(0) == 99) && (((keyCode >= 65) && (keyCode <=90)) || ((keyCode >= 97) && (keyCode <= 122)))) //&& (((keyCode >= 65) && (keyCode <= 90)) || ((keyCode >= 99) && (keyCode <= 122))))
			retValue = true;
		else if(maskChar == String.fromCharCode(keyCode)) // special
			retValue = true;
		else
			retValue = false;
			
		if(retValue && autoFill == 'true') {
			var i=1;
			var addedKey = false;
			while(nextMaskChar != '') {
				if((val.length + i) <= mask.length)
					nextMaskChar = mask.substr(val.length + i, 1);
				if(nextMaskChar.toLowerCase() == '9' || nextMaskChar.toLowerCase() == 'c')
					nextMaskChar = '';
				var charCode = nextMaskChar.toLowerCase().charCodeAt(0);
				if((charCode != 57) && ((charCode < 48) || (charCode > 57)) && (charCode != 99)) {
					if(!addedKey) {
						event.srcElement.value = event.srcElement.value + String.fromCharCode(keyCode) + nextMaskChar;
						addedKey = true;
					} else
						event.srcElement.value = event.srcElement.value + nextMaskChar;
					retValue = false;
				}
				i++;
			}
		}
	}
	
	return retValue;
}
// -->
///////////////////////////////////////////////////////////////////////////////////////////////////////////
///// Abre a visualização da agenda.
	ultima_agenda="";
		function agenda_abre(a) {
			if(ultima_agenda!="" || ultima_agenda==a) {
				fecha_agenda(ultima_agenda);
				if(ultima_agenda==a) a="";
				ultima_agenda="";
			}
			
			if(a!="") {
				document.getElementById("res_"+a).style.display='block';
				ultima_agenda=a;
			}
			/*if(div_ativa.style.display == 'none') {
				div_ativa.style.display='block';
			} else {
				div_ativa.style.display='none';
			}*/
		}
		
		function fecha_agenda(t) {	
			document.getElementById("res_"+t).style.display='none';
			carregaPag('res_'+t+'', 'php', 'agenda_retorna_altera', '');
		}

//////////////////////////////////////////////////////////////////////////////////////////////////////
// Seleciona todos dos itens do select multiplo da pesquisa pre definida da agenda

function tudo(elemento) {

//
var combo=document.forms[0].elements[elemento];
var q=combo.length;

for(i=0; i<q; i++) {
  combo.options[i].selected=true;
}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////
// Tela para modificações de banco de dados ex( Inserido com sucesso )

function time_modificao(tempo) {
	
	if(tempo>'') {
		var temp = tempo;
	}else{
		var temp = 5000;
	}

 	window.setTimeout(fecha_tela_modificacao, temp, true);

}
function fecha_tela_modificacao(){
	document.getElementById("TELA_MODIFICACAO").style.display='none';
}

//////////////////////////////////////////////////////////////////////////////////////////////////////
// Java script para o sistema de multi empresas
	function fecha_janela_marca() {
		document.getElementById('tela_trocamarca').style.display='none';
	}
	function abrir_janela_marca() {
		document.getElementById('tela_trocamarca').style.display='block';
	}
	function muda_empresa() {
		var empresa = document.getElementById("empresa_seta").value;
		window.location="gerenciador.php?empresa="+empresa;
	}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}