function jtrim( str )

{

	if ( str == null )

		return null;



	return str.replace( /\s+$/, "" ).replace( /^\s+/, "" );

}



function TieneVacios(s)

{	var re, ini

	re = /\s/ig

	ini = s.search(re)

	if (ini != -1)

		{return 1}

	else

		{return 0}

}



function DeshabilitaCombo(cbo, iCodi) {



        var iIndex = cbo.selectedIndex;



        if (cbo.options[iIndex].value != iCodi) {

		alert('No es posible modificar este valor.');

		BuscarCombo(cbo, iCodi);

		return;

	}



}





function BuscarCombo(cbo, sCodi)

{

	var i;

	var indice;

	//alert(cbo.options.length);

	//alert(cbo.tagName);

	//alert(sCodi);

	

	if (cbo.tagName=="SELECT")

	{

		for (i=0; i < cbo.options.length; i++ ) 

		{

			if (cbo.options(i).value == sCodi ) 

			{

				cbo.options(i).selected = true;

				break;

			}

		}

	}

	else

	{

		for (i=0; i < cbo.ListCount; i++ ) 

		{

			if (cbo.List(i,1) == sCodi ) 

			{

				cbo.ListIndex = i;

				break;

			}

		}

	}

}





/******************************************************************************************

* Función: ValidarURL

* Descripción:

* El formato de la URL debe ser: 

* protocolo://host(:puerto)/path/ donde el :puerto es opcional

* 

* - protocolo (uno o más caracteres que no son :, seguidos por : [^:]+:

* - servidor (viene después de las dos barras, seguido por el puerto y los dos puntos o 

*     por la barra //[^:/]+

* - puerto, opcional (:([0-9]+))?

* - path (lo que sea que empiece con una barra) /.*

*******************************************************************************************/



function ValidarURL(sURL) {



	var sURLExp = /([^:]+):\/\/([^:\/]+)(:([0-9]+))?(\/.*)/;



	iDosPuntos = url.indexOf(":");

	sProtocolo = url.substr(0,iDosPuntos);



	if (sProtocolo == "http" || sProtocolo == "https") {

		if (!sURLExp.test(sURL)) {

			return false;

		}

	} else {

		alert("El protocolo debe ser http o https.");

		return false;

	}

	

	return true;

}



function ValidarSiNo(obj) {



	var sValor = obj.value.toUpperCase();



	if (sValor.length > 0) {

		if (sValor != 'N' && sValor != 'S') {

			alert("Debe ingresar (S/N)");

			obj.value = sValor;

			obj.focus()

		}

	}

}



function ValidarVirtualPath(obj) {



	var sPath = obj.value;



	if (sPath.length > 0) {

		if (!(sPath.charAt(0) == "/" && sPath.charAt(sPath.length - 1) != "/" && sPath.indexOf(" ") <= 0)) {

			alert("El directorio debe tener el formato /dir1/dir2/ + ... + /dirn");

			obj.focus()

		}

	}



}



function ValidarPathFisico(obj) 

{

	var sPath = obj.value;

}



function compararFechas( fecha1, fecha2, type )

{

	switch ( type )

	{

		case "dmy" :

		{

			sFecha1 = fecha1.substr( 6 ) + fecha1.substr( 3, 2 ) + fecha1.substr( 0, 2 );

			sFecha2 = fecha2.substr( 6 ) + fecha2.substr( 3, 2 ) + fecha2.substr( 0, 2 );

			break;

		}

		

		case "mdy" :

		{

			sFecha1 = fecha1.substr( 6 ) + fecha1.substr( 0, 2 ) + fecha1.substr( 3, 2 );

			sFecha2 = fecha2.substr( 6 ) + fecha2.substr( 0, 2 ) + fecha2.substr( 3, 2 );

			break;

		}

	}

	

	switch ( true )

	{

		case ( sFecha1 < sFecha2 ) : return 1;

		case ( sFecha1 == sFecha2 ) : return 0;

		case ( sFecha1 > sFecha2 ) : return -1;

	}

}





function hoy( type )

{

	var oDate = new Date();

	var sDate = "";

	var sDay = ( "00" + oDate.getDate() );

	sDay = sDay.substr( sDay.length - 2 );



	var sMonth = ( "00" + ( oDate.getMonth() + 1 ) );

	sMonth = sMonth.substr( sMonth.length - 2 );



	var sYear = oDate.getFullYear();



	switch ( type )

	{

		case "dmy" :

		{

			sDate = sDay + "/" + sMonth + "/" + sYear;

			break;

		}

		

		case "mdy" :

		{

			sDate = sMonth + "/" + sDay + "/" + sYear;

			break;

		}

	}

	

	return sDate;

}



function ValidarTelefono( value )

{

	var sNume = "";

	var sDigito;

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

	{

		sDigito = value.charAt( i );

		if ( !isNaN( sDigito ) )

			sNume += sDigito;

	}

	

	if ( sNume.length < 10 )

		return false;

	else

		return true;

}
