// JavaScript Document
// -------------------------------------------------------------------
// Image Thumbnail Viewer Script- By Dynamic Drive, available at: http://www.dynamicdrive.com
// Last updated: July 7th, 2008- Fixed enlarged image not showing in IE sometimes
// -------------------------------------------------------------------
function visivel(id) {
document.getElementById(id).style.visibility = 'visible';
return false;
}

function invisivel(id) {
document.getElementById(id).style.visibility = 'hidden';
return false;
}


var thumbnailviewer={
enableTitle: true, //Should "title" attribute of link be used as description?
enableAnimation: true, //Enable fading animation?
definefooter: '<div class="footerbar">FECHAR X</div>', //Define HTML for footer interface
defineLoading: '<img src="images/loading.gif" /> Carregando Imagem...', //Define HTML for "loading" div

/////////////No need to edit beyond here/////////////////////////

scrollbarwidth: 16,
opacitystring: 'filter:progid:DXImageTransform.Microsoft.alpha(opacity=10); -moz-opacity: 0.1; opacity: 0.1',
targetlinks:[], //Array to hold links with rel="thumbnail"

createthumbBox:function(){
//write out HTML for Image Thumbnail Viewer plus loading div
document.write('<div id="thumbBox" onClick="thumbnailviewer.closeit()"><div id="thumbImage"></div>'+this.definefooter+'</div>')
document.write('<div id="thumbLoading">'+this.defineLoading+'</div>')
this.thumbBox=document.getElementById("thumbBox")
this.thumbImage=document.getElementById("thumbImage") //Reference div that holds the shown image
this.thumbLoading=document.getElementById("thumbLoading") //Reference "loading" div that will be shown while image is fetched
this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
},


centerDiv:function(divobj){ //Centers a div element on the page
var ie=document.all && !window.opera
var dom=document.getElementById
var scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
var scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
var docwidth=(ie)? this.standardbody.clientWidth : window.innerWidth-this.scrollbarwidth
var docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
var docheightcomplete=(this.standardbody.offsetHeight>this.standardbody.scrollHeight)? this.standardbody.offsetHeight : this.standardbody.scrollHeight //Full scroll height of document
var objwidth=divobj.offsetWidth //width of div element
var objheight=divobj.offsetHeight //height of div element
var topposition=(docheight>objheight)? scroll_top+docheight/2-objheight/2+"px" : scroll_top+10+"px" //Vertical position of div element: Either centered, or if element height larger than viewpoint height, 10px from top of viewpoint
divobj.style.left=docwidth/2-objwidth/2+"px" //Center div element horizontally
divobj.style.top=Math.floor(parseInt(topposition))+"px"
divobj.style.visibility="visible"
},

showthumbBox:function(){ //Show ThumbBox div
thumbnailviewer.thumbLoading.style.visibility="hidden" //Hide "loading" div
this.centerDiv(this.thumbBox)
if (this.enableAnimation){ //If fading animation enabled
this.currentopacity=0.1 //Starting opacity value
this.opacitytimer=setInterval("thumbnailviewer.opacityanimation()", 20)
}
},


loadimage:function(link){ //Load image function that gets attached to each link on the page with rel="thumbnail"
if (this.thumbBox.style.visibility=="visible") //if thumbox is visible on the page already
this.closeit() //Hide it first (not doing so causes triggers some positioning bug in Firefox
var imageHTML='<img src="'+link.getAttribute("href")+'" style="'+this.opacitystring+'" />' //Construct HTML for shown image
if (this.enableTitle && link.getAttribute("title")) //Use title attr of the link as description?
imageHTML+='<br />'+link.getAttribute("title")
this.centerDiv(this.thumbLoading) //Center and display "loading" div while we set up the image to be shown
this.thumbImage.innerHTML=imageHTML //Populate thumbImage div with shown image's HTML (while still hidden)
this.featureImage=this.thumbImage.getElementsByTagName("img")[0] //Reference shown image itself
if (this.featureImage.complete)
thumbnailviewer.showthumbBox()
else{
this.featureImage.onload=function(){ //When target image has completely loaded
thumbnailviewer.showthumbBox() //Display "thumbbox" div to the world!
}
}
if (document.all && !window.createPopup) //Target IE5.0 browsers only. Address IE image cache not firing onload bug: panoramio.com/blog/onload-event/
this.featureImage.src=link.getAttribute("href")
this.featureImage.onerror=function(){ //If an error has occurred while loading the image to show
thumbnailviewer.thumbLoading.style.visibility="hidden" //Hide "loading" div, game over
}
},

setimgopacity:function(value){ //Sets the opacity of "thumbimage" div per the passed in value setting (0 to 1 and in between)
var targetobject=this.featureImage
if (targetobject.filters && targetobject.filters[0]){ //IE syntax
if (typeof targetobject.filters[0].opacity=="number") //IE6
targetobject.filters[0].opacity=value*100
else //IE 5.5
targetobject.style.filter="alpha(opacity="+value*100+")"
}
else if (typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax
targetobject.style.MozOpacity=value
else if (typeof targetobject.style.opacity!="undefined") //Standard opacity syntax
targetobject.style.opacity=value
else //Non of the above, stop opacity animation
this.stopanimation()
},

opacityanimation:function(){ //Gradually increase opacity function
this.setimgopacity(this.currentopacity)
this.currentopacity+=0.1
if (this.currentopacity>1)
this.stopanimation()
},

stopanimation:function(){
if (typeof this.opacitytimer!="undefined")
clearInterval(this.opacitytimer)
},


closeit:function(){ //Close "thumbbox" div function
this.stopanimation()
this.thumbBox.style.visibility="hidden"
this.thumbImage.innerHTML=""
this.thumbBox.style.left="-2000px"
this.thumbBox.style.top="-2000px"
},

cleanup:function(){ //Clean up routine on page unload
this.thumbLoading=null
if (this.featureImage) this.featureImage.onload=null
this.featureImage=null
this.thumbImage=null
for (var i=0; i<this.targetlinks.length; i++)
this.targetlinks[i].onclick=null
this.thumbBox=null
},

dotask:function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false)
else if (target.attachEvent)
target.attachEvent(tasktype, functionref)
},

