var popUp; 

function OpenCalendar(idname, postBack,pathBack)
{
	popUp = window.open(pathBack + 'Calendar.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
		'popupcal', 
		'width=200,height=250,left=200,top=250');
	/*popUp = window.open(pathBack + 'Calendar.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
		'popupcal', 
		'fullscreen=1,scrollbars=0,resizable=0,width=165,height=212,left=200,top=250');
	popUp.moveTo(200,250);*/
	popUp.resizeTo(215,310);
}

function SetDate(formName, id, newDate, postBack)
{
	eval('var theform = document.' + formName + ';');
	popUp.close();
	theform.elements[id].value = newDate;
	if (postBack)
		__doPostBack(id,'');
}


/* ------------------------ Funciones Proyecto -- */

function OpenWin(idname, postBack, pathBack)
{
	popUp = window.open(pathBack + 'admEmpresa.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
		'popupEmpresa', 
		'width=700,height=500,left=100,top=50');
}


/*
function nuevaMutua(){
	popUp = window.open('../cli/datMutua.aspx',null,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=541,height=210');
}	

function guardaMutua(){
	window.opener.actualiza('cmbMutua');
}

function actualiza(id){
	__doPostBack(id,'');
}

function buscaGrupo(id){
	popUp = window.open('../loc/locGrupos.aspx?idCtrl=' + id,null,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=541,height=410');
}


function mostrarAyuda(id,cy,sp){
	popUp = window.open(sp + 'aspx/hlp/hlpShown.aspx?l_codhlp=' + id + '&s_cyp=' + cy,null,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=471,height=410');
}

function buscaEmpresa(id,cod,ad){
	popUp = window.open('../loc/locEmpresas.aspx?idCtrl=' + id + "&l_codgrp=" + cod + "&b_add=" + ad,null,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=541,height=410');
}

function buscaCentro(id,cod,cod2){
	popUp = window.open('../loc/locCentros.aspx?idCtrl=' + id + "&l_codgrp=" + cod + "&l_codemp=" + cod2,null,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=541,height=410');
}

function restableceContrasena(id,orig,lev){
	if (lev == 2)
		popUp = window.open('../ass/resPwd.aspx?l_codper=' + id + '&s_origen=' + orig,null,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=430,height=217');
	else
		if (lev == 1)
			popUp = window.open('ass/resPwd.aspx?l_codper=' + id + '&s_origen=' + orig,null,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=430,height=217');
}

function buscaTrabajador(nom,ape){
	popUp = window.open('busTrabajador.aspx?s_nom=' + nom + '&s_ape=' + ape,null,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=541,height=450');
}

function muestraConfirmacion(lCodMsg){
	popUp = window.open('confirma.aspx?l_codmsg=' + lCodMsg,null,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=541,height=250');
}

function fichaMensaje(lCodMsg){
	popUp = window.open('ficMensaje.aspx?l_codmsg=' + lCodMsg,null,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=541,height=450');
}

function ponTrabajador(cod,pr,nom,ape,ape2,dni,fna,sex){
	var objF = window.opener.document.forms[0];
	objF.txtNombre.value = nom;
	objF.codtr.value = cod;
	objF.codpr.value = pr;
	objF.txtPApellido.value = ape;
	objF.txtSApellido.value = ape2;
	objF.txtDni.value = dni;
	objF.txtFNAcimiento.value = fna.substring(0,10);
	if (sex == 'HOMBRE')
		objF.cmbSexo.selectedIndex = 0;
	else
		objF.cmbSexo.selectedIndex = 1;
	window.close();
}

function enlazaGrupo(cod,id,ad,na){
	var elem = window.opener.document.forms[0].elements[id];
	var bYa = false;
	
	for (var i = 0; i < elem.length && !bYa && ad; i++)
		if (elem.options[i].value == cod)
			bYa = true;
	
	if (!bYa)
		if (ad){
			if (document.all){
				elem.options.add(window.opener.document.createElement("OPTION"));
				elem.options[elem.length - 1].text = na;
				elem.options[elem.length - 1].value = cod;
			}
			else{
				elem.options[elem.length] = new Option(na);
				elem.options[elem.length - 1].value = cod;
			}
			if (elem.selectedIndex == -1) elem.selectedIndex += 1;
			else elem.selectedIndex -= 1;
			
		}
		else
			for(var i = 0; i < window.opener.document.forms[0].elements[id].length; i++)
				if (window.opener.document.forms[0].elements[id].options[i].value == cod )
					window.opener.document.forms[0].elements[id].options[i].selected = true;
		
	window.opener.actualiza(id);
	window.close();
}

function quitaElemento(id){
	var elem = document.forms[0].elements[id];
	var i = elem.selectedIndex;
	if (i != -1){
		if (elem.length > 1)
			for (;i < elem.length - 1; i++){
				elem.options[i].text = elem.options[i+1].text;
				elem.options[i].value = elem.options[i+1].value;
			}
		elem.length -= 1;
	 }
}

window.onunload=function(){
	if(popUp != null && !popUp.closed)popUp.close();
	if(typeof document.forms[0].cmbEmpresas == 'object')
		for(var i = 0; i < document.forms[0].cmbEmpresas.length; i++)
			document.forms[0].cmbEmpresas.options[i].selected = true;
}
*/
