// +----------------------------------------------+ //
// |  Copyright©2009, Steven Douglas Huddleston   | //
// |             All Rights Reserved              | //
// | No portion of this code can be copied, used, | //
// | published or reproduced in any way without   | //
// | the expressed written consent of the author. | //
// +----------------------------------------------+ //

// +----------------------------------------------+ //
// |     Microsoft Internet Explorer Detection    | //
// +----------------------------------------------+ //

var IEBrowser = (navigator.appName.indexOf("Microsoft Internet Explorer") == -1) ? 0 : 1;
     
// +----------------------------------------------+ //
// |               Standard Postings              | //
// +----------------------------------------------+ //

function copyright() {
     d=new Date();
     y='' + d.getFullYear();
     document.write('Original Content Copyright <span style="font-size:14px; font-weight:bolder;">&copy;</span> 1997-' + y + ', Steven Douglas Huddleston, All Rights Reserved.');
     }

function postlink(URL,SID) {
     document.write('<a href="' + URL + '" target="_blank">' + SID + '</a><br/>');
}

// +----------------------------------------------+ //
// |                Hard-Copy Gizmo               | //
// +----------------------------------------------+ //

function printitem(ItemID,ItemURL) {
     // Scrape Article Contents
     d=new Date();
     PrintPage = 'toolbar=yes,location=no,directories=yes,menubar=yes,scrollbars=yes,width=700,height=500,left=100,top=25';
     ItemConts = '<div name="content">' + document.getElementById(ItemID).innerHTML + '</div>';

     // Remove Superfluous Elements
     rFlag = '<!-- NoPrint -->';
     rOffset = rFlag.length;

     while (ItemConts.indexOf(rFlag) > -1 ) {
          rStart = ItemConts.indexOf(rFlag);
          rFinish = ItemConts.indexOf(rFlag, rStart + rOffset) + rOffset;
          ItemConts = ItemConts.substr(0, rStart) + ItemConts.substr(rFinish);
          }

     // Add Copyright & Reference Notice
     ItemConts += '<div class="printcnote"><hr>NOTICE: This article was printed from The Kongaloid Website (http://www.kongaloid.org).<br>Original contents is Copyright&copy;' + d.getFullYear() + ', Steven Douglas Huddleston, All Rights Reserved<br>If you wish to access the referenced links in this article, please visit the on-line version at:<br>' + ItemURL + '<br>Please direct all requests and/or inquiries to: ' + getrecipient(1) + '<br><br></div>';
     // Construct & Display Hard Copy
     hardcopy = window.open('', 'HardCopy' + ItemID, PrintPage);
     hardcopy.document.write('<html><head><title>Hard Copy</title><link rel="stylesheet" href="http://www.kongaloid.org/src/kongastyles.css" type="text/css"><link rel="stylesheet" href="http://www.kongaloid.org/src/hardcopy.css" type="text/css"></head><body>');
     hardcopy.document.write(ItemConts);
     hardcopy.document.write('</body></html>');
     if (!IEBrowser) {hardcopy.document.close()};
     hardcopy.focus();
     }
 
// +----------------------------------------------+ //
// |      Visitor Comments & WebMail Gizmos       | //
// +----------------------------------------------+ //

var c_cnt = 0;
var commentID = 0;

function opencomments(cid,tid) {
     window.open('http://www.kongaloid.org/koments.html?' + cid + '&' + tid,'Koments' + cid,'width=420,height=500,scrollbars=yes,resizable=yes,status=yes');
     }

function openguestbuk(cid,tid) {
     window.open('http://www.kongaloid.org/gbook.html?' + cid + '&' + tid,'GuestBook' + cid,'width=420,height=500,scrollbars=yes,resizable=yes,status=yes');
     }

