/* ------------------------------------------------------------------ */
/* Abrir nova Janela             								      */
/* ------------------------------------------------------------------ */
function novaJanela(theURL,winName,features) {
	window.open(theURL,winName,features);	
}
/* Examplo: novaJanela('teste.php','Indique a um amigo','width=300,height=300'); */

/* ------------------------------------------------------------------ */
/* Aceita somente números nos campos  						          */
/* ------------------------------------------------------------------ */
function numbersonly(myfield, e, dec){
	
	var key;
	var keychar;

	if(window.event){
		key = window.event.keyCode;
	}else if(e){
		key = e.which;
	}else{
		return true;
	}
	
	keychar = String.fromCharCode(key);

	//control keys
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27)){
		return true;
	}else if((("0123456789").indexOf(keychar) > -1)){
		return true;
	}else if(dec && (keychar == ".")){ //decimal point jump
		myfield.form.elements[dec].focus();
		return false;
	}else{
		return false;
	}
}

/* ------------------------------------------------------------------ */
/* Alterando as propriedades do campo input					          */
/* ------------------------------------------------------------------ */
var currentlyActiveInputRef = false;
var currentlyActiveInputClassName = false;

function highlightActiveInput(){
	if(currentlyActiveInputRef){
    	currentlyActiveInputRef.className = currentlyActiveInputClassName;
	}
  	currentlyActiveInputClassName = this.className;
	this.className = 'inputHighlighted';
	currentlyActiveInputRef = this;
}

function blurActiveInput(){
	this.className = currentlyActiveInputClassName;
}

function initInputHighlightScript() {
	var tags = ['INPUT','TEXTAREA'];
	for(tagCounter=0;tagCounter<tags.length;tagCounter++){
		var inputs = document.getElementsByTagName(tags[tagCounter]);
		for(var no=0;no<inputs.length;no++){
			if(inputs[no].className && inputs[no].className=='doNotHighlightThisInput')continue;
			if(inputs[no].tagName.toLowerCase()=='textarea' || (inputs[no].tagName.toLowerCase()=='input' && 
																inputs[no].type.toLowerCase()=='text')){
				inputs[no].onfocus = highlightActiveInput;
				inputs[no].onblur = blurActiveInput;
			}
		}
	}		
}


