if (typeof(root)=="undefined") root="";

function odd(oddnumber) { return (oddnumber==2||oddnumber%2==0)?true:false; }

//---------constants:
var rapture_offscreen="-1000px";
var rapture_fullwidth=600;
var rapture_fullheight=405;
//---------div references:
var rapture_cherubs=[];
var rapture_hearts=[];
var rapture_arrows=[];
var rapture_satan=0;
var rapture_knife=0;
var rapture_god=0;
var rapture_cover=0;
var rapture_signbox=0;
var rapture_cheat=0;
var rapture_wins=0;
var rapture_score=0;

//-----rapture_lives constants-----
rapture_defaultlives=3;
rapture_liveheart=new Image();rapture_liveheart.src=root+"heartr.gif";
rapture_deadheart=new Image();rapture_deadheart.src=root+"heartb.gif";

function rapture_initlives() 
{
  rapture_lives=rapture_defaultlives;
  for (var i=0;i<5;i++)
  {
    var heart=document.getElementById("heart"+i+"div");
    rapture_hearts[i]=heart;
    heart.childNodes[0].src=rapture_liveheart.src; 
  }
}

//-----rapture_satan constants-----
rapture_basicsatan=new Image();rapture_basicsatan.src=root+"satan.gif";
rapture_throwingsatan=new Image();rapture_throwingsatan.src=root+"satans.gif";
rapture_dyingsatan=new Image();rapture_dyingsatan.src=root+"satand.gif";
rapture_satanprox=45;

function rapture_initsatan() 
{
  //-----setting start position variables-----
  rapture_satandying=false;
  rapture_throwing=false;
  //-----setting start positions-----
  rapture_knife=document.getElementById("knifediv");
  rapture_satan=document.getElementById("satandiv");
  rapture_satan.childNodes[0].src=rapture_basicsatan.src;
  rapture_knife.style.top=rapture_offscreen;
  rapture_satan.style.left=((rapture_fullwidth-150)/2)+"px";
}


//-----CHERUB constants-----
rapture_cherubwidth=40;
rapture_cherubheight=40;
rapture_cherubstepdown=rapture_cherubheight/2;
rapture_cherubrows=3;
rapture_cherubcols=5;
rapture_padbottom=300;rapture_padtop=50;
rapture_padleft=20;rapture_padright=580;
rapture_hpadcherub=20;rapture_vpadcherub=10;    //---space between rapture_cherubs
rapture_basicanim=25;
rapture_basiccherubA=new Image();rapture_basiccherubA.src=root+"cheruba.gif";
rapture_shootingcherubA=new Image();rapture_shootingcherubA.src=root+"cherubas.gif";
rapture_basiccherubB=new Image();rapture_basiccherubB.src=root+"cherubb.gif";
rapture_shootingcherubB=new Image();rapture_shootingcherubB.src=root+"cherubbs.gif";
rapture_dyingcherub=new Image();rapture_dyingcherub.src=root+"cherubd.gif";
rapture_cherubprox=14;

function rapture_initcherubs() 
{
   //-----setting start position variables-----
   rapture_right_left=1;
   rapture_godownnext=false;
   rapture_allthewaydown=false;
   rapture_cherubdying=false;

   //-----setting start positions-----
   rapture_cherubs=new Array();
   var col=0;var row=0;
   var bottomrow=0;
   for (var i=0;i<14;i++)
   {
     var cherub=document.getElementById("cherub"+i);
     rapture_cherubs[i]=cherub;
     var cherubimg=rapture_cherubs[i].childNodes[0];
     cherubimg.src=(odd(i))?rapture_basiccherubA.src:rapture_basiccherubB.src;
     cherub.style.left=(rapture_padleft+(col*(rapture_cherubwidth+rapture_hpadcherub))+bottomrow)+"px";
     cherub.style.top=(rapture_padtop+(row*(rapture_cherubheight+rapture_vpadcherub)))+"px";
     col++;
     if (col==rapture_cherubcols)
     {
       col=0;row++; 
       //-----alternate cherub row of 4-----
       if (row==2) bottomrow=(rapture_cherubwidth+rapture_hpadcherub)/2;
     } 
   } 
}