function bugreport(bugtype,post) {
     // Define Report Type
     switch (bugtype) {
          case 'bug': rt='BUG'; break;
          case 'link': rt='BROKEN LINK'; break;
          case 'spell': rt='UNCOUTH-NESS'; break;
          }
     // Compose Message
     usr_nav = navigator.appName;
     send_to = getrecipient(IEBrowser);
     subject = rt + " report for: " + post;
     fmt_msg = "Your%20browser is%20" + usr_nav + ".%0D%0DPlease%20enter%20you%20comments%20(if%20any)%20below%20and%20click%20on%20send.%0D%0DThank you for helping to improve this website!%0D%0DYour%20Message:%0D";
     execlnk = 'ma' + 'il' + 'to:' + send_to + '?' + 'sub' + 'j' + 'ect=' + subject + '&' + 'bo' + 'dy=' + fmt_msg;
     // Send Report
     window.location = execlnk;
     }

// +----------------------------------------------+ //
// |             Photo Switch Gizmo               | //
// +----------------------------------------------+ //

function SwitchThen() { blendimage('http://www.kongaloid.org/src/photo/sdh_then.jpg',1); }

function SwitchNow() { blendimage('http://www.kongaloid.org/src/photo/sdh_now.jpg',1); }

function SwitchNeat(obj) { blendimage('steve99.jpg',1); }

function changeOpac(opacity, id) {
     obj = document.getElementById(id).style;
     obj.opacity = (opacity / 100);
     obj.filter = 'alpha(opacity=' + opacity + ')';
     }

function blendimage(imagefile,sec) {
     speed = (sec * 10);
     timer = 0;

     document.getElementById('img1').style.backgroundImage = "url(" + document.getElementById('img2').src + ")";
     changeOpac(0, 'img2');
     document.getElementById('img2').src = imagefile;

     for(i = 0; i <= 100; i++) {
         setTimeout("changeOpac(" + i + ",'img2')",(timer * speed));
         timer++;
         }
     }

// +----------------------------------------------+ //
// |            Object Fader Transition           | //
// +----------------------------------------------+ //
function fader(obj,newval,dur) {
     obj.style.filter="BlendTrans(duration=dur)";
     if (obj.filters.blendTrans.Status != 2) 
          {
          obj.filters.blendTrans.Apply();
          obj.style.display=newval;
          obj.filters.blendTrans.Play();
          }
     }

// +----------------------------------------------+ //
// |              Jumpto Next Gizmo               | //
// +----------------------------------------------+ //

var preveid = '';

function nextgizmo(eid) {

     if (preveid != '') 
          {
          gizmoid = 'nextgizmo' + preveid;
          if (eid == 'eop') 
               {
               gizspec = 'archives.gif';
               giztext = 'Archive Index';
               gizdest = 'http://www.kongaloid.org/archives.html';
               }
          else
               {
               gizspec = 'scrolldownh.gif';
               giztext = 'Next';
               gizdest = '#' + eid;
               }
          innrtxt = '<img src="http://www.kongaloid.org/src/img/' + gizspec + '" alt="' + giztext + '" onclick="window.location=\'' + gizdest + '\'" style="cursor: pointer; border:0;">';
          document.getElementById(gizmoid).innerHTML = innrtxt;
          }

     preveid = eid;
}

// +----------------------------------------------+ //
// |              Generic Button Link             | //
// +----------------------------------------------+ //

function linkbutton(txt,url) {
     document.write('<input type="button" value="' + txt + '" class="thinbutton" onclick="document.location=\'' + url + '\';" onmouseover="style.color=\'#0080FF\';" onmousedown="style.color=\'#ff0000\';" onmouseout="style.color=\'#0000ff\';">');
     }

function CSSValidator(url) {
     url = encodeURIComponent(url);
     document.write('<a href="http://jigsaw.w3.org/css-validator/validator?uri=' + url + '&amp;profile=css3&amp;usermedium=all&amp;warning=1&amp;lang=en" target="_blank"><img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid Level 3 CSS!" style="border:0; width:88px; height:31px" /></a>');
     }

// +----------------------------------------------+ //
// |           Audio Selection Controls           | //
// +----------------------------------------------+ //

function insertaudio(loop) {
    if (IEBrowser) { 
         document.write('<bgsound id="audio" src="" loop="' + loop + '" />'); 
         }
    else
         {
         return; 
         }
    }

