function gt(seccion){
	document.getElementById('s1').value = seccion;
	document.getElementById('form_seccion').submit();
}
function gt2(seccion,id){
	document.getElementById('s1').value = seccion;
	document.getElementById('id1').value = id;
	document.getElementById('form_seccion').submit();
}
function gt2b(seccion,id){
	document.getElementById('s1').value = seccion;
	document.getElementById('id2').value = id;
	document.getElementById('form_seccion').submit();
}
function gt3(seccion,id,id2){
	document.getElementById('s1').value = seccion;
	document.getElementById('id1').value = id;
	document.getElementById('id2').value = id2;
	document.getElementById('form_seccion').submit();
}
function gt4(seccion1,seccion2,id1){
	document.getElementById('s1').value = seccion1;
	document.getElementById('s2').value = seccion2;
	document.getElementById('id1').value = id1;
	document.getElementById('criterio1').value = document.getElementById('nombre').value;
	document.getElementById('criterio2').value = document.getElementById('apellidos').value;
	document.getElementById('criterio3').value = document.getElementById('dni').value;
	document.getElementById('form_seccion').submit();
}
function gtpage(seccion,pag){
	document.getElementById('s1').value = seccion;
	document.getElementById('pag').value = pag;
	document.getElementById('form_seccion').submit();
}
function gtpage2(seccion,id1,pag,orden,inc){
	document.getElementById('s1').value = seccion;
	document.getElementById('pag').value = pag;
	document.getElementById('id1').value = id1;
	document.getElementById('orden').value = orden;
	document.getElementById('inc').value = inc;
	document.getElementById('form_seccion').submit();
}
function duplicar(id){
	if(window.confirm('Haga click en aceptar si realmente desea duplicar este foro.'))
		{
		document.getElementById('id1').value = id;
		document.getElementById('form_seccion').action = 'acc/dupforo.php';
		document.getElementById('form_seccion').submit();
		document.getElementById('form_seccion').action = 'index.php';
		}
}
function listar(seccion,id,orden,inc){
	document.getElementById('s1').value = seccion;
	document.getElementById('id1').value = id;
	document.getElementById('orden').value = orden;
	document.getElementById('inc').value = inc;
	document.getElementById('form_seccion').submit();
}
function gtenlace(id,str){
	document.getElementById('s1').value = str;
	document.getElementById('id1').value = id;
	document.getElementById('form_seccion').action = 'acc/enlazar.php';
	document.getElementById('form_seccion').submit();
	document.getElementById('form_seccion').action = 'index.php';
}
function gtbk(id){
	document.getElementById('id1').value = id;
	document.getElementById('form_seccion').action = 'list_gral.php';
	document.getElementById('form_seccion').target = '_blank';
	document.getElementById('form_seccion').submit();
	document.getElementById('form_seccion').target = '_self';
	document.getElementById('form_seccion').action = 'index.php';
}
function cAsist(id,idin){
	document.getElementById('id1').value = id;
	document.getElementById('id2').value = idin;
	document.getElementById('form_seccion').action = 'print_asist.php';
	document.getElementById('form_seccion').target = '_blank';
	document.getElementById('form_seccion').submit();
	document.getElementById('form_seccion').target = '_self';
	document.getElementById('form_seccion').action = 'index.php';
}
function cPanel(id,idin){
	document.getElementById('id1').value = id;
	document.getElementById('id2').value = idin;
	document.getElementById('form_seccion').action = 'print_panel.php';
	document.getElementById('form_seccion').target = '_blank';
	document.getElementById('form_seccion').submit();
	document.getElementById('form_seccion').target = '_self';
	document.getElementById('form_seccion').action = 'index.php';
}
function cPonent(id,idin){
	document.getElementById('id1').value = id;
	document.getElementById('id2').value = idin;
	document.getElementById('form_seccion').action = 'print_ponent.php';
	document.getElementById('form_seccion').target = '_blank';
	document.getElementById('form_seccion').submit();
	document.getElementById('form_seccion').target = '_self';
	document.getElementById('form_seccion').action = 'index.php';
}
function cCredit(id,idin){
	document.getElementById('id1').value = id;
	document.getElementById('id2').value = idin;
	document.getElementById('form_seccion').action = 'print_credit.php';
	document.getElementById('form_seccion').target = '_blank';
	document.getElementById('form_seccion').submit();
	document.getElementById('form_seccion').target = '_self';
	document.getElementById('form_seccion').action = 'index.php';
}
function cPaneles(id,idin){
	document.getElementById('id1').value = id;
	document.getElementById('id2').value = idin;
	document.getElementById('form_seccion').action = 'print_paneles.php';
	document.getElementById('form_seccion').target = '_blank';
	document.getElementById('form_seccion').submit();
	document.getElementById('form_seccion').target = '_self';
	document.getElementById('form_seccion').action = 'index.php';
}
function cCurso(id,pi,f){
	document.getElementById('id1').value = id;
	document.getElementById('id2').value = pi;
	document.getElementById('id3').value = f;
	document.getElementById('form_seccion').action = 'print_curso.php';
	document.getElementById('form_seccion').target = '_blank';
	document.getElementById('form_seccion').submit();
	document.getElementById('form_seccion').target = '_self';
	document.getElementById('form_seccion').action = 'index.php';
}
function cImp(id,idc){
	document.getElementById('id1').value = id;
	document.getElementById('id2').value = idc;
	document.getElementById('form_seccion').action = 'print_imp.php';
	document.getElementById('form_seccion').target = '_blank';
	document.getElementById('form_seccion').submit();
	document.getElementById('form_seccion').target = '_self';
	document.getElementById('form_seccion').action = 'index.php';
}
function list_inv(id){
	document.getElementById('id1').value = id;
	document.getElementById('form_seccion').action = 'list_inv.php';
	document.getElementById('form_seccion').target = '_blank';
	document.getElementById('form_seccion').submit();
	document.getElementById('form_seccion').target = '_self';
	document.getElementById('form_seccion').action = 'index.php';
}
function list_cursos(id){
	document.getElementById('id1').value = id;
	document.getElementById('form_seccion').action = 'list_cursos.php';
	document.getElementById('form_seccion').target = '_blank';
	document.getElementById('form_seccion').submit();
	document.getElementById('form_seccion').target = '_self';
	document.getElementById('form_seccion').action = 'index.php';
}
function list_ponent(id){
	document.getElementById('id1').value = id;
	document.getElementById('form_seccion').action = 'list_ponent.php';
	document.getElementById('form_seccion').target = '_blank';
	document.getElementById('form_seccion').submit();
	document.getElementById('form_seccion').target = '_self';
	document.getElementById('form_seccion').action = 'index.php';
}
function etiquetas(id,tab){
	document.getElementById('id1').value = id;
	document.getElementById('id2').value = tab;
	document.getElementById('form_seccion').action = 'print_etiquetas.php';
	document.getElementById('form_seccion').target = '_blank';
	document.getElementById('form_seccion').submit();
	document.getElementById('form_seccion').target = '_self';
	document.getElementById('form_seccion').action = 'index.php';
}
function chapas(id,tab){
	document.getElementById('id1').value = id;
	document.getElementById('id2').value = tab;
	document.getElementById('form_seccion').action = 'print_chapas.php';
	document.getElementById('form_seccion').target = '_blank';
	document.getElementById('form_seccion').submit();
	document.getElementById('form_seccion').target = '_self';
	document.getElementById('form_seccion').action = 'index.php';
}
function emails(id,tab){
	document.getElementById('id1').value = id;
	document.getElementById('id2').value = tab;
	document.getElementById('form_seccion').action = 'generar_emails.php';
	document.getElementById('form_seccion').target = '_blank';
	document.getElementById('form_seccion').submit();
	document.getElementById('form_seccion').target = '_self';
	document.getElementById('form_seccion').action = 'index.php';
}
function dis(){//HABILITA O DESHABILITA EL INPUT PARA SUBIR LOGO
	if(document.getElementById('logousc').checked ==true){
		document.getElementById('logo').disabled = true;
	}else{
		document.getElementById('logo').disabled = false;
		}
}
function ini(){
	if(document.getElementById('editinv')!=null){
		verpaneles(document.getElementById('editinv'));
		vertarifas(document.getElementById('editinv'));
	}
	if(document.getElementById('form_editforo')!=null){
		vertrans(document.getElementById('form_editforo'));
		vertrans2(document.getElementById('form_editforo'));
	}
}
function verpaneles(f){//HABILITA O DESHABILITA EL FORMULARIO PANELISTA
	if(f.panelista.checked==true){
		x=false;
		color='#FFFF99';
		verpanel(1);
	}
	else if(f.panelista.checked==false){
		x=true;
		color='#CCCCCC';
		ocultar();
	}
	document.getElementById('titulo_cartel1').style.backgroundColor= color;
	document.getElementById('titulo_cartel2').style.backgroundColor= color;
	document.getElementById('titulo_cartel3').style.backgroundColor= color;
}
function verpanel(num){//MUESTRA EL PANEL SELECCIONADO Y OCULTA EL RESTO
	if(document.getElementById('panelista').checked==true){
		if(document.getElementById('cartel'+num).style.display='none'){
			ocultar();
			document.getElementById('cartel'+num).style.display='block';
		}
	}
}

