function confirmLink(theLink, confirmMsg)
{
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
        return true;
    }

    var is_confirmed = confirm(confirmMsg);
    if (is_confirmed) {
        theLink.href += '&confirmado=1';
    }

    return is_confirmed;
} // end of the 'confirmLink()' function


function setFocus(form, field) {
  // set the focus of field in form
  if (document.forms.length > 0) {
   document.forms[form].elements[field].focus();
  }
 }
 
 
 function toggle(id) {
	if (document.getElementById(id).style.display == "none") {
		document.getElementById(id).style.display = "block";
	} else {
		document.getElementById(id).style.display = "none";
	}
}

 

function placeFocus() {
	// puts the focus on the first field of the page
	if (document.forms.length > 0) {
		var field = document.forms[0];
		for (i = 0; i < field.length; i++) {
			if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
				document.forms[0].elements[i].focus();
			break;
         }
      }
   }
}


function healthy_blink(obj) {
		// blinks an object; respects the usability guidelines for blinking objects
		// usability guidelines:
		// - blink should be almost unoticeable (long intervals)
		// - draw attention of the user to a spot must be careful (only when necessary - this criterion must be implemented outside this function)
		// - adaptiveness: users adapt themself to repeated stimuli (making blink intervals random)
		if(obj) {
			str = obj + ".style.color='#990000'";
			setInterval(str, 3000);
			str = obj + ".style.color='#000000'";
			setInterval(str, 3000);
		}
}
		
// abre uma janela pop-up, mostrando file (IE)
function openNewWindow(url) {
	popupWin = window.open(url, 'open_window',
    'menubar=no,toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable,dependent=yes,width=750,height=280,left=200,top=200')
}


function setText(obj, text) {
	//obj.removeChild(obj.lastChild);
	//return obj.appendChild(document.createTextNode(text));
	obj.innerText(text);
}
