function obtener_ancho()
{
	if (navigator.userAgent.indexOf("MSIE") > 0)
	{
		return(document.body.clientWidth);
	}
	else
	{
		return window.outerWidth;
	}
}
	
function obtener_alto()
{
	if (navigator.userAgent.indexOf("MSIE") > 0)
	{
		return(document.body.clientHeight);
	} 
	else
	{
		return(window.outerHeight);
	}
}


function highLight(objeto)
{
	objeto.style.backgroundColor="#FFFCD8";
}

function normalLight(objeto,color)
{
	objeto.style.backgroundColor=color;
}

function win_Search(fullUrl)
{
	var miPopup;
	var options = "menubar=0,location=0,scrollbars,resizable,width=800,height=400";
	miPopup = window.open("../scripts/mps_search.php?" + fullUrl,"win_Search",options);
	return miPopup;
}

/*
Muestra una pantalla para seleccioanr un registro de la base de datos
onclick="win_Buscar('OBJETO','NUMERO DE COLUMNAS','CAMPOS','TABLA');"
onclick="win_Buscar('OBJETO','NUMERO DE COLUMNAS','CAMPOS','TABLA','CONDICI�N');"
onclick="win_Buscar('OBJETO','NUMERO DE COLUMNAS','CAMPOS','TABLA','ORDENAMIENTO');"
onclick="win_Buscar('OBJETO','NUMERO DE COLUMNAS','CAMPOS','TABLA','AGRUPACI�N');"
onclick="win_Buscar('OBJETO','NUMERO DE COLUMNAS','CAMPOS','TABLA','CONDICI�N','ORDENAMIENTO','AGRUPACI�N');"
onclick="win_Buscar('OBJETO','NUMERO DE COLUMNAS','CAMPOS','TABLA','CONDICI�N','ORDENAMIENTO',);"

<input onclick="win_Buscar('AURLID','1','USUNOM','USU','','USUNOM');" type=button value=+  />
*/
function win_Buscar(HWD)
{
	var URL = "../scripts/mps_search.php?objeto=" + HWD;
	var miPopup;
	var options = "menubar=0,location=0,scrollbars,resizable,width=800,height=400";

	if(arguments.length > 1) URL  = URL + "&COLS=" + arguments[1];
	if(arguments.length > 2) URL  = URL + "&F=" + arguments[2];
	if(arguments.length > 3) URL  = URL + "&T=" + arguments[3];
	if(arguments.length > 4) if (arguments[4].length > 0) URL  = URL + "&W=" + arguments[4];
	if(arguments.length > 5) if (arguments[5].length > 0) URL  = URL + "&O=" + arguments[5];
	if(arguments.length > 6) if (arguments[6].length > 0) URL  = URL + "&G=" + arguments[6];

	miPopup = window.open(URL ,"win_Buscar",options);
	miPopup.focus();
	return miPopup;
}

	/*
	Abre una ventana PoUp, Ancho y alto opcionales
	onClick="win_Open('URL')"
	onClick="win_Open('URL',WIDTH)"
	onClick="win_Open('URL',WIDTH,HEIGHT)"
	*/
	function win_Open(URL)
	{
		// Par�metros opcionales: width y height
		var width  = 870;
		var height = 400;
		if(arguments.length > 1) width  = arguments[1];
		if(arguments.length > 2) height = arguments[2];

		//var options = "menubar=0,location=0,scrollbars,resizable,width=800,height=400";
		//miPopup = window.open(fullUrl,winName,options);	
		var day = new Date();
		var winName = day.getTime();
		var popup = new Object()
		var X = obtener_ancho() / 2;
		var Y = obtener_alto() / 2;
		popup = window.open(URL,
			winName, 
			' scrollbars=yes ' +
			',resizable ' +
			',menubar=0 ' +
			',width=' + width +
			',height=' + height +
			',top=' + (window.screenTop + (Y - (height/2))) +
			',left=' + (window.screenLeft + (X - (width/2)))
			);
		popup.focus();
		return popup;
		}

	function win_GET(i)
		{
		cadVariables = location.search.substring(1,location.search.length);
		arrVariables = cadVariables.split("&");
		arrVariableActual = arrVariables[i].split("=");
		//if (isNaN(parseFloat(arrVariableActual[1])))
		//	eval(arrVariableActual[0]+"='"+unescape(arrVariableActual[1])+"';");
		//else
		//	eval(arrVariableActual[0]+"="+arrVariableActual[1]+";");
		return arrVariableActual[1];
		}

	function _GET(variable)
		{ 
		var remplaza = /\+/gi; 
		var url = window.location.href;
		
		url = unescape(url);
		url = url.replace(remplaza, " ");
		//url = url.toUpperCase();			
		
		//var variable_may = variable.toUpperCase();
		var variable_may = variable;
		var variable_pos = url.indexOf(variable_may);
		
		if (variable_pos != -1)
		{
			var pos_separador = url.indexOf("&", variable_pos);
			
			if (pos_separador != -1)
			{
				return url.substring(variable_pos + variable_may.length + 1, pos_separador);
			} else
			{
				return url.substring(variable_pos + variable_may.length + 1, url.length);
			}
			
		} else 
		{
			return "";
		}
		}

	function set_value(txt)
		{ 
		//alert(win_GET(0));
		//alert(_GET('objeto'));
		//window.opener.document.getElementById(_GET('objeto')).value = txt;
		window.opener.document.forms[0].elements[_GET('objeto')].value = txt;
		window.opener.focus();
		window.close();
		return 0;
		}

	/*
	Eliminar un registro, pregunta antes de eliminar.
	onClick="win_confirm('URL')"
	*/
	function win_confirm(fullUrl)
		{
		var Msg = "Deseas eliminar el elemento seleccionado";
		if(arguments.length > 1) Msg = arguments[1];
		if (confirm(Msg)) document.location.href=fullUrl; 
		}
