//these are variables for the engine
var lln;
var lbc;
var lbn;
var llc;
var lbm; 
var llm;  
var llnn;
var lbnn; 
var leftload; 
lbc=0;
llc=0; 
llnn=0;
lbnn=0; 

//left panel variables 

leftload=0; //has the left panel been loaded? 
lbm=4; //equals number of variables in lbn 

var lbn = new Array();
lbn[0] = "Click here to close.";
lbn[1] = "Vote here to see Stephen the Grand's version of the character Redphantom.";
lbn[2] = "Vote here to learn about the real Sparkey";
lbn[3] = "Turn off interface."

llm=3; //number of variables in lln 

var lln = new Array();
lln[0] = "http://topwebcomics.com/vote/7918/default.aspx";
lln[1] = "http://www.buzzcomix.net/in.php?cid=12652";
lln[2] = "#shed"; 

//This is the "engine" which drives the comic

function loaded()
{
sexy();
setbig();
setgif();
nill();
}

function sexy()
{
if (issue==28)
{
alert("This issue contains mild sexual content")
}
else
{
++string;
}
}

function nill()
{
if (ffload==0)
{
ff(); 
}
else
{
ill(); 
}
}


function ff()
{
if (apan<6)
{
document.getElementById("nextup").src="images/p"+apan+".png";
++apan; 
}
else
{
nill(); 
}
}

function ffback()
{
if (apan==6)
{
++ffload;
nill(); 
}
else if (apan<6)
{
ff(); 
}
else
{
++string; 
}
}

function ill()
{
if (gifload==0)
{
loadani(); 
}
else 
{
document.getElementById("tp").src="images/wctp"+issue+".png";
document.getElementById("pannel").src="images/title.png";
}
}

function loadani()
{
if (anistart<aninum)
{
anipan=ap[anistart]; 
document.getElementById("preload").src="images/p"+anipan+".gif"; 
++anistart; 
}
else 
{
++gifload;
ill(); 
}
}

function loadaniback()
{
if (anistart>aninum)
{
++gifload;
ill(); 
}
else
{
loadani(); 
}
}

function setbig()
{
bigpast=bigpresent-1;
bigfuture=bigpresent+1;
big=sp[bigpresent];
--big;
}

function setgif()
{
gifpast=gifpresent-1;
giffuture=gifpresent+1;
}

function spec()
{
document.getElementById("cp").className="anip";
document.getElementById("rp").className="anip";
document.getElementById("lp").className="anip";
document.getElementById("tp").className="anip";
document.getElementById("prev").className="inb";
document.getElementById("home").className="inb";
document.getElementById("next").className="inb";
document.getElementById("pannel").className="border";
}

function norm()
{
document.getElementById("cp").className="pina";
document.getElementById("rp").className="pina";
document.getElementById("lp").className="pina";
document.getElementById("tp").className="pina";
document.getElementById("prev").className="anip";
document.getElementById("home").className="anip";
document.getElementById("next").className="anip";
document.getElementById("pannel").className="pina";
}

function modes()
{
if (mode==0)
{
spec();
++mode;
}
else if(mode==1)
{
norm();
--mode;
}
else 
{
mode=mode; 
}
}

function future()
{
if (pan==sp[bigfuture])
{
++bigpresent;
setbig();
modes();
fgif();
}
else
{
fgif();
}
}

function fgif()
{
if (pan==ap[giffuture])
{
++gifpresent;
setgif();
nextgif();
}
else
{
nextpage();
}
}

function past()
{
if (pan==big)
{
--bigpresent;
setbig();
modes();
bgif();
}
else
{
bgif();
}
}

function bgif()
{
if (pan==ap[gifpast])
{
--gifpresent;
setgif();
nextgif();
}
else
{
nextpage();
}
}

function nextpage()
{
if (pan<=0)
{
document.pannel.src="images/title.png";
}
else if (pan>=1 && pan<=panmax)
{
++apan; 
document.getElementById("pannel").src="images/p"+pan+".png";
document.getElementById("nextup").src="images/p"+apan+".png";
}
else
{
document.getElementById("pannel").src="images/end.png";
}
}