//-----rapture_arrows init-----
function rapture_initarrows() 
{
   //-----setting start position variables:
   rapture_pseudorandom=0;
   rapture_arrowstwanging=0;
   rapture_activearrows=new Array(5); 
   for (i=0;i<5;i++) {rapture_activearrows[i]="free";}

   //-----setting start positions-----
   for (var i=0;i<5;i++)
   {
     var arrow=document.getElementById("arrow"+i);
     if (rapture_arrows.length<5) rapture_arrows[i]=arrow;
     arrow.style.top=rapture_offscreen;
   } 
}

//-----rapture_god constants-----
rapture_basicgod=new Image();rapture_basicgod.src=root+"god.gif";
rapture_dyinggod=new Image();rapture_dyinggod.src=root+"deadgod.gif";
rapture_godprox=50;

function rapture_initgod() 
{
   //-----setting start position variables
   rapture_goddead=false;
   rapture_goddying=false;

   //-----setting start positions-----
   rapture_god=document.getElementById("goddiv");
   var rapture_godimg=rapture_god.childNodes[0];
   rapture_godimg.src=rapture_basicgod.src;
   rapture_god.style.left=rapture_offscreen;
}






//--------------------------------------------------
//------------------<MOVEMENT>----------------------
//--------------------------------------------------




function rapture_movecherubs() 
{
   if (rapture_pause==true) return;
   if (rapture_gameover==true) {clearInterval(rapture_cherubattack); return; }
   var rapture_availablearrow=(rapture_arrowstwanging<rapture_arrows.length) ? true:false;
//-----moving cherub attack group
  //if (rapture_cherubdying!=false) return;
  if (rapture_godownnext==true) 
  {
//-----vertical move
    rapture_right_left=-rapture_right_left;
    rapture_godownnext=false;
    rapture_groupbottom=rapture_padtop;
    for (var i=0;i<rapture_cherubs.length;i++) 
    {
      if (rapture_cherubs[i])
      {
        rapture_cherubs[i].style.top=(rapture_cherubs[i].offsetTop+rapture_cherubstepdown)+"px";
        rapture_groupbottom=Math.max(rapture_groupbottom,rapture_cherubs[i].offsetTop+rapture_cherubheight);
      } 
    } 
    if (rapture_groupbottom>=rapture_padbottom) 
    {
      clearInterval(rapture_cherubattack); 
      rapture_endGame('loser'); 
      return;
    } 
    rapture_chanceoccurence-=Math.ceil(rapture_chanceoccurence/5); 
    if (rapture_chanceoccurence<rapture_minchance) rapture_chanceocurrence=rapture_minchance;
    clearInterval(rapture_cherubattack);
    rapture_cherubattack=setInterval("rapture_movecherubs()",rapture_cherubdelay); //---moves faster
  } 
  else 
  {
//-----horizontal move
    rapture_cherubsleft=0;
    rapture_groupleft=rapture_padright;
    rapture_groupright=rapture_padleft;
    for (var i=0;i<rapture_cherubs.length;i++) 
    {
      if (rapture_cherubs[i])
      {
        rapture_cherubs[i].style.left=(rapture_cherubs[i].offsetLeft+(rapture_cherubstep*rapture_right_left))+"px";
        rapture_groupleft=Math.min(rapture_groupleft,rapture_cherubs[i].offsetLeft); 
        rapture_groupright=Math.max(rapture_groupright,rapture_cherubs[i].offsetLeft+rapture_cherubwidth);
        rapture_cherubsleft++;
        if (rapture_availablearrow) 
        {
//-----firing arrow at rapture_satan 
          rapture_pseudorandom+=Math.random();
          if (rapture_pseudorandom>=rapture_chanceoccurence) 
          {
            rapture_pseudorandom=0;
            rapture_cherubFire(i);
          } 
        } 
      } 
    } 
    if (rapture_cherubsleft==0) 
    {
      clearInterval(rapture_cherubattack); 
      rapture_endGame('winner'); 
      return;
    }
    if ((rapture_groupleft<=rapture_padleft)||(rapture_groupright>=rapture_padright)) rapture_godownnext=true; 
  } 
}