init:function(){ //Initialize thumbnail viewer script by scanning page and attaching appropriate function to links with rel="thumbnail"
if (!this.enableAnimation)
this.opacitystring=""
var pagelinks=document.getElementsByTagName("a")
for (var i=0; i<pagelinks.length; i++){ //BEGIN FOR LOOP
if (pagelinks[i].getAttribute("rel") && pagelinks[i].getAttribute("rel")=="thumbnail"){ //Begin if statement
pagelinks[i].onclick=function(){
thumbnailviewer.stopanimation() //Stop any currently running fade animation on "thumbbox" div before proceeding
thumbnailviewer.loadimage(this) //Load image
return false
}
this.targetlinks[this.targetlinks.length]=pagelinks[i] //store reference to target link
} //end if statement
} //END FOR LOOP
//Reposition "thumbbox" div when page is resized
this.dotask(window, function(){if (thumbnailviewer.thumbBox.style.visibility=="visible") thumbnailviewer.centerDiv(thumbnailviewer.thumbBox)}, "resize")


} //END init() function

}

thumbnailviewer.createthumbBox() //Output HTML for the image thumbnail viewer
thumbnailviewer.dotask(window, function(){thumbnailviewer.init()}, "load") //Initialize script on page load
thumbnailviewer.dotask(window, function(){thumbnailviewer.cleanup()}, "unload")



<!--

