
function fvalidaformularios(idnombrecampo, nombrecampo, tipocampo, imprescindible){
	error=""
	if (tipocampo=="email"){
		if (imprescindible=="si"){
			if (document.getElementById(idnombrecampo).value==""){
				error = "        • El campo "+nombrecampo+" es imprescindible, por favor rellenelo."+"\n";
			}else if (document.getElementById(idnombrecampo).value.indexOf ("@")==-1 || document.getElementById(idnombrecampo).value.indexOf (".")==-1 || document.getElementById(idnombrecampo).value.indexOf (" ")!=-1){
				error = "        • El campo "+nombrecampo+" no contiene un email correcto."+"\n";
			}	
		}else if (document.getElementById(idnombrecampo).value!=""){ 
			if (document.getElementById(idnombrecampo).value.indexOf ("@")==-1 || document.getElementById(idnombrecampo).value.indexOf (".")==-1 || document.getElementById(idnombrecampo).value.indexOf (" ")!=-1){
				error = "        • El campo "+nombrecampo+" no contiene un email correcto."+"\n";
			}
		}
		
	} else if (tipocampo=="texto"){
		if (imprescindible=="si"){
			if (document.getElementById(idnombrecampo).value==""){
				error = "        • El campo "+nombrecampo+" es imprescindible, por favor rellenelo."+"\n";
			}
		}
	} else if (tipocampo=="dni"){
		if (imprescindible=="si"){
			if (document.getElementById(idnombrecampo).value==""){
				error = "        • El campo "+nombrecampo+" es imprescindible, por favor rellenelo."+"\n";
			}
		}else if (document.getElementById(idnombrecampo).value!=""){
			cadena="TRWAGMYFPDXBNJZSQVHLCKET";
			numeros = "1234567890"; 
			letrasynumeros = cadena+numeros
			atexto = document.getElementById(idnombrecampo).value.toUpperCase()
			atexto = atexto.split ("");
			for (k=0;k<atexto.length;k++){
				if (letrasynumeros.indexOf (atexto[k])==-1){
					error = "        • El campo "+nombrecampo+", no contiene un DNI-NIF valido."+"\n";
					error += "        no utilice simbolos como \"-\" ó \"espacio\""+"\r";
					error += "        ejemplo: 1234567L"+"\r";
					break
				}
			}
			if (error==""){
				numero = document.getElementById(idnombrecampo).value.substring (0,document.getElementById(idnombrecampo).value.length-1)
				posicion = numero % 23
	
				letra1 = cadena.substring(posicion,posicion+1).toUpperCase()
				letra2 = document.getElementById(idnombrecampo).value.substring ((document.getElementById(idnombrecampo).value.length)-1).toUpperCase()
				if (letra1 != letra2){
					error = "        • El campo "+nombrecampo+", no contiene un DNI-NIF valido."+"\n";
	
				}			
			}	
		}
	} else if (tipocampo=="combo"){
		if (imprescindible=="si"){
			if (document.getElementById(idnombrecampo).value==-1){
				error = "        • Seleccione una opción del campo "+nombrecampo+", es imprescindible."+"\n";
			}
		}
	}
	return error;
}


