function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function isEmpty(s)
{   
  s = Trim(s)
  return ((s == null) || (s.length == 0))
}

// Trims all spaces to the left of a specific string
function LTrim(str)
{
  var whitespace = new String(" \t\n\r "); // last space character is not a space, but alt+0160, another invisible char. Added by Imar Spaanjaars at 07-09-2000
  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;
  }

// Trims all spaces to the right of a specific 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 "); // last space character is not a space, but alt+0160, another invisible char. Added by Imar Spaanjaars at 07-09-2000
  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;
}

// Trims all spaces to the left and right of a specific string by calling RTim and LTrim
function Trim(str)
{
  return RTrim(LTrim(str));
}

// Checks if the three date elements together form a valid date
function isDate (year, month, day)
{
	if (isEmpty(year) || isNaN(year)) return false;
	if (isEmpty(month) || isNaN(month)) return false;
	if (isEmpty(day) || isNaN(day)) return false;
	var longMonth;
	var isFebruary;
	longMonth = false;
	isFebruary = false;
	if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
	{
		longMonth = true;		
	}
	if (month == 2)
	{
		isFebruary = true;
	}
	if (longMonth && day > 31) return false;
	if (!longMonth && day > 30) return false;
	if (isFebruary && day > daysInFebruary(year)) return false;
	return true;
}

// Internal function. Returns 29 when a leap year, else 28
function daysInFebruary (year)
{ // 29 days in febr, when it's a leap year. Not with a century, unless dev. by 400
    return (  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
}