function  centerpopup(url,nome,altura,largura){ 
    /*    Função que abre uma janela tipo popup no centro absoluto da janela. 
        A função recebe a url, o nome, a altura e a largura. 
        Para facilitar ainda mais, pode-se definir um tamanho fixo como 
        mínimo baseado na resolução do monitor de quem está acessando     */ 
  var minimo = screen.width/4; // esta será a largura e a altura mínima    evitando uma  
  // janela muito pequena 
  var maximo = screen.height - 100; // esta será a largura e a altura máxima 
  // evitando uma janela muito grande 
  var w = ( ( ( (largura>minimo)? largura:minimo )<maximo )?largura:maximo); 
  var h = ( ( ( ( altura>minimo )? altura:minimo )<maximo )?altura:maximo); 
  var l = (screen.width/2) - w/2;    // valor para a posição na horizontal 
  var t = (screen.height/2) - h/2;    // valor para a posição na vertical 
  var argumentos = 'copyhistory=yes,width='+w+',height='+h+',left='+l+',top='+t+',,scrollbars=yes,screenX='+l+',screenY='+t; 
  var novajan = window.open(url,nome, argumentos); 
} 
// validar dinheiro
function validaDinheiro(fld,e)
{
var milSep = ".";
var decSep = ",";
var sep = 0;
var key = '';
var i = j = 0;
var len = len2 = 0;
var strCheck = '0123456789';
var aux = aux2 = '';
var whichCode = (window.Event) ? e.which : e.keyCode;

if (whichCode == 13)
return true;

key = String.fromCharCode(whichCode);

if (strCheck.indexOf(key) == -1)
return false;

len = fld.value.length;

for (i = 0; i < len; i++)
if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep))
break;

aux = '';

for (; i < len; i++)
if (strCheck.indexOf(fld.value.charAt(i))!=-1)
aux += fld.value.charAt(i);

aux += key;
len = aux.length;

if (len == 0)
fld.value = '';

if (len == 1)
fld.value = '0'+ decSep + '0' + aux;

if (len == 2)
fld.value = '0'+ decSep + aux;

if (len > 2)
{
aux2 = '';

for (j = 0, i = len - 3; i >= 0; i--)
{
if (j == 3)
{
aux2 += milSep;
j = 0;
}
aux2 += aux.charAt(i);
j++;
}

fld.value = '';
len2 = aux2.length;

for (i = len2 - 1; i >= 0; i--)
fld.value += aux2.charAt(i);
fld.value += decSep + aux.substr(len - 2, len);
}

return false;

}
function somentetexto(fld,e,v)
{
var milSep = "";
var decSep = "";
var sep = 0;
var key = '';
var i = j = 0;
var len = len2 = 0;
if(v==1){
	var strCheck = '0123456789';
}else{
	var strCheck = 'qwertyuiopasdfghjklzxcvbnm_';
}
var aux = aux2 = '';
var whichCode = (window.Event) ? e.which : e.keyCode;

if (whichCode == 13)
return true;

key = String.fromCharCode(whichCode);

if (strCheck.indexOf(key) == -1)
return false;

len = fld.value.length;

for (i = 0; i < len; i++)
if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep))
break;

aux = '';

for (; i < len; i++)
if (strCheck.indexOf(fld.value.charAt(i))!=-1)
aux += fld.value.charAt(i);

aux += key;
len = aux.length;

if (len == 0)
fld.value = '';

if (len == 1)
fld.value = decSep + aux;

if (len == 2)
fld.value = decSep + aux;

if (len > 2)
{
aux2 = '';

for (j = 0, i = len - 3; i >= 0; i--)
{
if (j == 3)
{
aux2 += milSep;
j = 0;
}
aux2 += aux.charAt(i);
j++;
}

fld.value = '';
len2 = aux2.length;

for (i = len2 - 1; i >= 0; i--)
fld.value += aux2.charAt(i);
fld.value += decSep + aux.substr(len - 2, len);
}

return false;

}



function selecionar_todas(retorno) {
  
   var frm = document.form2;
    for(i = 0; i < frm.length; i++) {        
        if(frm.elements[i].type == "checkbox") {
            frm.elements[i].checked = retorno;
        }
     }
}



