

function box_links(tipo_link) {
	var selecione = eval("document.form_links." + tipo_link + ".options[document.form_links." + tipo_link + ".selectedIndex].value");
	if (selecione == 0) {
		alert("Selecione um link para visualizar em outra janela");
	}
	else {
		eval("window.open(document.form_links." + tipo_link + ".options[document.form_links." + tipo_link + ".selectedIndex].value);");
		eval("document.form_links." + tipo_link + ".options[0].selected=true;");
	}
}

//FORMATA TELEFONE

function TelefoneFormat(Campo, e) { 
    var key = ''; 
    var len = 0; 
    var strCheck = '0123456789'; 
    var aux = ''; 
    var whichCode = (window.Event) ? e.which : e.keyCode; 
     
    if (whichCode == 13 || whichCode == 8 || whichCode == 0) 
    { 
        return true;  // Enter backspace ou FN qualquer um que não seja alfa numerico 
    } 
    key = String.fromCharCode(whichCode); 
    if (strCheck.indexOf(key) == -1){ 
        return false;  //NÃO E VALIDO 
    } 
     
    aux =  Telefone_Remove_Format(Campo.value); 
     
    len = aux.length; 
    if(len>=10) 
    { 
        return false;    //impede de digitar um telefone maior que 10 
    } 
    aux += key; 
     
    Campo.value = Telefone_Mont_Format(aux); 
    return false; 
} 

function  Telefone_Mont_Format(Telefone) 
{ 
    var aux = len = ''; 
     
    len = Telefone.length; 
    if(len<=9) 
    { 
        tmp = 5; 
    } 
    else 
    { 
        tmp = 6; 
    } 
     
    aux = ''; 
    for(i = 0; i < len; i++) 
    { 
        if(i==0) 
        { 
            aux = '('; 
        } 
        aux += Telefone.charAt(i); 
        if(i+1==2) 
        { 
            aux += ') '; 
        } 
         
        if(i+1==tmp) 
        { 
            aux += '.'; 
        } 
    } 
    return aux ; 
} 

function  Telefone_Remove_Format(Telefone) 
{ 
    var strCheck = '0123456789'; 
    var len = i = aux = ''; 
    len = Telefone.length; 
    for(i = 0; i < len; i++) 
    { 
        if (strCheck.indexOf(Telefone.charAt(i))!=-1) 
        { 
            aux += Telefone.charAt(i); 
        } 
    } 
    return aux; 
} 

document.onkeypress = function (evt) {
  var r = '';
  var ctrl = 0;
  
  if (document.getElementById && (!document.all)) {
    ctrl = evt.ctrlKey;
    r = String.fromCharCode(evt.which).toUpperCase();
  }
  else if (document.layers) {
    ctrl = Event.CONTROL_MASK;
    r = String.fromCharCode(evt.which).toUpperCase();
  }
  
  if (ctrl){
  	if (r=='A'||r=='C'){
		alert(message);
		return false;
		}
	}
}

// Aumenta a fonte
var tam=11;
function mudaFonte(tipo)
{
	if (tipo=="mais")
	{
		if(tam < 17)
		  tam+=1;
	}else{
		if(tam > 11)
		tam-=1;
	}

	if (tam >= 11 && tam <=17)
	{
		document.getElementById('tx').style.fontSize=tam+'px';
		document.getElementById('tx1').style.fontSize=tam+'px';
		document.getElementById('tx2').style.fontSize=tam+'px';

/*	}else{
	  tam = 11;
		document.getElementById('tx').style.fontSize=tam;
		document.getElementById('tx1').style.fontSize=tam;
		document.getElementById('tx2').style.fontSize=tam;
*/
    }
	
}

function mudaFontePadrao(tam)
{
		var tam=11;
		document.getElementById('tx').style.fontSize=tam+'px';
		document.getElementById('tx1').style.fontSize=tam+'px';
		document.getElementById('tx2').style.fontSize=tam+'px';
}

function xautotab(thisval,fname, flen){
 
 var fieldname = eval("document.forms[0]." + fname);

 if(thisval != 9 && thisval != 16){

 if(fieldname.value.length + 1 <= flen){
  fieldname.focus();
 }else{
 
  for(x=0; x<document.forms[0].elements.length; x++){
        if(fieldname.name == document.forms[0].elements[x].name){
                var nextfield = x + 1;
        }
  }

          document.forms[0].elements[nextfield].focus();

 }
 }
}


// Left trim method: strltrim
function strltrim()
{
//Match spaces at beginning of text and replace with a null string
return this.replace(/^\s+/,'');
}
  

// Right trim method: strrtrim
function strrtrim()
{
//Match spaces at end of text and replace with a null string
return this.replace(/\s+$/,'');
}

//Trim method: strtrim

function strtrim()
{
//Match spaces at beginning and end of text and replace
//with null strings
return this.replace(/^\s+/,'').replace(/\s+$/,'');
}
String.prototype.ltrim = strltrim;
String.prototype.rtrim = strrtrim;
String.prototype.trim  = strtrim;

// Manejo de Ventanas

function CloseWindow()
{
    close();
}

function OpenProcura( Page)
{

pop_up = window.open(Page,'','location=no,scrollbars=yes,resizable=no,height=5,width=5,top=0,left=0');

}

function OpenWindow( Page, Winheight, Winwidth )
{

var hauteur_popup = Winheight;
var H = (screen.availHeight - hauteur_popup) / 2;
var largeur_popup = Winwidth;
var L = (screen.availWidth - largeur_popup) / 2;

pop_up = window.open(Page,'','location=no,scrollbars=yes,resizable=no,height=' + hauteur_popup + ',width=' + largeur_popup + ',top=' + H + ',left=' + L);
pop_up.focus();

}

function OpenWindowEx( Page, Winheight, Winwidth, top, left )
{

var hauteur_popup = Winheight;
var H = top;
var largeur_popup = Winwidth;
var L = left;

pop_up = window.open(Page,'','location=no,scrollbars=yes,resizable=no,height=' + hauteur_popup + ',width=' + largeur_popup + ',top=' + H + ',left=' + L);
pop_up.focus();

}

function OpenWindowNotScroll( Page, Winheight, Winwidth )
{

var hauteur_popup = Winheight;
var H = (screen.availHeight - hauteur_popup) / 2;
var largeur_popup = Winwidth;
var L = (screen.availWidth - largeur_popup) / 2;

pop_up = window.open(Page,'','location=no,scrollbars=no,resizable=no,height=' + hauteur_popup + ',width=' + largeur_popup + ',top=' + H + ',left=' + L);
pop_up.focus();

}

// Voltamos uma pagina para atras
function Volver()
{
    history.go(-1);
}

