/* 
 * Copyright 2006, David H. Marlin
 */

/*
 *  Classes
 */
var q=String.fromCharCode(34);

/*******************************************
 *  Table (Master)
 *******************************************/

function Table(numCols, classs, width, otheratts)
{
   this.numnumCols = numCols;
   this.classs = classs;
   this.width = width;
   this.otheratts = otheratts;
   this.theRows = new Array();
   this.anchors= new Array();
}

Table.prototype.AddCell=function(row, col, colspan, classs, width, otheratts, spanclass, content)
{
   if(typeof(this.theRows[row])=="undefined")
   {
      this.theRows[row] = new Object();
      this.theRows[row].theCells = new Array();
   }
   if(typeof(this.theRows[row].theCells[col])=="undefined")
      this.theRows[row].theCells[col] = new Object();
   var theCell = this.theRows[row].theCells[col];
   theCell.colspan = colspan;
   theCell.classs = classs;
   theCell.width = width;
   theCell.otheratts = otheratts;
   theCell.spanclass = spanclass;
   theCell.content = content;
}

Table.prototype.AddAnchor=function(row, anchor){this.anchors[row]=anchor;}
	
Table.prototype.GetTable=function(start,stop)
{
   var theTable = "<table";
   if (this.classs != "")
      theTable += " class="+this.classs;        
   if (this.width !=0)
      theTable += " width="+q+this.width+q; 
   if (this.otheratts != "")
      theTable += " "+this.otheratts;        
   theTable += ">";

   if (arguments.length==0)
      startRow=1;
   else
      startRow=start;
   if (arguments.length<2)
      stopRow=this.theRows.length;
   else
      stopRow=stop;

   for(var ii=startRow;ii<stopRow;ii++)
   {
      theTable+="<tr>";
      //if (this.anchors[ii]!=null)
      //{
      //   theTable += "<a name="+this.anchors[ii]+" />";
      //}
      var theRow = this.theRows[ii]; 
      for(var jj=1; jj<theRow.theCells.length;jj++)
      {
         var theCell = theRow.theCells[jj];
         theTable += "<td";
         if (theCell.classs != "")
            theTable += " class="+theCell.classs;        
         if (theCell.width !=0)
            theTable += " width="+theCell.width; 
         if (theCell.colspan !=0)
            theTable += " colspan="+theCell.colspan; 
         if (theCell.otheratts != "")
            theTable += " "+theCell.otheratts; 
         theTable += "><span";
         if (theCell.spanclass != "")
            theTable += " class="+theCell.spanclass;        
         theTable += ">";
         if (this.anchors[ii]!=null && jj==1)
            theTable += "<a name="+this.anchors[ii]+"></a>";
         theTable += theCell.content+"</span></td>";
         //theTable += ">"+theCell.content+"</span></td>";
      }
      theTable += "</tr>";
   }
   theTable += "</table>";
   return theTable;
}

Table.prototype.WriteTable=function(start,stop)
{
   if (arguments.length==0)
      document.write(this.GetTable());
   else if (arguments.length==1)
      document.write(this.GetTable(start));
   else
      document.write(this.GetTable(start,stop));
}


/*******************************************
 *  TwoCol
 *******************************************/

function TwoCol()
{
   this.lcount=1;  
   this.rcount=1; 
   this.left=new Table(1,"","100%","valign=top cellpadding=5");
   this.right=new Table(1,"","100%","valign=top cellpadding=5");
}

TwoCol.prototype.AddLeft=function(data)
{
   this.left.AddCell(this.lcount,1,0,"","","valign=top","",data);
   this.lcount++;
}

TwoCol.prototype.AddRight=function(data)
{
   this.right.AddCell(this.rcount,1,0,"","","valign=top","",data);
   this.rcount++;
}

TwoCol.prototype.GetTable=function(classs, lclass, rclass, width, lwidth)
{
   theTable=new Table(2,classs,width,"valign=top");
   theTable.AddCell(1,1,0,lclass,lwidth,"valign=top","",this.left.GetTable());
   theTable.AddCell(1,2,0,rclass,"","valign=top","",this.right.GetTable());
   return theTable.GetTable();
}

TwoCol.prototype.WriteTable=function(classs, lclass, rclass, width, lwidth)
{document.write(this.GetTable(classs, lclass, rclass, width, lwidth));}

/*******************************************
 *  ThreeCol
 *******************************************/

