# FILE bbmencomb.pl  working copy  running time  sec
# fix NC sandings to include /PL/ for playoffs
#============= CREATE SCORES PAGE ===================
$scofile='BBMsco0102.txt'; 
open (SCORES,"<$scofile") || die "Can't open $scorefile $!";
open (SCORESHTML, ">bbmscores0102.html");
print SCORESHTML "<html><head><title>CIAU Mens BB scores 2001-02</title>
</head>
<body>
<Font Face=Arial size=-1>\n
<big><b>Mens Basketball Scores 2001-02</b></big>";

while (<SCORES>) { 
	($date,$Tm1,$Sco1,$Tm2,$Sco2,$GmType,$Notes) = split(':',$_);	

  ### Flag any reversed score, stops program, prints line to warn 
if ($Sco1 < $Sco2) { 
die
print "$date $Tm1 $Sco1 $Tm2 $Sco2 $GmType $Notes";
}
                                        # dispose of heading in data file
if ($date =~ /CIAU/) {
print SCORESHTML "<big><b>$date</b></big>\n";   next;
}
                          # print date if alone on datafile row
if  ($Tm1 le " ") {   
  print SCORESHTML "<br><b>$date</b>\n";
                 }              
                          #print score lines without dates
else {                    
print SCORESHTML "<br>$Tm1 $Sco1 $Tm2 $Sco2 $Notes\n";
     }
}
print SCORESHTML "</body></html>"; #close HTML file
close SCORESHTML;

#====================================================
#### TEAM-BY-TEAM SCORES ###
#====================================================

$scofile='BBMsco0102.txt'; 
open (SCORES,"<$scofile") || die "Can't open $scorefile $!";
open (TEAMDATA, ">bbmteams0102.html");
print TEAMDATA "
<HTML><HEAD>

<STYLE>
TD {font: 10pt arial}
</STYLE>
</head>
<BODY bgcolor=white LINK=\"\#0000ff\" VLINK=\"\#0000ff\"> <Font Face=Arial Size=-1>

<TABLE border=0  cellspacing=4 cellpadding=4>
<TR>
<TD  colspan=4 align=center  BGCOLOR=\"\#d2d5e1\">
<B>2001-02 MBB Scores by Team</B><small>

<TR>
<TD  NOWRAP align=center valign=top BGCOLOR=\"\#d2d5e1\">
<B>Atlantic</B><Br>
<A HREF=\"\#Acadia\">Acadia</A><Br>
<A HREF=\"\#Dalhousie\">Dalhousie</A><Br>
<A HREF=\"\#Saint Mary's\">Saint Mary's</A><Br>
<A HREF=\"\#Memorial\">Memorial</A><Br>
<A HREF=\"\#StFX\">StFX</A><Br>
<A HREF=\"\#St. Thomas\">St. Thomas</A><Br>
<A HREF=\"\#UNB\">UNB</A><Br>
<A HREF=\"\#UPEI\">UPEI</A><Br>

<B>Quebec</B><Br>
<A HREF=\"\#Bishop's\">Bishop's</A><Br>
<A HREF=\"\#Concordia\">Concordia</A><Br>
<A HREF=\"\#Laval\">Laval</A><Br>
<A HREF=\"\#McGill\">McGill</A><Br>

<TD align=center valign=top BGCOLOR=\"\#d2d5e1\"><B>OUA East</B><Br>
<A HREF=\"\#Carleton\">Carleton</A><Br>
<A HREF=\"\#Ottawa\">Ottawa</A><Br>
<A HREF=\"\#Laurentain\">Laurentain</A><Br>
<A HREF=\"\#Queen's\">Queen's</A><Br>
<A HREF=\"\#RMC\">RMC</A><Br>
<A HREF=\"\#Ryerson\">Ryerson</A><Br>
<A HREF=\"\#Toronto\">Toronto</A><Br>
<A HREF=\"\#York\">York</A><Br>

<B>OUA West</B><Br>
<A HREF=\"\#Brock\">Brock</A><Br>
<A HREF=\"\#Guelph\">Guelph</A><Br>
<A HREF=\"\#Laurier\">Laurier</A><Br>
<A HREF=\"\#Lakehead\">Lakehead</A><Br>
<A HREF=\"\#McMaster\">McMaster</A><Br>
<A HREF=\"\#Waterloo\">Waterloo</A><Br>
<A HREF=\"\#Western\">Western</A><Br>
<A HREF=\"\#Windsor\">Windsor</A><Br>