function rapture_movegod() 
{
  if (rapture_gameover==true||rapture_pause==true) 
  {
    if (window.rapture_godmoving) clearInterval(rapture_godmoving); 
    if (rapture_pause==true) window.setTimeout("rapture_movegod()",rapture_goddelay); 
    return;
  } 
  var rapture_godRandom = Math.floor(Math.random()*5000);
  if (!window.rapture_godmoving) rapture_godmoving=setInterval("rapture_movegod()",rapture_godbreak+rapture_godRandom);
  if (rapture_goddying!=false) return; 
  if (rapture_god.offsetLeft+rapture_god.offsetWidth>rapture_fullwidth) rapture_god.style.left=rapture_offscreen;
  else 
  {
    if (rapture_god.offsetLeft<-20) rapture_god.style.left="-20px";
    else rapture_god.style.left=(rapture_god.offsetLeft+rapture_godstep)+"px";
    window.setTimeout("rapture_movegod()",rapture_goddelay); 
  } 
}

function rapture_movesatan(direction) 
{
   if (rapture_gameover==true || rapture_satandying!=false) return; 
   if (direction=='right' && rapture_satan.offsetLeft+rapture_satan.offsetWidth<rapture_fullwidth) 
     rapture_satan.style.left=(rapture_satan.offsetLeft+rapture_satanstep)+"px";
   else if (direction=='left' && rapture_satan.offsetLeft>0) 
     rapture_satan.style.left=(rapture_satan.offsetLeft-rapture_satanstep)+"px";
}

function rapture_startMotion() 
{ 
  var rapture_godRandom = Math.floor(Math.random()*5000);
  if (window.rapture_cherubattack) clearInterval(rapture_cherubattack); 
  rapture_cherubattack=setInterval("rapture_movecherubs()",rapture_cherubdelay); 
  rapture_shootarrows(); 
  if (window.rapture_godmoving) clearInterval(rapture_godmoving); 
  window.setTimeout("rapture_movegod()",(rapture_godRandom+rapture_godbreak)-(rapture_goddelay*rapture_fullwidth/rapture_godstep)); 
}



//--------------------------------------------------
//----------------<ATTACK FIRING>-------------------
//--------------------------------------------------

function rapture_hit(divone,divtwo,proximity) 
{
  var center1x=divone.offsetLeft+(divone.offsetWidth/2);
  var center2x=divtwo.offsetLeft+(divtwo.offsetWidth/2);
  if  ((center2x-proximity<center1x&&center1x<center2x+proximity)
        &&(divtwo.offsetTop<divone.offsetTop&&divone.offsetTop<divtwo.offsetTop+divtwo.offsetHeight))
        return true;
  else return false;
}

function rapture_satanFire() 
{
  if (rapture_gameover==true) return;
  if (rapture_throwing==false) 
  {
    rapture_knife.style.left=(rapture_satan.offsetLeft+(rapture_satan.offsetWidth/2))+"px";
    rapture_knife.style.top=(rapture_satan.offsetTop)+"px";
    rapture_throwing=true;
    rapture_throwknife();
    rapture_satan.childNodes[0].src=rapture_throwingsatan.src;  //may need to do twice with delay
    window.setTimeout("rapture_satan.childNodes[0].src=rapture_basicsatan.src;",rapture_animationdelay); 
  } 
}