function ThreeCol()
{
   this.lcount=1;  
   this.ccount=1;  
   this.rcount=1; 
   this.left=new Table(1,"","100%","valign=top cellpadding=5");
   this.center=new Table(1,"","100%","valign=top cellpadding=5");
   this.right=new Table(1,"","100%","valign=top cellpadding=5");
}

ThreeCol.prototype.AddLeft=function(data)
{
   this.left.AddCell(this.lcount,1,0,"","","valign=top","",data);
   this.lcount++;
}

ThreeCol.prototype.AddCenter=function(data)
{
   this.center.AddCell(this.ccount,1,0,"","","valign=top","",data);
   this.ccount++;
}

ThreeCol.prototype.AddRight=function(data)
{
   this.right.AddCell(this.rcount,1,0,"","","valign=top","",data);
   this.rcount++;
}

ThreeCol.prototype.WriteTable=function(classs, lclass, cclass, rclass, width, lwidth, cwidth)
{
   theTable=new Table(3,classs,width,"valign=top");
   theTable.AddCell(1,1,0,lclass,lwidth,"valign=top","",this.left.GetTable());
   theTable.AddCell(1,2,0,cclass,cwidth,"valign=top","",this.center.GetTable());
   theTable.AddCell(1,3,0,rclass,"","valign=top","",this.right.GetTable());
   theTable.WriteTable();
}


/*******************************************
 *  GreenBox (GP) (greenbox, greenboxh,greenboxu)
 *******************************************/

function GreenBox(width, underline)
{
   this.theTable = new Table(4,"greenbox",width,"align=center valign=top cellpadding=5");
   this.numRows=0;
   this.ul = underline;
   this.col21="";
   this.col22="";
   this.col31="";
   this.col32="";
   this.col33="";
   this.col41="";
   this.col42="";
   this.col43="";
   this.col44="";
}

GreenBox.prototype.SetWidths=function(col1, col2, col3)
{
   this.col21=col1+"%";
   this.col22=col2+col3+"%";
   this.col31=col1+"%";
   this.col32=col2+"%";
   this.col33=col3+"%";
}

GreenBox.prototype.AddTitle=function(title)
{
   this.numRows++;
   this.theTable.AddCell(this.numRows,1,4,"greenboxh","","valign=top","greenboxh", title);
}

GreenBox.prototype.Add1=function(item)
{
   this.numRows++;
   if (this.ul==1)
      this.theTable.AddCell(this.numRows,1,4,"greenboxu","","valign=top","greenbox", item);
   else
      this.theTable.AddCell(this.numRows,1,4,"greenbox","","valign=top","greenbox", item);
}

GreenBox.prototype.Add2=function(item1, item2)
{
   this.numRows++;
   if (this.ul==1)
   {
      this.theTable.AddCell(this.numRows,1,2,"greenboxu",this.col21,"valign=top","greenbox", item1);
      this.theTable.AddCell(this.numRows,2,2,"greenboxu",this.col22,"valign=top","greenbox", item2);
   }
   else
   {
      this.theTable.AddCell(this.numRows,1,2,"greenbox",this.col21,"valign=top","greenbox", item1);
      this.theTable.AddCell(this.numRows,2,2,"greenbox",this.col22,"valign=top","greenbox", item2);
   }
}

GreenBox.prototype.Add3=function(item1, item2, item3)
{
   this.numRows++;
   if (this.ul==1)
   {
      this.theTable.AddCell(this.numRows,1,0,"greenboxu",this.col31,"valign=top","greenbox", item1);
      this.theTable.AddCell(this.numRows,2,0,"greenboxu",this.col32,"valign=top","greenbox", item2);
      this.theTable.AddCell(this.numRows,3,2,"greenboxu",this.col33,"valign=top","greenbox", item3);
   }
   else
   {
      this.theTable.AddCell(this.numRows,1,0,"greenbox",this.col31,"valign=top","greenbox", item1);
      this.theTable.AddCell(this.numRows,2,0,"greenbox",this.col32,"valign=top","greenbox", item2);
      this.theTable.AddCell(this.numRows,3,2,"greenbox",this.col33,"valign=top","greenbox", item3);
   }
}

