function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function valFechaCastellano(v){
	if(v != ""){
		if(v.length < 10)return false;
		
		//dia=parseInt(v.substring(0,2),10);
		//mes=parseInt(v.substring(3,5),10);
		//anio=parseInt(v.substr(6),10);		

		dia=v.substring(0,2);
		mes=v.substring(3,5);
		anio=v.substr(6);		
		if ( !isFinite(anio) || !isFinite(mes) || !isFinite(dia))return false;
		if ( anio > 2100 || anio < 1900 ) return false;	
		if (mes < 1 || mes > 12) return false;
		if (dia < 1)return false;
				
		if (mes == 1 || mes == 3 || mes == 5 || mes == 7 || mes == 8 || mes == 10 || mes == 12){
			//meses de 31 dias
			if (dia > 31) return false;	
		}else{
			if (mes == 2 && anio % 4 == 0){
				if (dia > 29) 
					return false;
				else if (anio % 4 != 0)
					if (dia > 28)return false
			}else if(mes == 2 && anio % 4 != 0){
				if (dia > 28) return false
			}else{
				if (dia > 30)return false
			}
		}		
	}	
	return true;
}

function valFechaEuskera(v){
	if(v != ""){
		if(v.length < 10)return false;
		
		//dia=parseInt(v.substring(0,2),10);
		//mes=parseInt(v.substring(3,5),10);
		//anio=parseInt(v.substr(6),10);		

		dia=v.substring(8);
		mes=v.substring(5,7);
		anio=v.substr(0,4);				
		if ( !isFinite(anio) || !isFinite(mes) || !isFinite(dia))return false;
		if ( anio > 2100 || anio < 1940 ) return false;	
		if (mes < 1 || mes > 12) return false;
		if (dia < 1)return false;
				
		if (mes == 1 || mes == 3 || mes == 5 || mes == 7 || mes == 8 || mes == 10 || mes == 12){
			//meses de 31 dias
			if (dia > 31) return false;	
		}else{
			if (mes == 2 && anio % 4 == 0){
				if (dia > 29) 
					return false;
				else if (anio % 4 != 0)
					if (dia > 28)return false
			}else if(mes == 2 && anio % 4 != 0){
				if (dia > 28) return false
			}else{
				if (dia > 30)return false
			}
		}		
	}	
	return true;
}
function gfComprobarFechaC(pfecha){
	if (valFechaCastellano(pfecha.value)==false) {
		alert("No es una fecha válida.\nFormato correcto: dd/mm/aaaa");
		pfecha.value="";
		pfecha.focus();
		return false;
	}
	else{
		return true;
	}
}
function gfComprobarFechaE(pfecha){
	if (valFechaEuskera(pfecha.value)==false) {
		alert("Datak ez dauka formatu ona.\nFormatu ona: aaaa/mm/dd");
		//pfecha.value="";
		pfecha.focus();
		return false;
	}
	else{
		return true;
	}
}

function ComprobarNumero(pValor){
	var devolver=true;
	pnumero=pValor.value;
	if (!isFinite(pnumero)){
		//alert("No es un valor válido para este campo");
		//pValor.focus();
		//return false;
		devolver=false;
	}
	
	if(pnumero!="" && pnumero!=0){
		for(i=0;i<pnumero.length;i++){
			if(pnumero.charAt(i)!="" && pnumero.charAt(i)!="," && pnumero.charAt(i)!=".")vale=isFinite(pnumero.charAt(i));
			if(vale==false) devolver=false;
		}
	}		
	if (devolver==false){
		alert("No es un valor válido para este campo.");
		pValor.focus();
	}
	return devolver;
}
function Fichero(ruta,cAdjunto,cRutaRel,cCarpeta){ //Abre el formulario de adjuntar fichero
	if (cCarpeta!="") {			
		var fichero = "../Fichero.asp?Func=1&cRuta="+ruta+"&cAdjunto="+cAdjunto+"&cRutaRel="+cRutaRel+"&cCarpeta="+cCarpeta	
	}else {			
		var fichero = "../Fichero.asp?Func=1&cRuta="+ruta+"&cAdjunto="+cAdjunto+"&cRutaRel="+cRutaRel	
	}
	var ventana=window.open(fichero,'seleccion','top=50,left=100,width=418,height=250');
	if (ventana.opener==null){
		ventana.opener=this;
	}
}
//función que ejecuta un trim a un string
function trim(argvalue) {
  var tmpstr = ltrim(argvalue);

  return rtrim(tmpstr);
}