function rapture_throwknife() 
{
  if (rapture_gameover==true) return;
  if (rapture_pause==true) { window.setTimeout("rapture_throwknife()",rapture_knifedelay);return; }

  rapture_knife.style.top=(rapture_knife.offsetTop-rapture_knifestep)+"px";
  if (rapture_hit(rapture_knife,rapture_god,rapture_godprox)) 
  {
    rapture_goddying=true;
    rapture_knife.style.top=rapture_offscreen;
    rapture_throwing=false;
    rapture_god.childNodes[0].src=rapture_dyinggod.src;
    window.setTimeout("rapture_dyingDiv(rapture_god)",rapture_animationdelay);
  }
  for (var j=0;j<rapture_cherubs.length;j++) 
  {
    var i=rapture_cherubs.length-1-j;
    if (rapture_cherubs[i]) 
    { 
      if (rapture_hit(rapture_knife,rapture_cherubs[i],rapture_cherubprox)==true) 
      {
        rapture_cherubdying=true;
        rapture_knife.style.top=rapture_offscreen;
        rapture_throwing=false;
        rapture_cherubdelay-=rapture_cherubacceleration;
        rapture_chanceoccurence-=Math.ceil(rapture_chanceoccurence/10); 
        if (rapture_chanceoccurence<rapture_minchance) rapture_chanceocurrence=rapture_minchance;
        rapture_cherubs[i].childNodes[0].src=rapture_dyingcherub.src;
        window.setTimeout("rapture_dyingDiv("+i+")",rapture_animationdelay); 
      } 
    } 
  }
  if (rapture_knife.offsetTop+rapture_knife.offsetHeight<0) 
  {
    rapture_knife.style.top=rapture_offscreen;
    rapture_throwing=false; 
  }
  else window.setTimeout("rapture_throwknife()",rapture_knifedelay);
}

function rapture_cherubFire(cherubfiring) 
{
  var rapture_twanging=false;
  for (var i=0;i<rapture_arrows.length;i++) 
  {
    if ((rapture_twanging==false)&&(rapture_activearrows[i]=="free"))
    {
      rapture_twanging=true;
      rapture_arrowstwanging++;
      if (odd(cherubfiring)) 
      {
        rapture_cherubs[cherubfiring].childNodes[0].src=rapture_shootingcherubA.src;
        setTimeout("rapture_cherubs["+cherubfiring+"].childNodes[0].src="+
                                                       "rapture_basiccherubA.src",rapture_animationdelay) 
      }
      else 
      {
        rapture_cherubs[cherubfiring].childNodes[0].src=rapture_shootingcherubB.src;
        setTimeout("rapture_cherubs["+cherubfiring+"].childNodes[0].src="+
                                                       "rapture_basiccherubB.src",rapture_animationdelay) 
      }
      rapture_arrows[i].style.left=(rapture_cherubs[cherubfiring].offsetLeft+(rapture_cherubs[cherubfiring].offsetWidth/2))+"px";
      rapture_arrows[i].style.top=(rapture_cherubs[cherubfiring].offsetTop+rapture_cherubs[cherubfiring].offsetHeight)+"px";
      rapture_activearrows[i]='ready'; 
    } 
  }
}

function rapture_shootarrows() 
{
   if (rapture_gameover==true) return;
   if (rapture_pause==true){ window.setTimeout("rapture_shootarrows()",rapture_arrowdelay);return }
  for (var i=0;i<rapture_arrows.length;i++) 
  {
    if (rapture_activearrows[i]=="ready") 
    {
      rapture_arrows[i].style.top=(rapture_arrows[i].offsetTop+rapture_arrowstep)+"px";
      if (rapture_hit(rapture_arrows[i],rapture_satan,rapture_satanprox)) 
      {
        rapture_satandying=true;
        rapture_arrows[i].style.top=rapture_offscreen;
        rapture_activearrows[i]="free";
        rapture_pseudorandom-=Math.random();
        rapture_arrowstwanging-- ;    
        rapture_satan.childNodes[0].src=rapture_dyingsatan.src;
        window.setTimeout("rapture_dyingDiv(rapture_satan)",rapture_animationdelay); 
      }
      else if (rapture_arrows[i].offsetTop+rapture_arrows[i].offsetHeight>rapture_satan.offsetTop+rapture_satan.offsetHeight) 
      {
        rapture_arrows[i].style.top=rapture_offscreen;
        rapture_activearrows[i]="free";
        rapture_pseudorandom+=Math.random();
        rapture_arrowstwanging-- ;
      } 
    } 
  }
  window.setTimeout("rapture_shootarrows()",rapture_arrowdelay);
}




//--------------------------------------------------
//--------------------<DYING>-----------------------
//--------------------------------------------------