GreenBox.prototype.Add4=function(item1, item2, item3, item4)
{
   this.numRows++;
   if (this.ul==1)
   {
      this.theTable.AddCell(this.numRows,1,0,"greenboxu",this.col41,"valign=top","greenbox", item1);
      this.theTable.AddCell(this.numRows,2,0,"greenboxu",this.col42,"valign=top","greenbox", item2);
      this.theTable.AddCell(this.numRows,3,0,"greenboxu",this.col43,"valign=top","greenbox", item3);
      this.theTable.AddCell(this.numRows,4,0,"greenboxu",this.col44,"valign=top","greenbox", item4);
   }
   else
   {
      this.theTable.AddCell(this.numRows,1,0,"greenbox",this.col41,"valign=top","greenbox", item1);
      this.theTable.AddCell(this.numRows,2,0,"greenbox",this.col42,"valign=top","greenbox", item2);
      this.theTable.AddCell(this.numRows,3,0,"greenbox",this.col43,"valign=top","greenbox", item3);
      this.theTable.AddCell(this.numRows,4,0,"greenbox",this.col44,"valign=top","greenbox", item4);
   }
}

GreenBox.prototype.GetTable=function(){return this.theTable.GetTable();}

GreenBox.prototype.WriteTable=function(){document.write(this.GetTable());}


/*******************************************
 *  GoldBox (GP) (goldbox, boldboxb, goldboxu, goldboxbu)
 *******************************************/

function GoldBox(width, underline, border)
{
   if (border==1)
      this.theTable = new Table(1,"goldboxb",width,"align=center valign=top cellpadding=5");
   else
      this.theTable = new Table(1,"goldbox",width,"align=center valign=top cellpadding=5");
   this.numRows=0;
   this.ul = underline;
   this.bd = border;
}

GoldBox.prototype.AddTitle=function(title)
{
   this.numRows++;
   this.theTable.AddCell(this.numRows,1,2,"goldboxh","100%","valign=top","goldboxh", title);
}

GoldBox.prototype.AddTitleA=function(title, name)
{
   this.numRows++;
   this.theTable.AddCell(this.numRows,1,2,"goldboxh","100%","valign=top","goldboxh", "<a name="+name+"></a>"+title);
}

GoldBox.prototype.Add=function(item)
{
   this.numRows++;
   if (this.bd==1)
      if (this.ul==1)
         this.theTable.AddCell(this.numRows,1,2,"goldboxbu","100%","valign=top","goldbox", item);
      else
         this.theTable.AddCell(this.numRows,1,2,"goldboxb","100%","valign=top","goldbox", item);
   else
      if (this.ul==1)
         this.theTable.AddCell(this.numRows,1,2,"goldboxu","100%","valign=top","goldbox", item);
      else
         this.theTable.AddCell(this.numRows,1,2,"goldbox","100%","valign=top","goldbox", item);
}

GoldBox.prototype.GetTable=function(){return this.theTable.GetTable();}

GoldBox.prototype.WriteTable=function(){document.write(this.GetTable());}

 
/*******************************************
 *  NoteBox (GP) (notebox)
 *******************************************/

function NoteBox(width)
{
   this.theTable = new Table(1,"notebox",width,"align=center valign=top cellpadding=5");
   this.numRows=0;
}

NoteBox.prototype.Add=function(item)
{
   this.numRows++;
   this.theTable.AddCell(this.numRows,1,2,"notebox","100%","valign=top","notebox", item);
}

NoteBox.prototype.GetTable=function(){return this.theTable.GetTable();}

NoteBox.prototype.WriteTable=function(){document.write(this.GetTable());}

 
/*******************************************
 *  NewBox (newbox, goldbox)
 *******************************************/

function NewBox(width)
{
   this.theTable = new Table(3,"newbox",width,"align=center valign=top");
   this.numRows=0;
}

NewBox.prototype.AddExternal=function(date,item,url)
{
   this.numRows++;
   this.theTable.AddCell(this.numRows,1,0,"newbox","10%","valign=center align=right","newbox","("+date+")");
   this.theTable.AddCell(this.numRows,2,0,"newbox","5%","valign=center align=right","","<img src=/images/goldtrojan.gif width=20 valign=center>");
   item+="<a class=goldbox href="+url+" target=_blank>&nbsp;&nbsp;more...</a>";
   this.theTable.AddCell(this.numRows,3,0,"newbox","85%","valign=center","goldbox",item);
}

NewBox.prototype.AddLinked=function(date,item,url)
{
   this.numRows++;
   this.theTable.AddCell(this.numRows,1,0,"newbox","10%","valign=center align=right","newbox","("+date+")");
   this.theTable.AddCell(this.numRows,2,0,"newbox","5%","valign=center align=right","","<img src=/images/goldtrojan.gif width=20 valign=center>");
   item+="<a class=goldbox href="+url+">&nbsp;&nbsp;more...</a>";
   this.theTable.AddCell(this.numRows,3,0,"newbox","85%","valign=center","goldbox",item);
}

