/***************************************************************/
/*                                                             */
/*  Default javascript functions used on Droknars website      */
/*                                                             */
/*  Created by Derek Buck                                      */
/*                                                             */
/***************************************************************/

basefolder = "http://" + location.host;

/***************************************************************/
/*                                                             */
/*  This function is designed to show a e-mail address.        */
/*  It is used to prevent e-mail farming bots from seeing it.  */
/*                                                             */
/*  This function has no attributes:                           */
/*                                                             */
/*  This function does not return anything                     */
/*                                                             */
/***************************************************************/
function contact() {
   var part1 = "draco";
   var part2 = "@";
   var part3 = "droknarsarenadogs";
   var part4 = ".";
   var part5 = "com";
   var whole = part1 + part2 + part3 + part4 + part5;
   document.write("<a href=" + "mail" + "to:" + whole + ">" + whole + "</a>");
}



/***************************************************************/
/*                                                             */
/*  This function generates a random header then writes the    */
/*  tag to the page, it uses a table and sets the image as     */
/*  the background.                                            */
/*                                                             */
/*  This function has one attribute:                           */
/*  background - A image file that can be used instead of      */
/*  randomly choosing one from list.                           */
/*                                                             */
/*  This function does not return anything                     */
/*                                                             */
/***************************************************************/
function randomHeader(background, tag) {

   headerFolder = basefolder + "/headers/";
       
   if ((tag == "") || (tag == null))
   {
      startTag = '<img id="img0" src="' + headerFolder;
   }
   else
   {
      startTag = '<img id="img0" src="' + headerFolder + tag;
   }
   endTag = '" width="1000" height="300" />';

   /* If no background image specified randomly select one */
   if ((background == "") || (background == null))
   {
      image = '';

      var value = Math.random();

      if (value > 0.93)
      {
         image = 'hd01.jpg';
      }
      else if (value > 0.86)
      {
         image = 'hd02.jpg';
      }
      else if (value > 0.79)
      {
         image = 'hd03.jpg';
      }
      else if (value > 0.71)
      {
         image = 'hd04.jpg';
      }
      else if (value > 0.64)
      {
         image = 'hd05.jpg';
      }
      else if (value > 0.57)
      {
         image = 'hd06.jpg';
      }
      else if (value > 0.5)
      {
         image = 'hd07.jpg';
      }
      else if (value > 0.43)
      {
         image = 'hd08.jpg';
      }
      else if (value > 0.36)
      {
         image = 'hd09.jpg';
      }
      else if (value > 0.29)
      {
         image = 'hd10.jpg';
      }
      else if (value > 0.21)
      {
         image = 'hd11.jpg';
      }
      else if (value > 0.14)
      {
         image = 'hd12.jpg';
      }
      else if (value > 0.07)
      {
         image = 'hd13.jpg';
      }
      else
      {
         image = 'hd00.jpg';
      }


   }
   /* Else use specified image */
   else
   {
      image = background;
   }

   /* Construct image tag and print to page */
   document.write(startTag + image + endTag);
}


