
function fnCargarServicioPortalVentana(urlservicio)
{
	var servicio = new String(urlservicio);                              
    window.open(urlservicio,'new','toolbar=no,directories=no,status=no,menubar=no,width=300,height=405,left=80,top=15,scrollbars=no');
}
function jsPopUpAutenticacion()
{
	var urlservicio = new String('/Portal.Base/Web/verContenido.aspx?ID=132644&PP=1');                              
    window.open(urlservicio,'new','toolbar=no,directories=no,status=no,menubar=no,width=300,height=405,left=80,top=15,scrollbars=no');
}

function jsPopUpProcesarPlanificacion(pIDContenidoDestino, pIDContenidoProcesar)
{
	var urlservicio = new String('/Portal.Base/Web/verContenido.aspx?ID='+pIDContenidoDestino+'&PP=1&IDCPP='+pIDContenidoProcesar);
    window.open(urlservicio,'Proceso'+pIDContenidoDestino,'toolbar=no,directories=no,status=no,menubar=no,width=300,height=250,left=80,top=15,scrollbars=no');
}

function autoResize(id){
   
    var newheight;
    if (!window.opera && !document.mimeType && document.all && document.getElementById){
        newheight=document.getElementById(id).contentWindow.document .body.offsetHeight;
    }else if(document.getElementById){
       
        newheight=document.getElementById(id).contentWindow.document .body.scrollHeight;
    }
    document.getElementById(id).height= (newheight + 16) + "px";
}


var HttpReq = null;
var oDestino = null;
var oUsernameValor = null;
var oUsername = null;

function jsConsultarUsuarioAjax(pUsername,pCorreo)
{
	oCorreo=document.Form1[pCorreo];
	oCorreoValor=oCorreo.value;
	oUsername = document.Form1[pUsername];
	oUsernameValor = oUsername.value;	
	if(Page_ClientValidate())
	{
		url='/Portal.Base/Web/ConsultarUsuario.aspx?username='+oUsernameValor+'&correo='+oCorreoValor
		if (window.XMLHttpRequest) {
				HttpReq = new XMLHttpRequest();
				HttpReq.onreadystatechange = jsHttpRequestConsultaUsuario;
				HttpReq.open("GET",url, true);
				HttpReq.send(null);
		} 
		else if (window.ActiveXObject) 
		{
			HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			if (HttpReq) 
			{
				HttpReq.onreadystatechange = jsHttpRequestConsultaUsuario;
				HttpReq.open("GET", url, true);
				HttpReq.send();			
			}
		}
	}
	
	return false;
		
}

function jsIraAsociadas()
{
	var cboxN1 = document.Form1['N1']; 
	var lKeyN1 = cboxN1.options[cboxN1.selectedIndex].value; 
	var cboxN2 = document.Form1['N2']; 
	var lKeyN2 = cboxN2.options[cboxN2.selectedIndex].value; 
	var lDato = lKeyN2;
		if (lDato==0)
			lDato = lKeyN1;
	document.location.href='VerContenido.aspx?ID=150912&TXT=&DATO='+lDato+'&N1=0&N2=0&N3=0&N4=0';
}

function jsImportaContenido(pIDContenido,pIDCategoriaDestino, pIDUsuario)
{
	if (pIDUsuario == 0)
	{
		//var urlservicio = new String('/Portal.Base/Web/verContenido.aspx?ID=132644&PP=1');                              
		//window.open(urlservicio,'new','toolbar=no,directories=no,status=no,menubar=no,width=300,height=405,left=80,top=15,scrollbars=no');
		document.location.href='VerContenido.aspx?ID=132644';
	}
	else
	{
		var url='/Portal.Base/Web/ProcesarContenido.aspx?Accion=IMP&IDC='+pIDContenido+'&ICD='+pIDCategoriaDestino+'&IDU='+pIDUsuario;
		jsProcesaContenidoImportacion(url);
	}
}

function jsImportaEditaContenido(pIDContenido,pIDCategoriaDestino, pIDUsuario)
{
	if (pIDUsuario == 0)
	{
		//var urlservicio = new String('/Portal.Base/Web/verContenido.aspx?ID=132644&PP=1');                              
		//window.open(urlservicio,'new','toolbar=no,directories=no,status=no,menubar=no,width=300,height=405,left=80,top=15,scrollbars=no');
		document.location.href='VerContenido.aspx?ID=132644';
	}
	else
	{
		var url='/Portal.Base/Web/ProcesarContenido.aspx?Accion=IMPEDI&IDC='+pIDContenido+'&ICD='+pIDCategoriaDestino+'&IDU='+pIDUsuario;
		jsProcesaContenidoImportacionEdicion(url, pIDUsuario);
	}
}


function jsProcesaContenidoImportacionEdicion(pUrl, pIDUsuario)
{
	if (window.XMLHttpRequest) {
			lIDUsuario = pIDUsuario;
			HttpReq = new XMLHttpRequest();
			HttpReq.onreadystatechange = jsHttpRequestProcesaContenidoImportacionEdicion;
			HttpReq.open("GET",pUrl, true);
			HttpReq.send(null);
	} 
	else if (window.ActiveXObject) 
	{
		HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		if (HttpReq) 
		{
			lIDUsuario = pIDUsuario;
			HttpReq.onreadystatechange = jsHttpRequestProcesaContenidoImportacionEdicion;
			HttpReq.open("GET", pUrl, true);
			HttpReq.send();			
		}
	}

}

function jsHttpRequestProcesaContenidoImportacionEdicion() {

	if (HttpReq.readyState == 4 && HttpReq.status == 200)
	{
		var result = HttpReq.responseText;
		if (result=="NO")
		{
			alert('Para realizar esta acci\xF3n, debe ajustar su perfil.');
			return false;
		}
		else
		{
			jsAbrirContenidoHijoEdicion(result, 0, 404, 1200, 800, lIDUsuario);
			return true;
		}
	}

	return true;
}

function jsSetearNivelPerfil(pIDUsuario, pNivel, pSector)
{
	PoblarPunteroAjaxNivel('frmInfo:_D_001310:cmbValor', pIDUsuario, pNivel, pSector)
	CargarContenidoAprendizajeAjax();
	jsBloqueaNivelSector();
}

function jsSetearNivelSector(pNivel, pSector)
{
	cSector = document.Form1['frmInfo:_D_001311:cmbValor'];
	for(i=0; i<cSector.length; i++)
	{
		if (cSector.options[i].value==pSector)
			cSector.options[i].selected = true;
	}

	cNivel = document.Form1['frmInfo:_D_001310:cmbValor'];
	for(i=0; i<cNivel.length; i++)
	{
		if (cNivel.options[i].value==pNivel)
			cNivel.options[i].selected = true;
	}	
}


function jsSetearNivelAdministracion()
{
	CargarContenidoAprendizajeAjax();
	jsBloqueaNivelSector();
	
}

function jsBloqueaNivelSector()
{
	//frmInfo:_D_001312:lstValor
	obj=document.Form1['frmInfo:_D_001312:lstValor'];
	if (obj.length>0)
	{
		document.Form1['frmInfo:_D_001310:cmbValor'].disabled=true;
		document.Form1['frmInfo:_D_001311:cmbValor'].disabled=true;
	}
	else
	{
		document.Form1['frmInfo:_D_001310:cmbValor'].disabled=false;
		document.Form1['frmInfo:_D_001311:cmbValor'].disabled=false;
	}
}

function jsAsociarRecurso(pIDUsuario, pIDRecurso, pIDContenido, pIDContenidoPadre, pIDCategoria)
{
	var url;
	if (pIDUsuario == 0)
	{
		alert('Para ejecutar esta operaci\xF3n debe estar autenticado.');
	}
	else
	{
		if (pIDCategoria!=405)
		{
			alert('Los recursos deben ser asociados a clases.');
		}
		else
		{
			if (confirm('\xBFEst\xE1 seguro que desea asociar este recursos a su clase?'))
			{
				url='/Portal.Base/Web/AsociarRecursoContenido.aspx?IDC='+pIDRecurso+'&ICD='+pIDContenido+'&IDU='+pIDUsuario;
				jsProcesaAsociacionRecurso(url, pIDContenido);
				//window.parent.location.href = '/Portal.Base/Contenidos/EditarContenidoPlanificacion.aspx?IDCO='+pIDContenido+'&IDC=405&IDCP='+pIDContenidoPadre;
			}
		}
	}
	
}


function jsProcesaAsociacionRecurso(pUrl , pIDContenido)
{
	if (window.XMLHttpRequest) {
			lIDContenido = pIDContenido;
			HttpReq = new XMLHttpRequest();
			HttpReq.onreadystatechange = jsHttpRequestAsociacionRecurso;
			HttpReq.open("GET",pUrl, true);
			HttpReq.send(null);
	} 
	else if (window.ActiveXObject) 
	{
		HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		if (HttpReq) 
		{
			lIDContenido = pIDContenido;
			HttpReq.onreadystatechange = jsHttpRequestAsociacionRecurso;
			HttpReq.open("GET", pUrl, true);
			HttpReq.send();			
		}
	}

}


function jsHttpRequestAsociacionRecurso() {
	if (HttpReq.readyState == 4 && HttpReq.status == 200)
	{
		var result = HttpReq.responseText;
		if (result=="NO")
		{
			alert('Recurso no asociado.');
			return false;
		}
		else
		{
			alert('Recurso asociado.');
			jsRefrescaTablaDocumento(result);
			return true;
		}
	}

	return true;
}

function jsRefrescaTablaDocumento(pTexto)
{
	var d = parent.document.getElementById("frmInfo__D_001264_lblValor");
	d.innerHTML = pTexto;

}

function jsPostularContenido(pIDContenido,pIDCategoriaDestino, pIDUsuario)
{
	if (pIDUsuario == 0)
	{
		alert('Para ejecutar esta operaci\xF3n debe estar autenticado.');
	}
	else
	{
			var url='/Portal.Base/Web/ProcesarContenido.aspx?Accion=POS&IDC='+pIDContenido+'&ICD='+pIDCategoriaDestino+'&IDU='+pIDUsuario;
			jsProcesaContenido(url);
			alert('Planificaci\xF3n Postulada a Concurso.');
			window.close();
	}
}


function jsComparteContenido(pIDContenido,pIDCategoriaDestino, pIDUsuario)
{
	if (pIDUsuario == 0)
	{
		alert('Para ejecutar esta operaci\xF3n debe estar autenticado.');
	}
	else
	{
			var url='/Portal.Base/Web/ProcesarContenido.aspx?Accion=COP&IDC='+pIDContenido+'&ICD='+pIDCategoriaDestino+'&IDU='+pIDUsuario;
			jsProcesaContenido(url);
			alert('Planificaci\xF3n Compartida.');
			window.close();
	}
}

function jsRedireccionHijoEdicion(pIDContenido, pContenidoPadre, pIDCategoria, pAncho, pAlto, pIDUsuario)
{
	if (pIDUsuario == 0)
	{
		alert('Para ejecutar esta operaci\xF3n debe estar autenticado.');
	}
	else
	{	
		var url = "/Portal.Base/Contenidos/EditarContenidoPlanificacion.aspx?Rel=1&IDCO="+pIDContenido+"&IDC="+pIDCategoria+"&PP=1&IDCP="+pContenidoPadre;
		document.location.href=url;
	}
}


function jsAbrirContenidoHijoEdicion(pIDContenido, pContenidoPadre, pIDCategoria, pAncho, pAlto, pIDUsuario)
{
	if (pIDUsuario == 0)
	{
		alert('Para ejecutar esta operaci\xF3n debe estar autenticado.');
	}
	else
	{	
		var url = "/Portal.Base/Contenidos/EditarContenidoPlanificacion.aspx?Rel=1&IDCO="+pIDContenido+"&IDC="+pIDCategoria+"&PP=1&IDCP="+pContenidoPadre;
		window.open(url,'new','toolbar=no,directories=no,status=no,menubar=no,width='+pAncho+',height='+pAlto+',left=80,top=15,scrollbars=yes');
	}
}

function jsAbrirContenido(pIDContenido, pAncho, pAlto)
{
	var url = "/Portal.Base/Web/VerContenido.aspx?ID="+pIDContenido;
	window.open(url,'new','toolbar=no,directories=no,status=no,menubar=no,width='+pAncho+',height='+pAlto+',left=80,top=15,scrollbars=yes');
}

function jsProcesaContenidoImportacion(pUrl)
{
	if (window.XMLHttpRequest) {
			HttpReq = new XMLHttpRequest();
			HttpReq.onreadystatechange = jsHttpRequestProcesaContenidoImportacion;
			HttpReq.open("GET",pUrl, true);
			HttpReq.send(null);
	} 
	else if (window.ActiveXObject) 
	{
		HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		if (HttpReq) 
		{
			HttpReq.onreadystatechange = jsHttpRequestProcesaContenidoImportacion;
			HttpReq.open("GET", pUrl, true);
			HttpReq.send();			
		}
	}

}