NewBox.prototype.AddText=function(date,item)
{
   this.numRows++;
   this.theTable.AddCell(this.numRows,1,0,"newbox","10%","valign=center align=right","newbox","("+date+")");
   this.theTable.AddCell(this.numRows,2,0,"newbox","5%","valign=center align=right","","<img src=/images/goldtrojan.gif width=20 valign=center>");
   this.theTable.AddCell(this.numRows,3,0,"newbox","85%","valign=center","goldbox",item);
}

NewBox.prototype.GetTable=function(){return this.theTable.GetTable();}

NewBox.prototype.WriteTable=function(){document.write(this.GetTable());}


/*******************************************
 *  FundraisersI (Individual) (fund, fundh)
 *******************************************/

function FundraisersI(width)
{
   this.theTable = new Table(7, "fund", width, "align=center")
   //this.theTable.AddCell(1, 1, 4, "", "", "", "", "");
   //this.theTable.AddCell(1, 2, 2, "fund", "", "", "fundh", "Goal per Student");
   //this.theTable.AddCell(1, 3, 0, "", "",  "", "", "");

   this.theTable.AddCell(1, 1, 0, "fundh", "22%", "", "", "Fundraiser");
   this.theTable.AddCell(1, 2, 0, "fundh", "10%", "", "", "Start Date");
   this.theTable.AddCell(1, 3, 0, "fundh", "10%", "", "", "End Date");
   this.theTable.AddCell(1, 4, 0, "fundh", "22%", "", "", "Venue");
   this.theTable.AddCell(1, 5, 0, "fundh", "", "", "", "Comment");
   //this.theTable.AddCell(2, 5, 0, "fundh", "5%",  "", "", "Raise");
   //this.theTable.AddCell(2, 6, 0, "fundh", "18%", "", "", "&nbsp;Sell");
   //this.theTable.AddCell(2, 7, 0, "fundh", "6%",  "", "", "Total");

   this.numRows=1;
}

FundraisersI.prototype.Add=function(name, start, end, venue, comment)
//FundraisersI.prototype.Add=function(name, start, end, venue, goal, sell, total)
{
   //(row, col, colspan, classs, width, otheratts, fontclass, content)
   this.numRows++;
   var fund;
   if ((this.numRows%2)==1)
      fund="fund1";
   else
      fund="fund2";
   this.theTable.AddCell(this.numRows, 1, 0, fund, "", "", "", name);
   this.theTable.AddCell(this.numRows, 2, 0, fund, "", "", "", start);
   this.theTable.AddCell(this.numRows, 3, 0, fund, "", "", "", end);
   this.theTable.AddCell(this.numRows, 4, 0, fund, "", "", "", venue);
   this.theTable.AddCell(this.numRows, 5, 0, fund, "", "", "", comment);
   //this.theTable.AddCell(this.numRows, 5, 0, fund, "", "", "", goal);
   //this.theTable.AddCell(this.numRows, 6, 0, fund, "", "", "", sell);
   //this.theTable.AddCell(this.numRows, 7, 0, fund, "", "", "", total);
}

FundraisersI.prototype.GetTable=function(){return this.theTable.GetTable();}

FundraisersI.prototype.WriteTable=function(){document.write(this.GetTable());}


/*******************************************
 *  FundraisersG (General) (fund, fundh)
 *******************************************/

function FundraisersG(width)
{
   this.theTable = new Table(4, "fund", width, "align=center")
   this.theTable.AddCell(1, 1, 0, "fundh", "22%", "", "", "Fundraiser");
   this.theTable.AddCell(1, 2, 0, "fundh", "10%", "", "", "Start Date");
   this.theTable.AddCell(1, 3, 0, "fundh", "10%", "", "", "End Date");
   this.theTable.AddCell(1, 4, 0, "fundh", "22%", "", "", "Venue");
   this.theTable.AddCell(1, 5, 0, "fundh", "", "", "", "Comment");
   this.numRows=1;
}

FundraisersG.prototype.Add=function(name, start, end, venue, comment)
//FundraisersG.prototype.Add=function(name, start, end, venue)
{
   //(row, col, colspan, classs, width, otheratts, fontclass, content)
   this.numRows++;
   var fund;
   if ((this.numRows%2)==1)
      fund="fund1";
   else
      fund="fund2";
   this.theTable.AddCell(this.numRows, 1, 0, fund, "", "", "", name);
   this.theTable.AddCell(this.numRows, 2, 0, fund, "", "", "", start);
   this.theTable.AddCell(this.numRows, 3, 0, fund, "", "", "", end);
   this.theTable.AddCell(this.numRows, 4, 0, fund, "", "", "", venue);
   this.theTable.AddCell(this.numRows, 5, 0, fund, "", "", "", comment);
}

