function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {
	var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;
	if(document.all) { 
    	nTecla = evtKeyPress.keyCode;
	} else if(document.layers) { 
   		nTecla = evtKeyPress.which;
	} else {
	    nTecla = evtKeyPress.which;
	    if (nTecla == 8) {
	    return true;
    }  
	}

	sValue = objForm[strField].value;
	sValue = sValue.toString().replace( "-", "" );
	sValue = sValue.toString().replace( "-", "" );
	sValue = sValue.toString().replace( ".", "" );
	sValue = sValue.toString().replace( ".", "" );
	sValue = sValue.toString().replace( "/", "" );
	sValue = sValue.toString().replace( "/", "" );
	sValue = sValue.toString().replace( "(", "" );
	sValue = sValue.toString().replace( "(", "" );
	sValue = sValue.toString().replace( ")", "" );
	sValue = sValue.toString().replace( ")", "" );
	sValue = sValue.toString().replace( " ", "" );
	sValue = sValue.toString().replace( " ", "" );
	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) == "/"))
		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) { // backspace
	    if (sMask.charAt(i-1) == "9") { // apenas n�meros...
	    return ((nTecla > 47) && (nTecla < 58)); } // n�meros de 0 a 9
	else { // qualquer caracter...
	    return true;
	}
	} else {
	    return true;
	}
}

function clear_field(field){
	
	if (field.value==field.defaultValue){
		field.value='';
	}
}

function check_field(field){
	
	if (field.value=='' || field.value==' '){
		field.value=field.defaultValue;
	}
}

// **************** BAGULHADA DO HEADER ***********************************
myPopup = '';
 	obj = '';
   obj1 = '';
function openPopup(url,objt,objt1) {

	myPopup = window.open(url,"popupWindow","scrollbars=yes,status=yes,width=500,height=350");
	if (!myPopup.opener)
    	myPopup.opener = self; 
	obj = objt;
	obj1 = objt1;
}

function openPopupImg(url,img) {
	
	link = document.getElementById('placeholder').src;
    s = new String(link);        
    imagem = nomeImagem(s);        
	myPopup = window.open(url+"&imagem="+imagem,"popupWindow","scrollbars=yes,status=yes,width=450,height=450");    	
}

function nomeImagem(str) {
    
    var imagem = '';
    var pos = 0;       
    for ( var i=str.length; i > 0; i--) {        
        var ch = str.substring(i,i-1);         
        if (ch == "/"){ 
            pos = i;
            break;               
        }
    }    
    var inicio = pos; 
    for ( var i=inicio; i < str.length; i++) {
        var ch = str.substring(i,i+1);
        imagem = imagem + ch; 
    }     
    return(imagem);
}


function showPic (whichpic) {
	
	if (document.getElementById) {
		document.getElementById('placeholder').src = whichpic.href;
		if (whichpic.title) {
			document.getElementById('desc').childNodes[0].nodeValue = whichpic.title;
		}
		return false;
	} else {
		return true;
	}
}

// **************** FIM BAGULHADA DO HEADER ***********************************