function focultofocus(){
	window.focus()
}
function fabrir(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=0'
	win = window.open(mypage, myname, winprops)
	window.onfocus=function(){
 		//win.window.close()
	}
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

// DEJA ESCRIBIR NADA MAS QUE CIERTOS CARACTERES EN VARIABLE PERMITIDO, SIN COMAS EJEMPLO "12345678990", SERIAN LOS NOMUMEROS PERMITIDOS
function caracteres_campo_permitidos(e,permitido) {
	apermitido=permitido.split("");
	
	tecla = (document.all) ? e.keyCode : e.which;
	x=0
	for (k=0;k<apermitido.length;k++){
		var chr = String.fromCharCode(tecla);
		if (chr==apermitido[k]){
			x=1;
			break;
		}
	}
  	if (x==0){
		return false	
	}else{
		return true	
	}
} 
// NO DEJA ESCRIBIR NADA MAS QUE CIERTOS CARACTERES EN VARIABLE NOPERMITIDO, SIN COMAS EJEMPLO "12345678990", SERIAN LOS NOMUMEROS NO PERMITIDOS
function caracteres_campo_nopermitidos(e,nopermitido) {
	apnopermitido=nopermitido.split("");
	tecla = (document.all) ? e.keyCode : e.which;
	x=0
	for (k=0;k<apnopermitido.length;k++){
		var chr = String.fromCharCode(tecla);
		if (chr==apnopermitido[k]){
			x=1;
			break;
		}
	}
  	if (x==0){
		return true	
	}else{
		return false	
	}
} 

function ftabindex(donde){
	if (donde =="procesos"){
		index = new Array ('cliente', 'area_manager', 'puesto', 'zona', 'vacantes', 'fecha_ini', 'sector','funcion', 'status', 'fecha_status')
			for (k=0;k<index.length;k++){
				document.getElementById(index[k]).tabIndex =k+1
			}
	}
}
function fvisible(cual){
	document.getElementById(cual).style.display = 'block';	
}
function finvisible(cual){
	document.getElementById(cual).style.display = 'none';	
}
function HTMLEncode(wText){
if(typeof(wText)!="string"){
	wText=wText.toString();
}
	wText=wText.replace(/&/g, "@amp@") ;
	wText=wText.replace(/"/g, "@quot@") ;
	wText=wText.replace(/'/g, "@146@") ;
	wText=wText.replace(/[+]/g,'@mas@'); 
	return wText;
}

function addslashes1(str) {
	str=str.replace(/\'/g,'');
	str=str.replace(/\"/g,'');
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\0/g,'\\0');
	return str;
}

function addslashes(str) {
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\0/g,'\\0');
	return str;
}
function stripslashes(str) {
	str=str.replace(/\\'/g,'\'');
	str=str.replace(/\\"/g,'"');
	str=str.replace(/\\\\/g,'\\');
	str=str.replace(/\\0/g,'\0');
	return str;
}

/// sacamos la edad
//Sample usage
//displayage (year, month, day, unit, decimals, rounding)
//Unit can be "years", "months", or "days"
//Decimals specifies demical places to round to (ie: 2)
//Rounding can be "roundup" or "rounddown"

//displayage(1997, 11, 24, "years", 0, "rounddown")


var one_day=1000*60*60*24
var one_month=1000*60*60*24*30
var one_year=1000*60*60*24*30*12

function displayage(yr, mon, day, unit, decimal, round){
today=new Date()
var pastdate=new Date(yr, mon-1, day)

var countunit=unit
var decimals=decimal
var rounding=round

finalunit=(countunit=="days")? one_day : (countunit=="months")? one_month : one_year
decimals=(decimals<=0)? 1 : decimals*10

if (unit!="years"){
if (rounding=="rounddown")
return (Math.floor((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals)
else
return (Math.ceil((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals)
}
else{
yearspast=today.getFullYear()-yr-1
tail=(today.getMonth()>mon-1 || today.getMonth()==mon-1 && today.getDate()>=day)? 1 : 0
pastdate.setFullYear(today.getFullYear())
pastdate2=new Date(today.getFullYear()-1, mon-1, day)
tail=(tail==1)? tail+Math.floor((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals : Math.floor((today.getTime()-pastdate2.getTime())/(finalunit)*decimals)/decimals
return (yearspast+tail)
}
}













PositionX = 590;
PositionY = 590;
var winl1 = (screen.width - PositionX) / 2;
var wint1 = (screen.height - PositionY) / 2;
defaultWidth  = PositionX
defaultHeight = PositionY;
PositionX = winl1;
PositionY = wint1;


//kinda important
var AutoClose = true;

function popImage(imageURL,imageTitle){
  var imgWin = window.open('','_blank','scrollbars=no,resizable=0,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);
  if( !imgWin ) { return true; } //popup blockers should not cause errors
  imgWin.document.write('<html><head><title>'+imageTitle+'<\/title><script type="text\/javascript">\n'+
    'function resizeWinTo() {\n'+
    'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
    'var oH = document.images[0].height, oW = document.images[0].width;\n'+
    'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
    'window.doneAlready = true;\n'+ //for Safari and Opera
    'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+
    'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
    'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
    'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
    'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
    'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
    'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+
    'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
    'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
    'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
    '}\n'+
    '<\/script>'+
    '<\/head><body onload="resizeWinTo();"'+(AutoClose?' onblur=""':'')+'>'+
    (document.layers?('<layer left="0" top="0">'):('<div style="position:absolute;left:0px;top:0px;display:table;">'))+
    '<img src='+imageURL+' alt="Loading image ..." title="" onload="resizeWinTo();">'+
    (document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
  imgWin.document.close();
  if( imgWin.focus ) { imgWin.focus(); }
  //return false;
}
//ampliar imagen//////////////////////////////////////////////////////////////////////////////////// desde aqui
// estos dos parametros son opcionales a la pagina que abrimos

/////////////////////////////////////////////////////////////////////////////////////////// hasta qui