FundraisersG.prototype.GetTable=function(){return this.theTable.GetTable();}

FundraisersG.prototype.WriteTable=function(){document.write(this.GetTable());}


/*******************************************
 *  FundraisersW (Winners) (fund, fundh)
 *******************************************/

function FundraisersW(width, title)
{
   this.theTable = new Table(3, "fund", width, "align=center")

   this.theTable.AddCell(1, 1, 3, "fundh", "", "align=center", "fundh", title);

   this.theTable.AddCell(2, 1, 0, "fundh", "40%", "", "", "Prize");
   this.theTable.AddCell(2, 2, 0, "fundh", "30%", "", "", "Winner");
   this.theTable.AddCell(2, 3, 0, "fundh", "30%", "", "", "Ticket Sold by");
   this.numRows=2;
}

FundraisersW.prototype.Add=function(prize, winner, seller)
{
   //(row, col, colspan, classs, width, otheratts, fontclass, content)
   this.numRows++;
   var fund;
   if ((this.numRows%2)==1)
      fund="fund1";
   else
      fund="fund2";
   this.theTable.AddCell(this.numRows, 1, 0, fund, "", "", "", prize);
   this.theTable.AddCell(this.numRows, 2, 0, fund, "", "", "", winner);
   this.theTable.AddCell(this.numRows, 3, 0, fund, "", "", "", seller);
}

FundraisersW.prototype.GetTable=function(){return this.theTable.GetTable();}

FundraisersW.prototype.WriteTable=function(){document.write(this.GetTable());}

 
/*******************************************
 *  Calendar (calendar, calendarh)
 *******************************************/

function Calendar(width)
{
   this.theTable = new Table(6, "calendar", width, "align=center")
   this.numRows=0;
   this.numBreaks=0;
}

Calendar.prototype.AddHeader=function()
{
   this.numRows++;

   this.theTable.AddCell(this.numRows, 1, 0, "calendarh", "8%", "", "calendarh", "Month");
   this.theTable.AddCell(this.numRows, 2, 0, "calendarh", "9%", "", "calendarh", "Date");
   this.theTable.AddCell(this.numRows, 3, 0, "calendarh", "12%", "", "calendarh", "Weekday");
   this.theTable.AddCell(this.numRows, 4, 0, "calendarh", "39%", "", "calendarh", "Activity");
   this.theTable.AddCell(this.numRows, 5, 0, "calendarh", "17%",  "", "calendarh", "Location");
   this.theTable.AddCell(this.numRows, 6, 0, "calendarh", "15%", "", "calendarh", "Time");
}

Calendar.prototype.AddBreak=function()
{
   if (this.numBreaks == 0)
      this.breaks=new Array();
   this.breaks[this.numBreaks]=this.numRows+1;
   this.numBreaks++;
}

Calendar.prototype.Add=function(month, date, day, activity, location, time)
{
   //(row, col, colspan, classs, width, otheratts, fontclass, content)
   this.numRows++;
   var calendar;
   if ((this.numRows%2)==1)
      calendar="calendar1";
   else
      calendar="calendar2";
   this.theTable.AddCell(this.numRows, 1, 0, calendar, "", "", "calendar", month);
   this.theTable.AddCell(this.numRows, 2, 0, calendar, "", "", "calendar", date);
   this.theTable.AddCell(this.numRows, 3, 0, calendar, "", "", "calendar", day);
   this.theTable.AddCell(this.numRows, 4, 0, calendar, "", "", "calendar", activity);
   this.theTable.AddCell(this.numRows, 5, 0, calendar, "", "", "calendar", location);
   this.theTable.AddCell(this.numRows, 6, 0, calendar, "", "", "calendar", time);
}

Calendar.prototype.GetTable=function(section)
{
   if (arguments.length==0 || this.numBreaks==0)
     return this.theTable.GetTable();
   else if (section > this.numBreaks)
     return this.theTable.GetTable();
   else if (section==0)
     return this.theTable.GetTable(1,this.breaks[0]-1);
   else if (section==this.numBreaks)
     return this.theTable.GetTable(this.breaks[section-1]);
   else
     return this.theTable.GetTable(this.breaks[section-1],this.breaks[section]-1);
   //else
   //  return this.theTable.GetTable();

}

