// ------------------------------------------------------------
//        Scripts to write the components of the Website
// ------------------------------------------------------------

// MENU_STYLE: xmas:      XMas button is active
//             bunny:     Bunny button is active
//             any other: no additional button
MENU_STYLE = "default";


// banner in the top
function WriteBanner()
{
   if (MENU_STYLE == "xmas")
     document.write("<img src='./banner/signsmileys_xm.gif' alt='' border=0 onDblClick='window.location = \"./deifis.html\"'>");

   else if (MENU_STYLE == "bunny")
     document.write("<img src='./banner/signsmileys_bu.gif' alt='' border=0 onDblClick='window.location = \"./deifis.html\"'>");

   else
   {
      today = new Date();
      switch (today.getMonth())
      {
         case 0:
         case 1:
         case 11:
            document.write("<img src='./banner/signsmileys_wi.gif' alt='' border=0 onDblClick='window.location = \"./deifis.html\"'>");
            break;
         case 2:
         case 3:
         case 4:
            document.write("<img src='./banner/signsmileys_fr.gif' alt='' border=0 onDblClick='window.location = \"./deifis.html\"'>");
            break;
         case 5:
         case 6:
         case 7:
            document.write("<img src='./banner/signsmileys_so.gif' alt='' border=0 onDblClick='window.location = \"./deifis.html\"'>");
            break;
         case 8:
         case 9:
         case 10:
            document.write("<img src='./banner/signsmileys_he.gif' alt='' border=0 onDblClick='window.location = \"./deifis.html\"'>");
            break;
         default:
            document.write("<img src='./banner/signsmileys_standard.gif' alt='' border=0 onDblClick='window.location = \"./deifis.html\"'>");
      }
   }
}


// navigation menu
function WriteMenu(ActiveItem)
{
   document.write("<table width='100%'>");

   // 8 or 9 menu items?
   if ( (MENU_STYLE == "xmas") || (MENU_STYLE == "bunny") )
      document.write("<col width='12%' span=8>");
   else
      document.write("<col width='14%' span=7>");

   document.write("  <tr align='center'>");

   // start button
   if (ActiveItem == "start")
      document.write("<td class='button_red' rowspan=2><img src='./symbols/start.gif' alt='Startseite'></td>");
   else
      document.write("<td class='button_raw' onClick='window.location=\"./index.html\"' rowspan=2><img src='./symbols/start_bw.gif' alt='Home'></td>");

   // LongTom button
   if ( (ActiveItem == "ls") || (ActiveItem == "ln")  )
      document.write("<td class='button_blu' colspan=2><img src='./symbols/longtom_txt.gif' alt='Long Tom'></td>");
   else
      document.write("<td class='button_raw' onClick='window.location=\"./smiles_ls.html\"' colspan=2><img src='./symbols/longtom_txt.gif' alt='Long Tom'></td>");

   // dooya button
   if ( (ActiveItem == "ds") || (ActiveItem == "dn") )
      document.write("<td class='button_grn' colspan=2><img src='./symbols/dooya_txt.gif' alt='dooya'></td>");
   else
      document.write("<td class='button_raw' onClick='window.location=\"./smiles_ds.html\"' colspan=2><img src='./symbols/dooya_txt.gif' alt='dooya'></td>");

   // Xmas button
   if (MENU_STYLE == "xmas")
   {
      if (ActiveItem == "xmas")
         document.write("<td class='button_yel' rowspan=2><img src='./symbols/e_xmas.gif' alt='X-Mas'></td>");
      else
         document.write("<td class='button_raw' onClick='window.location=\"./smiles_xmas.html\"' rowspan=2><img src='./symbols/e_xmas_bw.gif' alt='X-Mas'></td>");
   }

   // bunny button
   if (MENU_STYLE == "bunny")
   {
      if (ActiveItem == "bunny")
         document.write("<td class='button_yel' rowspan=2><img src='./symbols/e_bunny.gif' alt='Bunnies'></td>");
      else
         document.write("<td class='button_raw' onClick='window.location=\"./smiles_bunny.html\"' rowspan=2><img src='./symbols/e_bunny_bw.gif' alt='Bunnies'></td>");
   }

   // list button
   if (ActiveItem == "list")
      document.write("<td class='button_red' rowspan=2><img src='./symbols/e_list.gif' alt='Smiley-List'></td>");
   else
      document.write("<td class='button_raw' onClick='window.location=\"./list.html\"' rowspan=2><img src='./symbols/e_list_bw.gif' alt='Smiley-List'></td>");

   // other button
   if (ActiveItem == "misc")
      document.write("<td class='button_red' rowspan=2><img src='./symbols/e_sonstiges.gif' alt='About this site'></td>");
   else
      document.write("<td class='button_raw' onClick='window.location=\"./misc_rules.html\"' rowspan=2><img src='./symbols/e_sonstiges_bw.gif' alt='About this site'></td>");

   document.write("  </tr><tr align='center'>");

   // long tom smileys with signs
   if (ActiveItem == "ls")
      document.write("<td class='button_blu'><img src='./symbols/e_public.gif' alt='Smileys with signs'></td>");
   else
      document.write("<td class='button_raw' onClick='window.location=\"./smiles_ls.html\"'><img src='./symbols/e_public_bw.gif' alt='Smileys with signs'></td>");

   // long tim smiley w/o signs
   if (ActiveItem == "ln")
      document.write("<td class='button_blu'><img src='./symbols/e_noschild.gif' alt='Smileys without signs'></td>");
   else
      document.write("<td class='button_raw' onClick='window.location=\"./smiles_ln.html\"'><img src='./symbols/e_noschild_bw.gif' alt='Smileys without signs'></td>");

   // dooya smileys with signs
   if (ActiveItem == "ds")
      document.write("<td class='button_grn'><img src='./symbols/e_public.gif' alt='Smileys with signs'></td>");
   else
      document.write("<td class='button_raw' onClick='window.location=\"./smiles_ds.html\"'><img src='./symbols/e_public_bw.gif' alt='Smileys with signs'></td>");

   // dooya smiley w/o signs
   if (ActiveItem == "dn")
      document.write("<td class='button_grn'><img src='./symbols/e_noschild.gif' alt='Smileys without signsr'></td>");
   else
      document.write("<td class='button_raw' onClick='window.location=\"./smiles_dn.html\"'><img src='./symbols/e_noschild_bw.gif' alt='Smileys without signs'></td>");

   document.write("  </tr></table>");
}