function ocultar(){
	document.getElementById('cartel1').style.display='none';
	document.getElementById('cartel2').style.display='none';
	document.getElementById('cartel3').style.display='none';
}
function vertarifas(f){//MUESTRA U OCULTA TARIFAS
	if(f.formapago.value=='1'){
		f.trans.style.display='none';
		f.recibo.style.display='none';
		document.getElementById('tabla_recibo').style.display='none';
		f.efectivo.style.display='none';
	}
	else if(f.formapago.value=='2'){
		f.trans.style.display='block';
		f.recibo.style.display='block';
		document.getElementById('tabla_recibo').style.display='block';
		f.efectivo.style.display='none';
	}
	else if(f.formapago.value=='4'){
		f.trans.style.display='none';
		f.recibo.style.display='none';
		document.getElementById('tabla_recibo').style.display='none';
		f.efectivo.style.display='block';
	}
}
function vertrans(f){//HABILITA O DESHABILITA LOS FORMULARIOS DE TRANSFERENCIA BANCARIA
	if(f.activa1.checked==true){
		xdisabled=false;
		color='#FFFFCC';
	}
	else if(f.activa1.checked==false){
		xdisabled=true;
		color='#CCCCCC';
		if(f.cuenta_euro[1].checked==false)
			f.cuenta_euro[0].checked=true;
	}
	f.banco.disabled = xdisabled;
	f.banco.style.backgroundColor = color;
	f.cuenta.disabled = xdisabled;
	f.cuenta.style.backgroundColor = color;
	f.detalle.disabled = xdisabled;
	f.detalle.style.backgroundColor = color;
	f.cuenta_euro[0].disabled = xdisabled;
	f.cuenta_euro[0].style.backgroundColor = color;
	f.cuenta_euro[1].disabled = xdisabled;
	f.cuenta_euro[1].style.backgroundColor = color;
}
function vertrans2(f){//HABILITA O DESHABILITA LOS FORMULARIOS DE TRANSFERENCIA BANCARIA
	if(f.activa2.checked==true){
		xdisabled=false;
		color='#FFFFCC';
	}
	else if(f.activa2.checked==false){
		xdisabled=true;
		color='#CCCCCC';
	}
	f.banco_iban.disabled = xdisabled;
	f.banco_iban.style.backgroundColor = color;
	f.cuenta_iban.disabled = xdisabled;
	f.cuenta_iban.style.backgroundColor = color;
	f.bic_iban.disabled = xdisabled;
	f.bic_iban.style.backgroundColor = color;
	f.detalle_iban.disabled = xdisabled;
	f.detalle_iban.style.backgroundColor = color;

}
function delforo(id){// BORRAR USUARIO
	if(window.confirm('Haga click en aceptar si realmente desea eliminar este foro.'))
		if(window.confirm('¡Atención! Si sigue adelante no podrá recuperar la información eliminada. Haga click en aceptar si realmente desea eliminar este foro.'))
			{
			document.getElementById('id1').value = id;
			document.getElementById('s1').value = 'del';
			document.getElementById('form_seccion').action = 'acc/delforo.php';
			document.getElementById('form_seccion').submit();
			}
}
function deluser(id){// BORRAR USUARIO
	if(window.confirm('Haga click en aceptar si realmente desea eliminar este usuario.'))
		{
		document.getElementById('id2').value = id;
		document.getElementById('s1').value = 'del';
		document.getElementById('form_seccion').action = 'acc/accuser.php';
		document.getElementById('form_seccion').submit();
		}
}
function delinv(id,idin){// BORRAR USUARIO
	if(window.confirm('Haga click en aceptar si realmente desea eliminar este invitado.'))
		{
		document.getElementById('id1').value = id;
		document.getElementById('id2').value = idin;
		document.getElementById('s1').value = 'del';
		document.getElementById('form_seccion').action = 'acc/delinv.php';
		document.getElementById('form_seccion').submit();
		}
}