function jsProcesaContenido(pUrl)
{
	if (window.XMLHttpRequest) {
			HttpReq = new XMLHttpRequest();
			HttpReq.onreadystatechange = jsHttpRequestProcesaContenido;
			HttpReq.open("GET",pUrl, true);
			HttpReq.send(null);
	} 
	else if (window.ActiveXObject) 
	{
		HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		if (HttpReq) 
		{
			HttpReq.onreadystatechange = jsHttpRequestProcesaContenido;
			HttpReq.open("GET", pUrl, true);
			HttpReq.send();			
		}
	}

}

function jsEliminaContenidoFicha(pIDContenido, pIDUsuario)
{
	if (pIDUsuario == 0)
	{
		alert('Para ejecutar esta operaci\xF3n debe estar autenticado.');
	}
	else
	{	
			url='/Portal.Base/Web/ProcesarContenido.aspx?Accion=ELI&IDC='+pIDContenido;
			jsProcesaContenido(url);

		ran = Math.random()*5;
		top.opener.location.href='VerContenido.aspx?ID=151510&ran='+ran;
		window.close();
	}		
}

function jsEliminaClaseFicha(pIDContenido, pIDUsuario)
{
	if (pIDUsuario == 0)
	{
		alert('Para ejecutar esta operaci\xF3n debe estar autenticado.');
	}
	else
	{	
		//if (confirm('\xBFEst\xE1 seguro de eliminar esta clase y todos los elementos de la planificaci\xF3n asociada?'))
		//{
			url='/Portal.Base/Web/ProcesarContenido.aspx?Accion=ELI&IDC='+pIDContenido;
			jsProcesaContenido(url);

			document.location.href='VerContenido.aspx?ID=131868';
		//}
	}		
}

function jsEliminaContenido(pDireccion, pIDContenido, pContenidoPadre, pIDCategoria)
{
	if (confirm('Esta seguro de eliminar?'))
	{
		url='/Portal.Base/Web/ProcesarContenido.aspx?Accion=ELI&IDC='+pIDContenido;
		jsProcesaContenido(url);
			
	if (pDireccion==0)
		document.location.href='EditarContenidoPlanificacion.aspx?IDCO='+pContenidoPadre+"&IDC="+pIDCategoria+"&IDCP="+pIDContenido;
	else		
		document.location.href='EditarContenido.aspx?IDCO='+pContenidoPadre+"&IDC="+pIDCategoria+"&IDCP="+pIDContenido;
	return true;
	}
}



function jsHttpRequestProcesaContenidoImportacion() {

	if (HttpReq.readyState == 4 && HttpReq.status == 200)
	{
		var result = HttpReq.responseText;
		if (result!="OK")
		{
			alert('No puede Importar una planificaci\xF3n que no se ajusta a su perfil.');
			return false;
		}
		else
		{
			alert('Planificaci\xF3n Importada.');
			return true;
		}
	}

	return true;
}


function jsHttpRequestProcesaContenido() {

	if (HttpReq.readyState == 4 && HttpReq.status == 200)
	{
		var result = HttpReq.responseText;
	}
	return true;
}

function jsHttpRequestConsultaUsuario() {

	if (HttpReq.readyState == 4 && HttpReq.status == 200)
	{
		var result = HttpReq.responseText;
		if(result=="1")		
		{	
			alert('* El Correo Electronico: '+oCorreoValor+' ya existe en nuestros registros \n* Lamentablemente el nombre de usuario que has elegido ya existe, te sugerimos utilizar '+oUsernameValor+'2006');
			if(oCorreo){
				oCorreo.focus();
				return false;
			}
		}
		if(result=="2")		
		{	
			alert('Lamentablemente el nombre de usuario que has elegido ya existe, te sugerimos utilizar '+oUsernameValor+'2006');
			if(oUsername){
				oUsername.focus();
				return false;
			}
		}
		if(result=="3")		
		{	
			alert('El Correo Electronico: '+oCorreoValor+' ya existe en nuestros registros');
			if(oCorreo){
				oCorreo.focus();
				return false;
			}
		}
		else
		{	
			return jsEjecutarRegistroAvanzado();
		}
	
	}
}

function PoblarPunteroAjaxCurricular(cOrigen, cDestino,bCurricular)
{
	
	var cbox = document.Form1[cOrigen];
	var lKey = cbox.options[cbox.selectedIndex].value;	
	
	var url = "/Portal.Base/Web/ObtenerValor.aspx?IDPadre="+lKey+"&Tipo="+bCurricular;
	
	oDestino = document.Form1[cDestino];
	if (document.getElementById) 
	{ //Verifica se o Browser suporta DHTML.
		if (window.XMLHttpRequest) {
			HttpReq = new XMLHttpRequest();
			HttpReq.onreadystatechange = XMLHttpRequestChange;
			HttpReq.open("GET", url, true);
			HttpReq.send(null);
		} 
		else if (window.ActiveXObject) 
		{
			HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			if (HttpReq) 
			{
				HttpReq.onreadystatechange = XMLHttpRequestChange;
				HttpReq.open("GET", url, true);
				HttpReq.send();
			}
		}
	}	
}


function PoblarPunteroAjaxNivel(cDestino, pIDUsuario, pNivel, pSector)
{
	var url = "/Portal.Base/Web/ObtenerValorNivel.aspx?IDPadre=0&IDU="+pIDUsuario;
	oDestino = document.Form1[cDestino];
	if (document.getElementById) 
	{ //Verifica se o Browser suporta DHTML.
		if (window.XMLHttpRequest) {
			lNivelPlan = pNivel;
			lSectorPlan = pSector;
			HttpReq = new XMLHttpRequest();
			HttpReq.onreadystatechange = XMLHttpRequestChangeNivelSector;
			HttpReq.open("GET", url, true);
			HttpReq.send(null);
		} 
		else if (window.ActiveXObject) 
		{
			HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			if (HttpReq) 
			{
				lNivelPlan = pNivel;
				lSectorPlan = pSector;			
				HttpReq.onreadystatechange = XMLHttpRequestChangeNivelSector;
				HttpReq.open("GET", url, true);
				HttpReq.send();
			}
		}
	}
}

function XMLHttpRequestChangeNivelSector() {
	if (HttpReq.readyState == 4 && HttpReq.status == 200)
	{
		var result = HttpReq.responseXML;		
		
		var mElementos = result.getElementsByTagName("E");
				
		oDestino.options.length = 0;
		oDestino.options[0] = new Option('    ',0);
		
		//oDestino.options.length = 0;
		for (var i = 1; i < mElementos.length+1; i++) 
		{		
			oDestino.options[i] = new Option(mElementos[i-1].childNodes[0].data,mElementos[i-1].getAttribute("id"));		
			oDestino.options[i].title = mElementos[i-1].childNodes[0].data;
		}		
		jsSetearNivelSector(lNivelPlan, lSectorPlan);	
	}
}


function PoblarPunteroAjaxNivel2(cOrigen, cDestino, pIDUsuario)
{
	var cboxN2 = document.Form1[cOrigen];
	var lKeyN2 = cboxN2.options[cboxN2.selectedIndex].value;	
	if (lKeyN2==0) lKeyN2 = -9999;
	var urlN2 = "/Portal.Base/Web/ObtenerValorNivel.aspx?IDPadre="+lKeyN2+"&IDU="+pIDUsuario;
	oDestinoN2 = document.Form1[cDestino];
	if (document.getElementById) 
	{ //Verifica se o Browser suporta DHTML.
		if (window.XMLHttpRequest) {
			HttpReqN2 = new XMLHttpRequest();
			HttpReqN2.onreadystatechange = XMLHttpRequestChangeN2;
			HttpReqN2.open("GET", urlN2, true);
			HttpReqN2.send(null);
		} 
		else if (window.ActiveXObject) 
		{
			HttpReqN2 = new ActiveXObject("Microsoft.XMLHTTP");
			if (HttpReqN2) 
			{
				HttpReqN2.onreadystatechange = XMLHttpRequestChangeN2;
				HttpReqN2.open("GET", urlN2, true);
				HttpReqN2.send();
			}
		}
	}	
}


function PoblarPunteroAjaxGenerico(cOrigen, cDestino)
{
	
	var cbox = document.Form1[cOrigen];
	var lKey = cbox.options[cbox.selectedIndex].value;	
	if (lKey==0) lKey = -9999;
	alert(lKey);
	var url = "/Portal.Base/Web/ObtenerValor.aspx?IDPadre="+lKey;
	oDestino = document.Form1[cDestino];
	if (document.getElementById) 
	{ //Verifica se o Browser suporta DHTML.
		if (window.XMLHttpRequest) {
			HttpReq = new XMLHttpRequest();
			HttpReq.onreadystatechange = XMLHttpRequestChange;
			HttpReq.open("GET", url, true);
			HttpReq.send(null);
		} 
		else if (window.ActiveXObject) 
		{
			HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			if (HttpReq) 
			{
				HttpReq.onreadystatechange = XMLHttpRequestChange;
				HttpReq.open("GET", url, true);
				HttpReq.send();
			}
		}
	}	
}

function PoblarPunteroAjaxGenericoG1(cOrigen, cDestino)
{
	var lstControl = document.Form1[cOrigen]; 
	var sValores='';
	for (x=0; x<lstControl.length; x++)
	{
		if (sValores!='')
			sValores+=",";
		sValores+=lstControl.options[x].value; 
	}
	
	var urlG1 = "/Portal.Base/Web/ObtenerValorEspecial.aspx?TIPO=APR&UNI="+sValores;
	oDestinoG1 = document.Form1[cDestino];
	if (document.getElementById) 
	{ //Verifica se o Browser suporta DHTML.
		if (window.XMLHttpRequest) {
			HttpReqG1 = new XMLHttpRequest();
			HttpReqG1.onreadystatechange = XMLHttpRequestChangeG1;
			HttpReqG1.open("GET", urlG1, true);
			HttpReqG1.send(null);
		} 
		else if (window.ActiveXObject) 
		{
			HttpReqG1 = new ActiveXObject("Microsoft.XMLHTTP");
			if (HttpReqG1) 
			{
				HttpReqG1.onreadystatechange = XMLHttpRequestChangeG1;
				HttpReqG1.open("GET", urlG1, true);
				HttpReqG1.send();
			}
		}
	}	
}

function PoblarPunteroAjaxGenericoG2(cOrigen, cDestino)
{
	
	var lstControl = document.Form1[cOrigen]; 
	var sValores='';
	for (x=0; x<lstControl.length; x++)
	{
		if (sValores!='')
			sValores+=",";
		sValores+=lstControl.options[x].value; 
	}
	
	var urlG2 = "/Portal.Base/Web/ObtenerValorEspecial.aspx?TIPO=CON&UNI="+sValores;
	oDestinoG2 = document.Form1[cDestino];
	if (document.getElementById) 
	{ //Verifica se o Browser suporta DHTML.
		if (window.XMLHttpRequest) {
			HttpReqG2 = new XMLHttpRequest();
			HttpReqG2.onreadystatechange = XMLHttpRequestChangeG2;
			HttpReqG2.open("GET", urlG2, true);
			HttpReqG2.send(null);
		} 
		else if (window.ActiveXObject) 
		{
			HttpReqG2 = new ActiveXObject("Microsoft.XMLHTTP");
			if (HttpReqG2) 
			{
				HttpReqG2.onreadystatechange = XMLHttpRequestChangeG2;
				HttpReqG2.open("GET", urlG2, true);
				HttpReqG2.send();
			}
		}
	}	
}


function PoblarPunteroAjax(cOrigen, cDestino)
{
	
	var cbox = document.Form1[cOrigen];
	var lKey = cbox.options[cbox.selectedIndex].value;	

	var url = "/Portal.Base/Web/ObtenerValor.aspx?IDPadre="+lKey;
	oDestino = document.Form1[cDestino];
	if (oDestino)
	{
	if (document.getElementById) 
	{ //Verifica se o Browser suporta DHTML.
		if (window.XMLHttpRequest) {
			HttpReq = new XMLHttpRequest();
			HttpReq.onreadystatechange = XMLHttpRequestChange;
			HttpReq.open("GET", url, true);
			HttpReq.send(null);
		} 
		else if (window.ActiveXObject) 
		{
			HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			if (HttpReq) 
			{
				HttpReq.onreadystatechange = XMLHttpRequestChange;
				HttpReq.open("GET", url, true);
				HttpReq.send();
			}
		}
	}	
	}
	if (cOrigen == '_P_3076:frmUsuario:_D_43:cmbValor')
		jsSeteaRutDni('_P_3076:frmUsuario:_D_43:cmbValor');

		if(cOrigen=='frmInfo:_D_001311:cmbValor')
		{
			CargarOFVAjax()
		}			
}

