
function left(str, n) {
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function right(str, n) {
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}


function abreVentana(URL_Ventana, nombreVentana, OpcionesVentana, Ancho, Alto, Centrada, PosX, PosY) {
	if (Centrada) {
		PosX = (screen.availWidth - Ancho)/2;
		PosY = (screen.availHeight - Alto)/2;
	}

	if (OpcionesVentana == '')
		OpcionesVentana = 'width=' + Ancho;
	else
		OpcionesVentana += ',width=' + Ancho;

	OpcionesVentana += ',height=' + Alto + ',left=' + PosX + ',top=' + PosY;
	return window.open(URL_Ventana, nombreVentana, OpcionesVentana);

}


function cierraVentana(objWin) {
	if (objWin!=0)
		if (!objWin.closed)
			objWin.close();
}


function trim(str) {
	return str.replace(/^\s*|\s*$/g,"");
}


function resize() {
	var h = e("contenedor").offsetHeight - e("cabecera").offsetHeight -	e("busqueda").offsetHeight;
	var marginTopContenedor = getStyle(e("contenedor"), "margin-top");
	var y = parseInt(marginTopContenedor);
	e("map").style.height = (h - y) + "px";
}

function verMsj(mensaje, color) {

	if (color == undefined || color == '') color = 'red';

	e('msjErr').firstChild.nodeValue = mensaje;
	e('msjErr').style.color = color;
	e('selDirecciones').style.display="none";
}

function borraMsj() {
	e('msjErr').firstChild.nodeValue = '';
}