function delinsc(id,idinsc){// BORRAR USUARIO
	if(window.confirm('Haga click en aceptar si realmente desea eliminar este invitado.'))
		{
		document.getElementById('id1').value = id;
		document.getElementById('id2').value = idinsc;
		document.getElementById('s1').value = 'del';
		document.getElementById('form_seccion').action = 'acc/delinsc.php';
		document.getElementById('form_seccion').submit();
		}
}

function delmesa(id2,id1){//BORRAR MESA
	if(window.confirm('Haga click en aceptar si realmente desea eliminar esta mesa.'))
		{
		document.getElementById('id1').value = id1;
		document.getElementById('id2').value = id2;
		document.getElementById('s1').value = 'del';
		document.getElementById('form_seccion').action = 'acc/accmesa.php';
		document.getElementById('form_seccion').submit();
		}
	}
function delcurso_inv(id2,id1,id3){//BORRAR relacion curso invitado
	if(window.confirm('Haga click en aceptar si realmente desea quitar al inscrito de este curso.'))
		{
		document.getElementById('id1').value = id1;//foro
		document.getElementById('id2').value = id2;//invitado
		document.getElementById('id3').value = id3;//id_ci
		document.getElementById('s1').value = 'del';
		document.getElementById('form_seccion').action = 'acc2/acccursos_inv.php';
		document.getElementById('form_seccion').submit();
		}
	}
