/*	
	Module: functions.js

	Funciones Genericas JScript

	Copyright (c) 2002, Miracle Consulting Group Inc.
	Mail: info@miracleconsulting.com   http://www.miracleconsulting.com
	
*/	

var doc_search_result;	// Flag en donde se almacena el returno id_document
						// de una busqueda de un documento
						
var frm_search_result;
var frm_thm_search_result;
var thm_msg_search_result;

function selectApplication(obj) {  // MAM
	win_select_App=openWindow('/resources/ext_applications.asp?obj=' + obj,350,250,null,null,'win_select_App',5,false,false,false);
}

function showUserAppFields(id_user,id_ext_application,id_ext_application_fields_inputname, fld_value_inputname)  {  // LGA
	win_input_app_fields=openWindow('/structure/str_user_ext_app_fields.asp?id_user='+id_user+'&id_ext_application='+id_ext_application+'&id_ext_application_fields_inputname='+
id_ext_application_fields_inputname+'&fld_value_inputname='+fld_value_inputname,350,250,null,null,'win_input_app_fields',5,false,false,false);
}



function mbx_search() {
	win_search_mbx = openWindow('/Modules/mailbox/mbx_search.asp',600,450,null,null,'win_search_frm',5,false,false,false);
}

function searchDocument() { // JES
	// El valor de retorno se almacena en doc_search_result
	win_select_Document=openWindow('/document/doc_search.asp?mode=1',600,450,null,null,'win_select_Document',5,false,false,false);
}

function secOrder() {
	// Se abre la ventana del ordenamiento de secciones
	openWindow('sec_order.asp',600,450,null,null,'sec_order',5,false,false,false);
}

function selectCompany() { // JES
	win_select_Company=openWindow('/Structure/Company_Relation/',350,250,null,null,'win_select_Company',5,false,false,false);
}
function selectAttributes() {   // JES
	win_select_Attributes=openWindow('/Attributes/',450,350,null,null,'win_select_Attributes',5,false,false,false);
}

function selectModule(obj) {  // JES
	win_select_Module=openWindow('/sections/sec_modules_list.asp?obj=' + obj,550,500,null,null,'win_select_Module',5,false,false,false);
}

function selectContent(obj) {  // JES
	return window.showModalDialog('/contents/con_contents_list.asp',null,'DialogHeight:350px;DialogWidth:300px;help:no;scroll:no;status:no');
}

function selectDocument(obj,modal) {  // JES
	// El valor de retorno se almacena en doc_search_result
	if (modal) {
		return window.showModalDialog('/document/doc_search.asp?mode=3&obj=',null,'DialogHeight:450px;DialogWidth:600px;help:no;scroll:no;status:no');
	} else {
		win_select_Document=openWindow('/document/doc_search.asp?mode=0&obj=' + obj,600,450,null,null,'win_select_Document',5,false,false,false);
	}
}

function insertDocument() {  // JES
	// Funcion para insertar documento desde el editor..
	win_select_Document=openWindow('/document/doc_search.asp?mode=2&obj=' + obj,600,450,null,null,'win_select_Document',5,false,false,false);
}

function showEditor() {  // JES
	// El valor de retorno se almacena en doc_search_result
	win_Editor=openWindow('/editor2/',850,650,null,null,'win_Editor',5,true,false,false);
}


var dateSelected = '';

function showColorBox(obj) {  // LGA
	win_ColorBox=openWindow('/resources/colorbox.asp?Page=BODY&Form=form1&Element=' + obj.name ,650,140,null,null,'win_Color',5,false,false,false);
}


function showCalendar(obj) {  // JES
	win_Calendar=openWindow('/resources/calendar_acc.asp?obj=' + obj.name,180,160,null,null,'win_Calendar',5,false,false,false);
}

function showImage(file_name) {  // JRO
	//win_Image=openWindow('/resources/Image_preview.asp?fle_filename=' + file_name,280,260,null,null,'win_Image_Preview',5,true,false,false);
	win_Image=openWindow('/Files/fle_preview.asp?fle_filename=' + file_name,280,260,null,null,'win_Image_Preview',5,true,false,false);
}

function selectImage(obj) {  // JES
	result = window.showModalDialog("/files/?fle_type=1",null,"dialogHeight:450px; dialogWidth: 550px; center: Yes; help: No; scroll:No; status: No");
	try {
		if (((result != 'none') || (result != 'undefined')) && (result))
				 obj.value = result;
		
	} catch (e) { return result; } 
}

