/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder = "buttons/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources = new Array("button1up.png","button2up.png","button3up.png","button4up.png","button5up.png","button6up.png","button7up.png");

overSources = new Array("button1over.png","button2over.png","button3over.png","button4over.png","button5over.png","button6over.png","button7over.png");

// 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();


//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//

subInfo[2][1] = new Array("Palabras y música","http://www.barmartinez-almaguer.com/escritores/poemas5.htm","_self");
subInfo[2][2] = new Array("Palabras y tiempo","http://www.barmartinez-almaguer.com/escritores/poemas2.htm","_self");
subInfo[2][3] = new Array("Relatos y poemas","http://www.barmartinez-almaguer.com/escritores/poemario1.htm","_self");
subInfo[2][4] = new Array("Más poemas","http://www.barmartinez-almaguer.com/escritores/poemas1.htm","_self");
subInfo[2][5] = new Array("Hombre yerto","http://www.barmartinez-almaguer.com/escritores/yerto.htm","_self");
subInfo[2][6] = new Array("Palabra interior","http://www.barmartinez-almaguer.com/escritores/poemas3.htm","_self");
subInfo[2][7] = new Array("Palabra exterior","http://www.barmartinez-almaguer.com/escritores/poemas4.htm","_self");
subInfo[2][8] = new Array("Palabra y hombre","http://www.barmartinez-almaguer.com/escritores/poemas6.htm","_self");
subInfo[2][9] = new Array("Desde dentro (Aforismos)","http://www.barmartinez-almaguer.com/escritores/poemas7.htm","_self");
subInfo[2][10] = new Array("Palabras de fondo","http://www.barmartinez-almaguer.com/escritores/poemas8.htm","_self");
subInfo[2][11] = new Array("Calles solitarias","http://www.barmartinez-almaguer.com/escritores/poemas9.htm","-self");
subInfo[2][12] = new Array("Aforismos","http://www.barmartinez-almaguer.com/escritores/poemas10.htm","");
subInfo[2][13] = new Array("Aforismos desde dentro de la realidad","http://www.barmartinez-almaguer.com/escritores/poemas11.htm","_self");
subInfo[2][14] = new Array("Diciembre 08","http://www.barmartinez-almaguer.com/escritores/poemas12.htm","_self");

subInfo[3][1] = new Array("Enciende el sentimiento","http://www.barmartinez-almaguer.com/escritores/mjesus/enciende.htm","_self");
subInfo[3][2] = new Array("Sueños de luz","http://www.barmartinez-almaguer.com/escritores/mjesus/suenos.htm","_self");
subInfo[3][3] = new Array("Retazos de cielo","http://www.barmartinez-almaguer.com/escritores/mjesus/retazos.htm","_self");
subInfo[3][4] = new Array("Entre la voz y el silencio","http://www.barmartinez-almaguer.com/escritores/mjesus/voz/voz.htm","_self");
subInfo[3][5] = new Array("Mi pueblo sueña","http://www.barmartinez-almaguer.com/escritores/mjesus/suena.htm","_self");
subInfo[3][6] = new Array("Ecos de primavera","http://www.barmartinez-almaguer.com/escritores/mjesus/ecos.htm","");
subInfo[3][7] = new Array("Mi aventura","http://www.barmartinez-almaguer.com/escritores/mjesus/aventura.htm","_self");
subInfo[3][8] = new Array("Hacia los límites del tiempo","http://www.barmartinez-almaguer.com/escritores/mjesus/limite.htm","");
subInfo[3][9] = new Array("Temo y quiero","http://www.barmartinez-almaguer.com/escritores/mjesus/temo.htm","_self");
subInfo[3][10] = new Array("En el mismo mar","http://www.barmartinez-almaguer.com/escritores/mjesus/mar.htm","_self");
subInfo[3][11] = new Array("Espejos","http://www.barmartinez-almaguer.com/escritores/mjesus/espejos.htm","");
subInfo[3][12] = new Array("La memoria primigenia","http://www.barmartinez-almaguer.com/escritores/mjesus/memoria.htm","_self");
subInfo[3][13] = new Array("Grecia","http://www.barmartinez-almaguer.com/escritores/mjesus/gracia.htm","");
subInfo[3][14] = new Array("Reflejos","http://www.barmartinez-almaguer.com/escritores/mjesus/reflejos.htm","_self");
subInfo[3][15] = new Array("Madre","http://www.barmartinez-almaguer.com/escritores/mjesus/madre.htm","_self");
subInfo[3][16] = new Array("Nacerá la palabra","http://www.barmartinez-almaguer.com/escritores//mjesus/palabras.htm","_self");
subInfo[3][17] = new Array("Detrás del silencio","http://www.barmartinez-almaguer.com/escritores/mjesus/silencio.htm","_self");
subInfo[3][18] = new Array("Las rejas del tiempo","http://www.barmartinez-almaguer.com/escritores/mjesus/rejas.htm","_self");
subInfo[3][19] = new Array("Primavera","http://www.barmartinez-almaguer.com/escritores/mjesus/primavera.htm","_self");
subInfo[3][20] = new Array("Dime Maria","http://www.barmartinez-almaguer.com/escritores/mjesus/muela.htm","_self");

subInfo[4][1] = new Array("Una vida normal","http://www.barmartinez-almaguer.com/escritores/vidanormal.htm","_self");

subInfo[5][1] = new Array("La loteria","http://www.barmartinez-almaguer.com/escritores/loteria.htm","_self");
subInfo[5][2] = new Array("La tienda del tio Rito","http://www.barmartinez-almaguer.com/escritores/rito.htm","");

subInfo[6][1] = new Array("46 relatos de Marisol","http://www.barmartinez-almaguer.com/escritores/marisol/marisol.htm","");

subInfo[7][1] = new Array("Se queja el Riánsares","http://www.barmartinez-almaguer.com/escritores/victoriana/riansares.htm","");
subInfo[7][2] = new Array("Regalo de Navidad","http://www.barmartinez-almaguer.com/escritores/victoriana/regalo.htm","");
subInfo[7][3] = new Array("Transito en el tiempo","http://www.barmartinez-almaguer.com/escritores/victoriana/tiempo.htm","");
subInfo[7][4] = new Array("Farola","http://www.barmartinez-almaguer.com/escritores/victoriana/farola.htm","");
subInfo[7][5] = new Array("A mi pueblo amado","http://www.barmartinez-almaguer.com/escritores/victoriana/pueblo.htm","");
subInfo[7][6] = new Array("La muerte","http://www.barmartinez-almaguer.com/escritores/victoriana/muerte.htm","");
subInfo[7][7] = new Array("Que nieva, que nieva","http://www.barmartinez-almaguer.com/escritores/victoriana/nieve1.htm","");
subInfo[7][8] = new Array("Así eres tu","http://www.barmartinez-almaguer.com/escritores/victoriana/eres.htm","");
subInfo[7][9] = new Array("Canto a la solidaridad","http://www.barmartinez-almaguer.com/escritores/victoriana/solidaridad.htm","");
subInfo[7][10] = new Array("Homenaje a Santa Águeda","http://www.barmartinez-almaguer.com/escritores/victoriana/agueda.htm","");
subInfo[7][11] = new Array("Amanecer","http://www.barmartinez-almaguer.com/escritores/victoriana/amanecer.htm","");


//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset = 0;
var ySubOffset = 26;



//*** 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();