//función que ejecuta un trim por la izquierda a un string
function ltrim(argvalue) {

  while (1) {
    if (argvalue.substring(0, 1) != " ")
      break;
    argvalue = argvalue.substring(1, argvalue.length);
  }

  return argvalue;
}
//función que ejecuta un trim por la derecha a un string
function rtrim(argvalue) {

  while (1) {
    if (argvalue.substring(argvalue.length - 1, argvalue.length) != " ")
      break;
    argvalue = argvalue.substring(0, argvalue.length - 1);
  }
  return argvalue;
}
//********* Función que compara dos fechas en castellano ***********************
function CompararFechasCastellano(FechaInicio,FechaFin){
  //fecha_actual = new Date();
  dia_fecha_Inicio=FechaInicio.value.substr(0,2);
  mes_fecha_Inicio=FechaInicio.value.substr(3,2);
  ano_fecha_Inicio=FechaInicio.value.substr(6,4);
  vfecha_Inicio=mes_fecha_Inicio+"/"+dia_fecha_Inicio+"/"+ano_fecha_Inicio
  fecha_Inicio=new Date(vfecha_Inicio);
  
  dia_fecha_Fin=FechaFin.value.substr(0,2);
  mes_fecha_Fin=FechaFin.value.substr(3,2);
  ano_fecha_Fin=FechaFin.value.substr(6,4);
  vfecha_Fin=mes_fecha_Fin+"/"+dia_fecha_Fin+"/"+ano_fecha_Fin
  fecha_Fin=new Date(vfecha_Fin);
  
var tiempoRestante=fecha_Fin.getTime()-fecha_Inicio.getTime();
var dias = Math.floor(tiempoRestante / (1000 * 60 * 60 * 24));
//alert (dias);
      
  // Los días límite vamos a buscarlos en la BBDD , para marcar el objetivo en funcion del tipo de contrato.
  // Cargo un array con los objetivos de la tabla
 // Modificado el 13/03/2002
 	/*if (Date.parse(FechaInicio.value) > Date.parse(FechaFin.value)){
		return false;
	}else{
		return true;
	}*/
	

if (dias<=-1){
	return false;
}
else {
	return true;
}
   // intFin Modificación
  }
  function CompararFechasEuskera(FechaInicio,FechaFin){
  //fecha_actual = new Date();
  dia_fecha_Inicio=FechaInicio.value.substr(8,2);
  mes_fecha_Inicio=FechaInicio.value.substr(5,2);
  ano_fecha_Inicio=FechaInicio.value.substr(0,4);
  vfecha_Inicio=mes_fecha_Inicio+"/"+dia_fecha_Inicio+"/"+ano_fecha_Inicio
  fecha_Inicio=new Date(vfecha_Inicio);
  
  dia_fecha_Fin=FechaFin.value.substr(8,2);
  mes_fecha_Fin=FechaFin.value.substr(5,2);
  ano_fecha_Fin=FechaFin.value.substr(0,4);
  vfecha_Fin=mes_fecha_Fin+"/"+dia_fecha_Fin+"/"+ano_fecha_Fin
  fecha_Fin=new Date(vfecha_Fin);
  
  var tiempoRestante=fecha_Fin.getTime()-fecha_Inicio.getTime();
  var dias = Math.floor(tiempoRestante / (1000 * 60 * 60 * 24));
      
  // Los días límite vamos a buscarlos en la BBDD , para marcar el objetivo en funcion del tipo de contrato.
  // Cargo un array con los objetivos de la tabla

  if (dias<=-1){
  	return false;
  }
  else {
  	return true;
  }
  
  }
function over(elemento){
	elemento.style.textDecoration='none';
	elemento.style.color='#003366'
}
function out(elemento){
	elemento.style.textDecoration='none';
	elemento.style.color='#005CD0'
}
function hideSelect(){
	if (document.all){document.all.formselect.style.visibility="hidden";}
}

function unhideSelect(){
	if (document.all){document.all.formselect.style.visibility="visible";}
}

function validarEmail(valor) {
	if (valor != "") {
	  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
		return (true);
	  } else {
		alert("El campo Email no tiene el formato correcto. Por favor, revíselo.")
	  }
	}  
}

function validarTelefono(valor) {
	alert(valor);
	if (valor != "") {
	  if (/^[0-9][0-9-\.]+[0-9]$/.test(valor)){
		return (true);
	  } else {
		alert("El campo Teléfono no tiene el formato correcto. Por favor, revíselo.")
	  }
	}  
}