Calendar.prototype.WriteTable=function(section)
{
   if (arguments.length==0)
      document.write(this.GetTable());
   else
      document.write(this.GetTable(section));
}


/*******************************************
 *  SCalendar (Summer) (calendar, calendarh, calendarh1)
 *******************************************/

function SCalendar(width, pd, pt, pw)
{
   this.theTable = new Table(3, "calendar", width, "align=center")
   this.numRows=0;
   this.pd=pd;
   this.pt=pt;
   this.pw=pw;
}

SCalendar.prototype.AddSection=function(section)
{
   this.numRows++;
   this.theTable.AddCell(this.numRows, 1, 3, "calendarh1", "", "", "calendarh1", section);
   this.numRows++;
   this.theTable.AddCell(this.numRows, 1, 0, "calendarh", this.pd, "", "calendarh", "Date");
   this.theTable.AddCell(this.numRows, 2, 0, "calendarh", this.pt, "", "calendarh", "Time");
   this.theTable.AddCell(this.numRows, 3, 0, "calendarh", this.pw, "", "calendarh", "Who");
//   this.theTable.AddCell(this.numRows, 1, 0, "calendarh", "32%", "", "calendarh", "Date");
//   this.theTable.AddCell(this.numRows, 2, 0, "calendarh", "25%", "", "calendarh", "Time");
//   this.theTable.AddCell(this.numRows, 3, 0, "calendarh", "43%", "", "calendarh", "Who");
}

SCalendar.prototype.Add=function(date, time, who)
{
   //(row, col, colspan, classs, width, otheratts, fontclass, content)
   this.numRows++;
   var calendar;
   if ((this.numRows%2)==1)
      calendar="calendar1";
   else
      calendar="calendar2";
   this.theTable.AddCell(this.numRows, 1, 0, calendar, "", "", "calendar", date);
   this.theTable.AddCell(this.numRows, 2, 0, calendar, "", "", "calendar", time);
   this.theTable.AddCell(this.numRows, 3, 0, calendar, "", "", "calendar", who);
}

SCalendar.prototype.GetTable=function(){return this.theTable.GetTable();}

SCalendar.prototype.WriteTable=function(){document.write(this.GetTable());}


/*******************************************
 *  AnnouncementsB (Brief)
 *******************************************/

function AnnouncementsB()
{
   this.bulll=new Table(1,"infobox2","100%","align=center cellpadding=10");
   this.bullr=new Table(1,"infobox2","100%","align=center cellpadding=10");
   this.bullcount=2;
   this.leftcount=0;
   this.rightcount=0;
   this.leftrow=1;
   this.rightrow=1;
}

AnnouncementsB.prototype.Add=function(classs,deadline,author,posted,id,data)
{
   //(row, col, colspan, classs, width, otheratts, fontclass, content)
   var alldata;
   if (classs==1)
   {
      clss="infobox2u";
      fnt="infoboxu";
      //alldata="<span class=infoboxhu>From "+author+" on "+posted+"</span><br>";
      alldata="<span class=infoboxhu>From "+author+" on "+posted+"</span>";
      if (deadline!="")
         alldata=alldata+", <span class=infoboxhu><i>Deadline "+deadline+"</i></span>";
         //alldata=alldata+"<span class=infoboxhu><i>Deadline "+deadline+"</i><br></span>";
      //alldata=alldata+"<span style=font-size:6pt;><br></span><b>"+data+"</b>";
      alldata=alldata+"<br><span style=font-size:6pt;><br></span><b>"+data+"</b>";
   }
   else
   {
      clss="infobox2";
      fnt="infobox";
      //alldata="<span class=infoboxh>From "+author+" on "+posted+"</span><br>";
      alldata="<span class=infoboxh>From "+author+" on "+posted+"</span>";
      if (deadline!="")
         alldata=alldata+", <span class=infoboxh><i>Deadline "+deadline+"</i></span>";
         //alldata=alldata+"<span class=infoboxh><i>Deadline "+deadline+"</i><br></span>";
      //alldata=alldata+"<span style=font-size:6pt;><br></span><b>"+data+"</b>";
      alldata=alldata+"<br><span style=font-size:6pt;><br></span><b>"+data+"</b>";
   }
   if (id != 0)
      alldata=alldata+FullLink(id); // need to check for existance of full before creating link

   this.Insert(clss,alldata);
}

