
// --------------------------------------------------------------------------
// Remove leading blanks from our string.
// --------------------------------------------------------------------------
function LTrim(str)
{
  var whitespace = new String(" \t\n\r");

  var s = new String(str);

  if (whitespace.indexOf(s.charAt(0)) != -1) {
    // We have a string with leading blank(s)...

    var j=0, i = s.length;

    // Iterate from the far left of string until we
    // don't have any more whitespace...
    while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
    j++;


    // Get the substring from the first non-whitespace
    // character to the end of the string...
    s = s.substring(j, i);
  }

  return s;
}

// --------------------------------------------------------------------------
// Remove trailing blanks from our string.
// --------------------------------------------------------------------------
function RTrim(str)
{
  // We don't want to trip JUST spaces, but also tabs,
  // line feeds, etc.  Add anything else you want to
  // "trim" here in Whitespace
  var whitespace = new String(" \t\n\r");

  var s = new String(str);

  if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
    // We have a string with trailing blank(s)...

    var i = s.length - 1;       // Get length of string

    // Iterate from the far right of string until we
    // don't have any more whitespace...
    while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
      i--;


    // Get the substring from the front of the string to
    // where the last non-whitespace character is...
    s = s.substring(0, i+1);
  }

  return s;
}


// --------------------------------------------------------------------------
// Remove trailing and leading blanks from our string.
// --------------------------------------------------------------------------
function Trim(str)
{
  return RTrim(LTrim(str));
}

function VerificaData(luna, zi, an)
{
	var Luna = document.getElementById(luna);
  	var Zi = document.getElementById(zi);
	var An = document.getElementById(an);

	//alert(Luna.options[Luna.selectedIndex].value + " - " + Zi.options[Zi.selectedIndex].value + " - " + An.options[An.selectedIndex].value); 
  	
	var currentTime = new Date();
	var month = currentTime.getMonth() + 1;
	var day = currentTime.getDate();
	var year = currentTime.getFullYear();
	
	if(An.options[An.selectedIndex].value < year) 
	{
		alert("You cannot choose a date in the past!")
		return false;
	}
	
	if(An.options[An.selectedIndex].value == year) 
	{
		if(Luna.options[Luna.selectedIndex].value < month) 
		{
			var a = document.getElementById(luna);
			x = a.options[a.selectedIndex].value;
			
			for ( i=0; i<a.options.length; i++ ) 
			{
				if ( a.options[i].value == month ) 
				{
					alert("You cannot choose a date in the past!");
					a.options[i].selected = true;
					break;
					return false;
				}
			}
		}
		if(Luna.options[Luna.selectedIndex].value == month) 
		{
			if(Zi.options[Zi.selectedIndex].value < day)
			{
				var b = document.getElementById(zi);
				y = b.options[b.selectedIndex].value;
				
				for ( i=0; i<b.options.length; i++ ) 
				{
					if ( b.options[i].value == month ) 
					{
						alert("You cannot choose a date in the past!");
						b.options[i].selected = true;
						break;
						return false;
					}
				}
				
			}
			
		}
	}
	
	//alert(month + "/" + day + "/" + year);

	return true;
}

//