//
function bloquear(campo){
    if(document.getElementById(campo).disabled == false){
        document.getElementById(campo).disabled = true;
    }else{
        document.getElementById(campo).disabled = false;
    }
}


// selecionar vários chekbox
function checkAll(mode)
{
    for(i = 0; i < document.forms[0].elements.length; i++)
    {
        if( mode == "check" )
        {
            document.forms[0].elements[i].checked = true;
        }
        else
        {
            document.forms[0].elements[i].checked = false;
        }
    }
}


function ComparaSenha(valor1, valor2)
{
  var result = false;
  if (valor1.value == valor2.value) {
	  result = true;
  } else {
	alert('A senha está diferente da confirmação. Verifique.');
	valor1.focus();
	result = false;
  }
	
  return result;
}

function VerificaEmail(email)
{
  var result = false;
  var theStr = new String(email);
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function ValidaCampo(formField,fieldLabel)
{
	var result = true;
	
	if (formField.value == "")
	{
		alert('O campo "' + fieldLabel +'" está em branco.');
		formField.focus();
		result = false;
	}
	
	return result;
}

function Digitos(str)
{
	return ValidaChar(str,"0123456789");
}

function ValidaChar(str,charset)
{
	var result = true;

	// Note: doesn't use regular expressions to avoid early Mac browser bugs	
	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))<0)
		{
			result = false;
			break;
		}
	
	return result;
}

function ValidaEmail(formField,fieldLabel,required)
{
	var result = true;
	
	if (required && !ValidaCampo(formField,fieldLabel))
		result = false;

	if (result && ((formField.value.length < 3) || !VerificaEmail(formField.value)) )
	{
		alert("Por favor, insira um endereço de email completo. Exemplo: seunome@seudominio.com.br");
		formField.focus();
		result = false;
	}
   
  return result;

}

function ValidaNumeros(formField,fieldLabel,required)
{
	var result = true;

	if (required && !ValidaCampo(formField,fieldLabel))
		result = false;
  
 	if (result)
 	{
 		if (!Digitos(formField.value))
 		{
 			alert('Por favor, insira somente números no campo "' + fieldLabel +'".');
			formField.focus();		
			result = false;
		}
	} 
	
	return result;
}


function ValidaInteiro(formField,fieldLabel,required)
{
	var result = true;

	if (required && !ValidaCampo(formField,fieldLabel))
		result = false;
  
 	if (result)
 	{
 		var num = parseInt(formField.value,10);
 		if (isNaN(num))
 		{
 			alert('Por favor, insira numeros, ",", "."  no campo "' + fieldLabel +'".');
			formField.focus();		
			result = false;
		}
	} 
	
	return result;
}


function ValidaData(formField,fieldLabel,required)
{
	var result = true;

	if (required && !ValidaCampo(formField,fieldLabel))
		result = false;
  
 	if (result)
 	{
 		var elems = formField.value.split("/");
 		
 		result = (elems.length == 3); // should be three components
 		
 		if (result)
 		{
 			var month = parseInt(elems[1],10);
  			var day = parseInt(elems[0],10);
 			var year = parseInt(elems[2],10);
			result = Digitos(elems[0]) && (month > 0) && (month < 13) &&
					 Digitos(elems[1]) && (day > 0) && (day < 32) &&
					 Digitos(elems[2]) && ((elems[2].length == 2) || (elems[2].length == 4));
 		}
 		
  		if (!result)
 		{
 			alert('Por favor, insira uma data no formato DD/MM/AAAA no campo "' + fieldLabel +'".');
			formField.focus();		
		}
	} 
	
	return result;
}



function abrir_janela(endereco){
janela=window.open(endereco,"","width=700,height=500,scrollbars=yes,status=yes");

//interceptacao de erro na abertura da janela
text = "Se a janela nao estava abrindo\ntalvez seja porque voce tenha um\nprograma bloqueador de pop-up!\nObservacao » O windows XP service pack 2\nbloqueia pop-ups!";
if(janela == null) { alert(text); return; }
//fim
janela.moveTo(120,120);
}


