/*** 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","button8up.png","button9up.png","button10up.png","button11up.png","button12up.png");

overSources = new Array("button1over.png","button2over.png","button3over.png","button4over.png","button5over.png","button6over.png","button7over.png","button8over.png","button9over.png","button10over.png","button11over.png","button12over.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();
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("Donate","http://1bestsellerebooks.bravehost.com/","-Donate");
subInfo[1][2] = new Array("Mailing List","http://1bestsellerebooks.bravehost.com/","-Mailing List");
subInfo[1][3] = new Array("Our Policies","http://1bestsellerebooks.bravehost.com/ourpolicies.htm","-Our Policies");

subInfo[2][1] = new Array("About us","http://1bestsellerebooks.bravehost.com/contactus.htm","-About us");
subInfo[2][2] = new Array("Support","http://1bestsellerebooks.bravehost.com/contactus.htm","-Support");
subInfo[2][3] = new Array("FAQ","http://1bestsellerebooks.bravehost.com/contactus.htm","-FAQ");
subInfo[2][4] = new Array("Corporate","http://1bestsellerebooks.bravehost.com/contactus.htm","-Corporate");

subInfo[3][1] = new Array("Make Online Order","http://1bestsellerebooks.bravehost.com/buynow.htm","-Make Online Order");
subInfo[3][2] = new Array("Pay Online 24/7","http://1bestsellerebooks.bravehost.com/buynow.htm","-Pay Online 24/7");
subInfo[3][3] = new Array("Pay Offline","http://1bestsellerebooks.bravehost.com/buynow.htm","-Pay Offline");
subInfo[3][4] = new Array("Buy Gift membership","http://1bestsellerebooks.bravehost.com/buynow.htm","-Buy Gift membership");
subInfo[3][5] = new Array("Buy Group membership","http://1bestsellerebooks.bravehost.com/buynow.htm","-Buy Group membership");
subInfo[3][6] = new Array("Buy subscription","http://1bestsellerebooks.bravehost.com/buynow.htm","-Buy subscription");

subInfo[4][1] = new Array("Free ebooks","http://1bestsellerebooks.bravehost.com/downloads.htm","-Free ebooks");
subInfo[4][2] = new Array("Free newsletters","http://1bestsellerebooks.bravehost.com/downloads.htm","-Free newsletters");
subInfo[4][3] = new Array("Free News Releases","http://1bestsellerebooks.bravehost.com/downloads.htm","-Free News Releases");
subInfo[4][4] = new Array("Free Special Reports","http://1bestsellerebooks.bravehost.com/downloads.htm","-Free Special Reports");

subInfo[5][1] = new Array("Online Chat","http://1bestsellerebooks.bravehost.com/guestcenter.htm","-Online Chat");
subInfo[5][2] = new Array("Guestbook","http://1bestsellerebooks.bravehost.com/guestcenter.htm","-Guestbook");
subInfo[5][3] = new Array("Forums","http://1bestsellerebooks.bravehost.com/guestcenter.htm","-Forums");
subInfo[5][4] = new Array("Tell a Friend","http://1bestsellerebooks.bravehost.com/guestcenter.htm","-Tell a Friend");
subInfo[5][5] = new Array("Send E-card","http://1bestsellerebooks.bravehost.com/guestcenter.htm","-Send E-card");
subInfo[5][6] = new Array("Mini-poles","http://1bestsellerebooks.bravehost.com/guestcenter.htm","-Mini-poles");
subInfo[5][7] = new Array("Horoscope","http://1bestsellerebooks.bravehost.com/guestcenter.htm","-Horoscope");
subInfo[5][8] = new Array("Daily Cartoon","http://1bestsellerebooks.bravehost.com/guestcenter.htm","-Daily Cartoon");

subInfo[6][1] = new Array("Place Featured Ad","http://1bestsellerebooks.bravehost.com/advertise.htm","-Place Featured Ad");
subInfo[6][2] = new Array("Place Banner Ad","http://1bestsellerebooks.bravehost.com/advertise.htm","-Place Banner Ad");
subInfo[6][3] = new Array("Place Sponsor Ad","http://1bestsellerebooks.bravehost.com/advertise.htm","-Place Sponsor Ad");

subInfo[7][1] = new Array("Join members","http://1bestsellerebooks.bravehost.com/joinus.htm","-Join members");
subInfo[7][2] = new Array("Member Benefits","http://1bestsellerebooks.bravehost.com/joinus.htm","-Member Benefits");
subInfo[7][3] = new Array("Become Sponsor","http://1bestsellerebooks.bravehost.com/joinus.htm","-Become Sponsor");
subInfo[7][4] = new Array("Sponsor Benefits","http://1bestsellerebooks.bravehost.com/joinus.htm","-Sponsor Benefits");

subInfo[8][1] = new Array("Categories","http://1bestsellerebooks.bravehost.com/ourcatalog.htm","-Categories");
subInfo[8][2] = new Array("Authors","http://1bestsellerebooks.bravehost.com/ourcatalog.htm","-Authors");
subInfo[8][3] = new Array("Media type","http://1bestsellerebooks.bravehost.com/ourcatalog.htm","-Media type");
subInfo[8][4] = new Array("Software type","http://1bestsellerebooks.bravehost.com/ourcatalog.htm","-Software type");

subInfo[9][1] = new Array("Our Top10","http://1bestsellerebooks.bravehost.com/bestsellers.htm","-Our Top10");
subInfo[9][2] = new Array("Amazon Top 10","http://1bestsellerebooks.bravehost.com/bestsellers.htm","-Amazon Top 10");
subInfo[9][3] = new Array("NYTimes Top 10","http://1bestsellerebooks.bravehost.com/bestsellers.htm","-NYTimes Top 10");

subInfo[10][1] = new Array("Free Classifieds","http://1bestsellerebooks.bravehost.com/earnwithus.htm","-Free Classifieds");
subInfo[10][2] = new Array("Affiliate Program","http://1bestsellerebooks.bravehost.com/earnwithus.htm","-Affiliate Program");
subInfo[10][3] = new Array("Resale ebooks","http://1bestsellerebooks.bravehost.com/earnwithus.htm","-Resale ebooks");
subInfo[10][4] = new Array("Wholesale ebooks","http://1bestsellerebooks.bravehost.com/earnwithus.htm","-Wholesale ebooks");

subInfo[11][1] = new Array("Submit Review","http://1bestsellerebooks.bravehost.com/bookreviews.htm","-Submit Review");
subInfo[11][2] = new Array("Rate ebook","http://1bestsellerebooks.bravehost.com/bookreviews.htm","-Rate ebook");
subInfo[11][3] = new Array("Testimonials","http://1bestsellerebooks.bravehost.com/testimonials.htm","-Testimonials");

subInfo[12][1] = new Array("Free basic submition","http://1bestsellerebooks.bravehost.com/submitebook.htm","-Free basic submition");
subInfo[12][2] = new Array("Featured submition","http://1bestsellerebooks.bravehost.com/submitebook.htm","-Featured submition");
subInfo[12][3] = new Array("Sponsor submition","http://1bestsellerebooks.bravehost.com/submitebook.htm","-Sponsor submition");
subInfo[12][4] = new Array("Submit ebook idea","http://1bestsellerebooks.bravehost.com/submitebook.htm","-Submit ebook idea");


//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset = 5;
var ySubOffset = 22;



//*** 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();