<TD  align=center valign=top BGCOLOR=\"\#d2d5e1\">
<B>CanWest</B><Br>
<A HREF=\"\#Brandon\">Brandon</A><Br>
<A HREF=\"\#Manitoba\">Manitoba</A><Br>
<A HREF=\"\#Regina\">Regina</A><Br>
<A HREF=\"\#Saskatchewan\">Saskatchewan</A><Br>
<A HREF=\"\#Winnipeg\">Winnipeg</A><Br>
<A HREF=\"\#Alberta\">Alberta</A><Br>
<A HREF=\"\#Calgary\">Calgary</A><Br>
<A HREF=\"\#Lethbridge\">Lethbridge</A><Br>
<A HREF=\"\#Simon Fraser\">Simon Fraser</A><Br>
<A HREF=\"\#TWU\">TWU</A><Br>
<A HREF=\"\#UBC\">UBC</A><Br>
<A HREF=\"\#Victoria\">Victoria</A><Br>
</TR></TD></TABLE>
&nbsp;
";



@TeamName = ("Acadia", "Memorial", "Saint Mary's", "StFX", 
"Dalhousie", "UCCB", "UNB", "UPEI",
"Bishop's", "Concordia", "Laval", "McGill",  
"Carleton", "Laurentian", "Queen's", "Ottawa", 
"RMC", "Ryerson", "Toronto", "York", 
"Brock", "Guelph", "Laurier","Lakehead", 
"McMaster", "Waterloo", "Western", "Windsor", 
"Brandon", "Manitoba", "Regina", "Winnipeg",
"Alberta", "Calgary", "Lethbridge", "Saskatchewan", 
"Simon Fraser", "TWU", "UBC", "Victoria",);

foreach $team (@TeamName) {
open (TEAMDATA, ">>bbmteams0102.html");

print TEAMDATA "<p><dd><big><big><A NAME=\"$team\">$team</A></big></big>\n";

open (SCORES,"<$scofile") || die "Can't open $scorefile $!";
while (<SCORES>) { 
	($Date,$Tm1,$Sco1,$Tm2,$Sco2,$GmType,$Notes) = split(':',$_);	
   
if  ($Tm1 eq $team || $Tm2 eq $team)   {   
  print TEAMDATA "<br>$Date $Tm1 $Sco1 $Tm2 $Sco2 $GmType $Notes\n";
     }
}
}
print TEAMDATA "</body></html>";


#====================================================
#### CREATING STANDINGS MDA file ###
#====================================================


$scofile='BBMsco0102.txt'; 
 open (BBMMDA, ">bbmstand.txt") || die "Can't open bbmstand.txt $!"; 
print BBMMDA "";

@TeamName = ("Acadia", "Dalhousie", "Saint Mary's", "Memorial",
"StFX", "UCCB", "UNB", "UPEI",
"Bishop's", "Concordia", "Laval", "McGill",  
"Carleton", "Laurentian", "Queen's", "Ottawa", 
"RMC", "Ryerson", "Toronto", "York", 
"Brock", "Guelph", "Laurier","Lakehead", 
"McMaster", "Waterloo", "Western", "Windsor", 
"Brandon", "Manitoba", "Regina", "Saskatchewan", "Winnipeg",
"Alberta", "Calgary", "Lethbridge", "Simon Fraser", 
"TWU", "UBC", "Victoria",);

