var backgroundImages=new Array(8);
	backgroundImages[0]="images/LadyHawks09_Bkgnd_Fade30.jpg";
	backgroundImages[1]="images/soccer kids 1511 - Fade30.jpg";
	backgroundImages[2]="images/Munchkins_Bkgnd_1_Fade30.jpg";
	backgroundImages[3]="images/Munchkins_Bkgnd_2_Fade30.jpg";
	backgroundImages[4]="images/Munchkins_Bkgnd_3_Fade30.jpg";
	backgroundImages[5]="images/Munchkins_Bkgnd_4_Fade30.jpg";
	backgroundImages[6]="images/Munchkins_Bkgnd_5_Fade30.jpg";
	backgroundImages[7]="images/Munchkins_Bkgnd_6_Fade30.jpg";



function selectMainBG()
{
	var e = (document.getElementById) ? document.getElementById("main_div") : ((document.all) ? document.all.main : ((document.layers) ? document.main : null));
	if(!e)
		return true;
	e.style.backgroundImage = "url("+backgroundImages[Math.floor(Math.random()*backgroundImages.length)]+")";
}



function popup(mylink, windowname, width, height, scroll)
{
	if (! window.focus)return true;
	var href;
	if (typeof(mylink) == 'string')
	   href=mylink;
	else
	   href=mylink.href;
	window.open(href, windowname, 'width=' + width + ',height=' + height + ',scrollbars=' + scroll);
	return false;
}

function check_int(textval, minval, maxval)
{
  var intval = parseInt(textval);
  if(isNaN(intval))
  {
    alert('The text "' + textval + '" could not be converted to an integer.');
    return false;
  }
  else if (intval < minval)
  {
    alert('Value (' + intval + ') is less than Minimum (' + minval + ').');
    return false;
  }
  else if (intval > maxval)
  {
    alert('Value (' + intval + ') is greater than Maximum (' + maxval + ').');
    return false;
  }
  return true;
}  

function check_text(text, maxlen, allow_empty)
{
  if(text == "" && !allow_empty)
  {
    alert("Field cannot be empty.");
    return false;
  }
  else if (text.length > maxlen)
  {
    alert("Length > " + maxlen + " characters: \"" + text + "\".");
    return false;
  }
  return true;
}  

function parse_date(date_str, splitter)
{
  var sections = date_str.split(splitter);
  if(sections.length != 3)
    throw("Invalid format! Should be 'yyyy" + splitter + "mm" + splitter + "dd'.");
 
  var year = parseInt(sections[0]);
  if(isNaN(year))
    throw("Invalid format! Year '" + sections[0] + "' is not a valid number.");
  else if (year < 2000 || year > 2100)
    throw("Invalid format! Year '" + sections[0] + "' is not between 2000 and 2100.");
   
  // parseInt: if string begins with a '0', string is parsed as an octal - go figure.
  // we modify a temp string so the original is still unchanged for error messages
  var new_string = sections[1];
  while(new_string.substring(0,1) == '0')
	new_string = new_string.substring(1);
  var month = parseInt(new_string);
  if(isNaN(month))
    throw("Invalid format! Month '" + sections[1] + "' is not a valid number.");
  else if (month < 1 || month > 12)
  {
    throw("Invalid format! Month '" + sections[1] + "' is not between 1 and 12.");
  }
   
  var monthdays = 31;
  if (month == 4 || month == 6 || month == 9 || month == 11)
    monthdays = 30;
  else if (month == 2)
  {
   if (year % 400 == 0 || ((year % 4 == 0) && (year % 100 != 0)))
     monthdays = 29;
   else
     monthdays = 28;
  }
    
  // parseInt: if string begins with a '0', string is parsed as an octal - go figure.
  // we modify a temp string so the original is still unchanged for error messages
  var new_string = sections[2];
  while(new_string.substring(0,1) == '0')
	new_string = new_string.substring(1);
  var day = parseInt(new_string);
  if(isNaN(day))
    throw("Invalid format! Day '" + sections[2] + "' is not a valid number.");
  else if (day < 1 || day > monthdays)
    throw("Invalid format! Day '" + sections[2] + "' is not between 1 and " + monthdays + ".");
   
  var date_ymd = [];
  date_ymd[0] = year;
  date_ymd[1] = month;
  date_ymd[2] = day;
	
  return date_ymd;
}

function formatDate(date,format)
{
  var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
  var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
  format=format+"";
  var result="";
  var i_format=0;
  var c="";
  var token="";
  var y=date.getYear()+"";
  var M=date.getMonth()+1;
  var d=date.getDate();
  var E=date.getDay();
  var H=date.getHours();
  var m=date.getMinutes();
  var s=date.getSeconds();
  var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
  var value=new Object();
  if(y.length < 4)
  {
    y=""+(y-0+1900);
  }
  value["y"]=""+y;
  value["yyyy"]=y;
  value["yy"]=y.substring(2,4);
  value["M"]=M;
  value["MM"]=LZ(M);
  value["MMM"]=MONTH_NAMES[M-1];
  value["NNN"]=MONTH_NAMES[M+11];
  value["d"]=d;
  value["dd"]=LZ(d);
  value["E"]=DAY_NAMES[E+7];
  value["EE"]=DAY_NAMES[E];
  value["H"]=H;
  value["HH"]=LZ(H);
  if(H==0)
  {
    value["h"]=12;
  }
  else if(H>12)
  {
    value["h"]=H-12;
  }
  else
  {
    value["h"]=H;
  }
    value["hh"]=LZ(value["h"]);
  if(H>11)
  {
    value["K"]=H-12;
  }
  else
  {
    value["K"]=H;
  }
  value["k"]=H+1;
  value["KK"]=LZ(value["K"]);
  value["kk"]=LZ(value["k"]);
  if(H > 11)
  {
    value["a"]="PM";
  }
  else
  {
    value["a"]="AM";
  }
  value["m"]=m;
  value["mm"]=LZ(m);
  value["s"]=s;
  value["ss"]=LZ(s);
  while(i_format < format.length)
  {
    c=format.charAt(i_format);
    token="";
    while((format.charAt(i_format)==c) &&(i_format < format.length))
    {
      token += format.charAt(i_format++);
    }
    if(value[token] != null)
    {
      result=result + value[token];
    }
    else
    {
      result=result + token;
    }
  }
  return result;
}


