function XmlCreateSessionsAlpha()
{
    $XmlDoc = new DOMDocument('1.0', 'UTF-8');
    $TmpNode = $XmlDoc->createProcessingInstruction("xml-stylesheet", 'type="text/xsl" href="/Common/Styles/StyleStartList.xsl" ');
    $XmlDoc->appendChild($TmpNode);
    $XmlRoot = $XmlDoc->createElement('Results');
    $XmlRoot->setAttribute('IANSEO', ProgramVersion);
    $XmlRoot->setAttribute('TS', date('Y-m-d H:i:s'));
    $XmlDoc->appendChild($XmlRoot);
    $ListHeader = NULL;
    $MyQuery = getStartListAlphaQuery();
    $Rs = safe_r_sql($MyQuery);
    $StartLetter = ".";
    while ($MyRow = safe_fetch($Rs)) {
        if ($StartLetter != strtoupper(substr($MyRow->FirstName, 0, 1))) {
            $StartLetter = strtoupper(substr($MyRow->FirstName, 0, 1));
            $ListHeader = $XmlDoc->createElement('List');
            $ListHeader->setAttribute('Title', $StartLetter);
            $ListHeader->setAttribute('Columns', 10);
            $XmlRoot->appendChild($ListHeader);
            $TmpNode = $XmlDoc->createElement('Caption', get_text('Code', 'Tournament'));
            $TmpNode->setAttribute('Name', 'Code');
            $TmpNode->setAttribute('Columns', '1');
            $ListHeader->appendChild($TmpNode);
            $TmpNode = $XmlDoc->createElement('Caption', get_text('Athlete'));
            $TmpNode->setAttribute('Name', 'Athlete');
            $TmpNode->setAttribute('Columns', '1');
            $ListHeader->appendChild($TmpNode);
            $TmpNode = $XmlDoc->createElement('Caption', get_text('Country'));
            $TmpNode->setAttribute('Name', 'Country');
            $TmpNode->setAttribute('Columns', '2');
            $ListHeader->appendChild($TmpNode);
            $TmpNode = $XmlDoc->createElement('Caption', get_text('Session'));
            $TmpNode->setAttribute('Name', 'Session');
            $TmpNode->setAttribute('Columns', '1');
            $ListHeader->appendChild($TmpNode);
            $TmpNode = $XmlDoc->createElement('Caption', get_text('Target'));
            $TmpNode->setAttribute('Name', 'Target');
            $TmpNode->setAttribute('Columns', '1');
            $ListHeader->appendChild($TmpNode);
            $TmpNode = $XmlDoc->createElement('Caption', get_text('AgeCl'));
            $TmpNode->setAttribute('Name', 'AgeClass');
            $TmpNode->setAttribute('Columns', '1');
            $ListHeader->appendChild($TmpNode);
            $TmpNode = $XmlDoc->createElement('Caption', get_text('SubCl', 'Tournament'));
            $TmpNode->setAttribute('Name', 'SubCl');
            $TmpNode->setAttribute('Columns', '1');
            $ListHeader->appendChild($TmpNode);
            $TmpNode = $XmlDoc->createElement('Caption', get_text('Div'));
            $TmpNode->setAttribute('Name', 'Div');
            $TmpNode->setAttribute('Columns', '1');
            $ListHeader->appendChild($TmpNode);
            $TmpNode = $XmlDoc->createElement('Caption', get_text('Cl'));
            $TmpNode->setAttribute('Name', 'Class');
            $TmpNode->setAttribute('Columns', '1');
            $ListHeader->appendChild($TmpNode);
        }
        $XmlAthlete = $XmlDoc->createElement('Athlete');
        $ListHeader->appendChild($XmlAthlete);
        $Element = $XmlDoc->createElement('Item', $MyRow->Bib);
        $Element->setAttribute('Name', 'Bib');
        $XmlAthlete->appendChild($Element);
        $Element = $XmlDoc->createElement('Item', $MyRow->FirstName . ' ' . $MyRow->Name);
        $Element->setAttribute('Name', 'Athlete');
        $XmlAthlete->appendChild($Element);
        $Element = $XmlDoc->createElement('Item', $MyRow->NationCode);
        $Element->setAttribute('Name', 'CountryCode');
        $XmlAthlete->appendChild($Element);
        $Element = $XmlDoc->createElement('Item', $MyRow->Nation);
        $Element->setAttribute('Name', 'Country');
        $XmlAthlete->appendChild($Element);
        $Element = $XmlDoc->createElement('Item', $MyRow->Session);
        $Element->setAttribute('Name', 'Session');
        $XmlAthlete->appendChild($Element);
        $Element = $XmlDoc->createElement('Item', $MyRow->TargetNo);
        $Element->setAttribute('Name', 'TargetNo');
        $XmlAthlete->appendChild($Element);
        $Element = $XmlDoc->createElement('Item', $MyRow->AgeClass);
        $Element->setAttribute('Name', 'AgeClass');
        $XmlAthlete->appendChild($Element);
        $Element = $XmlDoc->createElement('Item', $MyRow->SubClass);
        $Element->setAttribute('Name', 'SubClass');
        $XmlAthlete->appendChild($Element);
        $Element = $XmlDoc->createElement('Item', $MyRow->DivCode);
        $Element->setAttribute('Name', 'Div');
        $XmlAthlete->appendChild($Element);
        $Element = $XmlDoc->createElement('Item', $MyRow->ClassCode);
        $Element->setAttribute('Name', 'Class');
        $XmlAthlete->appendChild($Element);
    }
    return $XmlDoc;
}
function getStartListAlphabetical($ORIS = '')
{
    $Data = new StdClass();
    $Data->Code = 'C32B';
    $Data->Order = '3';
    $Data->Description = 'Entries by Name';
    $Data->Header = array("Name", "NOC", "Country", "Date of Birth", "Back No.", "Event");
    $Data->HeaderWidth = array(50, 10, 35, 30, 20, 45);
    $Data->Phase = '';
    $Data->Continue = get_text('Continue');
    $Data->Data = array();
    $Data->Data['Fields'] = array('SesName' => get_text('Session'), 'Athlete' => get_text('Athlete'), 'Bib' => get_text('Code', 'Tournament'), "Session" => get_text('SessionShort', 'Tournament'), 'TargetNo' => get_text('Target'), 'Nation' => get_text('Country'), 'NationCode' => get_text('Country'), 'AgeClass' => get_text('AgeCl'), 'SubClass' => get_text('SubCl', 'Tournament'), 'DivDescription' => get_text('Division'), 'ClDescription' => get_text('Class'), 'Category' => get_text('Event'), 'Status' => get_text('Status', 'Tournament'), 'TargetFace' => get_text('TargetType'));
    if ($ORIS) {
        $Data->Data['Fields']['Athlete'] = "Name";
        $Data->Data['Fields']['TargetNo'] = "Target";
        $Data->Data['Fields']['NationCode'] = "NOC";
        $Data->Data['Fields']['Nation'] = "Country";
        $Data->Data['Fields']['Category'] = "Event";
        $Data->Data['Fields']['SesName'] = "Session";
    } else {
        $Data->HideCols = GetParameter("IntEvent");
        $Data->Description = get_text('StartlistAlpha', 'Tournament');
    }
    $MyQuery = getStartListAlphaQuery($ORIS);
    $OldLetter = '';
    $Group = 0;
    //echo $MyQuery;exit;
    $Rs = safe_r_sql($MyQuery);
    while ($MyRow = safe_fetch($Rs)) {
        if ($OldLetter != $MyRow->FirstLetter) {
            $Group++;
            $OldLetter = $MyRow->FirstLetter;
        }
        $MyRow->EventName = get_text($MyRow->EventName, '', '', true);
        $Data->Data['Items'][$Group][] = $MyRow;
    }
    return $Data;
}