function SetHeightDivMenu()
{
	if (document.getElementById('contenido_der') != null && document.getElementById('contenido_izq') != null)
	{
		var divh = document.getElementById('contenido_der').offsetHeight;
		var fixiedisplay = document.getElementById('contenido_der');
		var target = document.getElementById('contenido_izq');
		if (divh < 487)
		{
			divh = 487;
			fixiedisplay.style.height = divh + "px";
		}
		target.style.height = divh + "px";
	}
}

var mwonlist = new Array();

function mwonExec()
{
	mwonAdd('SetHeightDivMenu()');
	window.onload = mwonLoop;
}

function mwonLoop()
{
	for (var i = 0; i < mwonlist.length; i++)
	{
		eval(mwonlist[i]);
	}
}

function mwonAdd(func)
{
	mwonlist[mwonlist.length] = func;
}

function FormatNumbers(num)
{
	var separador = ".";
	var decimal = ",";
	num = num.toString();
	a = num.split(decimal);
	x = a[0];
	y = a[1];
	z = "";
	if (typeof(x) != "undefined")
	{
		for (i = x.length - 1; i >= 0; i--)
		{
			z += x.charAt(i);
		}
		z = z.replace(/(\d{3})/g, "$1" + separador);
		if (z.slice(-separador.length) == separador)
		{
			z = z.slice(0, -separador.length);
		}
		x = "";
		for (i = z.length - 1; i >= 0; i--)
		{
			x += z.charAt(i);
		}
		if (typeof(y) != "undefined" && y.length > 0)
		{
			x += decimal + y;
		}
	}
	return x;
}

function ValidateInt(field)
{
	var formated = "";
	var repeat = 0;
	for(var i = 0; i < field.value.length; ++i)
	{
		var new_key = field.value.charAt(i);
		if((new_key == "0") || (new_key == "1") || (new_key == "2") || (new_key == "3") || (new_key == "4") || (new_key == "5") || (new_key == "6") || (new_key == "7") || (new_key == "8") || (new_key == "9"))
		{
			formated += new_key;
		}
		else
		{
			if(repeat < 1)
			{
				alert("Este campo sólo acepta dígitos");
				repeat++;
			}
			if(field.type == "password")
			{
				formated = "";
				break;
			}
		}
	}
	field.value = formated;
}

function ValidateDigit(campo)
{
	var formated = "";
	var repeat = 0;
	for(var i = 0; i < campo.length; ++i)
	{
		var new_key = campo.charAt(i);
		if((new_key == "0") || (new_key == "1") || (new_key == "2") || (new_key == "3") || (new_key == "4") || (new_key == "5") || (new_key == "6") || (new_key == "7") || (new_key == "8") || (new_key == "9"))
		{
			formated += new_key;
		}
		else
		{
			if(repeat < 1)
			{
				alert("Estos campos sólo aceptan dígitos");
				repeat++;
			}
		}
	}
	return formated;
}

function SwapSearchValues()
{
	if (document.getElementById('fromPoints') != null && document.getElementById('toPoints') != null)
	{
		var va1ormin = document.getElementById('fromPoints');
		var valormax = document.getElementById('toPoints');
		va1ormin = va1ormin.value;
		valormax = valormax.value;
		if (va1ormin != '' && valormax != '')
		{
			//va1ormin = va1ormin.replace(/^\s*|\s*$/g,"");
			//valormax = valormax.replace(/^\s*|\s*$/g,"");
			va1ormin = ValidateDigit(va1ormin);
			valormax = ValidateDigit(valormax);
			var minnum = new Number(va1ormin);
			var maxnum = new Number(valormax);
			if (minnum > maxnum)
			{
				document.getElementById('fromPoints').value = maxnum;
				document.getElementById('toPoints').value = minnum;
			}
			else
			{
				document.getElementById('fromPoints').value = minnum;
				document.getElementById('toPoints').value = maxnum;
			}
			return true;
		}
	}
	return false;
}
