/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder = "buttons/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources = new Array("button1up.gif","button2up.gif","button3up.gif","button4up.gif","button5up.gif","button6up.gif","button7up.gif","button8up.gif","button9up.gif","button10up.gif","button11up.gif","button12up.gif");

overSources = new Array("button1over.gif","button2over.gif","button3over.gif","button4over.gif","button5over.gif","button6over.gif","button7over.gif","button8over.gif","button9over.gif","button10over.gif","button11over.gif","button12over.gif");

// SUB MENUS DECLARATION, YOU DONT NEED TO EDIT THIS
subInfo = new Array();
subInfo[1] = new Array();
subInfo[2] = new Array();
subInfo[3] = new Array();
subInfo[4] = new Array();
subInfo[5] = new Array();
subInfo[6] = new Array();
subInfo[7] = new Array();
subInfo[8] = new Array();
subInfo[9] = new Array();
subInfo[10] = new Array();
subInfo[11] = new Array();
subInfo[12] = new Array();


//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//

subInfo[1][1] = new Array("Wicca FAQ","http://www.shadowsofoz.net/wicca_faq.html","");
subInfo[1][2] = new Array("Modern Wicca","http://www.shadowsofoz.net/modern_wicca.html","");
subInfo[1][3] = new Array("'Earth-Centred'","http://www.shadowsofoz.net/earth_centred.html","");
subInfo[1][4] = new Array("On Fluffy Bunnies","http://www.shadowsofoz.net/bunnies.html","");

subInfo[2][1] = new Array("History","http://www.shadowsofoz.net/basics/history.html","");
subInfo[2][2] = new Array("Traditions","http://www.shadowsofoz.net/basics/trads.html","");
subInfo[2][3] = new Array("The God & Goddess","http://www.shadowsofoz.net/basics/god_and_goddess.html","");
subInfo[2][4] = new Array("The Pentagram","http://www.shadowsofoz.net/basics/pentagram.html","");
subInfo[2][5] = new Array("Craft Names","http://www.shadowsofoz.net/basics/craft_names.html","");
subInfo[2][6] = new Array("The Book of Shadows","http://www.shadowsofoz.net/basics/the_bos.html","");
subInfo[2][7] = new Array("Dedication","http://www.shadowsofoz.net/basics/dedication.html","");

subInfo[3][1] = new Array("Wiccan Creation Myth","http://www.shadowsofoz.net/philosophy/in_the_beginning.html","");
subInfo[3][2] = new Array("Reincarnation & Summerland","http://www.shadowsofoz.net/philosophy/summerland.html","");
subInfo[3][3] = new Array("The Ordains","http://www.shadowsofoz.net/philosophy/the_ordains.html","");
subInfo[3][4] = new Array("The Wiccan Rede","http://www.shadowsofoz.net/philosophy/wiccan_rede.html","");
subInfo[3][5] = new Array("Principles of Wiccan Belief","http://www.shadowsofoz.net/philosophy/principles.html","");
subInfo[3][6] = new Array("Witch's Pyramid","http://www.shadowsofoz.net/philosophy/witchs_pyramid.html","");
subInfo[3][7] = new Array("13 Goals of a Witch","http://www.shadowsofoz.net/philosophy/thirteen_goals.html","");

subInfo[4][1] = new Array("Esbats","http://www.shadowsofoz.net/calendar/esbats.html","");
subInfo[4][2] = new Array("Wheel of the Year","http://www.shadowsofoz.net/calendar/wheel_of_the_year.html","");
subInfo[4][3] = new Array("Solstices and Equinoxes 2010-2013","http://www.shadowsofoz.net/calendar/solstices_equinoxes.html","");
subInfo[4][4] = new Array("Planets in the Zodiac 2010-2013","http://www.shadowsofoz.net/calendar/planets_zodiac.html","");
subInfo[4][5] = new Array("Moon Phases 2010-2013","http://www.shadowsofoz.net/calendar/moonphases.html","");
subInfo[4][6] = new Array("Significant Wiccan/Pagan Dates","http://www.shadowsofoz.net/calendar/index.html","");

