protected void Page_Load(object sender, EventArgs e)
        {
            String cmd = Request["cmd"];
            int showid = Convert.ToInt32(Request["showid"]);
            int showDetailsID = -1;
            if (!String.IsNullOrEmpty(Request["ShowDetailsID"])) showDetailsID = Convert.ToInt32(Request["ShowDetailsID"]);
            ShowDetails showDetails = new ShowDetails();
            showDetails.ShowID = showid;

            DataTable showDays = showDetails.GetDays();
            foreach (DataRow showDayRow in showDays.Rows)
            {
                showDetailsID = Convert.ToInt32(showDayRow["ShowDetailID"]);
                DateTime showDate = Convert.ToDateTime(showDayRow["ShowDate"]);
                Response.Write( showDate.ToString("<h2>ddd, dd MMM yyyy</h2>"));
                ShowDetails currentShowDate = new ShowDetails(showDetailsID);
                Rings rings = new Rings();
                DataSet ringsTable = rings.GetRingsForShowDay(showDetailsID);

                int lastRingNo = 0;
                foreach (DataRow row in ringsTable.Tables[0].Rows)
                {
                    int ringID = Convert.ToInt32(row["RingID"]);
                    if (ringID > -1 && lastRingNo != Convert.ToInt32(row["RingNo"]))
                    {
                        lastRingNo = Convert.ToInt32(row["RingNo"]);

                        Response.Write(String.Format("<p>Ring: {0}</p>", lastRingNo));
                        DataSet judgesDS = rings.GetJudgesForRing(ringID);
                        if (judgesDS.Tables.Count > 0)
                        {
                            foreach (DataRow judgeRow in judgesDS.Tables[0].Rows)
                            {
                                Response.Write(String.Format("<p>Judge: {0}</p>", judgeRow["Name"]));
                                Judge judge = new Judge(judgeRow);
                                DataSet classesDS = judge.getClassesForJudge();
                                if (classesDS.Tables.Count > 0)
                                {
                                    foreach (DataRow classRow in classesDS.Tables[0].Rows)
                                    {
                                        Response.Write(String.Format(" {2,-5} {3} {4} {7} {5} {6}  ({1})<br>",
                                                        classRow["ClassID"], CalcDogsInCalc(classRow), classRow["ClsNo"], ShowClasses.expandHeight(classRow), ShowClasses.expandCatagory(classRow), classRow["LongName"], classRow["Name"], ShowClasses.shortenGrades(classRow)
                                                    ));
                                    }
                                }
                            }

                        }

                        //ringContainer.InnerHtml += String.Format(ringTemplate, lastRingNo, 1, judges, classes, ringID, helperList);
                        Response.Write("<br><br>");
                    }

                }

                Response.Write("<br><hr><br>");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                String cmd = Request["cmd"];
                int showid = Convert.ToInt32(Request["showid"]);
                int showDetailsID = -1;
                if (!String.IsNullOrEmpty(Request["ShowDetailsID"])) showDetailsID = Convert.ToInt32(Request["ShowDetailsID"]);
                ShowID.Value = showid.ToString();
                ShowDetails showDetails = new ShowDetails();
                showDetails.ShowID = showid;

                DataTable showDays = showDetails.GetDays();
                foreach ( DataRow row in showDays.Rows) {
                    int currentShowDetailsID = Convert.ToInt32(row["ShowDetailID"]);

                    if (showDetailsID == -1) showDetailsID = currentShowDetailsID;

                    DateTime showDate = Convert.ToDateTime(row["ShowDate"]);

                    selShowDays.Items.Add(new ListItem(showDate.ToString("ddd, dd MMM yyyy"), row["ShowDetailID"].ToString() )) ;
                    if (showDetailsID == currentShowDetailsID)
                    {
                        selShowDays.SelectedIndex = selShowDays.Items.Count - 1;
                    }
                }

                ShowDetails currentShowDate = new ShowDetails(showDetailsID);
                ShowDetailsID.Value = showDetailsID.ToString();
                String tmp = "";

                DataRowCollection unallocatedClasses = showDetails.getUnallocatedClassFoDay(showDetailsID);
                foreach (DataRow row in unallocatedClasses)
                {
                    tmp += String.Format("<li class='ui-state-default classDetails'><div clsid='{0}' dogsinclass='{1}' judgeid='{7}' class='clsDetails' ><div class='clsNo'>{2}</div><div class='clsName'>{3} {4} {8} {5} {6}</div></div></li>",
                                                row["ClassID"], row["DogsInClass"], row["ClsNo"], ShowClasses.expandHeightShort(row), ShowClasses.expandCatagoryShort(row), row["ShortName"], row["Name"], row["JudgeID"], ShowClasses.shortenGrades(row)
                                                );
                }
                classesAvailable.InnerHtml = tmp;

                Rings rings = new Rings();
                DataSet ringsTable = rings.GetRingsForShowDay(showDetailsID);
                //DataSet judgesTable = rings.GetJudgesRingsForShow(showid);
                //DataSet helpersTable = rings.GetHelpersRingsForShow(showid);

                String ringTemplate = "<div class='ring ui-droppable ui-sortable' ringid='{0}' ringno='{1}' dogsinclass='0' judges='' helpers=''><h1 class='ui-widget-header'>Ring {1} (<span class='dogtotal'>0</span>)<span class='delthing'>X</span></h1>";
                String ringJudgeClassTemplate = "<div class='judgeAndClasses'><h2 class='judgeInfo'><span class='judgeName'>{0}</span></h2><div class='classListArea'><ul class='ui-sortable fpp_sort'>{1}</ul><ul class='ui-sortable helperlist' style='display:none'>{2}</ul></div></div>";

                int lastRingNo = 0;
                foreach (DataRow ringTableRow in ringsTable.Tables[0].Rows)
                {
                    Rings ring = new Rings(ringTableRow);
                    if (ring.ID> -1 &&  lastRingNo != ring.RingNo )
                    {
                        lastRingNo = ring.RingNo;

                        String ringTmp = String.Format(ringTemplate, ring.ID, ring.RingNo);
                        DataSet judgesDS = rings.GetJudgesForRing(ring.ID);
                        if (judgesDS.Tables[0].Rows.Count > 0)
                        {
                            foreach (DataRow judgeRow in judgesDS.Tables[0].Rows)
                            {
                                Judge judge = new Judge(judgeRow);
                                ringTmp += CreateRing(currentShowDate, ring, judge, ringJudgeClassTemplate, lastRingNo);
                            }
                        }
                        else
                        {
                            ringTmp += CreateRing(currentShowDate, ring, new Judge(), "", lastRingNo);
                        }

                        ringTmp += "</div>";
                        ringContainer.InnerHtml += ringTmp;
                    }

                }

                tmp = "";
                DataSet ds = Judge.GetAllFreeJudgesForShow(showDetailsID);
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    tmp += String.Format("<li class='ui-state-default judgeDetails'><div judgeid='{0}'  class='judgeDetails'>{1}</div></li>",
                                                row["JudgeID"], row["Name"]
                                                );
                }
                judgesAvailable.InnerHtml = tmp;

                tmp = "";
                Helpers helpers = new Helpers();
                ds = helpers.GetAllFreeHelpersForShow(showid, currentShowDate.ShowDate);
                if (ds.Tables.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        Helpers h = new Helpers(row);
                        String job = expandJob(h.Job, h.JobDetails);
                        tmp += String.Format("<li class='ui-state-default'><div helperid='{0}' judgeid='{2}'  class='helperDetails'>{1} ({3})</div></li>",
                                                    h.ID, h.Name, row["judgeid"], job
                                                    );
                    }
                }
                helpersAvailable.InnerHtml = tmp;

            }
        }