// JavaScript Document
function openImage(id_foto)
{
	vent = window.open('/admin/modulos/imagenes/index.php?action=getHTMLImagen&id_imagen='+id_foto, 'Images', 'width=466, height=392, scrollbars=yes, statusbar=no, resizable=yes');				
	centrarVentana(vent, 466, 392);
	vent.focus();
}

function centrarVentana(objvent, width, height)
{
	objvent.moveTo((screen.width-width)/2,(screen.height-height)/2);
}

function onclickEnter(e,funcion)
{
	var evento_key = (document.all) ? e.keyCode : e.which; 

	if(evento_key==13)//si la tecla apretada es enter
			return eval(funcion);
}

function openPopUpEnviar(url,ancho,alto,con_scroll,con_barra,resize)
{	
	vent = window.open(url, 'Images', 'width='+ancho+', height='+alto+', scrollbars='+con_scroll+', statusbar='+con_barra+', resizable='+resize);
	centrarVentana(vent,ancho,alto);
	
	return false;
}

function fieldNumber(objeto, numeroDecimales, e) 
{ 
	var valorCampo; 
	var evento_key = (document.all) ? e.keyCode : e.which; 
	var numPosPunto = 0; 
	var strParteEntera = ""; 
	var strParteDecimal = ""; 
	var NUM_DECIMALES = numeroDecimales; 
	
	switch (evento_key) 
	{ 
		case 48: 
		case 49: 
		case 50: 
		case 51: 
		case 52: 
		case 53: 
		case 54: 
		case 55: 
		case 56: 
		case 57: 
		break; 
		default: 
			if (((evento_key != 46) || (NUM_DECIMALES == 0)) && (evento_key != 8))
			{
				if (document.all) 
					e.keyCode = 0;
				else 
					e.stopPropagation();
				return false; 
			}
			else if (evento_key == 8) return true;
	} 

	valorCampo = objeto.value; 	
	if (evento_key == 46) 
	{
		if (valorCampo == '')
		{
			if (document.all) 
				e.keyCode = 0;
			else 
				e.stopPropagation();
			return false; 
		}
		else if (valorCampo.indexOf(".") != -1)
		{ 
			if (document.all) 
				e.keyCode = 0;
			else 
				e.stopPropagation();
			return false; 
		} 
	}
	/* Slo puede teclear el nmero de decimales indicado en NUM_DECIMALES */ 
	if ((numPosPunto = valorCampo.indexOf(".")) != -1) 
	{ 
		strParteEntera = valorCampo.substr(0,(numPosPunto - 1)); 
		strParteDecimal = valorCampo.substr((numPosPunto + 1), valorCampo.length) 
		
		if (strParteDecimal.length > (NUM_DECIMALES - 1)) 
		{ 
			if (document.all) 
				e.keyCode = 0;
			else 
				e.stopPropagation();
			return false; 
		} 
	} 
	
	return true; 
} 

function decodificar_palabras_rusas(palabra){
	

	palabra = palabra.replace("amp;", "");
	while (palabra.match("&#"))
		palabra = palabra.replace("&#", "");

	//Marca el espacio
	while (palabra.match(" "))
		palabra = palabra.replace(" ", "&;");
	var codigos = palabra.split(";");
	
	var decodificada = "";
	for(i=0; i < codigos.length; i++ )
	{
		if(codigos[i] == "&")
			decodificada = decodificada + " ";
		else	
			decodificada = decodificada + String.fromCharCode(codigos[i]);
	
	}

	return decodificada;

}