function rapture_dyingDiv(deadguy) 
{
  if (deadguy.id=="satandiv") 
  {
    if (rapture_lives < 1) return;
    if (rapture_immortality!=true) 
    {
      if (rapture_lives-->rapture_defaultlives) 
        rapture_hearts[rapture_lives].style.visibility="hidden";
      else 
        rapture_hearts[rapture_lives].childNodes[0].src=rapture_deadheart.src;
    }
    rapture_satandying=false;
    rapture_satan.childNodes[0].src=rapture_basicsatan.src;
    if (rapture_lives==0) 
    {
      rapture_satan.style.left=rapture_offscreen;  
      rapture_endGame('loser');
    }
  }
  else if (deadguy.id=="goddiv") 
  {
    rapture_god.style.left=rapture_offscreen; 
    rapture_god.childNodes[0].src=rapture_basicgod.src;
    rapture_incrementscore(rapture_godpoints);
    if (rapture_lives < rapture_hearts.length) 
    {
      rapture_hearts[rapture_lives].childNodes[0].src=rapture_liveheart.src;
      rapture_hearts[rapture_lives].style.visibility="visible";
      rapture_lives++;
    }
    rapture_goddying=false;
  }
  else 
  {
    rapture_cherubs[deadguy].style.left=rapture_offscreen; 
    rapture_cherubs[deadguy]=0;
    rapture_incrementscore(rapture_cherubpoints);
    rapture_cherubdying=false; 
  }
}


function rapture_incrementscore(number) 
{
   rapture_satanscore+=number;
   var rapture_score=document.getElementById("scorediv");
   rapture_score.innerHTML=rapture_satanscore;
}


//-------------------------------------------------------
//----------------<END LEVEL FUNCTIONS>------------------
//-------------------------------------------------------

function rapture_setLevel(level) 
{
  rapture_wins.innerHTML=level;
}


function rapture_endGame(outcome) 
{
   rapture_gameover=true;
   if (outcome=='winner') 
   { 
     rapture_createLevel(++rapture_trumpet);
     rapture_displaySign(rapture_trumpet); 
   }
   else if (outcome=='loser') 
     rapture_displaySign('loser');
}
function rapture_newGame() 
{ 
  rapture_createLevel(1);
  rapture_displaySign('start'); 
}

function rapture_startGame() 
{
//--start motion on click from user:
  rapture_cover.style.visibility="hidden";
  rapture_signbox.style.visibility="hidden";
  rapture_cheat.style.visibility="hidden";
  rapture_gameover=false;
  rapture_startMotion();   
}

rapture_cheats=new Array("NinthGate","BlairWitch","69","BillGates","OldScratch","FreeMasonry","Eleucinian","Isis","Pagan","Wicca","satanism","Atheism","Anarchy");
rapture_currentcheat="xxx";
rapture_cheatString="";
rapture_immortality=false;
function rapture_showcheat()
{
  rapture_currentcheat=rapture_cheats[Math.round(Math.random()*7)];
  rapture_cheat.innerHTML="*"+rapture_currentcheat+"";
  rapture_cheat.style.visibility="visible";
}

