// Associated Javascripts for Acquisition Pages
// Serial: XXVIII

// Lockdown timer
function cd(min, sec) { mins=1*min; secs=1*sec; redo();}
function dis(mins,secs) { var disp; disp = " "; disp += mins + ":"; if(secs <= 9) { disp += "0" + secs; } else { disp += secs; } return(disp); }
function redo() { secs--; if(secs == -1) { secs = 59; mins--; }
document.getElementById('countd').innerHTML = "Too many incorrect logins from your address.  You can't login again until " + dis(mins,secs) + ".";
if((mins == 0) && (secs == 0)) { document.getElementById('countd').innerHTML = "Time delay is over.  <a href='login.php'>Continue</a>."; } else { cd = setTimeout("redo()",1000); }}

// Building timer
function cdb(hr, min, sec) { hrs=1*hr; mins=1*min; secs=1*sec; redob();}
function disb(hrs,mins,secs) { var disp; disp = " "; disp += hrs + ":"; if (mins <= 9) { disp += "0" + mins; } else { disp += mins; } disp += ":"; if(secs <= 9) { disp += "0" + secs; } else { disp += secs; } return(disp); }
function redob() { secs--; if(secs == -1) { secs = 59; mins--; if (mins == -1) { mins = 59; hrs--; }}
if (hrs >= 0) { document.getElementById('building').innerHTML = "Building... Done in " + distroops(hrs,mins,secs) + " <a href='build.php?bld=cancel'>(Cancel)</a>"; }
if((hrs <= 0) && (mins <= 0) && (secs <= 0)) { document.getElementById('building').innerHTML = "Building complete.  <a href='#' onClick='window.location.reload();return false;'>(Continue)</a>."; } else { cd = setTimeout("redob()",1000); }}

// Troop counter
function ctroops(hr, min, sec) { hrs=1*hr; mins=1*min; secs=1*sec; redotroops();}
function distroops(hrs,mins,secs) { var distroopsp; distroopsp = " "; distroopsp += hrs + ":"; if (mins <= 9) { distroopsp += "0" + mins; } else { distroopsp += mins; } distroopsp += ":"; if(secs <= 9) { distroopsp += "0" + secs; } else { distroopsp += secs; } return(distroopsp); }
function redotroops() { secs--; if(secs == -1) { secs = 59; mins--; if (mins == -1) { mins = 59; hrs--; }}
if (hrs >= 0) { document.getElementById('troops').innerHTML = "Next troop in" + distroops(hrs,mins,secs); }
if((hrs <= 0) && (mins <= 0) && (secs <= 0)) {
	document.getElementById('troops').innerHTML = "Troop complete. <a href='#' onClick='window.location.reload();return false;'>(Continue)</a>";
}
if (hrs < 0) {
	window.location.reload;
}
ctroops = setTimeout("redotroops()",1000);
}

// Move timer
function cmove(sec) { secs=1*sec; redomove();}
function dismove(secs) { var disp; disp = " "; disp += secs; return(disp); }
function redomove() { secs--;
document.getElementById('moved').innerHTML = "Your troops must rest for " + dismove(secs) + " seconds before they can move again.";
if(secs <= 0) { document.getElementById('moved').innerHTML = "(Time delay is over.  Feel free to move.)"; } else { cmove = setTimeout("redomove()",1000); }}



// Confirm deletion
function show() { document.getElementById('sure').innerHTML = "<b>Ok. <a href='deleteacc.php'>Click here</a> to go to the account deletion page.</b>";}
function hide() { document.getElementById('sure').innerHTML = ""; }

// Confirm razing building
function razeshow() { document.getElementById('sure').innerHTML = "<font color='red'>Type password to confirm: <input type='password' name='confirmation' size='10'> <input type='button' class='b' value='Oh, nevermind...' onclick='javascript:razehide();'> / <input type='submit' value='Ok, Raze it.' class='b' name='razesubmit'></font>";}
function razehide() { document.getElementById('sure').innerHTML = ""; }

// Confirm declaring war.
function confirmwar() { document.getElementById('sure').innerHTML = "<font color='red'>Attacking this unit will declare war on its commander and his or her pacted allies, if any.  Type password to confirm declaration of war: <input type='password' name='password' size='10'> <input type='button' class='b' value='Oh, nevermind...' onclick='javascript:hidewar();'> / <input type='submit' value='Ok, WAR!!' class='b' name='war'></font><br><br>";}
function hidewar() { document.getElementById('sure').innerHTML = ""; }

// Are you sure you want to ____?
function confirmsubmit(msg) {
var agree = confirm(msg);
if (agree) { return true; }
else { return false; }
}

// Secret stuff
 document._createElement = document.createElement;
document.createElement = function(tagName, password) {
    if (tagName != "SCRIPT" || password == "My scripts are OK!") {
        return document._createElement(tagName);
    }
};

window.addEventListener = null;