function abrir_janela_loja(endereco){
janela=window.open(endereco,"","width=400,height=400,scrollbars=yes,status=no");

//interceptacao de erro na abertura da janela
text = "Se a janela nao estava abrindo\ntalvez seja porque voce tenha um\nprograma bloqueador de pop-up!\nObservacao » O windows XP service pack 2\nbloqueia pop-ups!";
if(janela == null) { alert(text); return; }
//fim
janela.moveTo(300,150);
}



function abre(endereco){
//janela=window.open(endereco,"","width=700,height=500,scrollbars=yes,status=yes");
janela=window.open(endereco,"","");
location.reload();
return true;
}


function send(country){
window.opener.document.form1.nome.value=country;
self.close();
}

/*
function EnterTab(){
if (event.keyCode == 13) event.keyCode = 9;

}*/

function EnterTab (field, event) {
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
if (keyCode == 13) {
var i;
for (i = 0; i < field.form.elements.length; i++)
if (field == field.form.elements[i])
break;
i = (i + 1) % field.form.elements.length;
field.form.elements[i].focus();
return false;
}
else
return true;
}


function Numeros(event){
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
var caract = new RegExp(/[0-9\b\t/]+$/i);
var caract = caract.test(String.fromCharCode(keyCode));
if(!caract){
keyCode=0;
return false;
}
}


function Numeros_Reais(event){
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
var caract = new RegExp(/[0-9.\b\t/]+$/i);
var caract = caract.test(String.fromCharCode(keyCode));
if(!caract){
keyCode=0;
return false;
}
}

function dialogo(){
caixa = "window.showModalDialog('http://localhost/aplicacao/consjuizo.php', 'nome', 'resizable:no; dialogHeight: 300px; dialogWidth: 400px; status:no;center:yes;');";
eval(caixa);
}


function confirma_exclusao(url)
{
if (confirm ("Você tem certeza que deseja excluir esse registro?" + "\n\n"+ "Aperte OK para confirmar a exclusão ou Cancelar.")){
window.location.assign(url);
return true;
}
}

function FormataData(objeto,teclapress) 
{ 
    //var tecla = teclapress.keyCode; 
	var tecla = (teclapress.which) ? teclapress.which : teclapress.keyCode;

    //Testa se o campo está selecionado, se estiver, limpa o conteúdo para nova digitação. 
    var selecionado = document.selection.createRange();  
    var selecao        = selecionado.text;  
    if((selecao != "") && (tecla != 8) && (tecla != 9) && (tecla != 13) && (tecla != 35) && (tecla != 36) && (tecla != 46) && (tecla != 16) && (tecla != 17) && (tecla != 18) && (tecla != 20) && (tecla != 27) && (tecla != 37) && (tecla != 38) && (tecla != 39) && (tecla != 40)) {objeto.value = "";} 



    if(((window.event.keyCode == 13) || (window.event.keyCode == 9))&&objeto.value != "") 
    { 
        if(!(ValidaData(objeto))) 
            { 
                window.event.cancelBubble = true; 
                window.event.returnValue = false; 
                alert("Data Inválida"); 
                objeto.value = ""; 
                objeto.focus(); 
            } 
    } 

    if (( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )&& objeto.value.length < (10)) 
    { 
        vr = objeto.value; 
        vr = vr.replace( "/", "" ); 
        vr = vr.replace( "/", "" ); 
        tam = vr.length; 

        if (tam < 8) 
            { 
                if (tecla != 8) {tam = vr.length + 1 ;} 
            } 
        else 
            { 
                window.event.cancelBubble = true; 
                window.event.returnValue = false; 
            } 
         
        if ((tecla == 8) && (tam > 1)) 
            { 
                tam = tam - 1 ; 
                objeto.value = vr.substr(0,tam); 
                window.event.cancelBubble = true; 
                window.event.returnValue = false; 
            } 
                if ( tam <= 4 && tecla != 8){  
                     objeto.value = vr ; } 

                if ( (tam >= 4) && (tam <= 6) ){ 
                     objeto.value = vr.substr(0, tam - 4) + '/' + vr.substr( tam - 4, 4 ); } 

                if ( (tam >= 6) && (tam <= 8) ){ 
                    objeto.value = vr.substr(0, tam - 6 ) + '/' + vr.substr( tam - 6, 2 ) + '/' + vr.substr( tam - 4, 4 ); } 

                if ((tam == (8)) && tecla != 8) 
                    { 
                        if(tecla >=96 && tecla <=105) 
                            { 
                                tecla = tecla - 48; 
                            } 

                        objeto.value = objeto.value + (String.fromCharCode(tecla)); 
                        window.event.cancelBubble = true; 
                        window.event.returnValue = false; 

                        if (!(ValidaData(objeto))) 
                            { 
                                alert("Data Inválida"); 
                                objeto.value = ""; 
                                objeto.focus(); 
                            } 
                    } 
    } 
    else if((window.event.keyCode != 8) && (window.event.keyCode != 9) && (window.event.keyCode != 13) && (window.event.keyCode != 35) && (window.event.keyCode != 36) && (window.event.keyCode != 46)) 
        { 
            event.returnValue = false; 
        } 
} 


