FOCUSED_FIELD_BGCOLOR="#ffff44";
FOCUSED_FIELD_TEXTCOLOR="#000000";

NON_FOCUSED_FIELD_BGCOLOR="#ffffff";

INITIAL_FIELD_BGCOLOR="#ffffff";
INITIAL_FIELD_TEXTCOLOR="#000000";

function ConfigureFormFields() {
	stFields=""; objFirstInput=null;
	//.................................................
	aFields=document.getElementsByTagName("input");
	for(i=0;i<aFields.length;i++) {
		if(objFirstInput==null) { objFirstInput=aFields[i]; }
		stFieldName=aFields[i].id; 
		if(!stFieldName){ stFieldName=aFields[i].name;}
		if(stFieldName.indexOf("Email")!=-1) {
			ConfigureEmailField(aFields[i]);
		} else if(stFieldName.indexOf("Submit")!=-1) {
			ConfigureSubmitButton(aFields[i]);
		} else {
		    if (aFields[i].type!="image")
			    ConfigureTextField(aFields[i]);
		}
	}
	//.................................................
	aFields=document.getElementsByTagName("form");
	for(i=0;i<aFields.length;i++) {
		stFieldName=aFields[i].id; 
		if(!stFieldName){ stFieldName=aFields[i].name;}
		ConfigureForm(aFields[i]);
	}
	//.................................................
	//objFirstInput.focus();
}

function ConfigureEmailField(objEmail){
	if(objEmail.value=="") objEmail.value="e-mail";
	objEmail.style.backgroundColor=NON_FOCUSED_FIELD_BGCOLOR;
	objEmail.style.color=INITIAL_FIELD_TEXTCOLOR;
	objEmail.onfocus=
		function(){
			if(this.value=="e-mail") this.value="";
			this.style.backgroundColor=FOCUSED_FIELD_BGCOLOR;
			this.style.color=FOCUSED_FIELD_TEXTCOLOR;
		};
	objEmail.onblur=
		function(){
			if(this.value!="" && this.value!="e-mail" && this.value.indexOf("@")==-1) { 
				alert("E-mail inválido."); this.select(); this.focus();
			}
			this.style.backgroundColor=INITIAL_FIELD_BGCOLOR;
			this.style.color=INITIAL_FIELD_TEXTCOLOR;
		};
}

function ConfigureTextField(objText){
	objText.style.backgroundColor=NON_FOCUSED_FIELD_BGCOLOR;
	objText.style.color=INITIAL_FIELD_TEXTCOLOR;
	objText.onfocus=
		function(){
			this.style.backgroundColor=FOCUSED_FIELD_BGCOLOR;
			this.style.color=FOCUSED_FIELD_TEXTCOLOR;
		};
	objText.onblur=
		function(){
			this.style.backgroundColor=INITIAL_FIELD_BGCOLOR;
			this.style.color=INITIAL_FIELD_TEXTCOLOR;
		};
}

function ConfigureSubmitButton(objSubmit){
	objSubmit.onclick=
		function(){
		}
}

function ConfigureForm(objForm) {
	objForm.hasClicked=0;
	objForm.onsubmit=
		function(){
			if(!this.hasClicked || this.hasClicked==0) {
				this.hasClicked=1;
				return true;				
			} else {
				alert("Aguarde, processando...");
				return false; 
			}
		}
}