function setaudio() {
    if (!IEBrowser) { return; }
    selectaudio(audiomenul);
    selectaudio(audiomenur);

    if (document.cookie == "")
          {document.cookie="audio=0; path=/";}
     else
          {
           x = document.cookie;
           playstatus = parseInt(x.substr(x.indexOf("audio=") + 6, 1));
           playpreset = parseInt(x.substr(x.indexOf(songindx) + 6, 1));

           if (playstatus == 1) 
               {
               switchaudio((playpreset > 0) ? playpreset : audiopreset);
               }
          }
     }

function showaudio(objid) {
     if (!IEBrowser) { 
          recpost = '<div style="text-align:center:"><a href="javascript:switchaudio(0);"><b>SORRY!<br /><br />Background Music<br />is NOT supported<br />by your browser.</b></a><br /></div>';
          document.getElementById(objid).innerHTML = recpost;
          }
          document.getElementById(objid).style.display = 'block';
     }

function leaveaudio(objid) {
     try {x = (event.toElement || event.relatedTarget).id;}
     catch(err) {return;}
     if (x.substr(0,5) == "pixie") {hideaudio(objid);}
     }

function hideaudio(objid) {
     document.getElementById(objid).style.display = 'none';
     objid = objid.substr(0,9) + ((objid.charAt(9) == "r") ? 'l': 'r');
     obj = document.getElementById(objid);
     if (obj.style.display !== 'none') {obj.style.display = 'none'};
     }

function forceaudio(sel) {
     if ((!IEBrowser) || (playstatus)) { return; }

     switch (sel) {
        case  0: catindex=7; break;
        case 27: catindex=8; break;
        }

     switch (catindex) {
        case  7: sng='borinken.mid'; ttl='La Borinque&ntilde;a, The Anthem of Puerto Rico'; break;
        case  8: sng='lamento.mid'; ttl='Lamento Borincano by Rafael Hernandez'; break;
        default: return;}

     imgs = 'http://www.kongaloid.org/src/img/audio1.gif';
     auds = 'http://www.kongaloid.org/src/audio/' + sng; 
     alts = ttl; 

     document.getElementById('audio').src = auds;
     document.getElementById('audlf').src = imgs;
     document.getElementById('audrg').src = imgs;
     document.getElementById('audlf').alt = alts;
     document.getElementById('audrg').alt = alts;
     document.getElementById('songinfo').innerHTML = '(You are listening to ' + ttl + ')';
     document.getElementById('songtitle').style.display = 'block';
     }

// +----------------------------------------------+ //
// |          Category Description Gizmo          | //
// +----------------------------------------------+ //

var catindex = 0;

function catinfo() {
     y = '' + document.getElementById('cattitle').innerHTML;
     msgtxt = y + ': Sorry! No description yet for this category.';

     if (y.indexOf("Age of Madness")       > -1) {catindex = 1};
     if (y.indexOf("Anarchic Roster")      > -1) {catindex = 2};
     if (y.indexOf("Cosmic Rendezvous")    > -1) {catindex = 3};
     if (y.indexOf("Kongaloid Archives")   > -1) {catindex = 4};
     if (y.indexOf("Monsters from the Id") > -1) {catindex = 5};
     if (y.indexOf("Pooflah!")             > -1) {catindex = 6};
     if (y.indexOf("Puerto Rico")          > -1) {catindex = 7};
     if (y.indexOf("Save The Coqu")        > -1) {catindex = 8};

     switch (catindex) {
          case 1: msgtxt='About what is wrong with Humanity'; break;
          case 2: msgtxt='Hall of Shame'; break;
          case 3: msgtxt='Space, Time, Everything! You know, way out there...'; break;
          case 4: msgtxt='Everything Kongaloid'; break;
          case 5: msgtxt='Unrepressed expressions of creative perversion.'; break;
          case 6: msgtxt='Well, Pooflah, of course!'; break;
          case 7: msgtxt='About the Island of Dissenchantment'; break;
          case 8: msgtxt='A personal crusade to save *THE* Puertorican National Treasure'; break;
          }

     document.getElementById('infogizmo').alt = msgtxt;}

// +----------------------------------------------+ //
// |         Temporal Displacement Factor         | //
// +----------------------------------------------+ //