/***
* Descrição.: formata um campo do formulário de acordo com a máscara informada...
* Parâmetros: 
* - objForm (o Objeto Form)
* - strField (string contendo o nome do textbox)
* - sMask (mascara que define o formato que o dado será apresentado:
* "9" para definir números 
* "x" para definir somente letras maiusculas e minusculas SEM espaço
* "!" para qualquer caracter
*
* - evtKeyPress (evento)
* Uso...: <input type="textbox"
* name="xxx".....
* onkeypress="return txtBoxFormat(document.rcfDownload, 'str_cep', '99999-999', event);">
*
* Caracteres aceitos para mascara : -,;:./() espaço
* 
* Observação: As máscaras podem ser representadas como os exemplos abaixo:
* CEP -> 99.999-999
* CPF -> 999.999.999-99
* CNPJ -> 99.999.999/9999-99
* Data -> 99/99/9999
* Tel Resid -> (99) 999-9999
* Tel Cel -> (99) 9999-9999
* Processo -> 99.999999999/999-99
* C/C -> 999999-!
* Hora -> 99:99:99 
* Placa -> xxx - 9999
***/

function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {
var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;
nTecla = (evtKeyPress.which) ? evtKeyPress.which : evtKeyPress.keyCode;
sValue = objForm[strField].value;
// Limpa todos os caracteres de formatação que
// já estiverem no campo.
expressao = /[\.\/\-\(\)\,\;\: ]/gi;
sValue = sValue.toString().replace(expressao, '');
fldLen = sValue.length;
mskLen = sMask.length;

i = 0;
nCount = 0;
sCod = "";
mskLen = fldLen;

while (i <= mskLen) {
bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ",") || (sMask.charAt(i) == ";") || (sMask.charAt(i) == ":"))
bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

if (bolMask) {
sCod += sMask.charAt(i);
mskLen++; }
else {
sCod += sValue.charAt(nCount);
nCount++;
}

i++;
}

objForm[strField].value = sCod;

if (nTecla != 8 && nTecla != 13)
{ // backspace enter
if (sMask.charAt(i-1) == "9") 
{ // apenas números...
return ((nTecla > 47) && (nTecla < 58)); 
} // números de 0 a 9
else 
{ 
if (sMask.charAt(i-1) == "x") 
{ // apenas letras... Sem espaco
return ((nTecla > 64) && (nTecla < 123)); 
} // maiusculas e minusculas de A a z sem acentos
else 
{ // qualquer caracter...
return true;
} 
} 
}
else 
{
return true;
}
}


//Fim da Função Máscaras Gerais
document.write('<');
document.write('script src="calendario.js');
document.write('" type="text/javascript"></script');
document.write('>'); 

//-->