﻿
/* Formatação para qualquer mascara */
	function formatar(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);
		}
	}
    

    function fnTrapKD(){
	k = event.keyCode
	//alert(k)

	//backspace - tab - shift - . alfa - . num
	if(k==8 || k == 9 || k == 16 ){
		event.returnValue=true
		return
	}
	//0-9 alfa
	if(k>=48 && k<=57){
		event.returnValue=true
		return
	}
	//0-9 num
	if(k>=96 && k<=105){
		event.returnValue=true
		return
	}
	//setas
	if(k>=37 && k<=40){
		event.returnValue=true
		return
	}
	//delete
	if(k==46){
		event.returnValue=true
		return
	}

	event.returnValue=false
}     

function EditaNoticia(val)
{
    window.location.href='index.aspx?editar='+ val
}


function Editar(endereco,val)
{
    window.location.href=''+endereco+'?edit='+ val
}


function PopUp(u, w, h){
    l = (screen.width - w) / 2;
    t = (screen.height - h) / 2;
    window.open(u, 'wpopup', 'top=' + t + ', left=' + l + ', width=' + w + ', height=' + h + ', scrollbars=yes, resizable=no, menubar=no, location=no, status=no, toolbar=no');
}

function PopUpS(u, w, h){
    l = (screen.width - w) / 2;
    t = (screen.height - h) / 2;
    window.open(u, 'wpopup', 'top=' + t + ', left=' + l + ', width=' + w + ', height=' + h + ', scrollbars=no, resizable=no, menubar=no, location=no, status=no, toolbar=no');
}

function PopUpB(u, w, h){
    l = (screen.width - w)/3;
    t = (screen.height - h) / 2;
    window.open(u, 'wpopup', 'top=' + t + ', left=' + l + ', width=' + w + ', height=' + h + ', scrollbars=no, resizable=no, menubar=no, location=no, status=no, toolbar=no');
}

function Del(endereco,val)
{
    if(confirm('Confirma exclusão deste Registro ?'))
    {
        window.location.href=''+endereco+'?DelId='+ val
    }
 }



var reDate1 = /^\d{1,2}\/\d{1,2}\/\d{1,4}$/;
var reDate2 = /^[0-3]?\d\/[01]?\d\/(\d{2}|\d{4})$/;
var reDate3 = /^(0?[1-9]|[12]\d|3[01])\/(0?[1-9]|1[0-2])\/(19|20)?\d{2}$/;
var reDate4 = /^((0?[1-9]|[12]\d)\/(0?[1-9]|1[0-2])|30\/(0?[13-9]|1[0-2])|31\/(0?[13578]|1[02]))\/(19|20)?\d{2}$/;
var reDate5 = /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/\d{4}$/;
var reDate = reDate4;

function doDate(source, arguments)
{
    arguments.IsValid = true;

    pStr = document.forms[0].txtNasc.value;
    pFmt = 5;

eval("reDate = reDate" + pFmt);

if (reDate.test(pStr)) {
    arguments.IsValid = true;
} else if (pStr != null && pStr != "") {
    arguments.IsValid = false;
}
return;

} // doDate


function LoadFlash(caminho,largura,altura)
{
    document.write('<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="'+largura+'" height="'+altura+'">');
    document.write('<param name="movie" value="'+caminho+'">');
    document.write('<param name="quality" value="high">'); 
    document.write('<param name="wmode" value="transparent">');
    document.write('<param name="menu" value="false">');
    document.write('<embed src="'+caminho+'" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+largura+'" height="'+altura+'"></embed>');
    document.write('</object>');
}	

function somenteNumero(textbox) { 
    var inputKey = event.keyCode; 
    if(!(inputKey > 47 && inputKey < 58) && (inputKey != 44)) {
	    if (inputKey == 46){
		    event.keyCode = 44;
	    } else { 
		    event.keyCode = 0; 
	    }
    }
}

function Deletar(endereco,val)
{
    if(confirm('Confirma exclusão do registro ?'))
    {
        window.location.href=''+endereco+'?DelId='+ val
    }
 }

function PopModal(adress,w,h)
{
    var TT;
	var aForm;
	
	var win = window.showModalDialog(adress, window, "status:yes;dialogWidth:"+w+"px;dialogHeight:"+h+"px");
//	var win = window.showModalDialog(adress, window, "status:yes;dialogWidth:600px;dialogHeight:480px");
}

function Fechar(){ window.close();}

		