foreach $team (@TeamName) {
  open (SCORES,"<$scofile") || die "Can't open $scorefile $!";
  open (BBMMDA, ">>bbmstand.txt") || die "Can't open bbmstand.txt $!"; 

            # initialize counts
$teamwins=0; $teamlosses=0; $teamgp=0; $teamties=0; 
$pfor=0; $Against=0; $WLpct=0; $Margin=0; $Pts=0; 
$WLpct=0; $pfpg=0; $papg=0; $mgp=0;  $olosses=0;  
$NCwins=0;  $NClosses=0;  $NCties=0;
$CISwins=0; $CISlosses=0; $CISpct=0;
$EXwins=0;  $EXlosses=0;  $EXties=0;
$OAwins=0;  $OAlosses=0;  $OApct=0; $OAgp=0;

              # while reading SCORES (BBMsco0102.txt) line-by-line 
              # parse it at colons : into standings variables  
while (<SCORES>) {    
	($date,$Tm1,$Sco1,$Tm2,$Sco2,$GmType,$Notes) = split(':',$_);	


                   #-------------------------------------------
                   # BEGIN calculation of standings variables.
                   #-------------------------------------------
if ($Tm1 eq $team and $GmType eq "" )   { 
                                     # selects Conference only
++$teamgp; ++$teamwins;             # counts name in winner column
$pfor = ($pfor + $Sco1);             # adds winner's score to FOR 
$Against = ($Against + $Sco2);       # adds loser's score to AGAINST
}
elsif ($Tm2 eq $team && $GmType eq "")   {
++$teamgp; ++$teamlosses;           # counts name in loser column 
$pfor = ($pfor + $Sco2);             # adds loser's score to FOR
$Against = ($Against + $Sco1);       # adds winner's score to AGAINST 
}
$Margin = ($pfor - $Against);

        #============== NON CONF ===============
if (($Tm1 eq $team) and ($GmType =~ /NC|PL/)) { 
++$NCwins;
}
elsif (($Tm2 eq $team) and ($GmType =~ /NC|PL/))   {
++$NClosses;
}
$CISwins = ( $teamwins + $NCwins) ;    
$CISlosses = ($teamlosses + $NClosses) ;    

        #============== OVERALL =================
if (($Tm1 eq $team) and ($GmType =~ /EX/)) { 
++$EXwins;
}
elsif (($Tm2 eq $team) and ($GmType =~ /EX/))   {
++$EXlosses;
}
$OAwins = ( $teamwins + $NCwins + $EXwins) ;    
$OAlosses = ($teamlosses + $NClosses + $EXlosses) ;    
         #=================================================

$Pts = (2 * $teamwins); 

#======================================
# WL Percent Conference
#======================================
if ($teamgp == 0) {  
    $WLpct = 1.000 ; 
}                    
                                     # calc W/L %, elim div by zero 
elsif ($teamlosses == 0 and $teamgp != 0) {  
$WLpct = 1.000;                          #NEW > > > > > > >
}
else {
$WLpct = ($teamwins / $teamgp );
}


if ($team =~ /Acadia|Memorial|Saint Mary's|StFX|/) {
   $conf = "aAUBaldwin";
   }
if ($team =~ /Dalhousie|UCCB|UNB|UPEI/) {   
   $conf = "bAUNelson";
   }
elsif ($team =~ /Bishop's|Concordia|Laval|McGill/) {
   $conf = "cQUE";
   }
elsif ($team =~ /Carleton|Laurentian|Ottawa|Queen's|RMC|Ryerson|Toronto|York/) {
   $conf = "dOUAE";
   }
elsif ($team =~ /Brock|Guelph|Lakehead|Laurier|McMaster|Waterloo|Western|Windsor/) {
   $conf = "eOUAW";
   }
elsif ($team =~ /Brandon|Manitoba|Regina|Winnipeg/) {
   $conf = "gCWGP";
   }
elsif ($team =~ /Alberta|Calgary|Lethbridge|Saskatchewan/) {
   $conf = "hCWC";
   }
elsif ($team =~ /Simon Fraser|TWU|UBC|Victoria/) {
   $conf = "jCWW";
   }
}   
# Baldwin:  Acadia, Memorial, Saint Mary's, StFX,
# Nelson:   Dalhousie, UCCB, UNB, UPEI
# Quebec:   Concordia, McGill, Bishop's, Laval
# OUA East: Carleton, Laurentian, Ottawa, Queen's, 
#           RMC, Ryerson, Toronto York 
# OUA West: Brock, Guelph, Laurier, Lakehead, 
#           McMaster Waterloo, Western, Windsor 
# G Plains: Brandon Manitoba Regina Winnipeg	
# Central:  Alberta Calgary Lethbridge Saskatchewan 
# Coast:    Simon Fraser TWU UBC Victoria

            # END calculation of standings variables for Team.

print BBMMDA "$team:$conf:$teamgp:$teamwins:$teamlosses:$pfor:$Against:$Pts:$WLpct:$Margin:$CISwins:$CISlosses:$OAwins:$OAlosses\n";
#"$team:$conf:$teamgp:$teamwins:$teamlosses:$pfor:$Against:$Margin:$Pts:
#$WLpct:$pfpg:$papg:$mgp:$CISwins:$CISlosses:$CISpct:$OAwins:$OAlosses:$#OApct\n";
}
close BBMMDA;

