function addFormEvent(func) {
  if (!document.getElementById | !document.getElementsByTagName) return
  var oldonload=window.onload
  if (typeof window.onload != 'function') { window.onload=func }
  else {
    window.onload=function() { oldonload(); func() }
  }
}



// --------------------- borders for text type inputs ------------------------------ //
function attachBorderAndSelect(id){
  var obj0 = document.getElementById(id)
  obj0.onfocus= function() {this.style.border="2px solid #f00"; this.select();}
  obj0.onblur = function() {
                  this.style.border="2px inset #ccc"
                  if (this.value=="") {this.value=this.defaultValue}
                  this.value=this.value
                }
}
// ----------------------------------------------------------------------------- //




// ------------------------------ border for submit buttons --------------------------- //
function attachBorderToButton(id){
  var obj0 = document.getElementById(id)
  obj0.onfocus= function() {this.style.border="2px solid #f00"}
  obj0.onblur = function() {this.style.border="2px outset #fff"}
}
// ----------------------------------------------------------------------------- //


// ------------------------ help clicked therefore show help ----------------------------- //
function showHelp(id){
  if (!document.getElementsByTagName) return
  if (document.getElementById(id).style.display=='block'){
    document.getElementById(id).style.display='none'
  }
  else{
    document.getElementById(id).style.display='block'
  }
  //  focus is moved by the href of the link to the start of the help
}
// ----------------------------------------------------------------------------- //


// ----------------------------- hide help --------------------------------- //
function hideHelp(id){
  if (document.getElementById) {document.getElementById(id).style.display='none'}
}
// ----------------------------------------------------------------------------- //

function cor(section)
{
document.getElementById(section).style.background = "#fff";
}

function ativa(txt,chk,opt1,opt2)
{
	var txt = document.getElementById(txt)
	var chk = document.getElementById(chk)
	var opt1 = document.getElementById(opt1)
	var opt2 = document.getElementById(opt2)
	if (null != txt) {
	
		if (chk.checked) {
			txt.disabled = false;
			txt.style.background = "#fff";
			opt1.disabled = false;
			opt1.checked = true;
			opt2.disabled = false;
			txt.focus();
		} else {
			txt.disabled = true;
			txt.value = '';
			txt.style.background = "#e0dfce";
			opt1.disabled = true;
			opt1.checked = '';
			opt2.disabled = true;
			opt2.checked = '';
		}
	}
}

function ativacheck(chk,opt1,txt)
{
	var chk = document.getElementById(chk)
	var opt1 = document.getElementById(opt1)
	var txt = document.getElementById(txt)
		if (opt1.checked) {
			chk.checked = true;
			txt.focus();
		}
}

function ganhafocus(txt)
{
	var txt = document.getElementById(txt)
	txt.focus();
}

function msg()
{
	alert ('Para Comprar/Analisar é preciso ir à Página de Cadastros!');
}

// example contact form
function initContact(){

  if (!document.getElementsByTagName) return


// JavaScript is available so hide the help divs
hideHelp('help-login')
hideHelp('help-senha')
hideHelp('help-email')
}


// Other "onload" events may be added in the same format as this //
addFormEvent(initContact)