function UpdtSpaceTime() {
     d = new Date();
     h = d.getHours();
     if (h < 17) Y = "Good Afternoon!";
     if (h > 16) Y = "Good Evening!";
     if (h < 12) {Y = "Good Morning!"; M = " AM";} else {M = " PM";}
     if (h > 12) h = h - 12;
     if (d.getMinutes() < 10) N = "0"; else N = "";
     document.getElementById('GreetHere').innerHTML = Y;
     document.getElementById('TimeHere').innerHTML = h + ':' + N + d.getMinutes() + M;
     document.getElementById('DateHere').innerHTML = (d.getMonth()+1) + '/' + (d.getDate()) + '/' + (d.getFullYear());
     }

// +----------------------------------------------+ //
// |            Document Update Stamp             | //
// +----------------------------------------------+ //

function updated() {

     x = new Date(document.lastModified);
     d = x.getDate();
     m = x.getMonth() + 1;
     y = x.getFullYear();

     switch (parseInt(m)) {
        case  1: m='JAN'; break;
        case  2: m='FEB'; break;
        case  3: m='MAR'; break;
        case  4: m='APR'; break;
        case  5: m='MAY'; break;
        case  6: m='JUN'; break;
        case  7: m='JUL'; break;
        case  8: m='AUG'; break;
        case  9: m='SEP'; break;
        case 10: m='OCT'; break;
        case 11: m='NOV'; break;
        case 12: m='DEC'; break;}

     document.write(d + ' ' + m + ' ' + y);}

// +----------------------------------------------+ //
// |              Birthday Heads-Up               | //
// +----------------------------------------------+ //

function showbirthday() {

     ms2 = '';
     img = '';
     x = new Date();
     d = x.getDate();
     m = x.getMonth() + 1;

     if ((m ==  3) && (d ==  3)) {
          msg = 'Konga';
          img = '0303.jpg';
          alt = 'Kongaloid-Brother!';}
     if ((m ==  5) && (d ==  1)) {
          msg = 'Chu-chu-lu';
          img = '0501.jpg';
          alt = 'The flower that grows in my heart.';}
     if ((m ==  5) && (d == 21)) {
          msg = 'Maf&uacute;';
          img = '0521.jpg';
          alt = 'Rockus Freakus Jupiteriens';}
     if ((m ==  9) && (d == 16)) {
          msg = 'Adriana';
          img = '0916.jpg';
          alt = 'The field where I plant my dreams.';}
     if ((m == 10) && (d ==  7)) {
          msg = 'Brian';
          img = '1007.jpg';
          alt = 'Beloved Brother';}
     if ((m == 12) && (d == 19)) {
          msg = 'Robert';
          img = '1219.jpg';
          alt = 'The CyberGenie';
          ms2 = '<br><span class="imgcaption">(<i><b>Now</b></i> you <i>are</i> <b>smilling</b>!)</span>';}

     if (img == '') {return;}

     document.getElementById('bdaymug').src = 'http://www.kongaloid.org/src/photo/' + img;
     document.getElementById('bdaymug').alt = alt;
     document.getElementById('bdaymsg').innerHTML = 'Happy Birthday ' + msg + '!' + ms2;
     document.getElementById('bdaybanner').style.display = 'block';
     }

// +----------------------------------------------+ //
// |           P i x i e   C o u n t e r          | //
// +----------------------------------------------+ //

function getpixie(max) { return(Math.ceil(Math.random() * max)); }