#====================================================
#### SORTING STANDINGS ###
#====================================================

$stanfile='bbmstand.txt'; 
open (BBMMDA, "<bbmstand.txt") || die "Can't open $stanfile $!"; 

@mda = <BBMMDA>; 
@mdasorted = map { $_->[0] }
 sort {
        $a->[2] cmp $b->[2]   # Conf
||      $b->[8] <=> $a->[8]   # Points
||      $b->[9] <=> $a->[9]   # Percent
||      $b->[10] <=> $a->[10]   # Margin
||      $a->[1] cmp $b->[1]   # Team 
}
map { [ $_, (split /:/, $_,) ] } 
@mda; 

open (STANHTML, ">bbmstand0102.html");
print STANHTM "";
open (STANHTML, ">>bbmstand0102.html");

open (STANAUSB, ">bbmstanausb.txt");
open (STANAUSN, ">bbmstanausn.txt");
open (STANQUE, ">bbmstanque.txt");
open (STANOUAE, ">bbmstanouae.txt");
open (STANOUAW, ">bbmstanouaw.txt");
open (STANCWGP, ">bbmstancwgp.txt");
open (STANCWC, ">bbmstancwc.txt");
open (STANCWW, ">bbmstancww.txt");

print STANAUSB @mdasorted[0 .. 3];  ##AUSBaldwin .. begins zero
print STANAUSN @mdasorted[4 .. 7];  ##AUSNelson 
print STANQUE @mdasorted[8 .. 11];  ##Quebec
print STANOUAE @mdasorted[12 .. 19];  ##OUAEast
print STANOUAW @mdasorted[20 .. 27];  ##OUAWest
print STANCWGP @mdasorted[28 .. 31];  ##CanWestGPlains
print STANCWC @mdasorted[32 .. 35];  ##CanWestCentral
print STANCWW @mdasorted[36 .. 39];  ##CanWestWest

##======================================================
print STANHTML "
<HTML><HEAD><title>BB Men Standings 2001-02</title>
<STYLE>
td {font: 10pt arial; text-align:right}
th {font: 10pt arial; font-weight=bold; text-align:right}
</STYLE>
</head>
<BODY bgcolor=white LINK=0000ff VLINK=0000ff> <Font Face=Arial Size=-1>
<TABLE border=0  cellspacing=3 cellpadding=0 bgcolor=white>
<TR>
<TD style=text-align:center colspan=8>
<B>2001-02 Mens BB Standings</B></td></TR>
<tr><td style=text-align:left> &nbsp; </td><td colspan=6 bgcolor=#d2d5e1 style=text-align:center>CONFERENCE</td><td colspan=2 bgcolor=#EFCDCC style=text-align:center> CIS </td><td colspan=2 bgcolor=#CCD7CA style=text-align:center>Oall</td></tr>
";
##======================================================
##================AUS Baldwin=======================
print STANHTML "
<tr><th style=text-align:left nowrap>AUS Baldwin</th><th>&nbsp;W </th><th>&nbsp;L </th><th> &nbsp; F  </th><th>   A </th><th>&nbsp;  P </th><th>Pct </th><th>W </th><th>L </th><th>W </th><th>L </th></tr>";

open (STANAUSB, "<bbmstanausb.txt");

while (<STANAUSB>) { 
	($tm,$tmconf,$tmgp,$tmw,$tml,$tmf,$tma,$tmpts,$tmpct,$Margin,
$CISwins,$CISlosses,$OAwins,$OAlosses) = split(':',$_);	

$tmpct = sprintf("%.3f", $tmpct);   ## converts to 3 places
$tmpct =~ s/^0/ /g;                 ## replace Leading Zeros

print STANHTML "
<tr><td style=text-align:left>$tm</td>
<td>$tmw</td><td>$tml</td>
<td>$tmf</td><td>$tma</td><td>$tmpts</td>
<td>$tmpct</td>
<td>$CISwins</td><td>$CISlosses</td>
<td>$OAwins</td><td>$OAlosses</td>
</tr>";
}