AnnouncementsB.prototype.Insert=function(clss,alldata)
{
   //document.write(this.leftcount+", "+this.rightcount+", "+data.length+"<br>");
   //if (this.bullcount%2 == 0)
   if (this.leftcount <= this.rightcount)
   {
      //document.write("left<br>");
      //this.bulll.AddCell(Math.floor(this.bullcount/2),1,0,clss,"","","",alldata);
      this.bulll.AddCell(this.leftrow,1,0,clss,"","","",alldata);
      this.leftcount+=alldata.length;
      this.leftrow++;
   }
   else
   {
      //document.write("right<br>");
      //this.bullr.AddCell(Math.floor(this.bullcount/2),1,0,clss,"","","",alldata);
      this.bullr.AddCell(this.rightrow,1,0,clss,"","","",alldata);
      this.rightcount+=alldata.length;
      this.rightrow++;
   }
   //this.bullcount++;
}

AnnouncementsB.prototype.GetLeftTable=function(){return this.bulll.GetTable();}

AnnouncementsB.prototype.GetRightTable=function(){return this.bullr.GetTable();}

AnnouncementsB.prototype.GetNumRows=function(){return Math.max(this.leftrow-1,this.rightrow-1);}

function FullLink(id){return "&nbsp;&nbsp;<a class=infobox href=/announcements/announcements.asp#full"+id+">more...</a>";}


/*******************************************
 *  AnnouncementsF (Full)
 *******************************************/

function AnnouncementsF()
{
   this.bulll=new Table(1,"infobox2","100%","align=center cellpadding=10");
   this.bullr=new Table(1,"infobox2","100%","align=center cellpadding=10");
   //this.bullcount=2;
   this.leftcount=0;
   this.rightcount=0;
   this.leftrow=1;
   this.rightrow=1;
   var theUrl=location.href;
   var loc=theUrl.indexOf("#full");
   var nstring=theUrl.substring(loc+5);
   this.id=Number(nstring);
}

AnnouncementsF.prototype.Add=function(classs,deadline,author,posted,id,data)
{
   //(row, col, colspan, classs, width, otheratts, fontclass, content)
   var alldata;
   alldata="";
   if (classs==1)
   {
      if (id==this.id)
         clss="infobox2us";
      else
         clss="infobox2u";
      fnt="infoboxu";
      alldata=alldata+"<span class=infoboxhu>From "+author+" on "+posted+"</span><br>";
      if (deadline!="")
        alldata=alldata+"<span class=infoboxhu><i>Deadline "+deadline+"</i><br></span>";
      alldata=alldata+"<br>"+data;
   }
   else
   {
      if (id==this.id)
         clss="infobox2s";
      else
         clss="infobox2";
      fnt="infobox";
      alldata=alldata+"<span class=infoboxh>From "+author+" on "+posted+"</span><br>";
      if (deadline!="")
        alldata=alldata+"<span class=infoboxh><i>Deadline "+deadline+"</i><br></span>";
      alldata=alldata+"<br>"+data;
   }
 
   //if (this.bullcount%2 == 0)
   count=alldata.length;
   next=alldata.search("<br>");
   ndx=0;
   while (next>=0)
   {
      count+=20;
      ndx+=next+4;
      next=(alldata.substr(ndx)).search("<br>");
   }
   if (this.leftcount <= this.rightcount)
   {
      this.bulll.AddAnchor(this.leftrow,"full"+id);
      //this.bulll.AddCell(Math.floor(this.bullcount/2),1,0,clss,"","","",alldata);
      this.bulll.AddCell(this.leftrow,1,0,clss,"","","",alldata);
      this.leftcount+=count;
      this.leftrow++;
   }
   else
   {
      this.bullr.AddAnchor(this.rightrow,"full"+id);
      //this.bullr.AddCell(Math.floor(this.bullcount/2),1,0,clss,"","","",alldata);
      this.bullr.AddCell(this.rightrow,1,0,clss,"","","",alldata);
      this.rightcount+=count;
      this.rightrow++;
   }
   //this.bullcount++;
}

AnnouncementsF.prototype.GetLeftTable=function(){return this.bulll.GetTable();}

AnnouncementsF.prototype.GetRightTable=function(){return this.bullr.GetTable();}


/*******************************************
 *  Gallery
 *******************************************/

function Gallery(id)
{
   this.gall=new Table(1,"","100%","cellpadding=5");
   this.row=1;
   this.col=1;
   this.count=0;
   this.numCol=4;
   this.id=id;
   this.theImages=new Array();
}