function jsSeteaRutDni(cOrigen)
{
	var cbox = document.Form1[cOrigen];
	var lKey = cbox.options[cbox.selectedIndex].value;	
		if(document.getElementById('tipoDocMem'))
		{
			if (Number(lKey)==10001)
			{
				document.getElementById('tipoDocMem').innerHTML='RUT';
				document.getElementById('tipoDocMemFormato').innerHTML='Ejemplo RUT (13288680-6)';
			}
			else
			{
				document.getElementById('tipoDocMem').innerHTML='DNI';
				document.getElementById('tipoDocMemFormato').innerHTML='';
			}
		}
}

function CargarOFVAjax()
{
	var cn1 = document.Form1['frmInfo:_D_001310:cmbValor'];
	var lKeyN1 = cn1.options[cn1.selectedIndex].value;	
	
	var cn2 = document.Form1['frmInfo:_D_001311:cmbValor'];
	var lKeyN2 = cn2.options[cn2.selectedIndex].value;		
	
	cDestinoOfv = 'frmInfo:_D_001315:cmbValor';
	
	var urlOFv = "/Portal.Base/Web/ObtenerValorEspecial.aspx?Tipo=OFV&N1="+lKeyN1+"&N2="+lKeyN2;
	
	oDestinoOfv = document.Form1[cDestinoOfv];
	if (document.getElementById) 
	{ //Verifica se o Browser suporta DHTML.
		if (window.XMLHttpRequest) {
			HttpReqOfv = new XMLHttpRequest();
			HttpReqOfv.onreadystatechange = XMLHttpRequestChangeOfv;
			HttpReqOfv.open("GET", urlOFv, true);
			HttpReqOfv.send(null);
		} 
		else if (window.ActiveXObject) 
		{
			HttpReqOfv = new ActiveXObject("Microsoft.XMLHTTP");
			if (HttpReqOfv) 
			{
				HttpReqOfv.onreadystatechange = XMLHttpRequestChangeOfv;
				HttpReqOfv.open("GET", urlOFv, true);
				HttpReqOfv.send();
			}
		}
	}	
}

function CargarContenidoAprendizajeAjax()
{
	PoblarPunteroAjaxGenericoG1('frmInfo:_D_001312:lstValor','frmInfo:_D_001313:cmbValor');
	PoblarPunteroAjaxGenericoG2('frmInfo:_D_001312:lstValor','frmInfo:_D_001314:cmbValor');
}


function XMLHttpRequestChangeOfv() {
	if (HttpReqOfv.readyState == 4 && HttpReqOfv.status == 200)
	{
		var resultOfv = HttpReqOfv.responseXML;		
		var mElementosOfv = resultOfv.getElementsByTagName("E");
				
		//if(mElementos.length==0)
		//{			
			oDestinoOfv.options.length = 0;
			oDestinoOfv.options[0] = new Option('    ',0);
		//}
		
		//oDestino.options.length = 0;
		for (var i = 1; i < mElementosOfv.length+1; i++) 
		{		
			oDestinoOfv.options[i] = new Option(mElementosOfv[i-1].childNodes[0].data,mElementosOfv[i-1].getAttribute("id"));		
			oDestinoOfv.options[i].title = mElementosOfv[i-1].childNodes[0].data;
		}		
	
	}
}

function XMLHttpRequestChangeCon() {
	if (HttpReqCon.readyState == 4 && HttpReqCon.status == 200)
	{
		var resultCon = HttpReqCon.responseXML;		
		var mElementosCon = resultCon.getElementsByTagName("E");
				
		//if(mElementos.length==0)
		//{			
			oDestinoCon.options.length = 0;
			oDestinoCon.options[0] = new Option('    ',0);
		//}
		
		//oDestino.options.length = 0;
		for (var i = 1; i < mElementosCon.length+1; i++) 
		{		
			oDestinoCon.options[i] = new Option(mElementosCon[i-1].childNodes[0].data,mElementosCon[i-1].getAttribute("id"));		
			oDestinoCon.options[i].title = mElementosCon[i-1].childNodes[0].data;
		}		
	
	}
}

function jsAgregarPerfilPlanificacion(pIDUsuario)
{		
	iNivel=document.Form1['cmbNivel'].value;
	iSector= document.Form1['cmbSubsector'].value;
	url='/Portal.Base/Web/AgregarPerfilPlanificacion.aspx?IDU='+pIDUsuario+'&N1='+iNivel+'&N2='+iSector;
		if (window.XMLHttpRequest) {
				HttpReq = new XMLHttpRequest();
				HttpReq.onreadystatechange = jsHttpRequestAgregarPerfil;
				HttpReq.open("GET",url, true);
				HttpReq.send(null);
		} 
		else if (window.ActiveXObject) 
		{
			HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			if (HttpReq) 
			{
				HttpReq.onreadystatechange = jsHttpRequestAgregarPerfil;
				HttpReq.open("GET", url, true);
				HttpReq.send();			
			}
		}
	//	ran = Math.random()*5;
	//document.location.href = 'VerContenido.aspx?ID=151509&EDPE=1&Ran='+ran;
	
	return true;
}	


function jsDesactivarPerfil(pID)
{		
if (confirm('Confirma desactivar este perfil?'))
{
	iNivel=document.Form1['cmbNivel'].value;
	iSector= document.Form1['cmbSubsector'].value;
	url='/Portal.Base/Web/AgregarPerfilPlanificacion.aspx?DES=1&ID='+pID;
		if (window.XMLHttpRequest) {
				HttpReq = new XMLHttpRequest();
				HttpReq.onreadystatechange = jsHttpRequestAgregarPerfil;
				HttpReq.open("GET",url, true);
				HttpReq.send(null);
		} 
		else if (window.ActiveXObject) 
		{
			HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			if (HttpReq) 
			{
				HttpReq.onreadystatechange = jsHttpRequestAgregarPerfil;
				HttpReq.open("GET", url, true);
				HttpReq.send();			
			}
		}
	//window.location.reload();
	//ran = Math.random()*5;
	//document.location.href = 'VerContenido.aspx?ID=151509&EDPE=1&Ran='+ran;
}
	return true;
}

function jsHttpRequestAgregarPerfil() {

	if (HttpReq.readyState == 4 && HttpReq.status == 200)
	{
		var result = HttpReq.responseText;
		if (result=="OK")
		{
			ran = Math.random()*5;
			document.location.href = 'VerContenido.aspx?ID=151509&EDPE=1&Ran='+ran;
		}
	}
	return true;
}


function PoblarPunteroAjaxIDMetadato(cOrigen, cDestino)
{
	
	var cbox = document.Form1[cOrigen];
	var lKey = cbox.options[cbox.selectedIndex].value;	
	var url = "/Portal.Base/Web/ObtenerValor.aspx?IDMetadato="+lKey;
	
	oDestino = document.Form1[cDestino];
	if (document.getElementById) 
	{ //Verifica se o Browser suporta DHTML.
		if (window.XMLHttpRequest) {
			HttpReq = new XMLHttpRequest();
			HttpReq.onreadystatechange = XMLHttpRequestChange;
			HttpReq.open("GET", url, true);
			HttpReq.send(null);
		} 
		else if (window.ActiveXObject) 
		{
			HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			if (HttpReq) 
			{
				HttpReq.onreadystatechange = XMLHttpRequestChange;
				HttpReq.open("GET", url, true);
				HttpReq.send();
			}
		}
	}	
}


function XMLHttpRequestChange() {
	if (HttpReq.readyState == 4 && HttpReq.status == 200)
	{
		var result = HttpReq.responseXML;		
		
		var mElementos = result.getElementsByTagName("E");
				
		//if(mElementos.length==0)
		//{			
			oDestino.options.length = 0;
			oDestino.options[0] = new Option('    ',0);
		//}
		
		//oDestino.options.length = 0;
		for (var i = 1; i < mElementos.length+1; i++) 
		{		
			oDestino.options[i] = new Option(mElementos[i-1].childNodes[0].data,mElementos[i-1].getAttribute("id"));		
			oDestino.options[i].title = mElementos[i-1].childNodes[0].data;
		}		
	
	}
}

function XMLHttpRequestChangeN2() {
	if (HttpReqN2.readyState == 4 && HttpReqN2.status == 200)
	{
		var resultN2 = HttpReqN2.responseXML;		
		
		var mElementosN2 = resultN2.getElementsByTagName("E");
				
		//if(mElementosN2.length==0)
		//{			
			oDestinoN2.options.length = 0;
			oDestinoN2.options[0] = new Option('    ',0);
		//}
		
		//oDestino.options.length = 0;
		for (var i = 1; i < mElementosN2.length+1; i++) 
		{		
			oDestinoN2.options[i] = new Option(mElementosN2[i-1].childNodes[0].data,mElementosN2[i-1].getAttribute("id"));		
			oDestinoN2.options[i].title = mElementosN2[i-1].childNodes[0].data;
		}		
	
	}
}


function XMLHttpRequestChangeG1() {
	if (HttpReqG1.readyState == 4 && HttpReqG1.status == 200)
	{
		var resultG1 = HttpReqG1.responseXML;		
		
		var mElementosG1 = resultG1.getElementsByTagName("E");
				
		//if(mElementos.length==0)
		//{			
			oDestinoG1.options.length = 0;
			oDestinoG1.options[0] = new Option('    ',0);
		//}
		
		//oDestino.options.length = 0;
		for (var i = 1; i < mElementosG1.length+1; i++) 
		{		
			oDestinoG1.options[i] = new Option(mElementosG1[i-1].childNodes[0].data,mElementosG1[i-1].getAttribute("id"));		
			oDestinoG1.options[i].title = mElementosG1[i-1].childNodes[0].data;
		}		
	
	}
}

function XMLHttpRequestChangeG2() {
	if (HttpReqG2.readyState == 4 && HttpReqG2.status == 200)
	{
		var resultG2 = HttpReqG2.responseXML;		
		
		var mElementosG2 = resultG2.getElementsByTagName("E");
				
		//if(mElementos.length==0)
		//{			
			oDestinoG2.options.length = 0;
			oDestinoG2.options[0] = new Option('    ',0);
		//}
		
		//oDestino.options.length = 0;
		for (var i = 1; i < mElementosG2.length+1; i++) 
		{		
			oDestinoG2.options[i] = new Option(mElementosG2[i-1].childNodes[0].data,mElementosG2[i-1].getAttribute("id"));		
			oDestinoG2.options[i].title = mElementosG2[i-1].childNodes[0].data;
		}		
	
	}
}


function fnCargarHerramienta(H_index)
			{
				var x;
				var largo;
				largo = AHerramientasImagenes.length;
				azar = H_index;
				for (x=0;x<largo;x++)
				{
					MM_swapImage('flecha_menu'+x,'','images/trans.gif',1);
				}	
				MM_swapImage('flecha_menu'+H_index,'','images/flechaverde.gif',1);
				MM_swapImage('imagen_herramienta','',AHerramientasImagenes[H_index],1);
				document.getElementById('link_herramienta').href=AHerramientasLinks[H_index];
				document.getElementById('subtitulo_herramienta').innerHTML=AHerramientasSubTitulos[H_index];
				document.getElementById('bajada_herramienta').innerHTML=AHerramientasBajadas[H_index];		
			}
			
			function fnHerramienta(modo)
			{
				var x;
				var largo;
				largo = AHerramientasImagenes.length;
				if (modo =='siguiente')
				{
					if (azar < largo-1)
					{
						azar = azar + 1
						fnCargarHerramienta(azar);
					}
				}
				else
				{
					if (azar > 0)
					{
						azar = azar - 1
						fnCargarHerramienta(azar);
					}
				}
			}							
		

function fnCargarServicioEscritorio(urlservicio)
{
	 var servicio = new String(urlservicio);
	 if (!(servicio.indexOf ('http://') > -1) )
	 {
		 urlservicio = 'http://www.educarchile.cl' + urlservicio;				 
	 }		 	 
	 window.top.location.href = urlservicio;
}


function video(theURL) 
{
   window.open(theURL,'video_sitio','width=240 height=150');
}

function audio(theURL) 
{
   window.open(theURL,'audio_sitio','width=240 height=20');
}

var mArray = new Array();

