// JavaScript Document



/*=======================================================================================================================*/
//APAGA CAMPO DO FORMULÁRIO AO CLICAR SOBRE ELE
function apaga(campo) { if (campo.value == campo.defaultValue) { campo.value = ""; } }
function escreve(campo) { if (campo.value == "") { campo.value = campo.defaultValue; } }



/*=======================================================================================================================*/
//ABRE POP-UP PARA ENVIAR FORMULÁRIO
function enviaForm1(valorx){ 
largura = 400;
altura = 300;
w = screen.width;
h = screen.height;
meio_w = w/2;
meio_h = h/2;
altura2 = altura/2;
largura2 = largura/2;
meio1 = meio_h-altura2;
meio2 = meio_w-largura2;
window.open('','Popup','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, height=' + altura + ', width=' + largura + ', top='+meio1+', left='+meio2+'');
if (valorx == "0"){document.form0.submit();} 
if (valorx == "1"){document.form1.submit();} 
if (valorx == "2"){document.form2.submit();} 
if (valorx == "3"){document.form3.submit();} 
if (valorx == "4"){document.form4.submit();} 
if (valorx == "5"){document.form5.submit();} 
}



/*=======================================================================================================================*/
//MÁSCARA PARA CAMPOS DO FORMULÁRIO
function formata(campo, mask, evt) { 
if(document.all) { // Internet Explorer
key = evt.keyCode; }
else{ // Nestcape
key = evt.which;
}
if (key == 8) {
return true;
}
string = campo.value;  
i = string.length;
if (i < mask.length) {
if (mask.charAt(i) == '?') {
return (key > 47 && key < 58);
} else {
if (mask.charAt(i) == '!') {  return true;  }
for (c = i; c < mask.length; c++) {
if (mask.charAt(c) != '?' && mask.charAt(c) != '!')
campo.value = campo.value + mask.charAt(c);
else if (mask.charAt(c) == '!'){
return true;
} else {
return (key > 47 && key < 58);
}
}
}
} else return false;
}




/*=======================================================================================================================*/
//ABRE POP-UP
function abrir(pagina,largura,altura) {
w = screen.width;
h = screen.height;
meio_w = w/2;
meio_h = h/2;
altura2 = altura/2;
largura2 = largura/2;
meio1 = meio_h-altura2;
meio2 = meio_w-largura2;
window.open(pagina,'','height=' + altura + ', width=' + largura + ', top='+meio1+', left='+meio2+''); 
}




/*=======================================================================================================================*/
//EDITA O ATRIBUTO TITLE

var obj;
var tagname = new Array('a', 'img', 'address');
var tooltip = {
init: function(){
obj = document.createElement('div');
obj.setAttribute('id', 'tooltip');
document.body.appendChild(obj);
window.document.onmousemove = this.move;
for(var i = 0; i < tagname.length; i++){
var ancora = document.getElementsByTagName(tagname[i]);
for(var j = 0; j < ancora.length; j++){
var a = ancora[j];
texttitle = a.getAttribute('title');
if(texttitle){
a.setAttribute('sTitle', texttitle);
a.removeAttribute('title');
a.onmouseover = function(){
t = this.getAttribute('sTitle');
obj.innerHTML = t;
obj.style.display = 'block';
};// end function					
a.onmouseout = function(){
obj.innerHTML = '';
obj.style.display = 'none';
};// end function
}//end if
}//end for
}//end for
},
move: function(e){
e = e || window.event;
if(e.pageX || e.pageY){
x = e.pageX;
y = e.pageY;
}else{
x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
y = e.clientY + (document.documentElement.scrollTop ||  document.body.scrollTop) -  document.documentElement.clientTop;
}//end if
obj.style.left = (x+11)+'px';
obj.style.top = (y-30)+'px';
obj.style.position = 'absolute';
return true;
}
}



/*=======================================================================================================================*/

