// 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.jsp 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(){

	if( typeof timer != 'undefined' ) {

		clearTimeout(timer); 

	}

}



// -------------





function openApplication(app_autologin,app_execute) {

	goLoc = "/portal/modules/extapplications/autosend.jsp?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.jsp',300,185,null,null,'win_search_frm',5,false,false,false);

}



function requestPassword() {

	requestPassword = openWindow('login_req_password.jsp',300,185,null,null,'requestPassword',5,false,false,false);

}



function showUserDataSheet(iduser) {

	userDataSheet = openWindow("/portal/user/user_datasheet.jsp?id_user=" +iduser ,450,210,null,null,'userDataSheet',5,false,false,false); //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.jsp";

}



function showUserData() {

	document.location="index.jsp?Module=UserData&page=user/user_data.jsp";

}



function showDocumentNotReaded() {

	document.location="index.jsp?Module=Documents&page=document/doc_list.jsp&doread=true";

}



function showSurveys() {

	document.location="index.jsp?Module=Survey&page=modules/survey/index.jsp";

}



function showLeave() {

	document.location="index.jsp?Module=Leave&page=modules/leave/index.jsp";

}





function listDocument(id_section,id_document) {

	goLocation = "index.jsp?Module=Documents&page=document/doc_list.jsp&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.jsp?id_template=' + id_template

showEditor()

}



function disableInputs() {

	/*oHTML = document.body.getElementsByTagName("INPUT")

	for(var i=0;i<oHTML.length;i++) oHTML[i].onchange = function() { return false } 

	for(var i=0;i<oHTML.length;i++) {

		if (oHTML[i].type != 'button') { oHTML[i].onclick = function() { return false }  }

	}*/

}



function listFaqs(id_section,id_faqs_tips) {

	goLocation = "index.jsp?Module=Faqs&page=modules/faqs/doc_list.jsp&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.jsp?Module=Sections&page=sections/sec_list.jsp&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.jsp?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.jsp&id_document=" + id_document;

}



function showSite(url) {

	document.location = "index.jsp?page=modules/centralsite/central_site.jsp&url=" + url;

}



function showMailbox() {

	document.location="index.jsp?page=modules/mailbox/index.jsp";

}



function changeUserRol() {

	document.location="index.jsp?page=user/user_change_rol.jsp";

}

function showExtApplications() {

	document.location="index.jsp?page=modules/extapplications/index.jsp";

}



function searchBirthday() {

	birthday_search = openWindow("modules/birthday/birthday_search.jsp",650,450,null,null,'birthday_search',5,false,false,false);

}



function ShowFaqs(id_faqs_tips, id_section)

{

	window.open('/portal/faqs_view.jsp?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 ShowExtAttachWindow(file_name)

{

	window.open('/storage/' + file_name,'Documentos','toolbar=yes, status=yes, dependent=yes, location=no, menubar=yes, scrollbars=yes, menubar=yes, width=800, height=600, left=10, top=10, resizable=yes');

}



function fnGoToSection(page,id_section) 	{

	if(page == '/portal/')

		{

		top.window.opener.location.href = '/portal/'

		}

	else

		{

		top.window.opener.location.href = 'index.jsp?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.jsp?id_document=' + id_document;	

	} else {

		 showDocument(id_document,0);

	}

}





function fnexecSendEditor()

{

	try {

		if( document.getElementById ) {

			form_send = document.getElementById( 'form_send' );

			doc_resource = document.getElementById( 'doc_resource' );

			mailTo = document.getElementById( 'mailTo' );

			doc_title = document.getElementById( 'doc_title' );

			setChildsValueAttr( doc_resource );

		} else {

		}	

	} catch( e ){

		//alert( 'Excepcion : ' + e );

	}



	if( form_send && doc_resource && mailTo && doc_title ) {

		try {

			form_send.doc_resource.value = doc_resource.innerHTML;

			form_send.doc_title.value = doc_title.value;

			form_send.mailTo.value = mailTo.value;



			// se quitan botones e imágenes del documento a enviar por mail

			form_send.doc_resource.value = form_send.doc_resource.value.replace( /(<img[^>]*>)|((<INPUT|<input)[^>]*value=(Enviar|"Enviar")[^>]*>)|(<INPUT[^>]*name=(mailTo|"mailTo")[^>]*>)/g, '' );

			// se inhabilitan campos input, select y textarea

			form_send.doc_resource.value = form_send.doc_resource.value.replace( /<input|<INPUT/g, '<INPUT readonly' );

			form_send.doc_resource.value = form_send.doc_resource.value.replace( /<select|<SELECT/g, '<SELECT disabled' ); 

			form_send.doc_resource.value = form_send.doc_resource.value.replace( /<textarea|<TEXTAREA/g, '<TEXTAREA readonly' ); 



		} catch(e) {

		//	alert( 'Ha ocurrido una excepcion: ' + e );

		}

		form_send.submit();

	}

}



/**

* This function sets all value attribute of the parent and its childs, having their id not null and not empty, to the element value.

*/

function setChildsValueAttr( parent ){

	if( parent ){

		if( parent.getAttribute && parent.setAttribute ){

			if( ( typeof parent.value != 'undefined' ) && ( parent.value != '' )){

				parent.setAttribute( 'value', parent.value );

			}

			if( ( typeof parent.selected != 'undefined' ) && ( parent.selected != false )){

				parent.setAttribute( 'selected', parent.selected );

			}

		}

		if( parent.childNodes ){

			var kids = parent.childNodes;

			for( var i = 0;i < kids.length; i++ ){

				setChildsValueAttr( kids[i] );

			}

		}

	}

}



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;



	function showMenu(obj) {

		clearTimer();

		try {

			if( (lastMenu.style != null ) && ( lastMenu.style.display != null ) ) {

				lastMenu.style.display = 'none';

			}

		} catch(e) {};

		objchild = document.getElementById( 'ch' + obj.id );

		objchild.style.display='';

		objchild.style.posWidth = obj.offsetWidth + 10;

		objchild.style.posTop = 20;

		objchild.style.posLeft =-4;



		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

// ----------------------------------------------------