function PoblarPunteroLista(cOrigen, cDestino)
{		
		var lKey;
		var list;
		var cbox = document.Form1[cOrigen];		
		var cbox2 = document.Form1[cDestino];			
		cbox2.options.length = 0;
		
		for(k=0;k<cbox.options.length;k++)
		{				
			if(cbox.options[k].selected==true)
			{
					lKey = cbox.options[k].value;		
					list = mArray[lKey];
					if (typeof list!='undefined')
					{				
						for(i=2;i<list.length;i+=2)
						{	
							cbox2.add(new Option(list[i],list[i+1]));
						}
					}
			}
		}
}

				
function PoblarPuntero(cOrigen, cDestino)
{		

		var cbox = document.Form1[cOrigen];
		var lKey = cbox.options[cbox.selectedIndex].value;		
		var list = mArray[lKey];
	
		if (typeof list!='undefined')
		{
		
			var cbox2 = document.Form1[cDestino];
			
			cbox2.options.length = 0;
			for(i=0;i<list.length;i+=2)
			{
				cbox2.options[i/2] = new Option(list[i],list[i+1]);
			}
		}
		else
		{
			var cbox2 = document.Form1[cDestino];
			cbox2.options.length = 0;
			cbox2.options[0] = new Option('',0);
		}
}
			
function jsExisteValor(oSel,valor)				
{
	for(var	i=0;i<oSel.length;i++)	
		if(oSel.options[i].value==valor)
			return true;
	

	return false;
}

function jsAgregarSeleccion(sOrigen,sDestino)
{
	var cBoxO =  document.Form1[sOrigen];
	var cBoxD =  document.Form1[sDestino];
	lblDestino = sDestino.replace("lst","hid");
	var lBoxD =  document.Form1[lblDestino];
  
  	for(var i=0;i<cBoxO.length;i++)
	{		

		if(cBoxO.options[i].selected && cBoxO.options[i].value!='0' && !jsExisteValor(cBoxD,cBoxO.options[i].value))	
		{		
			var oOption = document.createElement('option');
			oOption.text = cBoxO.options[i].text;
			oOption.value = cBoxO.options[i].value;
			oOption.title = cBoxO.options[i].text;
			
			try {
				cBoxD.add(oOption, null); // standards compliant; doesn't work in IE
			}
			catch(ex) {
				cBoxD.add(oOption); // IE only
			}
		}
	}
	
	lBoxD.value='';
	for(var i=0;i<cBoxD.length;i++)
	{	
	
		if(lBoxD.value.length==0)
			lBoxD.value = cBoxD.options[i].value
		else
			lBoxD.value =lBoxD.value+","+ cBoxD.options[i].value
	}
	
	if (sOrigen=='frmInfo:_D_001312:cmbValor')
	{
	    jsBloqueaNivelSector()
		CargarContenidoAprendizajeAjax();
	}
}

function jsEliminarSeleccion(sDestino)
{
	var cBoxD = document.Form1[sDestino];  
	lblDestino = sDestino.replace("lst","hid");
	var lBoxD =  document.Form1[lblDestino];
	  
	for (var i = cBoxD.length - 1; i>=0; i--) 
	{
		if (cBoxD.options[i].selected) {
			cBoxD.remove(i);
		}
	}
	
	lBoxD.value='';
	for(var i=0;i<cBoxD.length;i++)
	{	
		if(lBoxD.value.length==0)
			lBoxD.value = cBoxD.options[i].value
		else
			lBoxD.value =lBoxD.value+","+ cBoxD.options[i].value
	}
	if (sDestino=='frmInfo:_D_001312:lstValor')
	{
	    jsBloqueaNivelSector()
	    CargarContenidoAprendizajeAjax();
	}

}

function jsRecargar()
{
	form=document.Form1;
	form.pack.value="";
	__doPostBack('lnkRecargar','');
}

<!--

function jsRecomendar(pTitulo,pUrl,pEscritorio){
var ventana;
		
        ventana=window.open('/Recomendar/EnviarCorreo.aspx?Titulo='+ pTitulo+'&URL='+escape(pUrl)+'&Escritorio='+escape(pEscritorio),"ventana1","width=550, height=400, scrollbars=1, menubar=0, toolbar=0,status=0, location=0, resizable=0");
        ventana.focus();
        
} 


function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}


function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}

 

function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}
 

function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}

//-->



function jsAbrirCalendario(ID,sForm)
	{
	
	var sHref="/Portal.Base/Popups/Calendario.htm";
	var mCalendario=window.showModalDialog(sHref,"","dialogWidth:200px;dialogHeight:210px;help:no;scroll=no;status:no")
	if(mCalendario&&mCalendario.FechaSeleccionada)
		{
		document.forms[sForm][ID+":Dia"].value=mCalendario.DiaSeleccionado;
		document.forms[sForm][ID+":Mes"].value=mCalendario.MesSeleccionado;
		document.forms[sForm][ID+":Anio"].value=mCalendario.AnioSeleccionado;
		}
		
	}
	
function IsDigit()
	{
	return ((event.keyCode >= 48) && (event.keyCode <= 57))
	}

function IsDigitRut()
	{
	return (((event.keyCode >= 48) && (event.keyCode <= 57)) || (event.keyCode == 107)||(event.keyCode == 75))
	}
	
	
function IsFloat()
	{
	return (((event.keyCode >= 48) && (event.keyCode <= 57))||(event.keyCode==44)||(event.keyCode==45	))
	}
	
	
function jsConfirmacion(sMensaje)
{
	return confirm(sMensaje);
}		
function jsObtenerIDPortalActual()
{
	IDPortal=0;
	form=document.Form1;
	if(form["ctrlPortal:cmbPortal"])
		IDPortal=Number(form["ctrlPortal:cmbPortal"].value);
	else 
		if(form["IDPortalActual"])	
			IDPortal=Number(form["IDPortalActual"].value);
	return IDPortal;
}

function jsAbrirVentanaEdicionCategoria(IDC)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Contenidos/EditarCategoria.aspx?GUID="+GUID+"&IDC="+IDC+"&IDP="+jsObtenerIDPortalActual()
	vedc=window.open(sHref,"vedc","width=600,height=800");
	vedc.focus();
}


function jsAbrirVentanaEditarRss(IDC)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Contenidos/EditarRss.aspx?GUID="+GUID+"&IDC="+IDC+"&IDP="+jsObtenerIDPortalActual()
	vedc=window.open(sHref,"vedc","width=600,height=600");
	vedc.focus();

}
//---
function jsAbrirVentanaLog(IDC)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Contenidos/ListarLog.aspx?GUID="+GUID+"&IDC="+IDC+"&IDP="+jsObtenerIDPortalActual()
	vedc=window.open(sHref,"vedc","width=640,height=400");
	vedc.focus();
}
//---

function jsAbrirVentanaEdicionEspecial(IDE)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Contenidos/EditarEspecial.aspx?GUID="+GUID+"&IDE="+IDE+"&IDP="+jsObtenerIDPortalActual()
	
	vedc=window.open(sHref,"vedc","width=600,height=600");
	vedc.focus();
}
function jsAbrirVentanaEdicionLink(IDL)
{
	
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Contenidos/EditarDBLink.aspx?GUID="+GUID+"&IDL="+IDL+"&IDP="+jsObtenerIDPortalActual()
	
	vedc=window.open(sHref,"vedc","width=800,height=800");
	vedc.focus();
}
function jsAbrirVentanaEdicionMiniForo(IDCF)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Contenidos/EditarMiniForo.aspx?GUID="+GUID+"&IDCF="+IDCF+"&IDP="+jsObtenerIDPortalActual()
	
	vedc=window.open(sHref,"vedc","width=600,height=300");
	vedc.focus();
}
function jsAbrirVentanaListarDetalleEvaluacion(IDCONT)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Contenidos/ListarDetalleEvaluacion.aspx?GUID="+GUID+"&IDCONT="+IDCONT+"&IDP="+jsObtenerIDPortalActual()
	
	vedc=window.open(sHref,"vedc","width=600,height=500");
	vedc.focus();
}



function jsEditarCategoria(form)
{
	sMensaje="";
	if(form["frmCategoria:_Nombre:txtValor"].value.length==0)sMensaje+="Debe ingresar el nombre de la categoria";
	if(sMensaje.length>0)
	{
		alert(sMensaje);
		return false;
	}
	else
		return true;
}


function jsAbrirVentanaEdicionContenido(IDCONT,IDC, IDCP)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Contenidos/EditarContenido.aspx?GUID="+GUID+"&IDCO="+IDCONT+"&IDC="+IDC+"&IDCP=" + IDCP;
	vedco=window.open(sHref,"vedco","width=850,height=640,scrollbars=yes,resizable=yes");
	vedco.focus();
}
function jsAbrirVentanaVisualizacionXml(IDXml)
{
	
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/HicEntrada/VisualizarXml.aspx?GUID="+GUID+"&IDX="+IDXml;
	vedco=window.open(sHref,"vedco","width=600,height=600,scrollbars=no,resizable=yes");
	vedco.focus();
}
function jsCargaArchivosXml(IDPA)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/HicEntrada/HicEntrada.aspx?GUID="+GUID+"&IDPA="+IDPA;
	window.location.href=sHref;
	
	
}


function jsAbrirVentanaEdicionContenidoPropio(IDCONT,IDC, IDCP)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Contenidos/EditarContenidoPropio.aspx?GUID="+GUID+"&IDCO="+IDCONT+"&IDC="+IDC+ "&IDCP="+IDCP ;
	vedco=window.open(sHref,"vedco","width=850,height=640,scrollbars=yes,resizable=yes");
	vedco.focus();
	
}
//--


function jsAbrirVentanaLogContenido(IDC)
{	
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Contenidos/ListarLog.aspx?GUID="+GUID+"&IDC="+IDC+"&IDP="+jsObtenerIDPortalActual()
	vedc=window.open(sHref,"vedc","width=610,height=600");
	vedc.focus();
}
//--
function jsAbrirVentanaEdicionContenidoPadre(IDCONT,IDC, IDCP)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Contenidos/EditarContenidoPadre.aspx?GUID="+GUID+"&IDCO="+IDCONT+"&IDC="+IDC+ "&IDCP="+ IDCP;
	vedco=window.open(sHref,"vedco","width=850,height=640,scrollbars=yes,resizable=yes");
	vedco.focus();
	
}


function jsAbrirVentanaEdicionEspecialContenido(IDC,IDE)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Contenidos/ListaContenidosAdd.aspx?GUID="+GUID+"&IDC="+IDC+"&IDE="+IDE;
	vedco=window.open(sHref,"vedcoEs","width=850,height=640,scrollbars=yes,resizable=yes");
	vedco.focus();
}



function jsAbrirVentanaEdicionContenidoOld(IDCONT,IDC)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/base/contenido/Contenidos_Form.asp?GUID="+GUID+"&IDCONT="+IDCONT+"&IDCORG="+IDC;
	vedcoold=window.open(sHref,"vedcoold","width=850,height=640,scrollbars=yes,noresize");
	vedcoold.focus();
}







//** ENCUESTAS **/
function jsPrevisualizarEncuesta(plIDEncuesta)
{
	form=document.Form1;
	GUID=form.GUID.value;
	sHref="/Portal.Base/Web/VerEncuesta.aspx?GUID="+GUID+"&IDE="+plIDEncuesta;
	vpenc=window.open(sHref,"vpenc","width=400,height=520,scrollbars=yes");
	vpenc.focus();
}

function jsVerResultadosEncuesta(plIDEncuesta)
{
	form=document.Form1;
	GUID=form.GUID.value;
	sHref="/Portal.Base/Web/VerResultadosEncuesta.aspx?GUID="+GUID+"&IDE="+plIDEncuesta;
	vpenc=window.open(sHref,"vpenc","width=480,height=520,scrollbars=yes");
	vpenc.focus();
}
function jsAbrirVentanaEdicionEncuesta(IDE)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Encuestas/EditarEncuesta.aspx?GUID="+GUID+"&IDE="+IDE+"&IDP="+jsObtenerIDPortalActual()
	vedc=window.open(sHref,"vedc","width=630,height=480");
	vedc.focus();
}
function jsAbrirVentanaEdicionPregunta(IDPR, IDE)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Encuestas/EditarPregunta.aspx?GUID="+GUID+"&IDPR="+IDPR+"&IDE="+IDE+"&IDP="+jsObtenerIDPortalActual()
	vedpre=window.open(sHref,"vedpre","width=800,height=600,scrollbars=yes");
	vedpre.focus();
}
function jsAbrirVentanaEdicionOpcion(IDO, IDPR,IDE)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Encuestas/EditarOpcion.aspx?GUID="+GUID+"&IDO="+IDO+"&IDPR="+IDPR+"&IDE="+IDE;
	vedopc=window.open(sHref,"vedopc","width=630,height=280");
	vedopc.focus();
}

