// Easy Admin CP version 1.0 - Paper1 © 2005

// Dectect the url (myurl)
  var myurl;
  myurl=location.href.substr(0,location.href.lastIndexOf("/"))+"/";

// Detect the board name (myname)
var myname=myurl.lastIndexOf("/");
var myname1=myurl.lastIndexOf("/",myname-1);
myname=myurl.substring(myname, myname1+1);


// Make sure that the admin CP does not try to escape the frame
document.write("<body OnUnload='check();'>");

var status="False";

function check() {
  if (status == "True") {
    document.location.href=myurl+"index.php?admin=incorrect";
  }
}

if (document.location.href==myurl+"index.php?admin=incorrect") {
  document.getElementById("navstrip").innerHTML+="<br><br><div class='tableborder'><div class='maintitle'><img src='http://67.18.37.14/style_images/1/nav_m.gif' border='0' alt='' width='8' height='8'> Please log in</div><table width='100%' border='0' cellspacing='1' cellpadding='4'><tr><td class='row4' colspan='7' align='center'><br><span id='content'></span><br><br></td></tr></table><div align='center' class='darkrow2' style='padding:4px; font-size:9'>Easy Admin CP version 1.0 - Paper1 © 2005. Made for <a href='http://www.invisionfree.com/'>InvisionFree</a></div></div><br><br>";
  document.getElementById("content").innerHTML='<br><span style="color:red;font-weight:bold">An error occured:<ul><li>If you were trying to log in, you may have provided an incorrect user name</li><li>If you were trying to log in, you may have provided an incorrect password</li><li>You tried to navigate away from the page when the code was busy</li></ul></span>';
  var status="Disabled";
}


// This loads a form that administrators can use to login with
function load() {
  if (status!="Disabled") {
    document.getElementById("navstrip").innerHTML+="<br><br><div class='tableborder'><div class='maintitle'><img src='http://67.18.37.14/style_images/1/nav_m.gif' border='0' alt='' width='8' height='8'> Please log in</div><table width='100%' border='0' cellspacing='1' cellpadding='4'><tr><td class='row4' colspan='7' align='center'><br><span id='content'></span><br><br></td></tr></table><div align='center' class='darkrow2' style='padding:4px; font-size:9'>Easy Admin CP version 1.0 - Paper1 © 2005. Made for <a href='http://www.invisionfree.com/'>InvisionFree</a></div></div><br><br><iframe name='adminframe' id='adminframe' height='0' width='0' style='height:0;width:0;border-style:none' src='' OnLoad='Wrappers()'></iframe><br><textarea id='jswrapper' height='0' width='0' style='height:0;width:0;border-style:none'></textarea>";
    document.getElementById("content").innerHTML='<br><table border="0"><tr><td>User name:</td><td><input id="adminname" type="text" /></td></tr><tr><td>Password:</td><td><input id="adminpass" type="password" /></td></tr></table><input id="adminlogin" type="button" value="Submit" OnClick="LogIn();" />';
  }
}


// Login to the AdminCP through an Iframe
var complete="NA";

function LogIn() {
status="True";

var name=document.getElementById("adminname").value;
var password=document.getElementById("adminpass").value;

document.getElementById("adminlogin").value="Attempting to log in";
document.getElementById("adminlogin").disabled = true;
document.getElementById("adminframe").src=myurl+"admin.php?act=Post&login=yes&username="+name+"&password="+password;
complete="Wrappers";
}


// Direct the admin frame to the wrappers
function Wrappers() {
  if (complete=="Information") {
    document.getElementById("jswrapper").value=self.adminframe.document.theAdminForm.template1.value;
    complete="NA";
    status="False";
    loaded();
  }

  if (complete=="Save") {
    complete="NA";
    saved();
  }

  if (complete=="Wrappers") {
    var myadsess1=self.adminframe.body.location.href.indexOf("adsess=");
    var myadsess2=self.adminframe.body.location.href.indexOf("&act=index");
    var myadsess=self.adminframe.body.location.href.substring(myadsess1+7,myadsess2);
    document.getElementById("adminframe").src=self.adminframe.body.location.href+"&act=wrap";
    complete="Information";
  }
}


// Save the wrappers
function save() {
complete="Save";
self.adminframe.document.theAdminForm.template1.value=document.getElementById("jswrapper").value;
self.adminframe.document.theAdminForm.submit();
}