function whosonline() {
     k = (IEBrowser) ? document.getElementById('olk').innerText : document.getElementById('olk').textContent;

     k = parseInt(k, 10);                      // Kongaloids
     h = getpixie(3);     if (h == 0) {h = 1;} // Human
     p = getpixie(23); // Pixies
     b = getpixie(16); // Hobbits
     o = getpixie(8);  // Ogres
     r = getpixie(3);  // Orks
     g = getpixie(5);  // Gnomes
     l = getpixie(4);  // Trolls

     if (isNaN(k)) 
          {
          k = 1; 
          ktxt1 = '';
          ktxt2 = '';
          }
     else
          {
          ktxt1 = '<a href="http://www.freeonlineusers.com" target="_blank">';
          ktxt2 = '</a>';
          }

     kx = "&nbsp;Kongaloid" + ((k > 1) ? "s": "");
     
     if (getpixie(2)==1) {p = 0;} else {px = "&nbsp;Pixie" + ((p > 1) ? "s": "");}

     if (getpixie(2)==1) {b = 0;} else {bx = "&nbsp;Hobbit" + ((b > 1) ? "s": "");}

     ox = (getpixie(2)==1) ? "&nbsp;Ogre":"&nbsp;Ork";
          if (getpixie(2)==1) {o = 0;} else {if (ox=="&nbsp;Ork") {o = r;}}
          if (o > 1) {ox = ox + "s";}

     gx = (getpixie(2)==1) ? "&nbsp;Gnome":"&nbsp;Troll";
          if (getpixie(2)==1) {g = 0;} else {if (gx=="&nbsp;Troll") {g = l;}}
          if (g > 1) {gx = gx + "s";}

     t = k + h + p + + b + o + g;

     msg = "Visitors&nbsp;online:&nbsp;" + t + "&nbsp;(" + ktxt1  + k + kx + ktxt2 + ",&nbsp;" + h + "&nbsp;Human";
     if (p > 0) {msg += ",&nbsp;" + p + px;}
     if (b > 0) {msg += ",&nbsp;" + b + bx;}
     if (o > 0) {msg += ",&nbsp;" + o + ox;}
     if (g > 0) {msg += ",&nbsp;" + g + gx;}
     msg = msg + ",&nbsp;0&nbsp;&quot;Social-Workers&quot;)";

     document.write(msg);
     }

// +----------------------------------------------+ //
// |           WIKIPedia Reference Links          | //
// +----------------------------------------------+ //

document.write('<form action="http://en.wikipedia.org/wiki/Special:Search" id="WIKISearch" target="_blank">');
document.write('<input id="searchInput" name="search" type="hidden" accesskey="f" value=""></form>');
     
function WIKISearch(srch) {
     document.getElementById('WIKISearch').searchInput.value=srch;
     document.getElementById('WIKISearch').submit();}

// +----------------------------------------------+ //
// |        Dictionary.com Reference Links        | //
// +----------------------------------------------+ //

function DICTSearch(srch) {
     window.open('http://dictionary.reference.com/search?q=' + srch + '&db=*','');}

// +----------------------------------------------+ //
// |              Payments By PayPal              | //
// +----------------------------------------------+ //

document.write('<form action="https://www.paypal.com/cgi-bin/webscr" id="GoPayPal" method="post" target="_blank">');
document.write('<input type="hidden" name="cmd" value="_xclick">');
document.write('<input type="hidden" name="business" value="' + getrecipient(1) + '">');
document.write('<input type="hidden" name="amount" value="">');
document.write('<input type="hidden" name="item_name" value="">');
document.write('<input type="hidden" name="no_note" value="1">');
document.write('<input type="hidden" name="currency_code" value="USD">');
document.write('<input type="hidden" name="undefined_quantity" value="">');
document.write('<input type="hidden" name="item_number" value="">');
document.write('<input type="hidden" name="shipping" value="">');
document.write('<input type="hidden" name="shipping2" value="">');
document.write('<input type="hidden" name="return" value="http://www.kongaloid.org/coquicd/thanks.html">');
document.write('<input type="hidden" name="cancel_return" value="">');
document.write('<input type="hidden" name="lc" value="US">');
document.write('<input type="hidden" name="tax" value="0">');
document.write('<input type="hidden" name="bn" value="">');
document.write('</form>');

function SetPayPal(btype) {
     if (btype == "COQUI") {
          document.getElementById('GoPayPal').bn.value="PP-BuyNowBF";
          document.getElementById('GoPayPal').undefined_quantity.value="1";
          document.getElementById('GoPayPal').item_number.value="Compact Disk";
          document.getElementById('GoPayPal').shipping.value="3.00";
          document.getElementById('GoPayPal').shipping2.value="1.50";
          document.getElementById('GoPayPal').cancel_return.value="http://www.kongaloid.org/";
          } 
     }