function selectFotoUsr(obj) {  // JES
	result = window.open("/portal/files/swfUpload/usrFoto.asp",null,"dialogHeight:450px; dialogWidth: 550px; center: Yes; help: No; scroll:No; status: No");
	try {
		if (((result != 'none') || (result != 'undefined')) && (result))
				 obj.value = result;
		
	} catch (e) { return result; } 
}

function selectDlwFile(obj) {  // GPA (select file to download)
	result = window.showModalDialog("/files/?fle_type=2",null,"dialogHeight:450px; dialogWidth: 550px; center: Yes; help: No; scroll:No; status: No");
	result = '../storage/'+result;
	try {
		if (((result != 'none') || (result != 'undefined')) && (result))
				 obj.value = result;
	} catch (e) { return result; } 
}

function selectFile(obj) {  // JES
	result = window.showModalDialog("/files/?fle_type=2",null,"dialogHeight:450px; dialogWidth: 550px; center: Yes; help: No; scroll:No; status: No");
		if ((obj) && (result) && (result != 'none')) obj.value = result;
}

function showFile() {  // JES
	result = window.showModalDialog("/files/?fle_type=1",null,"dialogHeight:450px; dialogWidth: 550px; center: Yes; help: No; scroll:No; status: No");
}

function selectUser(obj) {  // JES
	result = openWindow("/Management/user/usr_search.asp?obj=" + obj,600,450,null,null,'win_select_Document',5,false,false,false);
		if ((obj) && (result) && (result != 'none')) obj.value = result;
}

//Abre la ventana de busqueda de comentarios a documentos
function doc_comm_search() {

	// El valor de retorno se almacena en win_search_comm_Document
	win_search_comm_Document=openWindow('/document/document_comment/doc_comm_search.asp',600,450,null,null,'win_search_comm_Document',5,false,false,false);

}


function selectWorkflowTemplate() {
	win_search_workflow_template=openWindow('/modules/workflow/flw_search.asp',600,450,null,null,'win_search_workflow_template',5,false,false,false);
}

function wizardWorkflowTemplate() {
	win_search_workflow_template=openWindow('/modules/workflow/flw_wizard1.asp',640,480,null,null,'win_search_workflow_template',5,false,false,false);
}

function wizardCodificacion() {
	win_wizard_code=openWindow('/modules/Doc_Code/doc_code_wizard1.asp',600,450,null,null,'win_wizard_code',5,false,false,false);
}

function showWorkflowTemplate(nro, name) {
	win_workflow_template=openWindow('/modules/workflow/flw_chart.asp?FKValue=' + nro + '&FKName=' + name,600,450,null,null,'win_workflow_template',5,false,false,false);	
}

function sendWorkflowComent(value1,value2) {  // JES
		return window.showModalDialog('/portal/modules/workflow/flw_popup_coment.asp?estado=' + value1 + "&id_tarea=" + value2 ,null,'DialogHeight:170px;DialogWidth:450px;help:no;scroll:no;status:no');
}

function isNumber(num) {
	if(!/^(\+|-)?(([1-9]\d*\.?\d{0,2})|(0?\.\d{0,2}))$/.test(num)){
			return false;
		} else return true;
}
/*
function openWindow(u,W,H,X,Y,n,b,x,m,r) {

	var cU  ='/images/window/close_up.gif'
	var cO  ='/images/window/close_ovr.gif'
	var cL  ='/images/window/clock.gif'
	var mU  ='/images/window/min_up.gif'
	var mO  ='/images/window/min_ovr.gif'
	var xU  ='/images/window/max_up.gif'
	var xO  ='/images/window/max_ovr.gif'
	var rU  ='/images/window/res_up.gif'
	var rO  ='/images/window/res_ovr.gif'
	var tH  ='<font face=verdana size=1 color=white>&nbsp;&nbsp;Portal Financiero</font>'
	var tW  ='&nbsp;&nbsp;Portal Financiero'
	var wB  ='#847BA6'
	var wBs ='#847BA6'
	var wBG ='#847BA6'
	var wBGs='#847BA6'
	var wNS ='toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0'
	var fSO ='scrolling=no noresize'
	var brd =b||0;
	var max =x||false;
	var min =m||false;
	var res =r||false;
	var tsz =20;
	return chromeless(u,n,W,H,X,Y,cU,cO,cL,mU,mO,xU,xO,rU,rO,tH,tW,wB,wBs,wBG,wBGs,wNS,fSO,brd,max,min,res,tsz)
}
*/