function rapture_displaySign(signname)
{
  switch (signname) 
  {
        case 'start':   text="<h2>--THE RAPTURE--</h2>"+
                             "<p>That's right: it's the end of the world.  You didn't change your naughty ways, and rapture_god is sure pissed at *you*! If you want to live till tomorrow, you're gonna have to kill legions of his servants and maybe even pop the Big Man himself.<br />Good luck! (You're gonna need it!)</p>"+
                             "<p class='keycodes'>[&lt;] LEFT / RIGHT [&gt;]<br />"+
                             "[SPACEBAR] SHOOTS<br /> "+
                             "([?] rapture_pause)</p>"+
                             "<a class='start' href='#' onclick='rapture_startGame();return false'> START GAME </a>";
                        break;
        case 2:         text="<h2>--YOU HAVE SURVIVED--<br />--THE FIRST TRUMPET!--</h2>"+
                             "<p>In what could only be called a devastatingly fluffy masacre of all that is evil, rapture_god's army has rained hail, fire, and blood upon the earth. You managed to escape any direct rapture_hits, but one-third of the earth was burned nonetheless.  Next time perhaps you ought to pay a bit more attention to the interests of your constituents.</p>"+
                             "<a class='start' href='#' onclick='rapture_startGame();return false'> SECOND TRUMPET </a>";

                        break;
        case 3:         text="<h2>--YOU HAVE SURVIVED--<br />--THE SECOND TRUMPET!--</h2>"+
                             "<p>Downy feathers may strew the earth at your feet, but rapture_god continues to hold the upper hand as His forces seized the Mediterranean and one-third of the sea was turned to blood and all the fishes killed. Better cancel that celebratory lobster dinner and settle in for a long siege.</p>"+
                             "<a class='start' href='#' onclick='rapture_startGame();return false'> THIRD TRUMPET </a>";

                        break;
        case 4:         text="<h2>--YOU HAVE SURVIVED--<br />--THE THIRD TRUMPET!--</h2>"+
                             "<p>Your plucky attempts to destroy the host of heaven are paying off... but not fast enough. This time rapture_god used His expansive understanding of Physics to hurl a sun from the Wormwood galaxy. It passed pretty damn close, leaving a swath of devastation which turned one-third of the fresh water sources on Earth bitter.</p>"+
                             "<a class='start' href='#' onclick='rapture_startGame();return false'> FOURTH TRUMPET </a>";

                        break;
        case 5:         text="<h2>--YOU HAVE SURVIVED--<br />--THE FOURTH TRUMPET!--</h2>"+
                             "<P>You've done a good job, especially with the timely aid of Bill Gates and his expansive technological resources. But how can you hope to win against an omnipotent priss like Jove?  rapture_god continues to run circles around you! This time he snuffed out one-third of the sun, moon, and stars.  I hope you have a good flashlight by your bed!</p>"+
                             "<a class='start' href='#' onclick='rapture_startGame();return false'> FIFTH TRUMPET </a>";

                        break;
        case 6:         text="<h2>--YOU HAVE SURVIVED--<br />--THE FIFTH TRUMPET!--</h2>"+
                             "<p>Now you are gaining an edge-- in a brilliantly calculated maneouver, you struck open the Pit of the Abyss.  Smoke poured out, followed by pagan beasts. Unfortunately for you and your followers, all the beasts were promptly converted by a passing JW and proceeded to torture all of humanity lacking the seal of rapture_god.  It took five months to get them under control!</p>"+
                             "<a class='start' href='#' onclick='rapture_startGame();return false'> SIXTH TRUMPET </a>";

                        break;
        case 7:         text="<h2>--YOU HAVE SURVIVED--<br />--THE SIXTH TRUMPET!--</h2>"+
                             "<p>You are in the homestretch!<BR>rapture_god released his four heavyweight angels and they attacked the entire human race upon fire-breathing, lion-headed horses. One-third of the population on Earth was killed. But humanity has still not given up and continue to follow you!</p>"+
                             "<a class='start' href='#' onclick='rapture_startGame();return false'> SEVENTH TRUMPET </a>";

                        break;
        case 8:         text="<h2>--YOU HAVE SURVIVED--<br />--THE SEVENTH TRUMPET!--</h2>"+
                             "<p>But unfortunately rapture_god won.<BR>Don't feel too bad, you gave it a good try-- rapture_god cast out a third of His angels, who promptly joined your side. A dragon chased down Mary and killed Jesus, and a second dragon with seven heads and ten horns did some pretty good PR work for you and your image.</p>"+
                             "<a class='start' href='#' onclick='rapture_displaySign('more');return false'> MORE &gt; </a>";
		        rapture_incrementscore(bonuspoints);
                        break;
        case 'more':    text="<br /><p>And you even managed to get that National Champ with the rams horns to do your 666 recruitment ads, but then rapture_god turned around and sent out seven angels with seven plagues, and due to the rampantly promiscuous sex your followers engage in, the plagues spread pretty fast.  Too bad!  Now rapture_god has sentanced you to an eternity in hell in which contemplate your naughty ways.</p>"+
                             "<a class='start' href='#' onclick='rapture_newGame();return false'> PLAY AGAIN </a>";
                        break;
        case 'loser':   text="<h2>--YOU LOST!--</h2>"+
                             "<p>With a loser like you in charge of the hosts of hell, it makes you wonder why anyone bothers to be evil at all these days. While your little wussy ass was running the other way, rapture_god took over the whole damn earth and instituted a millenial age with no illness, death, sex, or crime. IE-- all fun has been extinguished forever, thanks to you.</p>"+
                             "<a class='start' href='#' onclick='rapture_newGame();return false'> TRY AGAIN </a>";                     
                        break;
  }
  rapture_signbox.childNodes[1].innerHTML=text;
  rapture_signbox.style.visibility="visible";
}

