function trim(cadena) {
	return cadena.replace(/^\s*|\s*$/g,"");
}

function abrirentidadhomologada(id,abrirnormal) {
	var url = "entidades_homologadas_detalle.asp?id="+id
	if (abrirnormal==1) {document.location = url + "&abrirnormal=1" }
	else {window.open(url,'entidad_homologada','left=5,width=450,height=420,scrollbars=yes');}
}

function abrirentidadhomologada2(id,abrirnormal) {
	var url = "entidades_homologadas_detalle2.asp?id="+id
	if (abrirnormal==1) {document.location = url + "&abrirnormal=1" }
	else {window.open(url,'entidad_homologada','left=5,width=450,height=420,scrollbars=yes');}
}


function abriravisolegal() {
	window.open('avisolegal.asp','aviso','left=0,width=490,height=420,scrollbars=yes');
}
function abrirdocumentos() {
	window.open('documentostrabajador.asp','documentos','left=0,width=490,height=420,scrollbars=yes');
}

function imprimirsolicitud(sector) {
	if(sector == 1 ){
		window.open('solicitudpdf.asp','solicitud');
	}else if(sector == 2 ){
		window.open('SolicitudPDFmetal.asp','solicitud');
	}
}
function imprimircertificado() {
	window.open('certificadopdf.asp','certificado');
}


function abrircertificados() {
	window.open('certificados.asp','certificado','left=300,top=200,width=380,height=350,scrollbars=no');
}

function abrirformacionprevencion() {
window.open('formacion_prevencionpopup.asp','formacion_prevencion','left=0,width=450,height=420,scrollbars=yes');
}

midiv = 'nada';
function activacurso(curso) {
	if (document.getElementById(midiv)) {
		document.getElementById(midiv).style.display = 'none'; 
	}
	if (midiv!=curso) {
	document.getElementById(curso).style.display = 'block'; 
	midiv = curso;
	}
	else {
		midiv='nada';
	}
	
}

midiv2 = 'nada';
function activadiv(eldiv) {
	if (document.getElementById(midiv2)) {
		document.getElementById(midiv2).style.display = 'none'; 
	}
	if (midiv2!=eldiv) {
	document.getElementById(eldiv).style.display = 'block'; 
	midiv2 = eldiv;
	}
	else {
		midiv2='nada';
	}
	
}


function abrirpuntosinformacion() {
	window.open('puntosinformacionpopup.asp','puntos','left=0,width=450,height=460,scrollbars=yes');
}
function abrirtarjeta() {
	window.open('popuptarjeta.asp','tarjeta','width=261,height=176,left=10,top=10');
}

function conectar(){
	
	if (document.usuarios.user.value =='' || document.usuarios.pass.value =='') {
		alert("Debe introducir su usuario y contraseña para poder acceder");
	}
	else {
		document.usuarios.submit();
	}
}


function desconectar() {
	window.location = "desconectar.asp"
}


function nuevoAjax(){
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");  		// Creación del objeto ajax para navegadores diferentes a Explorer
	} catch (e) {
		try {								// o bien
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");		// Creación del objet ajax para Explorer
		} catch (E) {
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
		if (xmlhttp.overrideMimeType) {
                xmlhttp.overrideMimeType('text/xml');
            }
	}
	
	return xmlhttp;
}


function MarcaMenu(id) {
	menu = document.getElementById(id);
	if (menu) {	menu.className = "marcado"}
}


function MoveraPagina(numeropagina) {
	document.formulario.vnpage.value = numeropagina;
	document.formulario.submit();
}




//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}


function formateador_fecha(d,editando) {
	val = d.value	
	
	if (!editando) {
		if (val.length == 8) {
		barras = 0	
		for(r=0;r<val.length;r++) if (val.charAt(r) == '/')	barras += 1
		if (barras == 2) d.value = val.substring(0,6) + '20' + val.substring(6,8)
		}
	}
	
	if (val.length == 2) {
		barras = 0	
		for(r=0;r<val.length;r++) if (val.charAt(r) == '/')	barras += 1
		if (barras == 1) d.value = '0' + val.substring(0,1) + '/'
	}
	
	if (val.length == 5) {
		barras = 0	
		for(r=0;r<val.length;r++) if (val.charAt(r) == '/')	barras += 1
		if (barras == 2) d.value = val.substring(0,3) + '0' + val.substring(3,4) + '/'
	}
	
}

/**************************************************************
Mask to format. Script by Tunait! (21/12/2004)
Script free of use while mantain intact author credits
No re-distribution is allowed without permission.
http://javascript.tunait.com/      tunait@yahoo.com 
****************************************************************/
var patronfecha = new Array(2,2,4)
var patron2 = new Array(1,3,3,3,3)

function mascara(d,sep,pat,nums){
return true


if(d.valant != d.value){
	val = d.value
	largo = val.length
	val = val.split(sep)
	val2 = ''
	for(r=0;r<val.length;r++){
		val2 += val[r]	
	}
	if(nums){
		for(z=0;z<val2.length;z++){
			if(isNaN(val2.charAt(z))){
				letra = new RegExp(val2.charAt(z),"g")
				val2 = val2.replace(letra,"")
			}
		}
	}
	val = ''
	val3 = new Array()
	for(s=0; s<pat.length; s++){
		val3[s] = val2.substring(0,pat[s])
		val2 = val2.substr(pat[s])
	}
	for(q=0;q<val3.length; q++){
		if(q ==0){
			val = val3[q]
		}
		else{
			if(val3[q] != ""){
				val += sep + val3[q]
				}
		}
	}
	d.value = val
	d.valant = val
	}
}