##======================================================
##================AUS Nelson =======================
print STANHTML "
<tr><th style=text-align:left>AUS Nelson</th><th>&nbsp;W </th><th>&nbsp;L </th><th> &nbsp; F  </th><th>   A </th><th>&nbsp;  P </th><th>Pct </th><th>W </th><th>L </th><th>W </th><th>L </th></tr>";

open (STANAUSN, "<bbmstanausn.txt");

while (<STANAUSN>) { 
	($tm,$tmconf,$tmgp,$tmw,$tml,$tmf,$tma,$tmpts,$tmpct,$Margin,
$CISwins,$CISlosses,$OAwins,$OAlosses) = split(':',$_);	

$tmpct = sprintf("%.3f", $tmpct);   ## converts to 3 places
$tmpct =~ s/^0/ /g;                 ## replace Leading Zeros

print STANHTML "
<tr><td style=text-align:left>$tm</td>
<td>$tmw</td><td>$tml</td>
<td>$tmf</td><td>$tma</td><td>$tmpts</td>
<td>$tmpct</td>
<td>$CISwins</td><td>$CISlosses</td>
<td>$OAwins</td><td>$OAlosses</td>
</tr>";
}

##================ QUEBEC =====================

print STANHTML "
<tr><th style=text-align:left>Quebec</th><th>&nbsp;W </th><th>&nbsp;L </th><th> &nbsp; F  </th><th>   A </th><th>&nbsp;  P </th><th>Pct </th><th>W </th><th>L </th><th>W </th><th>L </th></tr>";

open (STANQUE, "<bbmstanque.txt");

while (<STANQUE>) { 
	($tm,$tmconf,$tmgp,$tmw,$tml,$tmf,$tma,$tmpts,$tmpct,$Margin,
$CISwins,$CISlosses,$OAwins,$OAlosses) = split(':',$_);	

$tmpct = sprintf("%.3f", $tmpct);   ## converts to 3 places
$tmpct =~ s/^0/ /g;                 ## replace Leading Zeros

print STANHTML "
<tr><td style=text-align:left>$tm</td>
<td>$tmw</td><td>$tml</td>
<td>$tmf</td><td>$tma</td><td>$tmpts</td>
<td>$tmpct</td>
<td>$CISwins</td><td>$CISlosses</td>
<td>$OAwins</td><td>$OAlosses</td>
</tr>";
}


##================OUAE=======================

print STANHTML "
<tr><th style=text-align:left>OUAE </th><th>&nbsp;W </th><th>&nbsp;L </th><th> &nbsp; F  </th><th>   A </th><th>&nbsp;  P </th><th>Pct </th><th>W </th><th>L </th><th>W </th><th>L </th></tr>";

open (STANOUAE, "<bbmstanouae.txt");

while (<STANOUAE>) { 
	($tm,$tmconf,$tmgp,$tmw,$tml,$tmf,$tma,$tmpts,$tmpct,$Margin,
$CISwins,$CISlosses,$OAwins,$OAlosses) = split(':',$_);	

$tmpct = sprintf("%.3f", $tmpct);   ## converts to 3 places
$tmpct =~ s/^0/ /g;                 ## replace Leading Zeros

print STANHTML "
<tr><td style=text-align:left>$tm</td>
<td>$tmw</td><td>$tml</td>
<td>$tmf</td><td>$tma</td><td>$tmpts</td>
<td>$tmpct</td>
<td>$CISwins</td><td>$CISlosses</td>
<td>$OAwins</td><td>$OAlosses</td>
</tr>";
}


##================OUAW=======================

print STANHTML "
<tr><th style=text-align:left>OUAW</th><th>&nbsp;W </th><th>&nbsp;L </th><th> &nbsp; F  </th><th>   A </th><th>&nbsp;  P </th><th>Pct </th><th>W </th><th>L </th><th>W </th><th>L </th></tr>";

open (STANOUAW, "<bbmstanouaw.txt");