//** FOROS **/
function jsAbrirVentanaEnviarMensaje(IDU)
{
	form=document.Form1;
	GUID=form.GUID.value;
	sHref="/Portal.Base/Web/Foros/EnviarMensaje.aspx?GUID="+GUID+"&IDU="+IDU;
	vpec=window.open(sHref,"vpec","width=500,height=500,scrollbars=yes,resizable");
	vpec.focus();
}
function jsValidarIngresoTema()
{
	var sMensaje="";
	form=document.Form1;
	//*ESTO BUSCA DENTRO DE UN IFRAME*/
	//var iFrame1 = document.frames("fckEditorMensaje___Frame").document.frames("eEditorArea").document.documentElement;		
	if(form["txtNombre"].value.length==0)
		sMensaje = "Debe ingresar el nombre del tema.";		
	if(sMensaje.length>0)
	{
		window.alert(sMensaje);
		return false;
	}
	else
		return true;	
	
}
function jsAbrirVentanaEdicionTemaPopup(IDT, IDF)
{
	form=document.Form1;
	GUID=form.GUID.value;
	sPP='';
	sHref="/Portal.Base/Foros/EdicionTema.aspx?GUID="+GUID+"&IDT="+IDT+"&IDFR="+IDF;
	vedft=window.open(sHref,"vedft","width=830,height=630");	
	vedft.focus();
}
function jsAbrirVentanaEdicionNick(IDF,IDT,IDPO,IDCO,Accion, PP)
{
	form=document.Form1;
	GUID=form.GUID.value;
	sHref="/Portal.Base/Foros/EditarNickForo.aspx?GUID="+GUID+"&IDFR="+IDF+"&IDT="+IDT+"&IDPO="+IDPO+"&IDCO="+IDCO+"&ACC="+Accion+"&PP="+PP;
	vedft=window.open(sHref,"vedft","width=530,height=230");	
	vedft.focus();
}
function jsAbrirVentanaEdicionTemaNick(IDT,IDPO,IDCO)
{
	form=document.Form1;
	GUID=form.GUID.value;
	sHref="/Portal.Base/Web/Foros/ListarMensajes.aspx?GUID="+GUID+"&IDT="+IDT+"&IDPO="+IDPO+"&IDCO="+IDCO+"&IDP="+jsObtenerIDPortalActual()
	//vedtema=window.open(sHref,"vedc","width=830,height=630");
	top.opener.location.href=sHref;
	window.close();
}
function jsAbrirVentanaEdicionMensajePopup(IDM, IDT)
{
	form=document.Form1;
	GUID=form.GUID.value;
	sHref="/Portal.Base/Foros/EdicionMensaje.aspx?GUID="+GUID+"&IDM="+IDM+"&IDT="+IDT;
	vedfm=window.open(sHref,"vedfm","width=830,height=630");
	vedfm.focus();
}

function jsAbrirVentanaEdicionTema(IDT,IDPO,IDCO, PP)
{
	form=document.Form1;
	GUID=form.GUID.value;
	/*var sPP='';
	if  (parent.frames.length > 0)
		sPP='&PP=1'*/
	
	sHref="/Portal.Base/Web/Foros/ListarMensajes.aspx?GUID="+GUID+"&IDT="+IDT+"&IDPO="+IDPO+"&IDCO="+IDCO+"&IDP="+jsObtenerIDPortalActual()+"PP="+PP;
	//vedtema=window.open(sHref,"vedc","width=830,height=630");
	window.location.href=sHref;
	vedc.focus();
}
function jsAbrirVentanaPrevisualizar(TIPODATO, IDDATO)
{
	form=document.Form1;
	GUID=form.GUID.value;
	sHref="/Portal.Base/Web/Foros/Previsualizar.aspx?GUID="+GUID+"&TIPODATO="+TIPODATO+"&ID="+IDDATO+"&IDP="+jsObtenerIDPortalActual()	
	vedprev=window.open(sHref,"vedprev","width=630,height=530");	
	vedprev.focus();
}
//** FIN FOROS **/


function jsAbrirVentanaEdicionFormatoContenido(IDF)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	IDCategoria=form.IDC.value;
	sHref="/Portal.Base/Contenidos/EditarFormato.aspx?GUID="+GUID+"&IDF="+IDF+"&IDC="+IDCategoria;
	vedc=window.open(sHref,"vedc","width=830,height=690,scrollbars=1");
	vedc.focus();
}

function jsEditarFormatoContenido(form)
{
	sMensaje="";
	if(form["frmFormato:_Nombre:txtValor"].value.length==0)sMensaje+="Debe ingresar el nombre del Formato";
	if(sMensaje.length>0)
	{
		alert(sMensaje);
		return false;
	}
	else
		return true;
	
}


function jsEditarContenidoClase(form, pIDContenido, pIDContenidoPadre)
{
	sMensaje="";
	
	if (form["frmInfo:_D_001259:txtValor"])
	{
		if(form["frmInfo:_D_001259:txtValor"].value.length==0)
		{
			alert('Debe Ingresar un Num de Clase.');
			return false;
		}
		else
		{
			jsValidaExistenciaNombreClase(form["frmInfo:_D_001259:txtValor"].value, pIDContenido, pIDContenidoPadre);
			return false;
		}
	}
	
}


	function jsValidaExistenciaNombreClase(pNombreClase, pIDContenido, pIDContenidoPadre)
	{
		var url='/Portal.Base/Web/ProcesarContenido.aspx?Accion=VAL&NOM='+pNombreClase+'&IDC='+pIDContenido+'&IDCP='+pIDContenidoPadre;
		jsProcesaNombreClase(url);
		
	}
	
	function jsProcesaNombreClase(pUrl)
	{
		if (window.XMLHttpRequest) {
				HttpReq = new XMLHttpRequest();
				HttpReq.onreadystatechange = jsHttpRequestProcesaNombreClase;
				HttpReq.open("GET",pUrl, true);
				HttpReq.send(null);
		} 
		else if (window.ActiveXObject) 
		{
			HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			if (HttpReq) 
			{
				HttpReq.onreadystatechange = jsHttpRequestProcesaNombreClase;
				HttpReq.open("GET", pUrl, true);
				HttpReq.send();			
			}
		}
	}
	
	function jsHttpRequestProcesaNombreClase() {
		if (HttpReq.readyState == 4 && HttpReq.status == 200)
		{
			var result = HttpReq.responseText;
			if(result=="OK")		
			{	
				alert('El Nombre de la clase ya existe en la planificaci\xF3n, Favor utilice otro.');
				return false;
			}
			else
			{
				jsSubmitClase(document.Form1);
			}
		}
	}


function jsSubmitClase(form)
{
	sMensaje="";
	
	if (form["frmInfo:_D_001259:txtValor"])
	{
		if(form["frmInfo:_D_001259:txtValor"].value.length==0)
		{
			alert('Debe Ingresar un Num de Clase.');
			return false;
		}
	}
	
	if (form["frmInfo:_D_001309:txtValor"])
	{
		if(form["frmInfo:_D_001309:txtValor"].value.length==0)
		{
			alert('Debe Ingresar el t\u00EDtulo de la Planificaci\xF3n.');
			return false;
		}
	}
	
	if (form["frmContenido:_Nombre:txtValor"])
	{
		if(form["frmContenido:_Nombre:txtValor"].value.length==0)
			sMensaje+="Debe ingresar el nombre del contenido\n";
	}
	
	if (form["frmContenido:_Formatos:cmbValor"])
	{
		if(form["frmContenido:_Formatos:cmbValor"].value<1)
			sMensaje+="Debe seleccionar un Formato";
	}	
	if(sMensaje.length>0)
	{	
		alert(sMensaje);
		return false;
	}
	else
	{
		if ((typeof(Page_ClientValidate) == 'function') && Page_ClientValidate())
		{
			__doPostBack('btnGuardar','')
			 
		}
		return true;
	}
}

function jsEditarContenidoConfirm(form,sMensajeConfirm)
{
	sMensaje="";
	if(confirm(sMensajeConfirm))
	{
		if(form["frmContenido:_Nombre:txtValor"].value.length==0)sMensaje+="Debe ingresar el nombre del contenido\n";
		if(form["frmContenido:_IDFormato:cmbValor"].value<1)sMensaje+="Debe seleccionar un Formato";
		if(sMensaje.length>0)
		{
			alert(sMensaje);
			return false;
		}
		else
		{
			if (typeof(Page_ClientValidate) == 'function') return Page_ClientValidate();
			return true;
		}
	}
	else
		return false;
}


function jsEditarContenido(form)
{
	sMensaje="";
	
	if (form["frmInfo:_D_001259:txtValor"])
	{
		if(form["frmInfo:_D_001259:txtValor"].value.length==0)
		{
			alert('Debe Ingresar un Num de Clase.');
			return false;
		}
	}
	
	if (form["frmInfo:_D_001309:txtValor"])
	{
		if(form["frmInfo:_D_001309:txtValor"].value.length==0)
		{
			alert('Debe Ingresar el t\u00EDtulo de la Planificaci\xF3n.');
			return false;
		}
	}
	
	if(form["frmContenido:_Nombre:txtValor"])
	{
		if(form["frmContenido:_Nombre:txtValor"].value.length==0)sMensaje+="Debe ingresar el nombre del contenido\n";
	}
	
	if(form["frmContenido:_Formatos:cmbValor"])
	{
		if(form["frmContenido:_Formatos:cmbValor"].value<1)sMensaje+="Debe seleccionar un Formato";
	}
	
	if(sMensaje.length>0)
	{	
		alert(sMensaje);
		return false;
	}
	else
	{
		if (typeof(Page_ClientValidate) == 'function') return Page_ClientValidate();
		return true;
	}
}

function jsAsignarImagen(psID,psImagen)
{
	sTempControl=psID;
	sHref="/iPortal.Web/FCKEditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/aspx/connectorBiblioteca.aspx";
	sHref+='&GUID='+document.Form1.GUID.value;
	sHref+='&EP=1';
		
	vselimg=window.open(sHref,"vselimg","width=600,height=450");
	vselimg.focus();
	return false;
}

function jsQuitarImagen(psID)
{
	if(confirm("Esta seguro de desasociar la imagen de este contenido?"))
	{
	sTempImg=psID.replace("txtValor","imgValor");
	this.Form1[psID].value="";
	document.images[sTempImg].src="";
	}
}


function jsPrevisualizarContenido(plIDContenido,plIDFormato)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	/*
	if(plIDFormato)
		sHref="/Portal.Base/Contenidos/PrevisualizarContenido.aspx?GUID="+GUID+"&IDC="+plIDContenido+"&IDF="+plIDFormato;
	else
		sHref="/Portal.Base/Contenidos/PrevisualizarContenido.aspx?GUID="+GUID+"&IDC="+plIDContenido;
	*/
	
	if(plIDFormato)
		sHref="/Portal.Base/Contenidos/PreContenido.aspx?GUID="+GUID+"&ID="+plIDContenido+"&IDF="+plIDFormato;
	else
		sHref="/Portal.Base/Contenidos/PreContenido.aspx?GUID="+GUID+"&ID="+plIDContenido;
	
	
	vpvc=window.open(sHref,"vpvc","width=800,height=500,scrollbars=yes,resizable=yes");
	vpvc.focus();
}

function jsVisualizarContenido(plIDContenido,plIDFormato)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	
	
	if(plIDFormato)
		sHref="/Portal.Base/Web/verContenido.aspx?ID="+plIDContenido+"&IDF="+plIDFormato;
	else
		sHref="/Portal.Base/Web/verContenido.aspx?ID="+plIDContenido;
	
	
	vpvc=window.open(sHref,"vpvc","");
	vpvc.focus();
}


function jsPrevisualizarContenidoFormateado(plIDContenido)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	var lIDFormato=0;
	if(form["frmContenido:_IDFormato:cmbValor"].selectedIndex>=0)
		lIDFormato=Number(form["frmContenido:_IDFormato:cmbValor"].value);
	if(lIDFormato>0)
	{
	sHref="/Portal.Base/Contenidos/PrevisualizarContenido.aspx?GUID="+GUID+"&IDC="+plIDContenido+"&IDF="+lIDFormato;
	vpvc=window.open(sHref,"vpvc","width=800,height=500,scrollbars=yes");
	vpvc.focus();
	}
	else
	{
	alert("Debe seleccionar un formato para previsualizar el contenido")
	}
}