function rapture_createLevel(level) 
{
  rapture_cover.style.visibility="visible";
  rapture_immortality=false;
  if (level==1) 
  {//--first time setup
        rapture_satanscore=0;
        rapture_trumpet=1;
        rapture_incrementscore(0);
        rapture_satanstep=20;
        rapture_cherubstep=10;
        rapture_godstep=10;
        rapture_knifestep=20; rapture_arrowstep=20;
        rapture_goddelay=150;
        rapture_knifedelay=100; rapture_arrowdelay=100;
        rapture_animationdelay=500;
        //rapture_godbreak=30000;

        rapture_initlives(); 
   }
   else rapture_incrementscore(rapture_levelpoints);

//------ alterations for all levels:
   rapture_cherubdelay=rapture_basiccherubdelay-(50*rapture_trumpet); if (rapture_cherubdelay<50) rapture_cherubdelay=50;
   rapture_cherubacceleration=rapture_cherubdelay/25;
   rapture_minchance=Math.floor(20/(rapture_trumpet+1));
   if (rapture_minchance<3&&rapture_trumpet<7) rapture_minchance=3;
   rapture_chanceoccurence=rapture_basicchanceoccurence-(10*rapture_trumpet); 
   if (rapture_chanceoccurence<rapture_minchance) rapture_chanceoccurence=rapture_minchance;
   rapture_godbreak=32000-(rapture_trumpet*2000)
   rapture_setLevel(rapture_trumpet);
   rapture_initcherubs();
   rapture_initarrows();
   rapture_initsatan();
   rapture_initgod();
   rapture_showcheat();
}


//---------------------------------------------------

function rapture_doKey(evt) 
{
  var e = (evt) ? evt : window.event;
  if (!e || !document.getElementById) return;
  var letter = String.fromCharCode(e.keyCode).toLowerCase();
  if (letter=="?"||letter=="/") rapture_pause=(rapture_pause==true)?false:true;
  if (e.keyCode==188) letter=",";
  else if (e.keyCode==190) letter=".";
  switch (letter) 
  {
    case "," :     
           if (!rapture_pause && !rapture_gameover) rapture_movesatan('left');break;
    case "." :
           if (!rapture_pause && !rapture_gameover) rapture_movesatan('right');break;
    case " " :
           if (!rapture_pause && !rapture_gameover) rapture_satanFire();break; 
    case "8" :
           if (e.shiftKey) rapture_cheatString="";break;
    default:
           if (/[a-z0-9]/i.test(letter)) rapture_cheatString+=letter;
   } 
  if (!rapture_immortality && rapture_cheatString==rapture_currentcheat.toLowerCase()) {rapture_immortality=true;}
  return false;
  return true;
}
function rapture_setup() 
{
  if (!document.getElementById) return;

//-----start position screen settings
   rapture_cover=document.getElementById("coverdiv");
   rapture_signbox=document.getElementById("signboxdiv");
   rapture_cheat=document.getElementById("cheatdiv");
   rapture_wins=document.getElementById("winsdiv");
   rapture_score=document.getElementById("scorediv");

//-----global constants ????????
   rapture_basiccherubdelay=650;    
   rapture_basicchanceoccurence=80; 
   rapture_basicrapture_cherubacceleration=20;
   rapture_godpoints=500;
   rapture_cherubpoints=50;
   rapture_levelpoints=1000;
   rapture_bonuspoints=(rapture_levelpoints*10)-rapture_levelpoints;
//-----global variables
   rapture_gameover=true;
   rapture_pause=false;
   if (!document.onkeydown) document.onkeydown = rapture_doKey;//?
   rapture_newGame();
}
