
// execSubmit
// Esta funcion se llama desde 'editor/functions.js' de la funcion 'iEditor_Done()'
// Accion: realiza el submit del form 'form' dentro de doc_view.asp que 
// guarda las modificaciones al documento realizadas desde el editor
// Al finalizar, devuelve el control a la funcion que la llamo
	function execSubmit(formName) {
		eval('document.' + formName + '.submit()')
	}
// ---------------

// Control de la accion hide del menu pulldown.
function runTimer() { 
	timer=setTimeout('hideMenu()',500); 
}
 
function clearTimer(){ 
	clearTimeout(timer); 
}

// -------------


function openApplication(app_autologin,app_execute) {
	goLoc = "/portal/modules/extapplication/autosend.asp?id_app=" +app_execute;
	if (app_autologin != 1) {goLoc = "http://" +app_execute}
	app_window = openWindow(goLoc,700,500,null,null,'app_window',5,true,true,false);
}

function isEmail(obj) {
	if (!(result = ((obj.value == "") || ((obj.value.indexOf("@") != -1) && (obj.value.indexOf(".") != -1))))) {
		alert(  "La dirección de eMail ingresada no es valida" );
		obj.focus(); return false;
	} else { return true };
}

function changePassword() {
	changePassword = openWindow('/portal/pass_change.asp',300,185,null,null,'win_search_frm',5,false,false,false);
}

function requestPassword() {
	requestPassword = openWindow('/portal/login/login_req_password.asp',300,185,null,null,'requestPassword',5,false,false,false);
}

function showUserDataSheet(iduser) {
	userDataSheet = window.open('/portal/user/user_datasheet.asp?id_user=' + iduser ,'','width=450,height=210'); //GPA 06/02/2003 fix
}

function showCustomerCare(id_vector) {
	loginCustomerCare = window.open('/customercare/login/?id_vector=' + id_vector,'','width=350,height=250'); //openWindow("/customercare/?id_vector=" + id_vector ,350,300,null,null,'loginCustomerCare',5,false,false,false);
}

function showHome() {
	document.location='index.asp';
}

function showUserData() {
	document.location='index.asp?Module=UserData&page=User/user_data.asp';
}

function showDocumentNotReaded() {
	document.location='index.asp?Module=Documents&page=Document/doc_list.asp&doread=true';
}

function showSurveys() {
	document.location='index.asp?Module=Survey&page=modules/Survey/index.asp';
}

function showLeave() {
	document.location='index.asp?Module=Leave&page=modules/leave/index.asp';
}


function listDocument(id_section,id_document) {
	goLocation = 'index.asp?Module=Documents&page=Document/doc_list.asp&id_section=' + id_section;
	if (id_document > 0) { goLocation += '&id_document=' + id_document; }
	document.location = goLocation;	 
}

function disableEditableRegion() {
	oHTML = document.body.getElementsByTagName("DIV")
	for(var i=0;i<oHTML.length;i++) if (oHTML[i].className=='editableRegion') oHTML[i].contentEditable = false;
}



function getClassifiedTemplate(id_template)
{
parent.loadTemplate.location = '/portal/modules/classifieds/cls_view_frame.asp?id_template=' + id_template
showEditor()
}

function disableInputs() {
	oHTML = document.body.getElementsByTagName("INPUT")
	for(var i=0;i<oHTML.length;i++) {
		// FIX sobre los campos que no pertenecen al documento
		if (oHTML[i].name != 'usr_password' && oHTML[i].name != 'usr_email' && oHTML[i].name != 'buscado' && oHTML[i].type != 'button') {
			oHTML[i].onchange = function() { return false } 
		}
	}

	for(var i=0;i<oHTML.length;i++) {
		// FIX sobre los campos que no pertenecen al documento
		if (oHTML[i].name != 'usr_password' && oHTML[i].name != 'usr_email' && oHTML[i].name != 'buscado' && oHTML[i].type != 'button') {
			oHTML[i].onclick = function() { return false }  
		} 
	}
}

function listFaqs(id_section,id_faqs_tips) {
	goLocation = "index.asp?Module=Faqs&page=Modules/Faqs/doc_list.asp&id_section=" + id_section;
	if (id_faqs_tips > 0) { goLocation += "&id_faqs_tips=" + id_faqs_tips + "&faqs_request=true"; }
	document.location = goLocation;	 
}

function listSection(id_section) {
	document.location="index.asp?Module=Sections&page=Sections/sec_list.asp&id_section=" + id_section;
}
// PIC - 4/9/2002
// Motivo: se abre la ventana que muestra un clasificado
function showClassified(id_classified)
{
	windowShowClassified = openWindow("/portal/modules/classifieds/cls_view.asp?id_classified=" + id_classified,700,500,null,null,'cls_view_window',5,true,true,false);
}

function showDocument(id_document,id_section,windowed) {
	document.location = "?page=Document/doc_list.asp&id_document=" + id_document;
}

function showSite(url) {
	url = url.replace ("http://", "");
	document.location = "index.asp?page=Modules/CentralSite/central_site.asp&url=" + url;

}

function showMailbox() {
	document.location="index.asp?page=Modules/Mailbox/index.asp";
}

function changeUserRol() {
	document.location="index.asp?page=User/user_change_rol.asp";
}
function showExtApplications() {
	document.location="index.asp?page=Modules/ExtApplications/index.asp";
}

function searchBirthday() {
	birthday_search = openWindow("Modules/BirthDay/birthday_search.asp",650,450,null,null,'birthday_search',5,false,false,false);
}