function haymensajes(id) {
	ajax = nuevoAjax();
	ajax.open("GET","comunicacion_haymensajesnuevos.asp?idusuario=" + id,true);
	ajax.onreadystatechange=function(){
		if (ajax.readyState==4) {
			if (ajax.status == 200) {
				if (ajax.responseText == 'YES') {
					if (confirm('Hay nuevos mensajes en su bandeja de entrada.\n\n            ¿Desea leerlos ahora?\n ')) {
						window.location = "comunicacion_entrada.asp?vermensajes=noleidos"
					}
				}
				setTimeout('haymensajes('+id+')',50000)
			}
		}
	}
	ajax.send(null);
}

function hayalertas() {
	ajax2 = nuevoAjax();
	ajax2.open("GET","hayalertas.asp",true);
	ajax2.onreadystatechange=function(){
		if (ajax2.readyState==4) {
			if (ajax2.status == 200) {
				if (ajax2.responseText == 'YES') {
					if (confirm('Hay alertas de expedientes.\n\n ¿Desea verlas ahora?\n ')) {
						window.location = "veralertas.asp"
					}
				}
			}
		}
	}
	ajax2.send(null);
}


// funciones de efectos en imagenes 
function alphaon(x)
	{document[x].filters.alpha.opacity +=50;}

function alphaoff(x){
	test=x
	provatimer=setInterval("prova(test)", 100)}

function prova(x){
	if(document[x].filters.alpha.opacity>50){
		document[x].filters.alpha.opacity -= 10
	}
	else{clearInterval(provatimer)}
	}

function bluron(x)
	{document[x].filters.blur.enabled=1;}

function bluroff(x)
	{document[x].filters.blur.enabled=0;}


function lighton(x)
	{document[x].filters.light.enabled=1;
	document[x].filters.light.addpoint(50,50,40,255,255,255,100);}

function lightoff(x)
	{document[x].filters.light.enabled=0;}

function waveon(x)
	{document[x].filters.wave.enabled=1;}

function waveoff(x)
	{document[x].filters.wave.enabled=0;}

function fliphon(x)
	{document[x].filters.fliph.enabled=1;}

function fliphoff(x)
	{document[x].filters.fliph.enabled=0;}

function flipvon(x)
	{document[x].filters.flipv.enabled=1;}

function flipvoff(x)
	{document[x].filters.flipv.enabled=0;}
// fin funciones de efectos en imagenes


function verListado() {
	if (document.formulario.fecha.options[document.formulario.fecha.selectedIndex].value != 0 ) {
	document.formulario.action = "dirptotraestampadas.asp"; 
	document.formulario.submit();
	} else {
		alert("Seleccione una fecha");
	}
}



function BusquedaAccionForm() {

	if (!isFecha(document.formulario.finicio, 'fecha de inicio', false, true, true, ES_es, '01/01/1910' )) return false;
	if (!isFecha(document.formulario.ffin, 'fecha de finalización	', false, true, true, ES_es, '01/01/1910' )) return false;
 document.formulario.target = '';	
document.formulario.modo.value='N';
document.formulario.submit();
}

function BusquedaAccionFormT() {

	if (!isFecha(document.formulario.finicio, 'fecha de inicio', false, true, true, ES_es, '01/01/1910' )) return false;
	if (!isFecha(document.formulario.ffin, 'fecha de finalización	', false, true, true, ES_es, '01/01/1910' )) return false;
document.formulario.modo.value='T';
document.formulario.target = '_blank';
document.formulario.submit();
 document.formulario.modo.value='N';
}


function insertar(texto,idem,valor,cont){
	contenedor = document.getElementById(cont)
	nuevo = document.createElement('option')
	nuevo.id = idem
	nuevo.value = valor
	nuevo.text = texto
	contenedor.options[contenedor.length] = nuevo
}

function esrepetido(cont,valor){
	contenedor = document.getElementById(cont)
	var encontrado = false
	var i = 0
	while ((i < contenedor.options.length) && (!encontrado)) {
		contenido = contenedor[i].value
		if (contenido == valor) {encontrado = true}
		i++
	}
	return encontrado
}

function quitoption(sel) {
	contenedor = document.getElementById(sel)
	var eliminar = ''

	for (i=0; i < contenedor.options.length; i++) {
		if (contenedor.options[i].selected)	{
			id = sel+contenedor.options[i].value
			if (eliminar.length > 0 ) { eliminar = eliminar + ' '}
			eliminar = eliminar + id 
		}
	}
	if (eliminar.length > 0) {
		veliminar = eliminar.split(" ")
		for (i=0; i < veliminar.length; i++) {
			nodoeliminar = document.getElementById(veliminar[i])
			contenedor.removeChild(nodoeliminar)
		}
	}
}

function quitalloption(sel) {
	contenedor = document.getElementById(sel)
	var combo = contenedor.options
	combo.length = null
}

function addoption(sel,cont) {
	seleccionado = document.getElementById(sel)
	for (i=0; i < seleccionado.options.length; i++)	{
		if (seleccionado.options[i].selected) {
			texto = seleccionado.options[i].text
			id 	  = cont+seleccionado.options[i].value
			valor = seleccionado.options[i].value
			if (!esrepetido(cont,valor))  {insertar(texto,id,valor,cont)}
		}
	}
}

function addalloption(sel,cont) {
	seleccionado = document.getElementById(sel)
	for (i=0; i < seleccionado.options.length; i++)	{
		texto = seleccionado.options[i].text
		id 	  = cont+seleccionado.options[i].value
		valor = seleccionado.options[i].value	
		if (!esrepetido(cont,valor))  {insertar(texto,id,valor,cont)}
	}
}

function CheckTodos(campo){
for(var i=0;i<document.formulario.elements.length;i++){
var e=document.formulario.elements[i];
if (e.name==campo)e.checked=document.formulario.checkAll.checked;}}