function WriteSmiles(Section)
{
   TabCSS = "";
   MaxCols = 8;
   MaxRows = 1;
   SmileyData = new Array();
   DataSet = "";
   SmileyCount = 0;
   SmileyIndex = 0;

   // check table color
   if ((Section == "ls") || (Section == "ln"))
   {
      TabCSS = "table_blu";
   }
   else if ((Section == "ds") || (Section == "dn"))
   {
      TabCSS = "table_grn";
   }
   else if ((Section == "xmas") || (Section == "bunny"))
   {
      TabCSS = "table_yel";
   }

   // get smileys of this section
   for (i = 0; i < raw_data.length; i++)
   {
      if (raw_data[i].split("|")[0] == Section)
      {
        SmileyData[SmileyCount] = raw_data[i];
        SmileyCount++;
      }
   }
   MaxRows = SmileyData.length/8;

   // write smiley table
   document.write("<table align='center' class='" + TabCSS + "'>");
   document.write("  <col width='12%' align='center' span=8>");
   for (Row = 0; Row < MaxRows; Row++)
   {
      document.write("  <tr id='line" + Row + "' class='cells_wht'>");

      for (Column = 0; Column < MaxCols ; Column++)
      {
         if (SmileyIndex < SmileyData.length)
         {
            DataSet = SmileyData[SmileyIndex].split("|");
            document.write("<td align='center'><img src='" + path[Section] + DataSet[2] + ".gif' style='cursor:pointer;' onClick='SmileShowCode(this.src)' alt = '" + DataSet[3].replace(/\s*/, "") + "'>");
            document.write("</td>");
            SmileyIndex++;
         }
         else document.write("<td align='center'><img src='./symbols/back.gif' alt='' onClick='SmileNoCode()'></td>");
      }
      document.write("</tr>");
   }
   document.write("</table>");

   // write foot table
   document.write("<table width='100%' style='margin-top:10px'><col width='25%'><col width='55%'><col width='5%'><col width='10%' span=2>");
   document.write("<tr align='center' valign='top'><td>&#160;</td>");

   document.write("<td class='info'><form action=''><input name='pfad' size=65>");
   document.write("<p style='margin-top:2px'>click on a smiley, copy the code and paste it into your post</p></form></td>");


   document.write("<td>&#160</td>");
   document.write("<td class='info' nowrap><img id='CodeUBB' style='cursor:pointer;' src='./symbols/code_ubb_on.gif'  alt='UBB-Code' onClick='SmileCodeChange(\"ubb\")'>");
   document.write("                        <img id='CodeHTM' style='cursor:pointer;' src='./symbols/code_html_off.gif' alt='HTML-Code' onClick='SmileCodeChange(\"html\")'><br>Coding</td>");
   document.write("<td class='info' nowrap><img id='BlaBa'   style='cursor:pointer;' src='./symbols/blackback_on.gif' alt='' onClick='SmileBlackBack(" + MaxRows + ")'>&#160; <br>Background</td>");
   document.write("</tr></table>");

}


// bottom line
function WriteBottom()
{
   document.write("<div style='position:absolute; right:10px; margin:5px' class='note'>");
   document.write("<a href='./sitemap.html'>Sitemap</a> |&#160;");
   document.write("<a href='./impressum.html' target='top'>Impressum</a> |&#160;");
   document.write("<a href='http://www.disclaimer.de/disclaimer.htm?farbe=FFFFFF/000000/000000/000000' target='top'>Disclaimer</a> |&#160;");
   document.write("<a href='mailto:long-tom&#0064;gmx.net'>Kontakt</a></div>");
   document.write("<div ><img src='./symbols/pi_off.gif' style='cursor:pointer' onMouseOver='this.src=\"./symbols/pi_on.gif\"' onMouseOut='this.src=\"./symbols/pi_off.gif\"' onClick='window.open(\"http://www.schildersmilies.de/usage/index.html\",\"_top\")' alt='Banner'></div>");
}


// change size of main window according to available window height
function AdjustHeight()
{
   document.getElementById("mainwin").height = document.body.clientHeight - 180;
}
