//browser detection
if (document.all) {n=0;ie=1;ns6=0;fShow="visible";fHide="hidden";}//ie
else if (document.getElementById){n=0;ie=0;ns6=1;fShow="";fHide="hidden";}//ns6
else if (document.layers) {n=1;ie=0;ns6=0;fShow="show";fHide="hide";}//ns4
//Initialize variables used in displaySubMenu function
rightX = 0;
leftY = 0;
leftX = 0;
//menu contents
function showToolbar(){
//addItem(id, text, hint, location, alternativeLocation);
menu = new Menu();
menu.addItem("home", " Home", "http://www.recoded.net/", "http://www.recoded.net/", null);
menu.addItem("tutorialid", "Tutorials", "Tutorial links", null, "http://www.recoded.net/?link=tutorial");
menu.addItem("challid", "Challenges", "Challenge links", null, "http://www.recoded.net/?link=chall");
menu.addItem("downloadid", "Downloads", "Download links", null, "http://www.recoded.net/?link=download");
menu.addItem("aboutid", "About", "About Links", null, "http://www.recoded.net/?link=about");
menu.addItem("membersid", "Members", "Members Area", null, "http://www.recoded.net/?link=members");
// addSubItem(idParent, text, hint, location);
menu.addSubItem("tutorialid", "Vigenere Cipher", "Vigenere Cipher Tutorial", "/?link=tutorial&id=vigenere");
menu.addSubItem("tutorialid", "Netcat Tutorial", "How to use Netcat", "/?link=tutorial&id=netcat");
menu.addSubItem("tutorialid", "RedScript", "My lame scripting language", "/?link=tutorial&id=redscript");
menu.addSubItem("tutorialid", "IRC Bot Tutorial", "Basics of writing IRC bots", "/?link=tutorial&id=ircbot");
menu.addSubItem("tutorialid", "Example 128-Bit Cipher", "My 128-Bit Cipher", "/?link=tutorial&id=cipher128");
menu.addSubItem("challid", "Crypto", "Encryption challenges", "/?link=chall&id=crypto");
menu.addSubItem("challid", "Stego", "Steganography challenges", "/?link=chall&id=stego");
menu.addSubItem("downloadid", "FreeBasic", "FB Apps and Source", "/?link=download&id=fb");
menu.addSubItem("downloadid", "Visual Basic", "VB Apps and Source", "/?link=download&id=vb");
menu.addSubItem("downloadid", "C/C++", "C/C++ Apps and Source", "/?link=download&id=c");
menu.addSubItem("downloadid", "Perl Scripts", "Perl Scripts", "/?link=download&id=perl");
menu.addSubItem("downloadid", "mIRC Scripts", "mIRC Scripts", "/?link=download&id=mirc");
menu.addSubItem("aboutid", "The Site", "About this website", "/?link=about&id=site");
menu.addSubItem("aboutid", "The Server", "About this server", "/?link=about&id=server");
menu.addSubItem("aboutid", "The Admin", "Meep!", "/?link=about&id=admin");
menu.addSubItem("membersid", "Login", "Login", "/?link=members&id=login");
menu.showMenu();
}
//create the menu
function Menu(){
this.addItem = addItem;
this.addSubItem = addSubItem;
this.showMenu = showMenu;
this.bgColor = "black";
this.mainPaneBorder = 1;
this.subMenuPaneBorder = 1;
this.subMenuPaneWidth = 150;
lastMenu = null;
HTMLstr = "";
HTMLstr += "\n";
HTMLstr += "\n";
HTMLstr += "
\n";
HTMLstr += "
\n";
HTMLstr += "";
if (n) HTMLstr += "| ";
HTMLstr += "\n";
HTMLstr += "\n";
HTMLstr += "\n";
if (n) HTMLstr += " | ";
HTMLstr += "
\n";
HTMLstr += "
\n";
HTMLstr += "\n";
HTMLstr += "\n";
HTMLstr += "\n";
HTMLstr += "\n";
HTMLstr += "\n";
HTMLstr+= "
\n";
HTMLstr += "\n";
}
//add drop-down container
function addItem(idItem, text, hint, location, altLocation){
var Lookup = "";
if (HTMLstr.indexOf(Lookup) != -1){
alert(idParent + " already exist");
return;
}
var MENUitem = "";
MENUitem += "\n\n";
if (n){
MENUitem += "";
MENUitem += "";
MENUitem += "";
}
else{//IE or NS6
MENUitem += "\n";
MENUitem += "\n";
MENUitem += " | \n";
}
MENUitem += "\n\n";
MENUitem += "\n";
HTMLstr = HTMLstr.replace("\n", MENUitem);
}
//add sub-menu items to applicable drop-down containor
function addSubItem(idParent, text, hint, location){
var MENUitem = "";
Lookup = "";
if (HTMLstr.indexOf(Lookup) == -1){
alert(idParent + " not found");
return;
}
Lookup = "";
if (HTMLstr.indexOf(Lookup) == -1){
if (n){
MENUitem += "\n";
MENUitem += "\n";
MENUitem += "\n";
}
else{//IE or NS6
MENUitem += "\n";
MENUitem += "\n";
MENUitem += "\n";
}
MENUitem += "\n";
HTMLstr = HTMLstr.replace("\n", MENUitem);
}
Lookup = "\n";
if (n) MENUitem = "
|
\n";
else //IE or NS6
if(ie)
MENUitem = "
|
\n";
if(ns6)
MENUitem = "
|
\n";
MENUitem += Lookup;
HTMLstr = HTMLstr.replace(Lookup, MENUitem);
}
//write out main menu bar
function showMenu(){
document.writeln(HTMLstr);
}
//show submenu, and then calculate its x and y coordinates
function displaySubMenu(idMainMenu){
var menu;
var submenu;
if (n){
submenu = document.layers[idMainMenu+"submenu"];
if (lastMenu != null && lastMenu != submenu) hideAll();
submenu.left = document.layers[idMainMenu].pageX;
submenu.top = document.layers[idMainMenu].pageY + document.layers[idMainMenu].clip.height;
submenu.visibility = fShow;
submenu.zIndex=10
leftX = document.layers[idMainMenu+"submenu"].left;
rightX = leftX + document.layers[idMainMenu+"submenu"].clip.width;
leftY = document.layers[idMainMenu+"submenu"].top+document.layers[idMainMenu+"submenu"].clip.height;
} else if (ns6) {
menu = document.getElementById(idMainMenu);
submenu = document.getElementById(idMainMenu+"submenu");
if (lastMenu != null && lastMenu != submenu) hideAll();
submenu.style.left = calculateSumOffset(menu, 'offsetLeft');
submenu.style.top = document.getElementById(idMainMenu).offsetHeight + 4;
submenu.style.visibility = fShow;
leftX = calculateSumOffset(menu, 'offsetLeft');
rightX =leftX + document.getElementById(idMainMenu+"submenu").offsetWidth;
leftY = document.getElementById(idMainMenu+"submenu").offsetHeight + window.pageYOffset + 4;
} else if (ie) {
menu = eval(idMainMenu);
submenu = eval(idMainMenu+"submenu.style");
if (lastMenu != null && lastMenu != submenu) hideAll();
submenu.left = calculateSumOffset(menu, 'offsetLeft');
submenu.top = document.all[idMainMenu].offsetHeight + 4;
submenu.visibility = fShow;
leftX = document.all[idMainMenu+"submenu"].style.posLeft;
rightX = leftX + document.all[idMainMenu+"submenu"].offsetWidth;
leftY = document.all[idMainMenu+"submenu"].style.posTop+document.all[idMainMenu+"submenu"].offsetHeight + 4;
}
lastMenu = submenu;
}
//hide the submenu
function hideAll(){
if (ns6){
if (lastMenu != null)
{lastMenu.style.visibility = fHide;}
}else{
if (lastMenu != null)
{lastMenu.visibility = fHide;}
}
}
//used to calculate position of a submenu
function calculateSumOffset(idItem, offsetName){
var totalOffset = 0;
var item = eval('idItem');
do{
totalOffset += eval('item.'+offsetName);
item = eval('item.offsetParent');
} while (item != null);
return totalOffset;
}
//close menu on mouse out of menu containor
function updateIt(e){
if (ns6){
var x = e.pageX;
var y = e.pageY;
if (x > rightX || x < leftX) hideAll();
else if (y > leftY) hideAll();
}
else if (ie){
var x = window.event.clientX;
var y = window.event.clientY;
if (x > rightX || x < leftX) hideAll();
else if (y > leftY) hideAll();
}
else if (n){
var x = e.pageX;
var y = e.pageY;
if (x > rightX || x < leftX) hideAll();
else if (y > leftY) hideAll();
}
}
//set page to hide menus on a mouse click or on mouseout of menu containor
if (ns6)
{
document.body.onclick=hideAll;
document.body.onmousemove=updateIt;
}
else if (ie)
{
document.body.onclick=hideAll;
document.body.onscroll=hideAll;
document.body.onmousemove=updateIt;
}
else if (n)
{
document.onmousedown=hideAll;
window.captureEvents(Event.MOUSEMOVE);
window.onmousemove=updateIt;
}