function win_close_n_reload()
	{
	opener.history.go(0);
	window.close();
	}
function win_redirect(fullUrl)
	{
	document.location.href=fullUrl; 
	}

	/*
	Elimina los espacios al inicio y al final de una cadena
	*/
	function trim(cadena)
	{
		for(i=0; i<cadena.length; )
		{
			if(cadena.charAt(i)==" ")
				cadena=cadena.substring(i+1, cadena.length);
			else
				break;
		}
	
		for(i=cadena.length-1; i>=0; i=cadena.length-1)
		{
			if(cadena.charAt(i)==" ")
				cadena=cadena.substring(0,i);
			else
				break;
		}
		
		forma.caja2.value=cadena;
	}

/*
	function trim(stringToTrim) {
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	}
	function ltrim(stringToTrim) {
		return stringToTrim.replace(/^\s+/,"");
	}
	function rtrim(stringToTrim) {
		return stringToTrim.replace(/\s+$/,"");
	}
*/

	/*
	Abre una ventana PoUp para buscar un archivo, Ancho y alto opcionales
	onClick="win_Open(targetField,'PATH')"
	onClick="win_Open(targetField,'PATH',WIDTH)"
	onClick="win_Open(targetField,'PATH',WIDTH,HEIGHT)"
	*/
	function win_searchFile(objeto,PATH)
	{
		// Par�metros opcionales: width y height
		var URL = "../scripts/mps_filesearch.php";
		var width  = 400;
		var height = 400;
		URL = URL + "?objeto="+objeto;
		URL = URL + "&dir="+PATH;
		if(arguments.length > 2) width  = arguments[1];
		if(arguments.length > 3) height = arguments[2];

		//var options = "menubar=0,location=0,scrollbars,resizable,width=800,height=400";
		//miPopup = window.open(fullUrl,winName,options);	
		var day = new Date();
		var winName = day.getTime();
		var popup = new Object()
		var X = obtener_ancho() / 2;
		var Y = obtener_alto() / 2;
		popup = window.open(URL,
			winName, 
			' scrollbars=yes ' +
			',resizable ' +
			',menubar=0 ' +
			',width=' + width +
			',height=' + height +
			',top=' + (window.screenTop + (Y - (height/2))) +
			',left=' + (window.screenLeft + (X - (width/2)))
			);
		popup.focus();
		return popup;
		}	function searchWorde(e,stext) 
	{
		tecla = (document.all) ? e.keyCode : e.which;
		if (tecla==13) 
		{
			searchWord(stext);
			
		}
	}	

	function searchWord(stext)
	{
		var salida = "";
		var texto = "";
		var coincide = 0;
		var filas=document.getElementById('contentTable').getElementsByTagName('tr');
		for(var i=0;i<filas.length;i++)    
		{
			filas[i].style.display='';
		}
		for(var i=0;i<filas.length;i++)    
		{
			coincide = 0;
			for (var j=0;j<document.getElementById('contentTable').rows[i].cells.length;j++)
			{
				salida = salida + texto.indexOf(stext) + " ";
				texto = document.getElementById('contentTable').rows[i].cells[j].innerHTML + '\n';
				if(texto.toUpperCase().indexOf(stext.toUpperCase()) > -1)
				{
					coincide = 1;
					j=5;
				}
			}
			salida = salida + " \n ";
			if(coincide == 0) filas[i].style.display='none';
		}		
	}