function jsAbrirVentanaEdicionPortal(IDP)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Portales/EditarPortal.aspx?GUID="+GUID+"&IDP="+IDP;
	vedp=window.open(sHref,"vedp","width=680,height=590,scrollbars=yes");
	vedp.focus();
}
function jsAbrirVentanaAsociarPortal(IDP)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Portales/AsociarPortal.aspx?GUID="+GUID+"&IDP="+IDP;
	vedp=window.open(sHref,"vedp","width=680,height=590,scrollbars=yes");
	vedp.focus();
}

function jsEditarPortal(form)
{
	sMensaje="";
	if(form["frmPortal:_Nombre:txtValor"].value.length==0)sMensaje+="Debe ingresar el nombre del  portal\n";
	if(form["frmPortal:_Sigla:txtValor"].value.length==0)sMensaje+="Debe ingresar la sigla del  portal\n";
	if(form["frmPortal:_Url:txtValor"].value.length==0)sMensaje+="Debe ingresar el URL del  portal\n";
	/*
	if(Number(form["frmPortal:_IDEnvelopeContenido:cmbValor"].value)==0)sMensaje+="Debe seleccionar el contenido del formato general\n";
	if(Number(form["frmPortal:_IDEnvelopeContenido:cmbValor"].value)==0)sMensaje+="Debe seleccionar el formato del formato general\n";
	if(Number(form["frmPortal:_IDContenidoHome:cmbValor"].value)==0)sMensaje+="Debe seleccionar el contenido de la pagina Inicial\n";
	*/
	if(sMensaje.length>0)
	{
		alert(sMensaje);
		return false;
	}
	else
		return true;
}



function FlashInstalled(){
	result = false;

	if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]){
		result = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
	}
	else if (document.all && (navigator.appVersion.indexOf("Mac")==-1)){
		// IE Windows only -- check for ActiveX control, have to hide code in eval from Netscape (doesn't like try)
		eval ('try {var xObj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if (xObj)	result = true; xObj = null;	} catch (e)	{}');
	}
	return result;
}

function FlashWrite(url,width,height){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.write(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" ');
	document.write(' width=' + width + ' height=' + height + '>');
	document.write('<param name=movie value="' + url + '">');
	document.write('<param name=quality value=high>');
	document.write('<param name=bgcolor value=#ffffff>');
	document.write('<param name=wmode value=transparent>');
	document.write('<embed src="' + url + '" quality=high bgcolor=#ffffff ');
	document.write(' swLiveConnect=false width=' + width + ' height=' + height);
	document.write(' type="application/x-shockwave-flash"');
	document.write(' wmode=transparent');
	document.write(' pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">');
	document.write('</embed></object>');
}


function jsAutentificar(txtUsername,txtPassword,chkRecordar,txtPageReferer)
{
	form=document.Form1;
	form.pack.value="Login";
	
	if (chkRecordar)
	{
		if(chkRecordar.checked)form.param5.value=1;
		else form.param5.value=0;
	}
	
	
	
	form.iUsername.value=txtUsername.value;
	form.iPassword.value=txtPassword.value;
	
	if(txtPageReferer)form.iPageReferer.value=txtPageReferer;	
	form.submit();
}



function jsEnviarCorreoContacto(form)
{
	sMensaje="";
	if(form["frmContacto:_De:txtValor"].value.length==0)sMensaje+="Debe ingresar su email.\n";
	else
		if(!jsValidarEmail(form["frmContacto:_De:txtValor"]))sMensaje+="Debe ingresar un email valido.\n";
	if(form["frmContacto:_Nombre:txtValor"].value.length==0)sMensaje+="Debe ingresar su nombre y apellidos.\n";
	if(form["frmContacto:_Empresa:txtValor"].value.length==0)sMensaje+="Debe ingresar su empresa.\n";
	if(form["frmContacto:_Telefono:txtValor"].value.length==0)sMensaje+="Debe ingresar su telefono.\n";
	if(form["frmContacto:_Ciudad:txtValor"].value.length==0)sMensaje+="Debe ingresar su ciudad.\n";
	if(form["frmContacto:_Pais:txtValor"].value.length==0)sMensaje+="Debe ingresar su pais.\n";
	
	if(sMensaje.length>0)
		{
		alert(sMensaje);
		return false;
		}
	else
		return true;
	
}

function jsValidarEmail(objeto)
{
	validos = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0987654321_@.-"
	largo = objeto.value.length
	
	if (largo > 0)
	{
		i = 0
		
		while (i < largo)
		{
			car = objeto.value.substr(i,1)
			caracter = validos.indexOf(car)
			i = i + 1
			if (caracter < 0)
			{
				i = largo + 1
				return false;
			}
		}
		arroba1 = objeto.value.indexOf("@")
		guion   = objeto.value.indexOf("-")
		unders	= objeto.value.indexOf("_")
		punto	= objeto.value.indexOf(".")
		arroba2 = objeto.value.lastIndexOf("@",largo)
		ultpunto= objeto.value.lastIndexOf(".",largo)		
		dominio = largo - ultpunto	
		
		if (guion == 0 || punto == 0 || unders == 0 || arroba1 == 0)
			return false;
		
		if ((objeto.value.substr(arroba1 - 1,1) == ".") || (objeto.value.substr(arroba1 - 1,1) == "-") || (objeto.value.substr(arroba1 - 1,1) == "_"))
			return false;
		
		if (arroba2 < 0)
			arroba2 = arroba1
			
		if (arroba1 > 0 && arroba1 == arroba2 && dominio <= 4 && ultpunto < largo && arroba1 < largo) 		
			return true;
		else 
			return false;
	}
	else
		return true;
}


function jsAbrirVentanaDuplicarCategoria(IDC)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Contenidos/DuplicarCategoria.aspx?GUID="+GUID+"&IDC="+IDC+"&IDP="+jsObtenerIDPortalActual()
	vdca=window.open(sHref,"vdca","width=500,height=320");
	vdca.focus();
}
function jsAbrirVentanaCompartirCategoria(IDC)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Contenidos/CompartirCategoria.aspx?GUID="+GUID+"&IDC="+IDC+"&IDP="+jsObtenerIDPortalActual()
	vcca=window.open(sHref,"vcca","width=500,height=350");
	vcca.focus();
}

function jsAbrirVentanaDuplicarContenido(IDC)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Contenidos/DuplicarContenido.aspx?GUID="+GUID+"&IDC="+IDC+"&IDP="+jsObtenerIDPortalActual()
	vdco=window.open(sHref,"vdco","width=600,height=330");
	vdco.focus();
}


function jsCambiarPortalDuplicacionContenido(form)
{
	form.pack.value="CambiarPortalDuplicacionContenido";
	form.submit();
}


function jsSeleccionarCheckBoxs(psCheckBoxControl,psCheckBoxName)
{
	//alert();
	form=psCheckBoxControl.form;
	for(i=0;i<form.length;i++)
		{
		sName=form[i].name;
		sName=sName.substring(sName.length-psCheckBoxName.length,sName.length);
		if(sName==psCheckBoxName)
			form[i].checked=psCheckBoxControl.checked;
		}	
}


function jsAbrirVentanaEdicionGrupo(IDG)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Membresia/EditarGrupo.aspx?GUID="+GUID+"&IDG="+IDG+"&IDP="+jsObtenerIDPortalActual()
	vedg=window.open(sHref,"vedg","width=700,height=450");
	vedg.focus();
}

function jsEditarGrupo(form)
{
	sMensaje="";
	if(form["frmGrupo:_Nombre:txtValor"].value.length==0)sMensaje+="Debe ingresar el nombre del grupo";
	if(sMensaje.length>0)
	{
		alert(sMensaje);
		return false;
	}
	else
		return true;
}

function jsAbrirVentanaUsuariosGrupo(IDG)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Membresia/ReporteUsuarios.aspx?GUID="+GUID+"&IDG="+IDG;
	window.location.href=sHref;	
}
function jsAbrirVentanaPermisosGrupo(IDG)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Membresia/PermisosGrupo.aspx?GUID="+GUID+"&IDG="+IDG;
	vpg=window.open(sHref,"vpg","width=700,height=400,scrollbars=no");
	vpg.focus();
}
function jsAbrirVentanaGruposUsuario(IDU)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Membresia/GruposUsuario.aspx?GUID="+GUID+"&IDU="+IDU;
	vgu=window.open(sHref,"vgu","width=700,height=400,scrollbars=no");
	vgu.focus();
}
function jsAbrirVentanaEdicionUsuario(IDG)
{
	form=document.Form1;
	
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Membresia/EditarUsuario.aspx?GUID="+GUID+"&IDG="+IDG+"&IDP="+jsObtenerIDPortalActual()
	vedg=window.open(sHref,"vedg","width=800,height=450,scrollbars=yes");
	vedg.focus();
}

function jsEditarUsuario(form)
{
	if (typeof(Page_ClientValidate) == 'function') return Page_ClientValidate(); 
	/*sMensaje="";
	//if(form["frmUsuario:_:txtValor"].value.length==0)sMensaje+="Debe ingresar el username del Usuario";
	if(sMensaje.length>0)
	{
		alert(sMensaje);
		return false;
	}
	else
		return true;*/
}

function jsAbrirVentanaEdicionDatoMembresia(IDD)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Membresia/EditarDato.aspx?GUID="+GUID+"&IDD="+IDD;
	vedg=window.open(sHref,"vedg","width=700,height=450");
	vedg.focus();
}

function jsEditarDato(form)
{
	sMensaje="";
	if(form["frmDato:_Nombre:txtValor"].value.length==0)sMensaje+="Debe ingresar el nombre del dato\n";
	if(form["frmDato:_IDTipoDato:cmbValor"].value<1)sMensaje+="Debe seleccionar el tipo de dato\n";
	if(form["frmDato:_IDTipoVisualizacion:cmbValor"].value<1)sMensaje+="Debe seleccionar el tipo de visualizacion\n";
	if(sMensaje.length>0)
	{
		alert(sMensaje);
		return false;
	}
	else
		return true;
}
function jsAbrirVentanaEdicionFormatoMembresia(IDC)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Membresia/EditarFormato.aspx?GUID="+GUID+"&IDC="+IDC+"&IDP="+jsObtenerIDPortalActual()
	vedc=window.open(sHref,"vedc","width=830,height=660,scrollbars=1");
	vedc.focus();
	
}

function jsEditarFormatoMembresia(form)
{
	sMensaje="";
	if(form["frmFormato:_Nombre:txtValor"].value.length==0)sMensaje+="Debe ingresar el nombre del Formato";
	if(form["frmFormato:_Alias:txtValor"].value.length==0)sMensaje+="Debe ingresar un alias para el Formato";
//	if(form["frmFormato:_HTML:txtValor"].value.length==0)sMensaje+="Debe ingresar el codigo HTML del Formato";
	if(sMensaje.length>0)
	{
		alert(sMensaje);
		return false;
	}
	else
		return true;
}


function jsAbrirVentanaEdicionDatoCategoria(IDC,IDD)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Contenidos/EditarDato.aspx?GUID="+GUID+"&IDC="+IDC+"&IDD="+IDD;
	vedg=window.open(sHref,"vedg","width=700,height=550");
	vedg.focus();
}

function jsAbrirVentanaConfigurarFiltroCategoria(IDC)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Contenidos/ConfigurarFiltroCategoria.aspx?GUID="+GUID+"&IDC="+IDC;
	vcca=window.open(sHref,"vcca","width=840,height=570");
	vcca.focus();
}
function jsExportarExcel(psDatagridTable,psTitulo)
{
	sHref="/Portal.Base/Popups/ExportacionExcel.aspx?GUID="+document.Form1.GUID.value+"&DGExcel="+psDatagridTable+"&Tit="+psTitulo;
	window.location.href=sHref;
}

function jsAbrirVentanaEdicionMetadato(IDM)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Metadatos/EditarMetadato.aspx?GUID="+GUID+"&IDM="+IDM+"&IDP="+jsObtenerIDPortalActual()
	vedc=window.open(sHref,"vedc","width=600,height=350");
	vedc.focus();
}

function jsEditarMetadato(form)
{
	sMensaje="";
	if(form["frmMetadato:_Nombre:txtValor"].value.length==0)sMensaje+="Debe ingresar el nombre del Metadato";
	if(sMensaje.length>0)
	{
		alert(sMensaje);
		return false;
	}
	else
		return true;
}
function jsEditarDBLink(form)
{
	sMensaje="";
	if(form["frmLink__Url_txtValor"].value.length==0)sMensaje+="Debe ingresar la Url";
	if(sMensaje.length>0)
	{
		alert(sMensaje);
		return false;
	}
	else
		return true;
}


function jsAbrirVentanaEdicionValorMetadato(IDM,IDP,IDV)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Metadatos/EditarValorMetadato.aspx?GUID="+GUID+"&IDM="+IDM+"&IDP="+IDP+"&IDV="+IDV;
	vedvm=window.open(sHref,"vedvm","width=600,height=300,scrollbars=yes");
	vedvm.focus();
}

