// drowtales manga rotating images dropdown box 
// written by mladyjade (mladyjade@yahoo.com) for Kern of http://www.drowtales.com
// do not reuse without permission

// happy 21st birthday Kern!

/********************************************************************************************/
// field 0 - URL for the link
// field 1 - title of the link
// field 2 - URL to the image for the link, if it exists.

var dtLinkList = [
   ["","  -- Drowtales' manga : --  "],
   ["http://www.drowtales.com"                 ,"Moonless Age"   ,"http://www.drowtales.com/manga_buttons/moonlessage.gif"],
 ["http://www.drowtales.com/longestwait.php"       ,"The Longest Wait"],
  ["http://www.drowtales.com/~workandduty/"   ,"Work And Duty*" ,"http://www.drowtales.com/manga_buttons/workandduty.gif"],
   ["http://www.drowtales.com/~hiddenlight"    ,"Hidden Light"  ,"http://www.drowtales.com/manga_buttons/hiddenlight.gif"],
   ["http://www.drowtales.com/~gladiator"      ,"Gladiator*"     ,"http://www.drowtales.com/manga_buttons/gladiator.gif"],
   ["http://www.drowtales.com/~spiderborn"     ,"Spider Born"    ,"http://www.drowtales.com/manga_buttons/spiderborn.gif"],
   ["http://www.drowtales.com/~breachoffaith"  ,"Breach of Faith","http://www.drowtales.com/manga_buttons/breachoffaith.gif"],
   ["http://www.drowtales.com/~daydream/"       ,"Daydream"       ,"http://www.drowtales.com/manga_buttons/daydream.gif"],
   ["http://www.drowtales.com/melknighthood.php"       ,"Mel's Knighthood"],
   ["http://www.drowtales.com/archivechibi.php?location=20030508"       ,"Chibi'Age"],
   ["http://www.drowtales.com/~orthorbbae"     ,"Orthorbbae*"    ,"http://www.drowtales.com/manga_buttons/orthorbbae.gif"],
   ["http://www.drowtales.com/~rebirth"        ,"Rebirth"        ,"http://www.drowtales.com/manga_buttons/rebirth.gif"],
   ["http://www.drowtales.com/~soulfusion"     ,"Soul Fusion*"   ,"http://www.drowtales.com/manga_buttons/soulfusion.gif"],
   ["http://www.drowtales.com/~evilinthedepths","Evil in the Depths*"  ,"http://www.drowtales.com/manga_buttons/evilinthedepths.gif"],
   ["http://www.drowtales.com/~taintedblood"   ,"Tainted Blood"  ,"http://www.drowtales.com/manga_buttons/taintedblood.gif"],
   ["http://www.drowtales.com/~demonheart"     ,"Demon Heart*"    ,"http://www.drowtales.com/manga_buttons/demonheart.gif"],
   ["","Sponsored Manga:"],
   ["http://www.drowtales.com/~hightreason"    ,"High treason"   ,"http://www.drowtales.com/manga_buttons/hightreason.gif"],
   ["","* = dead or on hiatus"]
];

/********************************************************************************************/

var OP = (navigator.userAgent.indexOf('Opera')>-1);
var NS = (document.getElementById&&!document.all);
var IE = (document.all);

function initDtImages() {
   for (i=0; i < dtLinkList.length ; i++ ) {
      if ( dtLinkList[i][2] ) {
         dtLinkList[i][3] = new Image();
         dtLinkList[i][3].src = dtLinkList[i][2];
      }
   }
}

function getDtItems() {
   var itxt = "<option selected value =''>" + dtLinkList[0][1] + "</option>\n";
   for ( i = 1 ; i < dtLinkList.length ; i++ ) {
      if ( dtLinkList[i][0] ) {
         itxt += "<option value = '" + dtLinkList[i][0] + "'>";
      } else {
         itxt += "<option value=''>";
      }
      itxt += dtLinkList[i][1] + "</option>\n";
   }
   return itxt;
}

function getDtDoChange() {
   var cdctxt;
   if (NS) {
	   cdctxt = "if (document.getElementById('dtdropdown').selectedIndex != 0) document.location = document.getElementById('dtdropdown').options[document.getElementById('dtdropdown').selectedIndex].value; else alert('Select a manga!');";
   } else { 
	   cdctxt = "if (document.all('dtdropdown').selectedIndex != 0) document.location = document.all('dtdropdown').options[document.all('dtdropdown').selectedIndex].value; else alert('Select a manga!');";
   }
   return cdctxt;
}

function getDtStyle() {
   var dts = "<style>\n";
   
   dts += "#dtbutton {width:170; height:25;}\n";
   dts += "#dtdropdown {width:170;}\n";
   dts += "</style>\n";
   
   return dts;
}

function writeDtImgBox() {
   
   initDtImages(); // initialize the images

   var dtTxt = getDtStyle();
   var doChange = getDtDoChange();
   
   // table around image and box
   dtTxt += "<table ";
   dtTxt += "align='center' border='0'";
   dtTxt += "cellspacing='0' cellpadding='0'>\n";
   dtTxt += "<tr><td>\n";

   // image on top of selection box
   dtTxt += "<a href='" + dtLinkList[1][0] + "' name='dtlink'";
   dtTxt += "id='dtlink'>\n";
   dtTxt += "<img border='0' src='" + dtLinkList[1][2] + "'";
   dtTxt += "name='dtbutton' id='dtbutton'><br>\n";
   dtTxt += "</a>";

   // table between image and box
   dtTxt += "</td></tr><tr><td>\n";

   // selection box
   dtTxt += "<select ";
   dtTxt += "size='1' name='dtdropdown' id='dtdropdown' ";
   dtTxt += "class='drowdropdown' ";
   dtTxt += "onchange=\"" + doChange + "\">\n";

   // selection box items
   dtTxt += getDtItems();

   // end box
   dtTxt += "</select>\n";

   // end table
   dtTxt += "</td></tr></table>\n";
   
   // write the dropdown
   document.write(dtTxt);
}

function dtRotateImgs() {
   var nameButton = "dtbutton";
   var nameLink = "dtlink";
   
   var docCall;
   if (NS){
      docCall= document.getElementById(nameLink);
   } else {
      docCall= document.all(nameLink);
   }
   
   dtCnt++;
   if ( dtCnt >= dtLinkList.length ) {
      dtCnt = 1;
   }

   // skip links that have no img
   while ( !(dtLinkList[dtCnt][3]) ) {
      dtCnt++;
      // make sure we don't go off the end of the array
      if ( dtCnt >= dtLinkList.length ) {
         dtCnt = 1;
      }
   }
   
   document.images[nameButton].src = dtLinkList[dtCnt][3].src;
   docCall.href = dtLinkList[dtCnt][0];
}

/********************************************************************************************/

var dtCnt = 0;
var dtRotate = setInterval('dtRotateImgs();',4000);

/********************************************************************************************/

writeDtImgBox();