function saveInsc(f){
		f.action = 'acc2/acccursos_insc.php';
		f.submit();
}
function saveInv(f){
		f.action = 'acc2/acccursos_inv.php';
		f.submit();
}
function savePon(f){
		f.action = 'acc2/acccursos_pon.php';
		f.submit();
}

function delcurso_insc(id2,id1,id3){//BORRAR relacion curso invitado
	if(window.confirm('Haga click en aceptar si realmente desea quitar al inscrito de este curso.'))
		{
		document.getElementById('id1').value = id1;//foro
		document.getElementById('id2').value = id2;//invitado
		document.getElementById('id3').value = id3;//id_ci
		document.getElementById('s1').value = 'del';
		document.getElementById('form_seccion').action = 'acc2/acccursos_insc.php';
		document.getElementById('form_seccion').submit();
		}
	}

	
function delcurso_pon(id2,id1,id3){//BORRAR relacion curso invitado
	if(window.confirm('Haga click en aceptar si realmente desea quitar al ponente de este curso.'))
		{
		document.getElementById('id1').value = id1;//foro
		document.getElementById('id2').value = id2;//ponente
		document.getElementById('id3').value = id3;//id_cp
		document.getElementById('s1').value = 'del';
		document.getElementById('form_seccion').action = 'acc2/acccursos_pon.php';
		document.getElementById('form_seccion').submit();
		}
	}
function delcurso_i(id2,id1,id3){//BORRAR relacion curso invitado
	if(window.confirm('Haga click en aceptar si realmente desea quitar al inscrito de este curso.'))
		{
		document.getElementById('id1').value = id1;//foro
		document.getElementById('id2').value = id2;//ponente
		document.getElementById('id3').value = id3;//id_ci
		document.getElementById('s1').value = 'deli';
		document.getElementById('form_seccion').action = 'acc2/acccursos_curso.php';
		document.getElementById('form_seccion').submit();
		}
	}

function delcurso_in(id2,id1,id3){//BORRAR relacion curso invitado
	if(window.confirm('Haga click en aceptar si realmente desea quitar al inscrito de este curso.'))
		{
		document.getElementById('id1').value = id1;//foro
		document.getElementById('id2').value = id2;//ponente
		document.getElementById('id3').value = id3;//id_cinsc
		document.getElementById('s1').value = 'delinsc';
		document.getElementById('form_seccion').action = 'acc2/acccursos_curso.php';
		document.getElementById('form_seccion').submit();
		}
	}