function ShowFaqs(id_faqs_tips, id_section)
{
	window.open('/portal/faqs_view.asp?id_faqs_tips=' + id_faqs_tips + '&id_section=' + id_section,'View_Document','toolbar=no, scrollbars=yes, width=660, height=580, left=10, top=10');
}

function fnGoToSection(page,id_section) 	{
	if(page == '/portal/')
		{
		top.window.opener.location.href = '/portal/'
		}
	else
		{
		top.window.opener.location.href = 'index.asp?page=' + page + '&id_section=' + id_section
		}
	top.window.close()
}

function rowExpand(obj) {

	comm_obj = eval('comm_' + obj.name);

	if (comm_obj) {
		if (comm_obj.style.display == "none") {
			if(obj.name != 'XXX')
			{
			obj.innerHTML = "<img src='../images/tree_colapse.gif' alt='Haga click aquí para cerrar el comentario'>";
			}
			comm_obj.style.display = "";
		} else {
			if(obj.name != 'XXX')
			{
			obj.innerHTML = "<img src='../images/tree_expand.gif' alt='Haga click aquí para leer el comentario'>";
			}
			comm_obj.style.display = "none";
		}
	}
	
	if(obj.name == 'XXX')
		{
		window.location.href = '#1'
		}
			
}

function fnCheckFrmComment(obj)
{
	if(obj.frm_cmt_body.value.length > 255)
		{
		alert('El comentario es demasiado largo.')
		obj.frm_cmt_body.focus()
		}
	else
		{
		if(obj.frm_cmt_body.value == '')
			{
			alert('Debe ingresar un comentario')
			obj.frm_cmt_body.focus()
			}
		else
			{
			obj.submit()
			}
		}
}
// JES 31 may 2002 
// Función para links internos que pega el Editor

function getDocument(id_document) {
	
	if (top.window.name == 'doc_view_window') {
		// La ventana ya esta abierta
		document.location='doc_view.asp?id_document=' + id_document;	
	} else {
		 showDocument(id_document,0);
	}
}


function fnexecSendEditor(id_document)
{
		try {
			form_send.doc_title.value = this.doc_title.value;
			form_send.mailTo.value =  this.mailTo.value;
			form_send.doc_resource.value = this.doc_resource.innerHTML;
		} catch(e) {}
		form_send.submit();
}

function fnControl(tagname,controltype)
{

    var objHTML = document.getElementsByTagName(tagname)
	var strValues_tmp = '';

    for(var i=1;i<objHTML.length;i++)
    {

	if((objHTML[i].type==controltype))
		{                              
			switch(controltype)
			{
			case 'checkbox':
				strValues_tmp = strValues_tmp + escape(objHTML[i].checked) + '@-|-@'
				break;
			case 'radio':
				strValues_tmp = strValues_tmp + escape(objHTML[i].checked) + '@-|-@'
				break;
				
			case 'text':
				strValues_tmp = strValues_tmp + escape(objHTML[i].value) + '@-|-@'
				break;
		
			case 'textarea':

				var controlName;
				controlName = 'o' + controltype + 'Editor'
				controlName = controlName.toString()

				//Filtramos que solo sea el control que necesitamos
				if((objHTML[i].name==controlName))
				{
				strValues_tmp = strValues_tmp + escape(objHTML[i].value) + '@-|-@'
				break;
				}
			}
		}
    }
    strValues = strValues + '&' + controltype + '=' + strValues_tmp
}

// ----------------------------------------------------
// JES 30 may 2002
// Funciones para el Menu Pull Down LOC100

	var lastMenu = new Object;
	var lastOver = new Object;
	var itemSelected = null; 
	var nodeSelected = null;
	var lastNodeSelected = null;

	function setFirst(id, objColor)
			 { 
 				if (!document.getElementsByTagName) return; 
 				var cols = document.getElementsByTagName("td"); 
					for (var i=0; i<cols.length ; i++) 
					{ 
						var col = cols[i]; 
						if (col.getAttribute("id") == id) 
						{
						col.style.backgroundColor= objColor;
						}					
					} 
			
			} 


	function nodeClick (obj, objColor){
		if (nodeSelected != null) // nodeSelected not null 
		{
			if (nodeSelected != obj) // se selecciona otro nodo
			{
				lastNodeSelected = nodeSelected;				
				nodeSelected = obj;
				nodeMouseOut(lastNodeSelected); 
				obj.style.backgroundColor= objColor;
			}
		}
		else // nodeSelected == null no hay nodo seleccionado
		{
			nodeSelected = obj;
			lastNodeSelected = nodeSelected;
			obj.style.backgroundColor= objColor;
		}
	
	}
	function nodeMouseOut(obj){
		if (obj != nodeSelected)
		{		
		obj.style.backgroundColor='transparent'; 
	}
		}
	
	function setItem (obj){
		if ((itemSelected == null)||(itemSelected != obj))
		{
		showMenu(obj);
		itemSelected = obj;
		}
	}
	
	function showMenu(obj) {

		try { lastMenu.style.display = 'none'; } catch(e) {}
		objchild = eval('ch' + obj.id);
		objchild.style.display='';
		//objchild.style.posWidth = obj.offsetWidth + 30;
		objchild.style.width = 750;
		objchild.style.posTop = 24;
		//objchild.style.posLeft =0;
		objchild.style.posLeft = 0 - obj.offsetLeft;
		lastMenu = objchild;
		
	}

	function overMenu(obj) {
		
		lastOver.className = 'l100_child_name';
		lastOver = obj;
		obj.className = 'l100_child_name_over';
		

	}

	function hideMenu() { try { lastMenu.style.display = 'none'; } catch(e) {} }
	
	
// FIN FUCIONES MENU PULL DOWN
// ----------------------------------------------------