subInfo[5][1] = new Array("The Altar","http://www.shadowsofoz.net/ritual/altar.html","");
subInfo[5][2] = new Array("Ritual Tools","http://www.shadowsofoz.net/ritual/tools.html","");
subInfo[5][3] = new Array("Doing Ritual","http://www.shadowsofoz.net/ritual/doing.html","");
subInfo[5][4] = new Array("Sacred Space","http://www.shadowsofoz.net/ritual/sacred_space.html","");
subInfo[5][5] = new Array("Magick Circle","http://www.shadowsofoz.net/ritual/magick_circle.html","");
subInfo[5][6] = new Array("Summon, Stir, Call, Invite?","http://www.shadowsofoz.net/ritual/summon_stir_call_invite.html","");
subInfo[5][7] = new Array("Pantheons","http://www.shadowsofoz.net/ritual/pantheons.html","");
subInfo[5][8] = new Array("Consecrating","http://www.shadowsofoz.net/ritual/consecrating.html","");
subInfo[5][9] = new Array("Ritual Glossary","http://www.shadowsofoz.net/ritual/glossary.html","");
subInfo[5][10] = new Array("Rituals archive","http://www.shadowsofoz.net/rituals/index.html","");

subInfo[6][1] = new Array("Principles of Magick","http://www.shadowsofoz.net/magick/principles.html","");
subInfo[6][2] = new Array("Casting Spells","http://www.shadowsofoz.net/magick/casting.html","");
subInfo[6][3] = new Array("Magickal Alphabets","http://www.shadowsofoz.net/magick/alphabets.html","");
subInfo[6][4] = new Array("Magickal Symbols","http://www.shadowsofoz.net/magick/symbols.html","");
subInfo[6][5] = new Array("Candle Magick","http://www.shadowsofoz.net/magick/candle_magick.html","");
subInfo[6][6] = new Array("Cord Magick","http://www.shadowsofoz.net/magick/cord_magick.html","");
subInfo[6][7] = new Array("Spells archive","http://www.shadowsofoz.net/spells/index.html","");

subInfo[7][1] = new Array("Botanicals","http://www.shadowsofoz.net/correspondences/botanicals.html","");
subInfo[7][2] = new Array("Colours","http://www.shadowsofoz.net/correspondences/colours.html","");
subInfo[7][3] = new Array("Days of the Week","http://www.shadowsofoz.net/correspondences/days.html","");
subInfo[7][4] = new Array("Directions","http://www.shadowsofoz.net/correspondences/directions.html","");
subInfo[7][5] = new Array("Elements","http://www.shadowsofoz.net/correspondences/elements.html","");
subInfo[7][6] = new Array("Stones","http://www.shadowsofoz.net/correspondences/stones.html","");

subInfo[8][1] = new Array("Moon Phases","http://www.shadowsofoz.net/astrological/moon_phases.html","");
subInfo[8][2] = new Array("Planets","http://www.shadowsofoz.net/astrological/planets.html","");
subInfo[8][3] = new Array("Planetary Hours","http://www.shadowsofoz.net/astrological/planetary_hours.html","");
subInfo[8][4] = new Array("Using the Zodiac","http://www.shadowsofoz.net/astrological/zodiac.html","");
subInfo[8][5] = new Array("Astronomical Glossary","http://www.shadowsofoz.net/astrological/astronomical_glossary.html","");

subInfo[9][1] = new Array("Book List","http://www.shadowsofoz.net/extras/book_list.html","");
subInfo[9][2] = new Array("Image Galleries","http://www.shadowsofoz.net/images/index.html","");
subInfo[9][3] = new Array("Downloads","http://www.shadowsofoz.net/extras/downloads.html","");
subInfo[9][4] = new Array("Witchcraft Laws in Australia","http://www.shadowsofoz.net/extras/laws.html","");
subInfo[9][5] = new Array("Glossary","http://www.shadowsofoz.net/extras/glossary.html","");
subInfo[9][6] = new Array("Shops","http://www.shadowsofoz.net/extras/shops.html","");
subInfo[9][7] = new Array("Wiccan/Pagan Humour","http://www.shadowsofoz.net/extras/humour.html","");


