function setFocus(nombreFormulario, nombreControl){
    var focusControl = document.forms[nombreFormulario].elements[nombreControl];
    focusControl.focus();
}
function setChecked(nombreFormulario, nombreRadio, indexRadio){
    var checkedControl = document.forms[nombreFormulario].elements[nombreRadio];
    checkedControl[indexRadio].checked = true;
}
function enProceso(objeto){
	objeto.value="Procesando...";
	return;
}
function check(objeto,valor){
	if(valor!=""){
		objeto.form.ayuda.value=valor;
		objeto.blur();
		objeto.form.submit();
	}
	return;
}
var contSubmit=0;
function realizarEnvio(valor, indiceForm){
    if(contSubmit==0){
    	if(indiceForm == undefined)
    		indiceForm = 0;
        contSubmit++;
        document.forms[indiceForm].ayuda.value=valor;
        document.forms[indiceForm].submit(); 
        if(document.readyState == "loading")
        	popWait('div_wait');
    }
}
function mypopup(accion,titulo)
{
	mywindow = window.open (accion,
		titulo,"menubar=no,directories=no,location=no,toolbar=no,top=50,left=50,scrollbars=yes,titlebar=yes,height=600,width=850,resizable=yes,status=yes");
	mywindow.focus();
}
function VerificarF5(){
	var tecla= window.event.keyCode;
	if(tecla==116){
		event.keyCode=0;
		event.returnValue=false;
	}
}
function verificarEnter(evento){
  	var KeyID = (window.event) ? event.keyCode : e.keyCode;
	if(KeyID==13) {
      return true;
    }
	return false;
}
function continuarEvento(evento,continuar){ 
	if (evento.preventDefault && !continuar){
		evento.preventDefault();
		evento.stopPropagation();
	} 
	return continuar;
}
function resultadosBusqueda(url,nombreVentana,parametros,indiceForm){
	if(indiceForm == undefined)
		indiceForm = 0;
	url=url+"?";
	var formElements = document.forms[indiceForm].elements;
	var formElement = "";
	for(var i=0;i<parametros.length;i++)
	{
		formElement = formElements[parametros[i]];
		if(formElement.length == undefined){			
			if(encodeURIComponent(formElement.type)!="checkbox" && encodeURIComponent(formElement.type)!="radio"){
				url=url+"&"+encodeURIComponent(formElement.name)+"="+encodeURIComponent(formElement.value);
			}else if(encodeURIComponent(formElement.type)=="checkbox" && encodeURIComponent(formElement.checked)=="true"){
				url=url+"&"+encodeURIComponent(formElement.name)+"="+encodeURIComponent(formElement.value);
			}else if(encodeURIComponent(formElement.type)=="radio" && encodeURIComponent(formElement.checked)=="true"){
				url=url+"&"+encodeURIComponent(formElement.name)+"="+encodeURIComponent(formElement.value);
			}
		}else{
			for(var j=0;j<formElement.length;j++){				
				if(encodeURIComponent(formElement[j].type)!="checkbox" && encodeURIComponent(formElement[j].type)!="radio")
					url=url+"&"+encodeURIComponent(formElement[j].name)+"="+encodeURIComponent(formElement[j].value);
				else if(encodeURIComponent(formElement[j].type)=="checkbox" && encodeURIComponent(formElement[j].checked)=="true")
					url=url+"&"+encodeURIComponent(formElement[j].name)+"="+encodeURIComponent(formElement[j].value);
				else if(encodeURIComponent(formElement[j].type)=="radio" && encodeURIComponent(formElement[j].checked)=="true")
					url=url+"&"+encodeURIComponent(formElement[j].name)+"="+encodeURIComponent(formElement[j].value);
			}
		}	
	}
        dialogoWeb(url,nombreVentana,'dialogHeight:650px;dialogWidth:900px;help:no;scroll:no');
}
function dialogoWeb(url,nombreVentana,propiedades){
    popWait('div_wait'); 
    window.showModalDialog(url,nombreVentana,propiedades);
    killWait('div_wait'); //elimina el mensaje procesando...
}
function resultadosBusquedaENTER(url,nombreVentana,parametros,indiceForm){
	var keycode;
	if (window.event)
		keycode = window.event.keyCode;
	else return true;
	if (keycode == 13){
		resultadosBusqueda(url,nombreVentana,parametros,indiceForm)
   		return false;
  	}else return true;
}
var isNav4, isIE4, isNav6 = false; //variables que verifican el navegador
var range = "";
var styleObj = "";
if (navigator.appVersion.charAt(0) >= 4) {
	if (navigator.appName == "Netscape") {
		if (navigator.appVersion.charAt(0) >= 5) {
			isNav6 = true;
		}
		else {
			isNav4 = true;
		}
	}
	else {
		isIE4 = true;
		range = "all.";
		styleObj = ".style";
	}
}
function getObject(obj) {
	var theObj;
	if (typeof obj == "string") {
		if (isNav6) {
			theObj = document.getElementById(obj);
			if (theObj != null) theObj = theObj.style;
		}
		else {
			theObj = eval("document." + range + obj);
			if (theObj != null) theObj = eval("theObj" + styleObj);
		}
	}
	else {
		theObj = obj;
	}
	return theObj;
}
function show () {
	var theObj;
	for (var i = 0; i < show.arguments.length; i++) {
		theObj = getObject(show.arguments[i]);
		if (theObj != null) {
			theObj.display = "block";
			theObj.visibility = "visible";
		}
	}
}
function hide () {
	var theObj;
	for (var i = 0; i < hide.arguments.length; i++) {
		theObj = getObject(hide.arguments[i]);
		if (theObj != null) {
			theObj.display = "none";
			theObj.visibility = "hidden";
		}
	}
}
function cambiarEstilo (myObj, color, grosor) {
	var theObj;
	theObj = getObject(myObj);
	if (theObj != null) {
		theObj.fontWeight = grosor;
		theObj.backgroundColor = color;
	}
}
function cambiarEstiloChequeado(objeto, id, nuevoColor, colorOriginal) {
    if(objeto.checked == true)
        cambiarEstilo(id, nuevoColor, 'normal');
    else
        cambiarEstilo(id, colorOriginal, 'normal');
}
function cambiarEstiloClick(objeto, id, nuevoColor, colorOriginal){
    if(objeto.checked == false){
        objeto.checked = true;
        cambiarEstilo(id, nuevoColor, 'normal');
    }else{
        objeto.checked = false;
        cambiarEstilo(id, colorOriginal, 'normal');
    }
}
function chequear(objeto){
    if(objeto.type == 'radio')
        objeto.checked = true;
    else if(objeto.type == 'checkbox'){
        if(objeto.checked = false)
            objeto.checked = true;
        else
            objeto.checked = false;
    }
}
function setHeightPage(newHeight){
    var divPage = document.getElementById('div_pagina');
    if (divPage != null) {
        if (newHeight == undefined){
            newHeight = document.getElementById('hiddenMessages').value;
        }
        divPage.style.height = newHeight;
    } 
}
function closeMessages(messageType){
    var divHeightS = document.getElementById('div_pagina').style.height; 
    var newHeight = null;
    divHeightS = divHeightS.substring(0, divHeightS.indexOf("p"));
    newHeight = (document.getElementById("hidden" + messageType).value * 1) + (divHeightS * 1);
    document.getElementById(messageType).innerHTML = "";
    setHeightPage(newHeight + "px");
}	
function getContentsFCKContenidoForm(){
	var oEditor = FCKeditorAPI.GetInstance('fckIntrotext') ;
	document.contenidoForm.introtext.value=oEditor.GetXHTML(true);
	oEditor =null;
	var oEditor = FCKeditorAPI.GetInstance('fckFulltext');
	document.contenidoForm.fulltext.value=oEditor.GetXHTML( true );  
}
function printContent(text) {
	text = document;
	if (window.print) {
		print(text);
	}
	else {
		alert("Lo sentimos, pero su navegador no soporta esta opción. / We sorry but your server does not acept this option");
	}
}
function doPrint(url){
	var httpRequest; 
	if (window.ActiveXObject)
	{ 
    	httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	else if (window.XMLHttpRequest)
	{ 
    	httpRequest = new XMLHttpRequest(); 
    	if(httpRequest.overrideMimeType){
      		httpRequest.overrideMimeType('text/xml');
    	}
	} 
	httpRequest.open('GET',url, false);
	httpRequest.send(null);
	var response = httpRequest.responseText;
	var frm = document.oculto;
	frm.codigoPag.value = response;
	frm.action = "impresion.ks";
	window.open("","newWin","menubar=no,directories=no,location=no,toolbar=no,top=50,left=50,scrollbars=yes,titlebar=yes,height=600,width=900,resizable=yes,status=yes");
    frm.submit();
}
function esIE(){
	var resultado;
	if(window.XMLHttpRequest){ 
        	resultado=false;
    	}else if (window.ActiveXObject){ // Internet Explorer
        	resultado=true;
     	}
     	return resultado;
}
function setFocus(nombreFormulario, nombreControl){
    var focusControl = document.forms[nombreFormulario].elements[nombreControl];
    focusControl.focus();
}
function setChecked(nombreFormulario, nombreRadio, indexRadio){
    var checkedControl = document.forms[nombreFormulario].elements[nombreRadio];
    checkedControl[indexRadio].checked = true;
}
function enProceso(objeto){
	objeto.value="Procesando...";
	return;
}
function check(objeto,valor){
	if(valor!=""){
		objeto.form.ayuda.value=valor;
		objeto.blur();
		objeto.form.submit();
	}
	return;
}
var contSubmit=0;
function realizarEnvio(valor, indiceForm){
    if(contSubmit==0){
    	if(indiceForm == undefined)
    		indiceForm = 0;
        contSubmit++;
        document.forms[indiceForm].ayuda.value=valor;
        document.forms[indiceForm].submit(); 
        if(document.readyState == "loading")
        	popWait('div_wait');
    }
}
function mypopup(accion,titulo){
	mywindow = window.open (accion,
		titulo,"menubar=no,directories=no,location=no,toolbar=no,top=50,left=50,scrollbars=yes,titlebar=yes,height=600,width=850,resizable=yes,status=yes");
	mywindow.focus();
}
function VerificarF5(){
	var tecla= window.event.keyCode;
	if(tecla==116){
		event.keyCode=0;
		event.returnValue=false;
	}
}
function resultadosBusqueda(url,nombreVentana,parametros,indiceForm)
{
	if(indiceForm == undefined)
		indiceForm = 0;
	url=url+"?";
	var formElements = document.forms[indiceForm].elements;
	var formElement = "";
	for(var i=0;i<parametros.length;i++)
	{
		formElement = formElements[parametros[i]];
		if(formElement.length == undefined){
			if(encodeURIComponent(formElement.type)!="checkbox" && encodeURIComponent(formElement.type)!="radio"){
				url=url+"&"+encodeURIComponent(formElement.name)+"="+encodeURIComponent(formElement.value);
			}else if(encodeURIComponent(formElement.type)=="checkbox" && encodeURIComponent(formElement.checked)=="true"){
				url=url+"&"+encodeURIComponent(formElement.name)+"="+encodeURIComponent(formElement.value);
			}else if(encodeURIComponent(formElement.type)=="radio" && encodeURIComponent(formElement.checked)=="true"){
				url=url+"&"+encodeURIComponent(formElement.name)+"="+encodeURIComponent(formElement.value);
			}
		}else{
			for(var j=0;j<formElement.length;j++){
				if(encodeURIComponent(formElement[j].type)!="checkbox" && encodeURIComponent(formElement[j].type)!="radio")
					url=url+"&"+encodeURIComponent(formElement[j].name)+"="+encodeURIComponent(formElement[j].value);
				else if(encodeURIComponent(formElement[j].type)=="checkbox" && encodeURIComponent(formElement[j].checked)=="true")
					url=url+"&"+encodeURIComponent(formElement[j].name)+"="+encodeURIComponent(formElement[j].value);
				else if(encodeURIComponent(formElement[j].type)=="radio" && encodeURIComponent(formElement[j].checked)=="true")
					url=url+"&"+encodeURIComponent(formElement[j].name)+"="+encodeURIComponent(formElement[j].value);
			}
		}	
	}
        dialogoWeb(url,nombreVentana,'dialogHeight:650px;dialogWidth:900px;help:no;scroll:no');
}
function dialogoWeb(url,nombreVentana,propiedades){
    popWait('div_wait'); //crea el mensaje procesando...
    window.showModalDialog(url,nombreVentana,propiedades);
    killWait('div_wait'); //elimina el mensaje procesando...
}
function resultadosBusquedaENTER(url,nombreVentana,parametros,indiceForm){
	var keycode;
	if (window.event)
		keycode = window.event.keyCode;
	else return true;
	if (keycode == 13){
		resultadosBusqueda(url,nombreVentana,parametros,indiceForm)
   		return false;
  	}else return true;
}
var isNav4, isIE4, isNav6 = false; //variables que verifican el navegador
var range = "";
var styleObj = "";
if (navigator.appVersion.charAt(0) >= 4) {
	if (navigator.appName == "Netscape") {
		if (navigator.appVersion.charAt(0) >= 5) {
			isNav6 = true;
		}
		else {
			isNav4 = true;
		}
	}
	else {
		isIE4 = true;
		range = "all.";
		styleObj = ".style";
	}
}
function getObject(obj) {
	var theObj;
	if (typeof obj == "string") {
		if (isNav6) {
			theObj = document.getElementById(obj);
			if (theObj != null) theObj = theObj.style;
		}
		else {
			theObj = eval("document." + range + obj);
			if (theObj != null) theObj = eval("theObj" + styleObj);
		}
	}
	else {
		theObj = obj;
	}
	return theObj;
}
function show () {
	var theObj;
	for (var i = 0; i < show.arguments.length; i++) {
		theObj = getObject(show.arguments[i]);
		if (theObj != null) {
			theObj.display = "block";
			theObj.visibility = "visible";
		}
	}
}
function hide () {
	var theObj;
	for (var i = 0; i < hide.arguments.length; i++) {
		theObj = getObject(hide.arguments[i]);
		if (theObj != null) {
			theObj.display = "none";
			theObj.visibility = "hidden";
		}
	}
}
function cambiarEstilo (myObj, color, grosor) {
	var theObj;
	theObj = getObject(myObj);
	if (theObj != null) {
		theObj.fontWeight = grosor;
		theObj.backgroundColor = color;
	}
}
function cambiarEstiloChequeado(objeto, id, nuevoColor, colorOriginal) {
    if(objeto.checked == true)
        cambiarEstilo(id, nuevoColor, 'normal');
    else
        cambiarEstilo(id, colorOriginal, 'normal');
}
function cambiarEstiloClick(objeto, id, nuevoColor, colorOriginal){
    if(objeto.checked == false){
        objeto.checked = true;
        cambiarEstilo(id, nuevoColor, 'normal');
    }else{
        objeto.checked = false;
        cambiarEstilo(id, colorOriginal, 'normal');
    }
}
function chequear(objeto)
{
    if(objeto.type == 'radio')
        objeto.checked = true;
    else if(objeto.type == 'checkbox'){
        if(objeto.checked = false)
            objeto.checked = true;
        else
            objeto.checked = false;
    }
}
function setHeightPage(newHeight){
    var divPage = document.getElementById('div_pagina');
    
    if (divPage != null) {
        if (newHeight == undefined){
            newHeight = document.getElementById('hiddenMessages').value;
        }
        divPage.style.height = newHeight;
    } 
}
function closeMessages(messageType){
    var divHeightS = document.getElementById('div_pagina').style.height; 
    var newHeight = null;
    divHeightS = divHeightS.substring(0, divHeightS.indexOf("p"));
    newHeight = (document.getElementById("hidden" + messageType).value * 1) + (divHeightS * 1);
    document.getElementById(messageType).innerHTML = "";
    setHeightPage(newHeight + "px");
}
function getContentsFCKContenidoForm(){
	var oEditor = FCKeditorAPI.GetInstance('fckIntrotext') ;
	document.contenidoForm.introtext.value=oEditor.GetXHTML( true ); 
	oEditor =null;
	var oEditor = FCKeditorAPI.GetInstance('fckFulltext') ;
	document.contenidoForm.fulltext.value=oEditor.GetXHTML( true );  
}
function printContent(text) {
	text = document;
	if (window.print) {
		print(text);
	}
	else {
		alert("Lo sentimos, pero su navegador no soporta esta opción. / We sorry but your server does not acept this option");
	}
}
function obtenerHTMLTopico(form, titulo){
if (document.getElementById != null){
	var html = "<HTML> \n <HEAD> \n";
	if (document.getElementsByTagName != null){
		var headTags = document.getElementsByTagName("head");
		if (headTags.length > 0)
			html += headTags[0].innerHTML;		
		if(html.indexOf("<SCRIPT")>0)
			html = html.substr(0,html.indexOf("<SCRIPT"));
		}
		html += "</HE" + "AD> \n <BODY> \n";
		html += "<H2> " + titulo + " </H2> \n";
		var printReadyElem = document.getElementById("zonaPrint");
		if (printReadyElem != null){
			html += printReadyElem.innerHTML;
		}
		else{
			alert("No se encuentra el texto a imprimir en el codigo HTML");
			return;
		}
		var printFooterElem = document.getElementById("zonaFooter");
		if (printFooterElem != null){
			html += "\n" + printFooterElem.innerHTML;
		}
		html += "\n </BO" + "DY> \n </HT" + "ML>";
		return html;
	}
	else{
		return null;
	}
}
function impresion(form, titulo){	
	var htmlTopico= obtenerHTMLTopico(form, titulo);
	if (htmlTopico!= null){
		var printWin = window.open("","winPrint","menubar=no,directories=no,location=no,toolbar=no,top=50,left=50,scrollbars=yes,titlebar=yes,height=600,width=900,resizable=yes,status=yes");
		printWin.document.open();
		printWin.document.write(htmlTopico);
		printWin.document.close();
		printWin.print();
	}
	else{
		alert("Lo sentimos, pero su navegador no soporta esta opción.");
	}
}
function mailpage(form, titulo){
	var htmlTopico= obtenerHTMLTopico(form, titulo);
  	if (htmlTopico!= null){
    	var frm = document.correo;
		frm.htmlbodymail.value = htmlTopico;
		frm.action = "mail.ks";
		window.open("","winMail","menubar=no,directories=no,location=no,toolbar=no,top=50,left=50,scrollbars=yes,titlebar=yes,height=250,width=400,resizable=yes,status=yes");
	    frm.submit();
	}
	else{
		alert("Lo sentimos, pero su navegador no soporta esta opción.");
	} 
}
function mailcontacto(form, contactoid, contactonombre, titulo){
	if (contactoid!= null || contactonombre!= null){
    	var frm = document.correo;
    	frm.htmlbodymail.value = null;
		frm.paraRef.value = contactoid!= null?contactoid:contactonombre;
		frm.tituloRef.value = titulo;
		frm.action = "mail.ks";
		window.open("","winMail","menubar=no,directories=no,location=no,toolbar=no,top=50,left=50,scrollbars=yes,titlebar=yes,height=290,width=400,resizable=yes,status=yes");
	    frm.submit();
	}
	else{
		alert("Lo sentimos, pero los datos de referencia del contacto no se encuentran registrados.");
	} 
}
function commentforo(form, padreid){
	window.open("foro.ks?padreid="+padreid,"winComment","menubar=no,directories=no,location=no,toolbar=no,top=50,left=50,scrollbars=yes,titlebar=yes,height=250,width=400,resizable=yes,status=yes");
}
function showImageToolTip(image, name ) {
	var pattern = /\b \b/ig;
	name = name.replace(pattern,'_');
	name = name.toLowerCase();
	var html= '<br /><img border="1" src="'+image+'" name="imagelib" alt="No preview available" width="206" height="145" />';
	return overlib(html, CAPTION, name)
}
function showTextToolTip(text, name ) {
	var pattern = /\b \b/ig;
	name = name.replace(pattern,'_');
	name = name.toLowerCase();
	ol_bgcolor = '#FFF';
	var html= '<br />'+text;
	return overlib(html, CAPTION, name)
}
function abrirVentana(url) {
	var element = window.document.getElementById('newWin');
	if(element) delete element;
	window.open(url,"newWin","menubar=no,directories=no,location=no,toolbar=no,top=50,left=50,scrollbars=yes,titlebar=yes,height=600,width=900,resizable=yes,status=yes");
	window.focus();
}
function enviarUrlPost( frmName, url, vu, tem) {
	frm = document[frmName];
	alert("Abriendo componente con vu "+vu);
	frm.uid.value = vu;
	frm.templeta.value = tem;
	var element = window.document.getElementById('newWin');
	if(element) delete element;
	frm.action = url;
	window.open("","newWin","menubar=no,directories=no,location=no,toolbar=no,top=50,left=50,scrollbars=yes,titlebar=yes,height=600,width=900,resizable=yes,status=yes");
    frm.submit();
}
function replaceHtml(el, html) {
	var oldEl = (typeof el === "string" ? document.getElementById(el) : el);
	var newEl = oldEl.cloneNode(false);
	newEl.innerHTML = html;
	oldEl.parentNode.replaceChild(newEl, oldEl);
	return newEl;
}
function displayContentDescription(id, imgsrc, descr) {
	var imgtag = ' ';
	if(imgsrc && imgsrc!=null && imgsrc!='null') {
		imgtag = '<img src=\''+imgsrc+'\' />';
	}
	var htmlall = imgtag + '<br>' + descr;
	replaceHtml(id, htmlall);
}
function collapseModule(moduleid, owner) {          
	var elElemento = document.getElementById(moduleid);          
	if(elElemento.className == 'moduleHide') {               
		elElemento.className = 'moduleShow';               
		owner.className = 'expanded';          
	} 
	else {
		elElemento.className = 'moduleHide';               
		owner.className = 'collapsed';
	}
}
function mostrarArea(nombre, id, totalAreas) {          
	var idName = nombre + id;	
	for(var i=0;i<totalAreas;i++){
		var area = document.getElementById(nombre+i);		
		var titulo = document.getElementById('titulo'+i)
			area.style.display = "none";	
			titulo.className = "normal";
		if(area.id==idName){			
			titulo.className = "selected";
			area.style.display = "block";	
		}
	}
}
function mostrarContenido(nombre, id, totalContenidos, prefix) {
	if(id == -1) {
		var tituloPrimero = document.getElementById('titulo_'+prefix);
		tituloPrimero.className = "selected";
		var contenidoPrimero = document.getElementById(prefix+'_'+nombre);
		contenidoPrimero.style.display = "block";
		for(var i=0; i<totalContenidos; i++) {
			var contenido = document.getElementById(prefix+'_'+nombre+i);
			var titulo = document.getElementById('titulo_'+prefix+i);
			contenido.style.display = "none";
			titulo.className = "normal";
		}
	}
	else {
		var tituloPrimero = document.getElementById('titulo_'+prefix);
		tituloPrimero.className = "normal";
		var contenidoPrimero = document.getElementById(prefix+'_'+nombre);
		contenidoPrimero.style.display = "none";
		var idName = prefix + '_' + nombre + id;	
		for(var i=0; i<totalContenidos; i++) {
			var contenido = document.getElementById(prefix+'_'+nombre+i);
			var titulo = document.getElementById('titulo_'+prefix+i);
			contenido.style.display = "none";
			titulo.className = "normal";
			if(contenido.id==idName) {
				titulo.className = "selected";
				contenido.style.display = "block";	
			}
		}
	}
}
function abrirVideoPlayer(videoPath, videoName) {
	window.open("componentes/comvideo/comvideo_window.jsp?url_param="+videoPath+"&name_param="+videoName,"JarimbaVideoPlayer","toolbar=0, width=410, height=390, scrollbars=0, menubar=0, location=0, resizable=1").focus();
}
function openLink(ruta, target) {
	if(target=='_blank') {
		window.open(ruta,"","").focus();
	}
	else {
		window.location.href = ruta;
	}
}
function registrarSalida(){
	//alert("Gracias por vistar ecuador exporta");
}