function jsEditarValorMetadato(form)
{
	sMensaje="";
	if(form["frmValorMetadato:_Valor:txtValor"].value.length==0)sMensaje+="Debe ingresar el Valor";
	if(sMensaje.length>0)
	{
		alert(sMensaje);
		return false;
	}
	else
		return true;
}


function jsEjecutarPortlet(ID)
{
	
	if(document.getElementById('tipoDocMem'))
	{
		if (!jsEjecutaValidacionFormularioRegistroBasico())
			return false;
	}

	var bEjecutar=false;	
	if (typeof(Page_ClientValidate) == 'function') bEjecutar=Page_ClientValidate();
	
	if(bEjecutar)
	{
		form=document.Form1;
		if(ID>0)
		{
			form.pack.value="EjecutarPortlet";
			form.idportlet.value=ID;
			form.submit();
		}
	}
}
function jsEjecutarPortletSinValidacion(ID)
{
	
	var bEjecutar=true;
	if(bEjecutar)
	{
		form=document.Form1;
		if(ID>0)
		{
			form.pack.value="EjecutarPortlet";
			form.idportlet.value=ID;
			form.submit();			
		}
	}
}

function jsEjecutarPortletSinValidacionMarco(ID, bMarco)
{
	
	var bEjecutar=true;
	var sAction = '';
	if(bEjecutar)
	{
		form=document.Form1;
		alert(bMarco);
		if (bMarco==0)
		{
			//form.action + '&PP=1';
			//form.action = sAction;
		}
		alert(form.action);
		if(ID>0)
		{
			form.pack.value="EjecutarPortlet";
			form.idportlet.value=ID;
			form.submit();			
		}
	}
}


function jsRecargarSesion()
{
		form=document.Form1;
		form.pack.value="RecargarSesion";
		form.idportlet.value=0;
		form.submit();
}

function jsEjecutarPortletBusqueda(ID,txtBusqueda)
{
	form=document.Form1;
	form.pack.value="EjecutarPortlet"
	form.param1.value=txtBusqueda.value;
	form.idportlet.value=ID;
	form.submit();
}

function jsAbrirVentanaEdicionModerador(IDF)
{
	form=document.Form1;
	GUID=form.GUID.value;
	sHref="/Portal.Base/Foros/AsociarModerador.aspx?GUID="+GUID+"&IDF="+IDF+"&IDP="+jsObtenerIDPortalActual()
	vedmod=window.open(sHref,"vedmod","width=700,height=500");
	vedmod.focus();
}
function jsAbrirVentanaEdicionModeradorGrupos(IDF)
{
	form=document.Form1;
	GUID=form.GUID.value;
	sHref="/Portal.Base/Foros/AsociarModeradorGrupos.aspx?GUID="+GUID+"&IDF="+IDF+"&IDP="+jsObtenerIDPortalActual()
	vedmod=window.open(sHref,"vedmod","width=700,height=500");
	vedmod.focus();
}


function jsAbrirVentanaEdicionForo(IDF)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Foros/EditarForo.aspx?GUID="+GUID+"&IDF="+IDF+"&IDP="+jsObtenerIDPortalActual()
	vedf=window.open(sHref,"vedf","width=600,height=600");
	vedf.focus();
}

function jsEditarForo(form)
{
	sMensaje="";
	if(form["frmForo:_Nombre:txtValor"].value.length==0)sMensaje+="Debe ingresar el nombre del Foro";
	if(sMensaje.length>0)
	{
		alert(sMensaje);
		return false;
	}
	else
		return true;
}


function jsEditarUsuarioRegistro(form)
{
	return true;
}

function jsEliminarDocumento(psPath,psKey)
{
	form=document.Form1;
	if(confirm("Esta seguro de eliminar este documento?"))
	{
		form.pack.value="EliminarDocumento";
		form.param1.value=psPath;
		form.param2.value=psKey;
		form.submit();
	}
}

function jsFiltrarCategoria(form)
{
	form.pack.value="FiltrarCategoria";
	form.submit();
}

function jsVerFichaUsuario(IDU)
{
	alert("En construccion");
}

function jsPrevisualizarContenidoNewsletter()
{
	form=document.Form1;
	lIDContenido=form["cmbContenido"].options[form["cmbContenido"].selectedIndex].value;
	lIDFormato=form["cmbFormato"].options[form["cmbFormato"].selectedIndex].value;
	jsPrevisualizarContenido(lIDContenido,lIDFormato);
}

function jsAbrirVentanaConfigurarFiltroBusquedaPortal(IDP)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Portales/ConfigurarFiltroBusqueda.aspx?GUID="+GUID+"&IDP="+IDP;
	vcfb=window.open(sHref,"vcfb","width=840,height=570");
	vcfb.focus();
}


function jsVerContenido(plIDContenido)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Web/VerContenido.aspx?GUID="+GUID+"&ID="+plIDContenido;
	window.location.href=sHref;
}

function jsExportarReporteUsuarios()
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Popups/ExportacionExcel.aspx?GUID="+GUID+"&DGExcel=ReporteUsuarios&Tit=Usuarios";
	window.location.href=sHref;
}


function jsChangePage(lIndex)
{

	form=document.Form1;
	form.pack.value="ChangePage";
	form.param1.value=lIndex;

}

function jsLimpiarListaRadio(psName)
{
	form=document.Form1;
	for(i=0;i<form[psName].length;i++)
		form[psName][i].checked=false;

}
function jsLimpiarListaCheckbox(psName)
{
	form=document.Form1;
	for(i=0;i<form[psName].length;i++)
		form[psName][i].checked=false;
}

function jsValidarListaRadio(psName,psAlert)
{
	
	form=document.Form1;
	for(i=0;i<form[psName].length;i++)
	{
		if(form[psName][i].checked)
			return true;
	}
	alert('Debes responder la pregunta:\n '+psAlert);
	//return false;
}

function jsValidarListaCheckbox(psName,psAlert)
{
	form=document.Form1;
	for(i=0;i<form[psName].length;i++)
	{
		if(form[psName][i].checked)
			return true;
	}
	alert('Debes responder la pregunta:\n '+psAlert);
	//return false;
}
function jsValidarTexto(psName,psAlert)
{
	form=document.Form1;
	var valor=form[psName].value;
	
	if(valor.length>0)
	{
		return true;
	}
	else
	{
		alert('Debes responder la pregunta:\n '+psAlert);
		//return false;
	}
}




function jsAbrirVentanaEdicionPortlet(IDP)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Contenidos/EditarPortlet.aspx?GUID="+GUID+"&IDP="+IDP+"&IDPT="+jsObtenerIDPortalActual()
	vedpo=window.open(sHref,"vedpo","width=600,height=710,scrollbars=1");
	vedpo.focus();
}


function jsEditarPortlet(form)
{
                sMensaje="";
                if(form["frmPortlet:_Nombre:txtValor"].value.length==0)sMensaje+="Debe ingresar el nombre del portlet";
                
                //validacion 
                if(form["frmPortlet:_IDTipo:cmbValor"].options[form["frmPortlet:_IDTipo:cmbValor"].selectedIndex].value==30)
                {
                                
                                if((form["frmPortlet:_IDAuxiliar3:cmbValor"].options[form["frmPortlet:_IDAuxiliar3:cmbValor"].selectedIndex].value>0) && (form["frmPortlet:_String4:txtValor"].value.length==0) )
                                                sMensaje+="\nDebe ingresar titulo filtro 1";
                                if((form["frmPortlet:_IDAuxiliar5:cmbValor"].options[form["frmPortlet:_IDAuxiliar5:cmbValor"].selectedIndex].value>0) && (form["frmPortlet:_String5:txtValor"].value.length==0) )
                                                sMensaje+="\nDebe ingresar titulo filtro 2";
                                if((form["frmPortlet:_IDAuxiliar8:cmbValor"].options[form["frmPortlet:_IDAuxiliar8:cmbValor"].selectedIndex].value>0) && (form["frmPortlet:_String6:txtValor"].value.length==0) )
                                                sMensaje+="\nDebe ingresar titulo filtro 3";
                                if((form["frmPortlet:_IDAuxiliar12:cmbValor"].options[form["frmPortlet:_IDAuxiliar12:cmbValor"].selectedIndex].value>0) && (form["frmPortlet:_String1:txtValor"].value.length==0) )
                                                sMensaje+="\nDebe ingresar titulo filtro 4";
                
                }
                //end
                
                if(sMensaje.length>0)
                {
                                alert(sMensaje);
                                return false;
                }
                else
                                return true;
}



function jsAlertaAccesoNegado()
{
	alert("Acceso Negado");
}

function jsSeleccionarEscritorio(IDEscritorio)
{
	form=document.Form1;
	form.pack.value="SeleccionarEscritorio";
	form.param1.value=IDEscritorio;
	form.submit();
}

function jsBrowseBiblioteca(IDPortal)
{
	var iWidth	= 750;
	var iHeight	= 600;
	var iLeft = (screen.width  - iWidth) / 2 ;
	var iTop  = (screen.height - iHeight) / 2 ;
	var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes" ;
	sOptions += ",width=" + iWidth ;
	sOptions += ",height=" + iHeight ;
	sOptions += ",left=" + iLeft ;
	sOptions += ",top=" + iTop ;
	
	sLinkBrowserURL = '/iPortal.Web/FCKEditor/editor/filemanager/browserBDImagen/default/browserBDImagen.aspx?Type=Image&Connector=connectors/aspx/connectorPortalBDImagen.aspx' ;
	sLinkBrowserURL+='&GUID='+document.Form1.GUID.value;
	sLinkBrowserURL+='&EP=1';
	

	// Open the browser window.
	var oBiblioteca = window.open( sLinkBrowserURL, "FCKBrowseWindow", sOptions ) ;

}


function jsAbrirVentanaPermisosDocumento(psDocumento)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Biblioteca/PermisosBiblioteca.aspx?GUID="+GUID+"&doc="+psDocumento;
	vpeb=window.open(sHref,"vpeb","width=500,height=550");
	vpeb.focus();
}

function jsAbrirVentanaPermisosContenido(plIDContenido)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Biblioteca/PermisosContenido.aspx?GUID="+GUID+"&IDC="+plIDContenido;
	vpec=window.open(sHref,"vpec","width=500,height=550");
	vpec.focus();
}

function jsAbrirVentanaSimple(psUrl,plWidth,plHeight,psExtras)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	
	if(psUrl.indexOf("GUID")<0)
		sHref=psUrl+"?GUID="+GUID;
	else
		sHref=psUrl;
		
	vavs=window.open(sHref,"vavs","width="+plWidth+",height="+plHeight+" "+psExtras);
	vavs.focus();
}
/**Foro**/

function jsAbrirVentanaLeerMensaje(IDM)
{
	form=document.Form1;
	GUID=form.GUID.value;
	sHref="/Portal.Base/Web/Foros/LeerMensaje.aspx?GUID="+GUID+"&IDM="+IDM+"&SHOW=1";
	vpec=window.open(sHref,"vpec","width=500,height=500,scrollbars=yes,resizable");
	vpec.focus();
}

function jsAbrirVentanaEnviarMensaje(IDU)
{
	form=document.Form1;
	GUID=form.GUID.value;
	sHref="/Portal.Base/Web/Foros/EnviarMensaje.aspx?GUID="+GUID+"&IDU="+IDU;
	vpec=window.open(sHref,"vpec","width=500,height=500,scrollbars=yes,resizable");
	vpec.focus();
}
function jsAbrirVentanaPreviewMensaje(IDM)
{
	form=document.Form1;
	GUID=form.GUID.value;
	sHref="/Portal.Base/Web/Foros/LeerMensaje.aspx?GUID="+GUID+"&IDM="+IDM+"&SHOW=0";
	vpec=window.open(sHref,"vpec","width=500,height=500,scrollbars=yes,resizable");
	vpec.focus();
}


/**** VALIDACION DE RUT *****************/
function formateo_Rut(obj,original)
{

     var xfm = document.Form1;
     var tmpInt = 0;     
     var rut= ObtenerRut(obj.value); 
	 
	var DV =rut.substring(rut.length-1,rut.length);
	rut = rut.substring(0,rut.length-1)
	rut = QuitarPuntos(rut);    
	esEntero = parseInt(rut); 
	if (!isNaN(esEntero) || rut.length>0)
	{
		if (rut != "")
		{
			if (checkDecimals(rut)==false)
				{
						obj.value = "";
						xfm.elements[original].value = "";
						obj.focus();
						return false;
				}
		
				tmpInt = parseInt(rut,10);
				rut = new String(tmpInt);
				xfm.elements[original].value = rut+DV;
				obj.value = insertapuntos(rut) + '-' +DV;	
				jsValidarRut(rut , DV, obj);       
			
		}
		
		
	}
	else
	{	
		obj.value="";
	}
      
     
     
      
   
}