//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset = 151;
var ySubOffset = 8;



//*** NO MORE SETTINGS BEYOND THIS POINT ***//
var overSub = false;
var delay = 1000;
totalButtons = upSources.length;

// GENERATE SUB MENUS
for ( x=0; x<totalButtons; x++) {
	// SET EMPTY DIV FOR BUTTONS WITHOUT SUBMENU
	if ( subInfo[x+1].length < 1 ) { 
		document.write('<div id="submenu' + (x+1) + '">');
	// SET DIV FOR BUTTONS WITH SUBMENU
	} else {
		document.write('<div id="submenu' + (x+1) + '" class="dropmenu" ');
		document.write('onMouseOver="overSub=true;');
		document.write('setOverImg(\'' + (x+1) + '\',\'\');"');
		document.write('onMouseOut="overSub=false;');
		document.write('setTimeout(\'hideSubMenu(\\\'submenu' + (x+1) + '\\\')\',delay);');
		document.write('setOutImg(\'' + (x+1) + '\',\'\');">');


		document.write('<ul>');
		for ( k=0; k<subInfo[x+1].length-1; k++ ) {
			document.write('<li>');
			document.write('<a href="' + subInfo[x+1][k+1][1] + '" ');
			document.write('target="' + subInfo[x+1][k+1][2] + '">');
			document.write( subInfo[x+1][k+1][0] + '</a>');
			document.write('</li>');
		}
		document.write('</ul>');
	}
	document.write('</div>');
}





//*** MAIN BUTTONS FUNCTIONS ***//
// PRELOAD MAIN MENU BUTTON IMAGES
function preload() {
	for ( x=0; x<totalButtons; x++ ) {
		buttonUp = new Image();
		buttonUp.src = buttonFolder + upSources[x];
		buttonOver = new Image();
		buttonOver.src = buttonFolder + overSources[x];
	}
}

// SET MOUSEOVER BUTTON
function setOverImg(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder + overSources[But-1];
}

// SET MOUSEOUT BUTTON
function setOutImg(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder + upSources[But-1];
}



//*** SUB MENU FUNCTIONS ***//
// GET ELEMENT ID MULTI BROWSER
function getElement(id) {
	return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null; 
}

// GET X COORDINATE
function getRealLeft(id) { 
	var el = getElement(id);
	if (el) { 
		xPos = el.offsetLeft;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
			tempEl = tempEl.offsetParent;
		} 
		return xPos;
	} 
} 

// GET Y COORDINATE
function getRealTop(id) {
	var el = getElement(id);
	if (el) { 
		yPos = el.offsetTop;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
			tempEl = tempEl.offsetParent;
		}
		return yPos;
	}
}

// MOVE OBJECT TO COORDINATE
function moveObjectTo(objectID,x,y) {
	var el = getElement(objectID);
	el.style.left = x;
	el.style.top = y;
}

// MOVE SUBMENU TO CORRESPONDING BUTTON
function showSubMenu(subID, buttonID) {
	hideAllSubMenus();
	butX = getRealLeft(buttonID);
	butY = getRealTop(buttonID);
	moveObjectTo(subID,butX+xSubOffset, butY+ySubOffset);
}

// HIDE ALL SUB MENUS
function hideAllSubMenus() {
	for ( x=0; x<totalButtons; x++) {
		moveObjectTo("submenu" + (x+1) + "",-500, -500 );
	}
}

// HIDE ONE SUB MENU
function hideSubMenu(subID) {
	if ( overSub == false ) {
		moveObjectTo(subID,-500, -500);
	}
}



//preload();