function PayPalButton(btype,amnt,desc) {
     if (btype == "D") {
          butimg = 'x-click-but21';
          document.getElementById('GoPayPal').bn.value="PP-DonationsBF";
          } 
     else 
          {
          butimg = 'btn_buynow_LG';
          SetPayPal('COQUI');
          }
     document.write('<img onclick="javascript:GoPayPal(\'' + amnt + '\',\'' + desc + '\');" src="https://www.paypal.com/en_US/i/btn/' + butimg + '.gif" width="107" height="26" border="0" name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!" vspace="5" style="cursor:pointer;">');
     document.write('<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">');
     }

function GoPayPal(amnt,desc) {
     document.getElementById('GoPayPal').amount.value=amnt;
     document.getElementById('GoPayPal').item_name.value=desc;
     document.getElementById('GoPayPal').submit();}

function BuyCoquiCD() {
     SetPayPal('COQUI');
     GoPayPal('12.99','The Coquies of Naranjito');
     }

// +----------------------------------------------+ //
// |             Recommendation Posts             | //
// +----------------------------------------------+ //

var autorecommend=1;

function resurec() {
     try {x = (IEBrowser) ? event.toElement.tagName : event.relatedTarget.tagName;}
     catch(err) {return;}
     if (x == "TD") {pauserec(1);} 
     }

function pauserec(newval) {
     autorecommend = newval;
     if (newval == 1) {status='Timer restarted.';}
     }

function AmazonLink(asin) {
     window.open('http://www.amazon.com/exec/obidos/ISBN=' + asin + '/thekongaloidundeA/','Amazon');
     }

function buildduobutton(asincode,atype) {
     return('<input type="button" value="' + atype + '" class="button-vid" onclick="javascript:AmazonLink(\'' + asincode + '\');"; onmouseover="style.color=\'#0080FF\';" onmousedown="style.color=\'#ff0000\';" onmouseout="style.color=\'#000000\';">');
     }

function insduo() {
     recpost += '<br>';
     recpost += buildduobutton(codvhs,'VHS');
     recpost += '&nbsp;&nbsp;';
     recpost += buildduobutton(coddvd,'DVD');
     }

function nonduo() {
     if (rectyp==2) {recpost += '<br><u>NOTE: ONLY in ' + FMT + ' Format</u>';}
     }

function buildpost(tagid) {
     siztxt='width="' + szw + '" height="' + szh + '"';
     if (FMT=="DUO") {TMP='DVD';} else {TMP=FMT;}
     alttxt='Get this ' + TMP + ' from Amazon.com';

     switch (rectyp) {
        case  0: callname='PostBook'; break;
        case  1: callname='PostMusic'; break;
        case  2: callname='PostVideo'; break;}

     recpost = '<input type="button" value="<< Back" class="button-vid" onclick="javascript:' + callname + '(-1);" onmouseover="style.color=\'#0080FF\';" onmousedown="style.color=\'#ff0000\';" onmouseout="style.color=\'#000000\';">&nbsp;&nbsp;';
     recpost += '<input type="button" value="Next >>" class="button-vid" onclick="javascript:' + callname + '(1);" onmouseover="style.color=\'#0080FF\';" onmousedown="style.color=\'#ff0000\';" onmouseout="style.color=\'#000000\';"><br>';
     recpost += '<img class="frameout" style="cursor:pointer; margin-bottom:5px;" src="http://www.kongaloid.org/src/media/thumbs/' + asinid + '.jpg" alt="' + alttxt + '" ' + siztxt + ' onmousedown="className=\'framein\';" onmouseout="className=\'frameout\';" onclick="javascript:AmazonLink(\'' + asinid + '\');"><br>';
     recpost += '<a href="javascript:AmazonLink(\'' + asinid +'\');">' + lnktxt + '</a>';

     if (rectyp==2) {if (FMT=="DUO") {insduo();} else {nonduo();}}

     document.getElementById(tagid).innerHTML = recpost;
     }

// +------------+ //
// | C'est Fini | //
// +------------+ //