function delcurso_p(id2,id1,id3){//BORRAR relacion curso invitado
	if(window.confirm('Haga click en aceptar si realmente desea quitar al ponente de este curso.'))
		{
		document.getElementById('id1').value = id1;//foro
		document.getElementById('id2').value = id2;//ponente
		document.getElementById('id3').value = id3;//id_cp
		document.getElementById('s1').value = 'delp';
		document.getElementById('form_seccion').action = 'acc2/acccursos_curso.php';
		document.getElementById('form_seccion').submit();
		}
	}
function delcurso(id2,id1){//BORRAR MESA
	if(window.confirm('Haga click en aceptar si realmente desea eliminar este curso.'))
		{
		document.getElementById('id1').value = id1;
		document.getElementById('id2').value = id2;
		document.getElementById('s1').value = 'del';
		document.getElementById('form_seccion').action = 'acc2/acccurso.php';
		document.getElementById('form_seccion').submit();
		}
	}
function delponente(id2,id1){//BORRAR PONENTE
if(window.confirm('Haga click en aceptar si realmente desea eliminar este ponente.'))
	{
	document.getElementById('id1').value = id1;
	document.getElementById('id2').value = id2;
	document.getElementById('s1').value = 'del';
	document.getElementById('form_seccion').action = 'acc/accpon.php';
	document.getElementById('form_seccion').submit();
	}
}
function delevento(id2){//BORRAR EVENTO
if(window.confirm('Haga click en aceptar si realmente desea eliminar este evento.'))
	{
	//document.getElementById('id1').value = id1;
	document.getElementById('id2').value = id2;
	document.getElementById('s1').value = 'del';
	document.getElementById('form_seccion').action = 'acc/accevento.php';
	document.getElementById('form_seccion').submit();
	}
}

function deltarifa(id2,id1){//BORRAR TARIFA
	if(window.confirm('Haga click en aceptar si realmente desea eliminar esta tarifa.'))
		{
		document.getElementById('id1').value = id1;
		document.getElementById('id2').value = id2;
		document.getElementById('s1').value = 'del';
		document.getElementById('form_seccion').action = 'acc/acctarifa.php';
		document.getElementById('form_seccion').submit();
		}
	}
function VF(f){//VALIDAR FORMULARIO 'CREAR FORO'
	if(trim(f.titulo_01.value)=='')
		window.alert('El campo \'Titulo 1\' es obligatorio.')
	else if(f.activa1.checked==true & (trim(f.banco.value)=='' || trim(f.cuenta.value)=='' || trim(f.detalle.value)==''))
		window.alert('La casilla \'Transferencia bancaria\' está activada. Los campos \'Banco\' y \'Cuenta\' son obligatorios.')
	else if(f.activa2.checked==true & (trim(f.banco_iban.value)=='' || trim(f.cuenta_iban.value)=='' ||trim(f.bic_iban.value)==''))
		window.alert('La casilla \'Transferencia bancaria internacional\' está activada. Los campos \'Banco\', \'Cuenta\' y \'Bic\' son obligatorios.')
	else if(trim(f.lugar.value)=='')
		window.alert('El campo \'Lugar\' es obligatorio.')
	else
		f.submit();
	}
function VU(f){//VALIDAR FORMULARIO 'CREAR USUARIO'
	if(trim(f.usuario.value)=='')
		window.alert('El campo \'Usuario\' es obligatorio.');
	else if(trim(f.clave.value)=='')
		window.alert('El campo \'Clave\' es obligatorio.');
	else
		f.submit();
	}

function VI(f){//VALIDAR FORMULARIO 'CREAR INVITADO'
	if(trim(f.nombre.value)=='')
		window.alert('El campo \'Nombre\' es obligatorio.');
	else
		f.submit();
	}
function VInsc(f){//VALIDAR FORMULARIO 'CREAR INSCRIPCION'
	if(trim(f.nombre.value)=='')
		window.alert('El campo \'Nombre\' es obligatorio.');
	else
		f.submit();
	}
function VInsc2(f){//VALIDAR FORMULARIO 'CREAR INSCRIPCION'
	if(trim(f.nombre.value)=='')
		window.alert('El campo \'Nombre\' es obligatorio.');
	else
		f.submit();
	}
function VP(f){//VALIDAR FORMULARIO 'CREAR PONENTE'
	if(trim(f.nombre.value)=='')
		window.alert('El campo \'Nombre\' es obligatorio.');
	else
		f.submit();
	}