function nextgif()
{
if (pan<=0)
{
document.pannel.src="images/title.png";
}
else if (pan>=1 && pan<=panmax)
{
document.pannel.src="images/p"+pan+".gif";
}
else
{
document.pannel.src="images/end.png";
}
}

function nextcomic()
{
if(lastest==1)
{
alert("The next comic has not been posted yet.");
}
else
{
nextcomicgine(); 
}
}

function nextcomicgine()
{
++issue;
if(last==1)
{
++arc;
window.location.assign("../../"+arc+"/"+issue+"/"+issue+".htm");
}
else
{
window.location.assign("../"+issue+"/"+issue+".htm");
}
}

function prevcomic()
{
--issue; 
if(first==1)
{
--arc; 
window.location.assign("../../"+arc+"/"+issue+"/"+issue+".htm"); 
}
else
{
window.location.assign("../"+issue+"/"+issue+".htm");
}
}

function splitf()
{
if(parts=2)
{
nextpart()
}
else
{
nextcomic()
}
}

function splitb()
{
if (parts=2)
{
prevpart();
}
else
{
prevcomic(); 
}
}

function nextpart()
{
if (pan<second)
{
pan=second;
future();
}
else
{
nextcomic();
}
}

function prevpart()
{
if (pan<second)
{
prevcomic(); 
}
else
{
pan=0;
bigpresent=0;
gifpresent=0;
setbig();
setgif();
past();
}
}

function gifset()
{
if(second<=ap[agiffuture])
{
++giffuture;
}
else
{
gifpresent=giffuture-1;
gifpast=gifpresent-1;
}
}

function mo()
{
++llnn;
text(); 
locale(); 
}

function premo()
{
if (leftload==0)
{
mo(); 
}
else
{
leftvis();
}
}

function leftvis()
{
document.getElementById("leftpanel").className="on";
}

function text()
{
++lbnn; 
if (lbc<lbm)
{
document.getElementById("lb"+lbnn).className="not";
document.getElementById("ll"+lbnn).className="sp";
document.getElementById("ll"+lbnn).innerHTML=lbn[lbc];
++lbc;
textback(); 
}
else
{
++lbc;
}
}

function textback()
{
if (lbc>lbm)
{
++lbc; 
}
else
{
text(); 
}
}

function locale()
{
++llnn; 
if (llc<llm)
{
document.getElementById("ll"+llnn).href=lln[llc];
++llc;
localeback(); 
}
else
{
++llc;
}
}

function localeback()
{
if (llc>llm)
{
++llc; 
}
else
{
locale(); 
}
}

function mooff()
{
++leftload; 
document.getElementById("leftpanel").className="off";
}

function shed()
{
mode==0;
modes();
++mode;
}

function rmo()
{
++rlnn;
rtext(); 
rlocale(); 
}

function link() 
{
if (rightload==0)
{
rmo(); 
}
else
{
rightvis();
}
}

function rightvis()
{
document.getElementById("rightpanel").className="on";
}

function rtext()
{
++rbnn; 
if (rbc<rbm)
{
document.getElementById("rb"+rbnn).className="not";
document.getElementById("rl"+rbnn).className="sp";
document.getElementById("rl"+rbnn).innerHTML=rbn[rbc];
++rbc;
rtextback(); 
}
else
{
++rbc;
}
}

function rtextback()
{
if (rbc>rbm)
{
++rbc; 
}
else
{
rtext(); 
}
}

function rlocale()
{
++rlnn; 
if (rlc<rlm)
{
document.getElementById("rl"+rlnn).href=rln[rlc];
++rlc;
rlocaleback(); 
}
else
{
++rlc;
}
}

function rlocaleback()
{
if (rlc>rlm)
{
++rlc; 
}
else
{
rlocale(); 
}
}

function rmooff()
{
++rightload; 
document.getElementById("rightpanel").className="off";
}
