		var errorColor="#fbc311";
		var normalColor="#FFFFFF";
		
function ValidationException(codigo,mensaje,campo){
	this.codigo=(codigo==undefined)?0:codigo;
	this.mensaje=(mensaje==undefined)?null:mensaje;
	this.campo=(campo==undefined)?null:campo;
}	
			
function validateElements(elementos){
	for(var idx=0;idx<elementos.length;idx++){
		var vacio=elementos[idx].getAttribute("lang");
		if( ((vacio=="false") && (elementos[idx].value=="")) || elementos[idx].style.backgroundColor=="rgb(251, 195, 17)"){
			throw new ValidationException(1,"Needed: ",elementos[idx])
		}
	}
}
			
function checkForm(form){
	var ok;
	try{
		validateElements(form.elements);
		ok=true;
	}catch(ex){
		ex.campo.style.backgroundColor=errorColor;	
		ex.campo.focus();
		ok=false;
	}
			
	return ok;
}

function validateEmail(email){
	//alert(email.value);
	if (!isEmail(email.value)) {
			email.style.backgroundColor=errorColor;	
		//	email.focus();	
	}
	else{
		email.style.backgroundColor=normalColor;
	}
}

		function validateText(e) {
			if (e.value.length < 3){
				e.style.backgroundColor=errorColor;	
				//e.focus();	
			} 
			else {
				e.style.backgroundColor=normalColor;
			}
		}
		
		function validateNumber(e) {
			if (e.value.length < 1){
		    	e.style.backgroundColor=errorColor;	
				//e.focus();	
		 	} 
			else {
		    	e.style.backgroundColor=normalColor;
		  	}
		}

		function isNumberKey(evt){
			var charCode = (evt.which) ? evt.which : event.keyCode;
				
			if((charCode==46||charCode==8||charCode==45||charCode==47) ||(charCode >= 48 && charCode <= 57) ){
				return true;
			}
			else {
				return false;
			}
		
		}
		  
		 function isAlphaKey(evt){
			 var charCode = (evt.which) ? evt.which : event.keyCode;
			 if ((charCode==231 || charCode==199) || (charCode==241 || charCode==209) ||(charCode==8 || charCode==32) || ( (charCode >= 65 && charCode <= 90) || (charCode >= 97 && charCode <= 122) ) ) {
			 	return true;
			 }
			 else {
				 return false;
			 }
		  }
		 
		 function isEmail(valor) {
		  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
			return (true)
		  } else {
			return false;
		  }
		}

function openClose(id){ //hide/close an element
	element = document.getElementById(id);
	if(element!=null){
		if (element.style.display == 'block') {
			hide(id);
		}
		else{
			show(id);
			}
		}
}

function showPopup(url) { 
	newwindow=window.open(url,'name','height=600,width=800,top=200,left=300,resizable'); 
	if (window.focus) {newwindow.focus()} 
	} 

function printSelection(node){

	  var content=node.innerHTML
	  var pwin=window.open('','print_content','width=100,height=100');

	  pwin.document.open();
	  pwin.document.write('<html><body onload="window.print()">'+content+'</body></html>');
	  pwin.document.close();
	 
	  setTimeout(function(){pwin.close();},1000);

	}
	
function show(id){//displays an html element
	element = document.getElementById(id);
	if(element!=null){
		element.style.display = 'block';
	}
}

function hide(id){//hide an html element
	element = document.getElementById(id);
	if(element!=null){
		element.style.display = 'none';
	}
} 

function brpapp(){ 
	window.open('https://brpgenerator.com/user/app/index.php','_blank','width=800,height=800,resizable=no,toolbar=no,addressbar=no,scrollbars=no,menubar=no,status=no,directories=no'); 
}

function start() {
	var
		seconds = 10,
		fps = 40,
		bar = document.getElementById('bar'),
		t = new Transition(1000 * seconds, fps);
	t.trackElementStyle(0, 400, Easing.Expo.easeOut, bar, 'width');
	// optional
	t.setEndFunction(function(){
		bar.parentNode.style.display = 'none';
		hide('progress_title')
		show('pdf')
	});
	t.begin();
}



