	function checkUncheckAll(theElement) {
		var theForm = theElement.form, z = 0;
		for(z=0; z<theForm.length;z++){
			if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
				theForm[z].checked = theElement.checked;
			}
		}
	}
	function chkMail(mail) {
	     return mail.match(/^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$/);
	}
	
	function checkmail(id){
		email = document.getElementById(id);
		if(!chkMail(email.value)){
			email.className='error';
			email.focus();
		}
		else{
			email.className='success';
		}
	}
	
	function checkit(id){
		text = document.getElementById(id);
		if(text.value==''){
			text.className='error';
			text.focus();
		}
		else{
			text.className='success';
		}
		}
		function checkpass(pass,confirm){
			pass = document.getElementById(pass);
			confirm = document.getElementById(confirm);
		if(pass.value!=confirm.value){
			confirm.className='error';
		}
		else{
			confirm.className='success';
		}
	}
	
	function chgName(form,idgrupo,value,grupo,value2){
		forms = document.getElementById(form);
		idgrupo = document.getElementById(idgrupo);
		idgrupo.value = value;
		grupo = document.getElementById(grupo);
		grupo.value = value2;
		forms.click();	
	}

	function addNewGr(form,grupo,value2){
		forms = document.getElementById(form);
		grupo = document.getElementById(grupo);
		grupo.value = value2;
		forms.click();	
	}

	var upload_number = 2;

	function addFileInput() {
		var d = document.createElement("div");
		var file = document.createElement("input");
		file.setAttribute("type", "file");
		file.setAttribute("name", "attach[]");
		d.appendChild(file);
		document.getElementById("moreUploads").appendChild(d);
		upload_number++;
	}

	function addFileImg() {
		var d = document.createElement("div");
		var file = document.createElement("input");
		file.setAttribute("type", "file");
		file.setAttribute("name", "image[]");
		d.appendChild(file);
		document.getElementById("moreUploads").appendChild(d);
		upload_number++;
	}

	function setBlock(id) {
		document.getElementById(id).style.display = 'block';
	}

	function trim(texto){
		texto = ltrim(texto);
		return rtrim(texto);
	}

	function rtrim(texto){
		while(texto.charAt((texto.length -1))==" "){
			texto = STRING.substring(0,texto.length-1);
		}
		return texto;
	}

	function ltrim(texto){
		while(texto.charAt(0)==" "){
			texto = texto.replace(texto.charAt(0),"");
		}
		return texto;
	}
    	
	function ValidateFormtoEmail(){
		var contador =0;
		for(i=0;i<campos.length;i++){
			var campo = document.getElementById(campos[i].id);
			switch(campos[i].tipo){
				case 'text':
					var contenido = trim(campo.value);
					if((contenido==null)||(contenido=='')){
						campo.focus();
						alert(campos[i].nombre);
						contador++;
					}
				break;
			}
			if(contador>0){
				return false;
				break;
			}
			else{
				continue;
			}
		}
		var type = 'input';
		var AllCheckboxes = document.getElementsByTagName(type);
	}
	
	function print_r(arr,level){
		var dumped_text = "";
		if(!level) level = 0;

		var level_padding = "";
		for(var j=0;j<level+1;j++){
			level_padding += "    ";
			if(typeof(arr) == 'object'){ 
				for(var item in arr){
				  	var value = arr[item];
				 
				  	if(typeof(value) == 'object'){
						dumped_text += level_padding + "'" + item + "' ...\n";
						dumped_text += dump(value,level+1);
				 	} 
				 	else{
						dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
				  	}
		 		}
			}
			else{ 
				dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
			}
			return dumped_text;
		}
	}
	
	function resultadoUpload(estado, file) {

		var link = '<br /><br /><a href="upload3.php">Subir Archivo</a> - <a href="verArchivos.php">Ver Imagenes</a>';

		if (estado == 0) var mensaje = 'El Archivo <a href="archs/' + file + '" target="_blank">' + file + '</a> se ha subido al servidor correctamente' + link;
		if (estado == 1) var mensaje = 'Error ! - El Archivo no llego al servdor' + link;
		if (estado == 2) var mensaje = 'Error ! - Solo se permiten Archivos tipo Imagen' + link;
		if (estado == 3) var mensaje = 'Error ! - No se pudo copiar Archivo. Posible problema de permisos en server' + link;

		document.getElementById('formUpload').innerHTML=mensaje;
	}
	
	function pupu(fid, tid){
		var element = document.getElementById(fid);
		var input = document.getElementById(tid);
		
		if(element.style.display=='block'){
			input.style.display='block';
			element.style.display='none'
		}
		else{
			input.style.display='none';
			element.style.display='block';
		}
		
	}