while (<STANOUAW>) { 
	($tm,$tmconf,$tmgp,$tmw,$tml,$tmf,$tma,$tmpts,$tmpct,$Margin,
$CISwins,$CISlosses,$OAwins,$OAlosses) = split(':',$_);	

$tmpct = sprintf("%.3f", $tmpct);   ## converts to 3 places
$tmpct =~ s/^0/ /g;                 ## replace Leading Zeros

print STANHTML "
<tr><td style=text-align:left>$tm</td>
<td>$tmw</td><td>$tml</td>
<td>$tmf</td><td>$tma</td><td>$tmpts</td>
<td>$tmpct</td>
<td>$CISwins</td><td>$CISlosses</td>
<td>$OAwins</td><td>$OAlosses</td>
</tr>";
}




##================CWGP=======================

print STANHTML "
<tr><th style=text-align:left>CW Plains</th><th>&nbsp;W </th><th>&nbsp;L </th><th> &nbsp; F  </th><th>   A </th><th>&nbsp;  P </th><th>Pct </th><th>W </th><th>L </th><th>W </th><th>L </th></tr>";

open (STANCWGP, "<bbmstancwgp.txt");

while (<STANCWGP>) { 
	($tm,$tmconf,$tmgp,$tmw,$tml,$tmf,$tma,$tmpts,$tmpct,$Margin,
$CISwins,$CISlosses,$OAwins,$OAlosses) = split(':',$_);	

$tmpct = sprintf("%.3f", $tmpct);   ## converts to 3 places
$tmpct =~ s/^0/ /g;                 ## replace Leading Zeros

print STANHTML "
<tr><td style=text-align:left>$tm</td>
<td>$tmw</td><td>$tml</td>
<td>$tmf</td><td>$tma</td><td>$tmpts</td>
<td>$tmpct</td>
<td>$CISwins</td><td>$CISlosses</td>
<td>$OAwins</td><td>$OAlosses</td>
</tr>";
}

##================CWC=======================

print STANHTML "
<tr><th style=text-align:left>CW Central</th><th>&nbsp;W </th><th>&nbsp;L </th><th> &nbsp; F  </th><th>   A </th><th>&nbsp;  P </th><th>Pct </th><th>W </th><th>L </th><th>W </th><th>L </th></tr>";

open (STANCWC, "<bbmstancwc.txt");

while (<STANCWC>) { 
	($tm,$tmconf,$tmgp,$tmw,$tml,$tmf,$tma,$tmpts,$tmpct,$Margin,
$CISwins,$CISlosses,$OAwins,$OAlosses) = split(':',$_);	

$tmpct = sprintf("%.3f", $tmpct);   ## converts to 3 places
$tmpct =~ s/^0/ /g;                 ## replace Leading Zeros

print STANHTML "
<tr><td style=text-align:left>$tm</td>
<td>$tmw</td><td>$tml</td>
<td>$tmf</td><td>$tma</td><td>$tmpts</td>
<td>$tmpct</td>
<td>$CISwins</td><td>$CISlosses</td>
<td>$OAwins</td><td>$OAlosses</td>
</tr>";
}

##================CWW=======================

print STANHTML "
<tr><th style=text-align:left>CW West</th><th>&nbsp;W </th><th>&nbsp;L </th><th> &nbsp; F  </th><th>   A </th><th>&nbsp;  P </th><th>Pct </th><th>W </th><th>L </th><th>W </th><th>L </th></tr>";

open (STANCWW, "<bbmstancww.txt");

while (<STANCWW>) { 
	($tm,$tmconf,$tmgp,$tmw,$tml,$tmf,$tma,$tmpts,$tmpct,$Margin,
$CISwins,$CISlosses,$OAwins,$OAlosses) = split(':',$_);	

$tmpct = sprintf("%.3f", $tmpct);   ## converts to 3 places
$tmpct =~ s/^0/ /g;                 ## replace Leading Zeros

print STANHTML "
<tr><td style=text-align:left>$tm</td>
<td>$tmw</td><td>$tml</td>
<td>$tmf</td><td>$tma</td><td>$tmpts</td>
<td>$tmpct</td>
<td>$CISwins</td><td>$CISlosses</td>
<td>$OAwins</td><td>$OAlosses</td>
</tr>";
}


print STANHTML "</td></tr></table></body></html>";

    ### END STANDINGS PAGE ###

##  Tm conf g w l   f  a    m  p    %    fgp   agp     mgp  
##York:aAUS:8:3:5:99:205:-106:6:0.375:12.375:25.625:-13.25
##  1    2  3 4 5  6  7    8  9  10     11    12      13    

#------------------------------------------------------------------
#------------------------------------------------------------------