function valor_originalRut(obj,original)
{
      var xfm = document.Form1;
      if (obj != null && xfm.elements[original]!= null )
      {
      if((obj.value !="") && (xfm.elements[original].value != ""))
         obj.value = xfm.elements[original].value;
        else
        xfm.elements[original].value = "";           
      }
}

function Right(strvar,intcant)
{
	strtemp = "";
	intlargo = strvar.length -1;
	for(i = 1;i <= intcant; i++)
	{
		strtemp = strtemp + strvar.charAt(intlargo);
		intlargo--;
	}
	strtmp2=""
	for(intlargo = strtemp.length -1; intlargo >=0; intlargo--)
	{
		strtmp2 = strtmp2 + strtemp.charAt(intlargo);
	}
	return(strtmp2);
}
function insertapuntos(strval)
{
	var A = new Array();
	var strtemp = new String(strval);
	if(strtemp.length > 0){
	strtemp = parseInt(strtemp,10);
	strtemp = new String(strtemp);
	if (strtemp.length > 3){
	for(var i = 0; strtemp.length > 3; i++)
	{
		A[i] = Right(strtemp,3);
		strtemp /= 1000;
		strtemp=new String(strtemp);
		if (strtemp.indexOf('.') != -1)
		{
		strtemp = strtemp.substr(0,strtemp.indexOf('.'));
		}
	}
	for(i-- ;i >= 0 ;i--){
	strtemp = strtemp + "." + A[i];
	}
	}
}
return(strtemp);
}

function QuitarPuntos(strval)
{
	   
	  strtemp = "";
      intlargo = strval.length -1;
      for(i = 0;i <=intlargo; i++)
      {
            if (strval.charAt(i) != '.')
            strtemp = strtemp + strval.charAt(i);
           
      }
      return strtemp; 		
}

function checkDecimals(fieldValue) 
{
	decallowed = 0;  // cantidad de decimales
	if (isNaN(fieldValue) || fieldValue == "") 
	{
		return false;
	}
	else 
	{
		if (fieldValue.indexOf('.') == -1) fieldValue += ".";
		dectext = fieldValue.substring(fieldValue.indexOf('.')+1, fieldValue.length);
			if (dectext.length > decallowed)
			{
				return false;
			}
		else 
		{
			return true;
		}
	}
}

function ObtenerRut(RutConDV)
{
    var arreglo = new Array(); 
	arreglo=RutConDV.split('-') ; 
	if (arreglo[1] != undefined)
	  RutSinDV = arreglo[0] + arreglo[1]; 
	else
	  RutSinDV = arreglo[0]; 
	  
	return RutSinDV; 
}


function jsValidarRut(rut, dv,obj)
{
           
				var xfm = document.Form1;
				var dvr = '0'

				if (dv.length == 0)
				{
				alert("Debe ingresar el Digito Verificador");
				obj.focus(); 
				return false; 
				}
	            
				suma = 0
				mul  = 2 
				for (i= rut.length -1 ; i >= 0; i--)
					{
					suma = suma + rut.charAt(i) * mul
						if (mul == 7)
						mul = 2
						else   
						mul++
					}
				res = suma % 11
				if (res==1)
					dvr = 'K'
				else if (res==0)
					dvr = '0'
				else
					{
					dvi = 11-res
					dvr = dvi + ""
					}
					
				if(dv == 'k' || dv == 'K')
					dv = 'K';
	 
				if ( dvr != dv)
				{
				alert("El rut ingresado no es válido"); 
				obj.value="";
				obj.focus();
				return false; 
				}
				else
				{		 
				return true; 
				}
			
			
			
}


function jsValidarAgregarContenedorDatos()
{
    var sMensaje="";
	form=document.Form1;
	
	if(form["frmDato__Nombre_txtValor"].value.length==0)
		sMensaje = "Debe ingresar el nombre del contenedor.";	
			
	if(form["frmDato__Descripcion_txtValor"].value.length==0)
		sMensaje += "\nDebe ingresar una descripci\xF3n para el contenedor.";	
	if(sMensaje.length>0)
	{
		window.alert(sMensaje);
		return false;
	}
	else
		return true;	


}
function jsAbrirVentanaEdicionContenedorDatos(IDC)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/ContenedorDatos/EditarContenedorDatos.aspx?GUID="+GUID+"&IDC="+IDC;
	vedco=window.open(sHref,"vedco","width=650,height=300,scrollbars=yes,resizable=yes");
	vedco.focus();
}

function jsAbrirVentanaEdicionDatoContenedor(IDC,IDD)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/ContenedorDatos/EditarDato.aspx?GUID="+GUID+"&IDC="+ IDC +"&IDD="+IDD;
	vedco=window.open(sHref,"vedco","width=750,height=550,scrollbars=yes,resizable=yes");
	vedco.focus();
}


function jsAbrirVentanaDatosContenedor(IDC)
{	
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/ContenedorDatos/ListarDatos.aspx?GUID="+GUID+"&IDC="+IDC;
	window.location.href=sHref;	
}

function jsAbrirVentanaAgregarArchivo(IDC, IDD)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/iPortal.Web/iControles/DocumentosMultiples/AgregarEliminarDocumento.aspx?IDC="+IDC+"&IDD="+IDD;
	vedc=window.open(sHref,"vedc","width=650,height=600,scrollbars=yes,resizable");
	vedc.focus();
}

function jsValidarSubirArchivoMultiple()
{
   var sMensaje="";
   form=document.Form1;
   
   if(form.filDocumento.value.length==0)
		sMensaje = "Debe ingresar la ruta del archivo.";
		
	if(sMensaje.length>0)
	{
		window.alert(sMensaje);
		return false;
	}
	else
		return true;		
}

function jsAbrirVentanaContenidosN2(IDCP,IDC1,IDC2)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Contenidos/ListaContenidosN2.aspx?GUID="+GUID+"&IDCP="+IDCP + "&IDC1=" + IDC1 + "&IDC2="+IDC2;
	window.location.href=sHref;	
}


function jsAbrirVentanaDuplicarContenidoArchivosMultiples(IDC)
{
	form=document.Form1;
	GUID=form.GUID.value;	
	sHref="/Portal.Base/Contenidos/DuplicarContenidoArchivosMultiples.aspx?GUID="+GUID+"&IDC="+IDC+"&IDP="+jsObtenerIDPortalActual()
	vdco=window.open(sHref,"vdco","width=600,height=450");
	vdco.focus();
}


function jsEjecutarPortletRss(IDP)
{
	
	 form=document.Form1;
     sHref="/Portal.Base/Web/VerRss.aspx?IDP="+IDP;
     //vdco=window.open(sHref,"vdco","width=600,height=330");
     //vdco.focus();
     window.location.href=sHref;

}

function jsValidaIngresoRutMembresia()
	{
		var lRut = document.getElementById('_P_3076_frmUsuario__D_72_txtValor').value;
		if(lRut.length==0)
		{
			alert('Rut o DNI ingresado incorrectamente.');
			return false;
		}
		else
			return true;

	}

	function jsValidaRutMembresia()
	{
		var lRut = document.getElementById('_P_3076_frmUsuario__D_72_txtValor').value;
		var arreglo = new Array(); 
		arreglo=lRut.split('-') ; 
		if(arreglo.length!=2)
		{
			alert('Rut ingresado incorrectamente.');
			return false;
		}
		else
		{
			return jsValidarRut(arreglo[0], arreglo[1],document.getElementById('_P_3076_frmUsuario__D_72_txtValor'));
		}

	}

	function getCheckedValue(radioObj) {
		if(!radioObj)
			return "";
		var radioLength = radioObj.length;
		if(radioLength == undefined)
			if(radioObj.checked)
				return radioObj.value;
			else
				return "";
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				return radioObj[i].value;
			}
		}
		return "";
	}
	
	function jsValidaDatosFormularioMembresia()
	{
		var cbox;
		var lKey;	
		//Nacionalidad
		cbox = document.Form1['_P_3076_frmUsuario__D_43_cmbValor'];
		lKey = cbox.options[cbox.selectedIndex].value;	
		if (Number(lKey)==0)
		{
			alert('Debe ingresar Nacionalidad.');
			return false;
		}
		//Región
		cbox = document.Form1['_P_3076_frmUsuario__D_44_cmbValor'];
		lKey = cbox.options[cbox.selectedIndex].value;	
		if (Number(lKey)==0)
		{
			alert('Debe ingresar Regi\u00f3n.');
			return false;
		}
		//Comuna
		cbox = document.Form1['_P_3076_frmUsuario__D_45_cmbValor'];
		lKey = cbox.options[cbox.selectedIndex].value;	
		if (Number(lKey)==0)
		{
			alert('Debe ingresar Comuna.');
			return false;
		}
		
		if (document.Form1['_P_3076:frmUsuario:_D_71:txtValor'].value.length==0)
		{
			alert('Debe ingresar Domicilio Particular.');
			return false;
		}
		
		return true;
		
	}

	function jsEjecutaValidacionFormularioRegistroBasico()
	{
		//var lGrupo = getCheckedValue(document.getElementById('rbGrupo'));
		var lGrupo = getCheckedValue(document.Form1.rbGrupo);
		if (document.getElementById('_P_3076_frmUsuario__D_72_txtValor'))
		{
			if (document.getElementById('_P_3076_frmUsuario__D_72_txtValor').value.length>0)
			{
				if (!jsValidaRutMembresia())
							return false;
			}
		}
		if (lGrupo==8 || lGrupo==12 || lGrupo==10 ||lGrupo==9)
		{
			if (lGrupo==8 || lGrupo==12 || lGrupo==10)
			{
				if(document.getElementById('tipoDocMem'))
				{
					var cbox = document.Form1['_P_3076:frmUsuario:_D_43:cmbValor'];
					var lKey = cbox.options[cbox.selectedIndex].value;	
					if (Number(lKey)==10001)
					{
						if (!jsValidaRutMembresia())
							return false;
					}
					else
					{
						if (!jsValidaIngresoRutMembresia())
							return false;
					}
				}
					if (!jsValidaDatosFormularioMembresia())
						return false;
			}
			else
			{
				if(document.getElementById('tipoDocMem'))
				{
					var cbox = document.Form1['_P_3076:frmUsuario:_D_43:cmbValor'];
					var lKey = cbox.options[cbox.selectedIndex].value;	
					if (Number(lKey)==10001)
					{
						if (!jsValidaRutMembresia())
							return false;
					}
					else
					{
						if (!jsValidaIngresoRutMembresia())
							return false;
					}
				}
			}
		}
		return true;
	}

function PoblarPunteroAjaxReplica(cOrigen, cDestino)
{
	
	var cbox = document.Form1[cOrigen];
	var lKey = cbox.options[cbox.selectedIndex].value;	

	var url = "/Portal.Base/Web/ObtenerValor.aspx?IDPadre="+lKey;
	oDestinoReplica = document.Form1[cDestino];
	if (document.getElementById) 
	{ //Verifica se o Browser suporta DHTML.
		if (window.XMLHttpRequest) {
			HttpReqReplica = new XMLHttpRequest();
			HttpReqReplica.onreadystatechange = XMLHttpRequestChangeReplica;
			HttpReqReplica.open("GET", url, true);
			HttpReqReplica.send(null);
		} 
		else if (window.ActiveXObject) 
		{
			HttpReqReplica = new ActiveXObject("Microsoft.XMLHTTP");
			if (HttpReqReplica) 
			{
				HttpReqReplica.onreadystatechange = XMLHttpRequestChangeReplica;
				HttpReqReplica.open("GET", url, true);
				HttpReqReplica.send();
			}
		}
	}	
	
}

function XMLHttpRequestChangeReplica() {
	if (HttpReqReplica.readyState == 4 && HttpReqReplica.status == 200)
	{
		var result = HttpReqReplica.responseXML;		
		
		var mElementos = result.getElementsByTagName("E");
				
		//if(mElementos.length==0)
		//{			
			oDestinoReplica.options.length = 0;
			oDestinoReplica.options[0] = new Option('    ',0);
		//}
		
		//oDestino.options.length = 0;
		for (var i = 1; i < mElementos.length+1; i++) 
		{		
			oDestinoReplica.options[i] = new Option(mElementos[i-1].childNodes[0].data,mElementos[i-1].getAttribute("id"));		
			oDestinoReplica.options[i].title = mElementos[i-1].childNodes[0].data;
		}		
	
	}
}