//function viewer(file,)
//function viewer(file, galleryId, imageId)
function viewer(galleryId, imageId)
{
   window.galleryId=galleryId;
   window.imageId=imageId;
   //window.open("galleryviewer.asp?"+file,"galleryviewer","menubar=no,resizable=yes,scrollbars");
   window.open("galleryviewer.htm","galleryviewer","menubar=no,status=no,resizable=yes,scrollbars");
}
var q=String.fromCharCode(34);
Gallery.prototype.AddImg=function(im, imth)
{
   //data="<a href="+im+" target=galleryviewer><img src="+imth+" width=190></a>";
   //data="<a onclick=javascript:viewer("+q+im+q+") style=cursor:hand><img src="+imth+"></a>";
   //data="<a onclick=javascript:viewer("+q+im+q+","+this.id+","+this.count+") style=cursor:hand><img src="+imth+"></a>";
   data="<a onclick=javascript:viewer("+this.id+","+this.count+") style=cursor:hand><img src="+imth+"></a>";
   this.gall.AddCell(this.row,this.col,0,"","","align=center","",data);
   this.theImages.push(im);
   this.count++;
   this.col++;
   if (this.col>this.numCol)
   {
      this.col=1;
      this.row++;
   }
}

Gallery.prototype.DrawTable=function(){document.write(this.gall.GetTable());}

Gallery.prototype.GetImages=function(){return this.theImages;}

function AdjustGallery(size)
{
   for (ii=1;ii<document.images.length;ii++) // assumes one picture (in menu) loaded before gallery
   {
      var width=document.images[ii].width;
      var height=document.images[ii].height;
      var aspect = height/width;
      var vert, max;
      if (aspect>1)
      {
         vert=true;
         max=height;
      }
      else
      {
         vert=false;
         max=width;
      }
      if (max>size)
      {
         if (vert)
         {
            height=size;
            width=size/aspect;
         }
         else
         {
            width=size;
            height=size*aspect;
         }
         document.images[ii].width=width;
         document.images[ii].height=height;
      }
   }
}


/*******************************************
 *  Functions
 *******************************************/

MAX_IMAGE=70.999;
MAX_COLOR=12.999;
fillColors=new Array(15);
fillColors[0]= "008080"; // teal
fillColors[1]= "00DED1"; // turquoise
fillColors[2]= "191970"; // midnight blue
fillColors[3]= "4169E1"; // royal blue
fillColors[4]= "4682B4"; // steel blue
fillColors[5]= "8B0000"; // dark red
fillColors[6]= "BA55D3"; // medium orchid
fillColors[7]= "C71585"; // violet red
fillColors[8]= "DA70D6"; // orchid
fillColors[9]= "DDA0DD"; // plum
fillColors[10]="EE82EE"; // violet
fillColors[11]="FFE4E1"; // misty rose
fillColors[12]="FF7F50"; // coral
prefix=new Array(2);
prefix[0]="v";
prefix[1]="h";
function GetFillers(numRows, numCols)
{
   var num=Math.floor(MAX_COLOR*Math.random());
   var num1=Math.floor(MAX_COLOR*Math.random());
   while(num1==num || num1==num-1 || num==num+1)
      num1=Math.floor(MAX_COLOR*Math.random());   
   var bgcolor="style=background-color:#"+fillColors[num];
   var bcolor="border-color:#"+fillColors[num1];

   var start=Math.round(Math.random());
   //data="<table class=goldboxb width=100% style=padding:2%>";
   var data="<table width=100% style=padding:2%;border-style:double;border-width:6px;"+bcolor+">";
   var used="";
   for (var ii=0;ii<numRows;ii++)
   {
      data+="<tr height=180>";
      for (var jj=0;jj<numCols;jj++)
      {
         data+="<td align=center valign=center width=50% "+bgcolor+"><img style=border-style:double;border-width:3px;"+bcolor+" src=/fills/";
         num=Math.floor(MAX_IMAGE*Math.random());
         if (num<10)
           num="0"+String(num);
         else
           num=String(num);
         while(used.indexOf(num)!=-1)
         {
            num=Math.floor(MAX_IMAGE*Math.random());
            if (num<10)
               num="0"+String(num);
            else
               num=String(num);
         }
         used+=num+",";
         //data+=num+".jpg>";
         data+=prefix[(ii+jj+start)%2]+num+".jpg>";
      }
      data+="</tr>";
   }
   data+="</table>";
   return data;
}

//function PageBreak(){document.write("<a class=newpage></a>");}

function GenLink(text,hreff,classs)
{
   var link="<a href="+hreff;
   if (classs != "")
      link+=" class="+classs;
   link+=">"+text+"</a>";
   return link;
}

//function SummAnchor(id){return "<a name=full"+id+"></a>";}
