    // Copyright (c) 2003, Remi Olsen (remio@scummbar.com)
    //  No part of this code may be used or re-produced without written permission. So don't steal. >:

    //    ##############################################
    //    #           GLOBAL VARIABLES                 #
    //    ##############################################

    var insultArray = new Array();
      insultArray[0] = "This is the END for you, you gutter-crawling cur!";
      insultArray[1] = "Soon you'll be wearing my sword like a shish kebab!";
      insultArray[2] = "My handkerchief will wipe up your blood!";
      insultArray[3] = "People fall at my feet when they see me coming.";
      insultArray[4] = "I once owned a dog that was smarter then you.";
      insultArray[5] = "You make me want to puke.";
      insultArray[6] = "Nobody's ever drawn blood from me and no body ever will.";
      insultArray[7] = "You fight like a dairy farmer.";
      insultArray[8] = "I got this scar on my face during a mighty struggle!";
      insultArray[9] = "Have you stopped wearing diapers yet?";
      insultArray[10] = "I've heard you were a contemptible sneak.";
      insultArray[11] = "You're no match for my brains, you poor fool.";
      insultArray[12] = "You have the manners of a begger.";
      insultArray[13] = "I'm not going to take your insolence sitting down!";
      insultArray[14] = "There are no words for how disgusting you are.";
      insultArray[15] = "I've spoken with apes more polite then you.";
      insultArray[16] = "Today, by myself, twelve people I've beaten.";
      insultArray[17] = "I've got muscles in places you've never even heard of.";
      insultArray[18] = "Give up now, or I'll crush you like a grape. ";
      insultArray[19] = "My ninety-eight-year-old grandmother has bigger arms than you. ";
      insultArray[20] = "I'm going to put your arm in a sling.";
      insultArray[21] = "My stupefying strength will shatter your ulna into a million pieces.";
      insultArray[22] = "Hey, look over there! ";
      insultArray[23] = "Your knuckles I'll grind to a splintery paste. ";
      insultArray[24] = "Your arms are no bigger than fleas that I've met. ";
      insultArray[25] = "People consider my fists lethal weapons. ";
      insultArray[26] = "You're the ugliest creature I've seen in my life. ";
      insultArray[27] = "My forearms have been mistaken for tree trunks. ";
      insultArray[28] = "I've out-wrestled Octopi with these arms. ";
      insultArray[29] = "Do I see quivers of agony dance on your lip?  ";
      insultArray[30] = "Every enemy I've met I've annihilated!";
      insultArray[31] = "You're as repulsive as a monkey in a negligee.";
      insultArray[32] = "Would you like to be buried or cremated?";
      insultArray[33] = "Heaven preserve me! You look like something that's died!";
      insultArray[34] = "I'll skewer you, like a sow at a buffet.";
      insultArray[35] = "Killing you would be justifiable homicide.";
      insultArray[36] = "En garde! Touché!";
      insultArray[37] = "Throughout the Caribbean my great deeds are celebrated!";
      insultArray[38] = "When your father first saw you, he must have been mortified.";
      insultArray[39] = "You can't match my witty repartee.";
      insultArray[40] = "I can't rest until you've been exterminated!";
      insultArray[41] = "You're the ugliest monster ever created.";
      insultArray[42] = "I'll leave you devastated, mutilated and perforated.";
      insultArray[43] = "Coming face to face with me must leave you petrified.";
      insultArray[44] = "I'll hound you night and day!";
      insultArray[45] = "I have never lost a mêlée!";

    var outputInsults = new Array(45);

    var answerArray = new Array();
      answerArray[0] = "And I´ve got a little TIP for you, get the POINT?";
      answerArray[1] = "First you better stop waiving it like a feather-duster.";
      answerArray[2] = "So you got that job as janitor, after all.";
      answerArray[3] = "Even BEFORE they smell your breath?";
      answerArray[4] = "He must have taught you everything you know.";
      answerArray[5] = "You make me think somebody already did.";
      answerArray[6] = "You run THAT fast?";
      answerArray[7] = "How appropriate. You fight like a cow.";
      answerArray[8] = "I hope now you've learned to stop picking your nose.";
      answerArray[9] = "Why, did you want to borrow one?";
      answerArray[10] = "Too bad no one's ever heard of YOU at all.";
      answerArray[11] = "I'd be in real trouble if you ever used them.";
      answerArray[12] = "I wanted to make sure you'd feel comfortable with me.";
      answerArray[13] = "Your hemorrhoids are flaring up again, eh?";
      answerArray[14] = "Yes there are. You just never learned them.";
      answerArray[15] = "I'm glad to hear you attended your family reunion.";
      answerArray[16] = "From the size of your gut, I'd guess they were eaten.";
      answerArray[17] = "It's too bad none of them are in your arms.";
      answerArray[18] = "I would if it would stop your WINE-ing.";
      answerArray[19] = "Yeah, but we've both got better bladder control than you.";
      answerArray[20] = "Why, are you studying to be a Nurse?";
      answerArray[21] = "I'm surprised you can count that high.";
      answerArray[22] = "Yeah, yeah, I know: It's a Three-Headed monkey.";
      answerArray[23] = "I thought the bean dip had a strange taste.";
      answerArray[24] = "So that's why you're scratching.  I'd go see a vet.";
      answerArray[25] = "Sadly, your breath should be equally reckoned.";
      answerArray[26] = "I'm shocked that you never have gazed at your wife.";
      answerArray[27] = "An over-the-counter defoliant could help with that problem.";
      answerArray[28] = "I'm sure that spineless creatures everywhere are humbled by your might.";
      answerArray[29] = "It's laugher that's caused by your feathery grip.";
      answerArray[30] = "With your breath, I'm sure they all suffocated. ";
      answerArray[31] = "I look THAT much like your fiancée? ";
      answerArray[32] = "With you around, I'd prefer to be fumigated. ";
      answerArray[33] = "The only way you'll be preserved is in formaldehyde. ";
      answerArray[34] = "When I'm done with YOU, you'll be a boneless fillet! ";
      answerArray[35] = "Then killing you must be justifiable fungicide. ";
      answerArray[36] = "Oh, that is so cliché! ";
      answerArray[37] = "Too bad they're all fabricated. ";
      answerArray[38] = "At least mine can be identified. ";
      answerArray[39] = "I could, if you would use some breath spray. ";
      answerArray[40] = "Then perhaps you should switch to decaffeinated. ";
      answerArray[41] = "If you don't count all the ones you've dated. ";
      answerArray[42] = "Your odor alone makes me aggravated, agitated, and infuriated! ";
      answerArray[43] = "Is that your face? I thought it was your backside!";
      answerArray[44] = "Then be a good dog. Sit! Stay!";
      answerArray[45] = "You would have, but you were always running away. ";


    var currentStrength;
    var setStrengths = new Array("",0,0,0);
    var spitLength = 0;
    var windstrength = 0;
    answerInterval = 0;
    var currentImage = 0;
    var holdAnimation = 1;
    var useIndex;
    var myAnimation;
    var insultsPerPage = 10;
    var currentInsultPage = 0;
    var myGuybrush = new Array("guybrushstance.gif",
                               "guybrushsword0.gif",
                               "guybrushsword1.gif",
                               "guybrushsword2.gif",
                               "guybrushsword3.gif",
                               "guybrushsword4.gif",
                               "guybrushsword5.gif",
                               "guybrushsword6.gif",
                               "guybrushsword7.gif",
                               "guybrushsword8.gif",
                               "sword0.gif",
                               "sword1.gif",
                               "sword2.gif",
                               "sword3.gif",
                               "sword4.gif",
                               "sword5.gif",
                               "sword6.gif",
                               "sword7.gif",
                               "machine.gif",
                               "smirk.gif",
                               "dance.gif",
                               "monkey.gif",
                               "background.gif");

    for(var i=0;i<myGuybrush.length;i++){
    	tmpImage = new Image;
    	tmpImage.src = myGuybrush[i];
    }
    
    //    ##############################################
    //    #           DISPLAY LINES+LINKS              #
    //    ############################################## 
    
    // GENERATE INSULT
    function generateInsult(){
      var getInsult;
      if(insultArray.length==answerInterval){
        getInsult = "won";
      } else {
        useIndex = outputInsults[answerInterval];
        getInsult = insultArray[outputInsults[answerInterval]];
      }
      if(getInsult=="won"){
        document.guybrush.src = "dance.gif";
        top.score.location.href = "../../../php/do.php?todo=insultscore&score=" + answerInterval;
//        window.open("http://www.scummbar.com/php/do.php?todo=insultscore&score=" + answerInterval,"Writing score","");
        document.getElementById("insult").innerHTML = "<b>You won! And all you got was this stupid message!<br><a href=\"index.php\">Play again</a> or <a href=\"hiscores.php\">view high-scores</a>.";
      } else {
        document.getElementById("insult").innerHTML = getInsult;
      }

    }
    
    // DISPLAY ANSWERS
    function displayInsultLines(){
      document.getElementById("line").innerHTML = "";
      if(currentInsultPage+insultsPerPage>=answerArray.length-answerInterval){
        var highestPage = answerArray.length-answerInterval;
      } else {
        var highestPage = currentInsultPage+insultsPerPage;
      }
      for(var i=currentInsultPage;i<highestPage;i++){
        document.getElementById("line").innerHTML += "&nbsp; <a href=\"javascript:answerInsult(" + (i) + ");\">" + answerArray[i] + "</a><br>";
      }
    }
    
    // ARROWS
    function moveLine(x){
      if(x=='up'){
        if(currentInsultPage-insultsPerPage>=0) {
          currentInsultPage -= insultsPerPage;
          displayInsultLines();
        }
      } else {
        if(currentInsultPage+insultsPerPage<=answerArray.length-answerInterval) {
          currentInsultPage += insultsPerPage;
          displayInsultLines();
        }
      }
    }
    
    function setAnimation(){
        var animationframe = currentImage;
        if(currentImage>7){animationframe=currentImage-7;}
        if(currentImage>14){
          document.guybrush.src = "guybrushstance.gif";
          document.getElementById("line").style.visibility='visible';
          displayInsultLines();
          currentImage = 0;
          generateInsult();
          window.clearInterval(myAnimation);
        } else {
          document.guybrush.src = "guybrushsword" + animationframe + ".gif";
          document.sword.src = "sword" + animationframe + ".gif";
          currentImage++;
        }
    }
    
    // CHECK ANSWERS
    function answerInsult(x){
      if(x==useIndex){
        document.getElementById("line").style.visibility='hidden';
        holdAnimation = 1;
        document.getElementById("insult").innerHTML = "";
        myAnimation = window.setInterval('setAnimation()',100);
        answerInterval++;
        for(i=useIndex;i<answerArray.length-answerInterval;i++){
          answerArray[i] = answerArray[i+1];
          insultArray[i] = insultArray[i+1];
        }
      } else {
        document.getElementById("line").innerHTML='';
        document.guybrush.src = "monkey.gif"
        document.getElementById("insult").innerHTML = "<b>Ouch! You lost! <br>You got " + answerInterval + " answers right.</b> <a href=\"index.php\">Play again</a>.";
        top.score.location.href = "../../../php/do.php?todo=insultscore&score=" + answerInterval;
//        window.open("http://www.scummbar.com/php/do.php?todo=insultscore&score=" + answerInterval, "Writing score","");
      }
    }


   
    // REVEAL AND INITIALIZE
    function showAll(){
      var answerCounter=0
      while(answerCounter<46){
        tryAgain = 1;
        while(tryAgain == 1){
          useIndex = Math.floor(Math.random() * insultArray.length-answerCounter);
          if(insultArray[useIndex] != "" && insultArray[useIndex] != undefined){
            tryAgain = 0;
            outputInsults[answerCounter] = useIndex;
            answerCounter++;
          } else {
            tryAgain = 1;
          }
        }
      }
      document.getElementById("parentDiv").style.visibility='visible';
      generateInsult();
      displayInsultLines();
    }