function VI2(f){//VALIDAR FORMULARIO 'EDITAR INVITADO'
	if(trim(f.nombre.value)=='')
		window.alert('El campo \'Nombre\' es obligatorio.');
	else if(f.formapago.value==1 & f.pagado.value=='si')
		window.alert('Debe especificar una forma de pago.');
	//else if(trim(f.panelista.checked==true) & trim(f.titulo1.value))
	else
		f.submit();
	}

function VM(f){//VALIDAR FORMULARIO 'CREAR MESA'
	if(trim(f.mesa.value)=='')
		window.alert('El campo \'Mesa\' es obligatorio.');
	else if(trim(f.fecha.value)=='')
		window.alert('El campo \'Fecha\' es obligatorio.');
	else if(trim(f.hora.value)!='' & (num(trim(f.hora.value)) & (trim(f.hora.value) > 23 || trim(f.hora.value) < 0) || !num(trim(f.hora.value))))
		window.alert('El campo \'Hora\' acepta valores entre 0 y 23.');
	else if(trim(f.minutos.value)!='' & (num(trim(f.minutos.value)) & (trim(f.minutos.value) > 59 || trim(f.minutos.value) < 0) || !num(trim(f.minutos.value))))
		window.alert('El campo \'Minutos\' acepta valores entre 0 y 59.');
	else
		f.submit();
	}

function VC(f){//VALIDAR FORMULARIO 'CREAR CURSO'
	if(trim(f.titulo.value)=='')
		window.alert('El campo \'Título\' es obligatorio.');
	else if(trim(f.tipo.value)=='')
		window.alert('El campo \'Tipo\' es obligatorio.');
	else if(trim(f.fecha.value)=='')
		window.alert('El campo \'Fecha\' es obligatorio.');
	else if(trim(f.hora.value)!='' & (num(trim(f.hora.value)) & (trim(f.hora.value) > 23 || trim(f.hora.value) < 0) || !num(trim(f.hora.value))))
		window.alert('El campo \'Hora\' acepta valores entre 0 y 23.');
	else if(trim(f.minutos.value)!='' & (num(trim(f.minutos.value)) & (trim(f.minutos.value) > 59 || trim(f.minutos.value) < 0) || !num(trim(f.minutos.value))))
		window.alert('El campo \'Minutos\' acepta valores entre 0 y 59.');
	else
		f.submit();
	}
	
function VT(f){//VALIDAR FORMULARIO 'CREAR TARIFA'
	if(!num(trim(f.importe_euro.value)))
		window.alert('El campo \'Importe (Euros)\' es obligatorio y acepta valores entre 1 y 999.');
	else
		f.submit();
	}
function busca(f){
	if(trim(f.nombre.value)=='' & trim(f.apellidos.value)=='' & trim(f.dni.value)=='')
		window.alert('Debe introducir algun criterio de búsqueda.');
	else
		f.submit();
}
function pulsar(e,f) {
	tecla = (document.all) ? e.keyCode :e.which;
	if (tecla==13){
		busca(f);
	}
}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
///////////////      FUNCIONES UTILES      ////////////////////////
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
function textCounter(field, maxlimit){
	if (field.value.length > maxlimit)
		field.value = field.value.substring(0, maxlimit);
	}
function num(x)
	{
	x = parseInt(x);
	if(isNaN(x))
		return false;
	else
		return true;
	}
function trim( str )
	{
	var Str2 = "";
	Str2 = TrimLeft(str);
	Str2 = TrimRight(Str2);
	return Str2;
	}
function TrimLeft( str ) {
	var resultStr = "";
	var i = len = 0;

	if (str+"" == "undefined" || str == null)	
		return null;

	str += "";

	if (str.length == 0) 
		resultStr = "";
	else {	
		len = str.length;
		
  		while ((i <= len) && (str.charAt(i) == " "))
			i++;
  		resultStr = str.substring(i, len);
  	}

  	return resultStr;
}

function TrimRight( str ) {
	var resultStr = "";
	var i = 0;

	if (str+"" == "undefined" || str == null)	
		return null;

	str += "";
	
	if (str.length == 0) 
		resultStr = "";
	else {

  		i = str.length - 1;
  		while ((i >= 0) && (str.charAt(i) == " "))
 			i--;

  		resultStr = str.substring(0, i + 1);
  	}
  	
  	return resultStr;  	
}
