/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder = "http://www.barakaoil.com/buttons/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources = new Array("button1up.png","BlackSeedOil.jpg","DiabeticsControl.jpg","HighBloodCholesterol.jpg","ControlHypertension.jpg","Osteoarthritis.jpg","PremenstrualSyndromes.jpg","WeightReduction.jpg","ImmuneEnhancing.jpg","MemoryEnhancing.jpg","AnalgesicBalm.jpg","SkinandHairCare.jpg","MultiVitamin.jpg","SmoothDigestion.jpg","MentalSharpness.jpg","GoodHealthVitality.jpg","SexualDesire.jpg","MouthUlcers.jpg","CoughCold.jpg","NaturalFoodSupplement.jpg");

overSources = new Array("button1up.png","BlackSeedOil.jpg","DiabeticsControl.jpg","HighBloodCholesterol.jpg","ControlHypertension.jpg","Osteoarthritis.jpg","PremenstrualSyndromes.jpg","WeightReduction.jpg","ImmuneEnhancing.jpg","MemoryEnhancing.jpg","AnalgesicBalm.jpg","SkinandHairCare.jpg","MultiVitamin.jpg","SmoothDigestion.jpg","MentalSharpness.jpg","GoodHealthVitality.jpg","SexualDesire.jpg","MouthUlcers.jpg","CoughCold.jpg","NaturalFoodSupplement.jpg");

// 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();
subInfo[13] = new Array();
subInfo[14] = new Array();
subInfo[15] = new Array();
subInfo[16] = new Array();
subInfo[17] = new Array();
subInfo[18] = new Array();
subInfo[19] = new Array();
subInfo[20] = new Array();

//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//

subInfo[2][1] = new Array("Black seed oil ","http://www.barakaoil.com/black_seed_oil.php","");

subInfo[3][1] = new Array("Diabsol ","http://www.barakaoil.com/black_seed_oil_soft_gel_capsules.php","");
subInfo[3][2] = new Array("Karawila Plus ","http://www.barakaoil.com/karawila_capsules.php","");

subInfo[4][1] = new Array("BARAKA GarliCHOL ","http://www.barakaoil.com/garlic_oil.php","");

subInfo[5][1] = new Array("BARAKA Rauvolfia ","http://www.barakaoil.com/rauwolfia.php","");

subInfo[6][1] = new Array("BARAKA JointSafe ","http://www.barakaoil.com/jointsafe.php","");

subInfo[7][1] = new Array("BARAKA Eve&Easy ","http://www.barakaoil.com/eve&easy.php","");

subInfo[8][1] = new Array("BARAKA Slimexol ","http://www.barakaoil.com/slimexol.php","");

subInfo[9][1] = new Array("Black Seed Powder Capsules ","http://www.barakaoil.com/powder_capsules.php","");

subInfo[10][1] = new Array("Black Seed Powder in Gotukola ","http://www.barakaoil.com/gotukola_capsules.php","");

subInfo[11][1] = new Array("BARAKA BLACK SEED BALM ","http://www.barakaoil.com/black_seed_balm.php","");

subInfo[12][1] = new Array("BARAKA Natural Vit. E ","http://www.barakaoil.com/vitamin_e_capsules.php","");
subInfo[12][2] = new Array("BARAKA BLACK SEED CREAM ","http://www.barakaoil.com/black_seed_creem.php","");

subInfo[13][1] = new Array("BARAKA CODseas","http://www.barakaoil.com/codseas.php","");

subInfo[14][1] = new Array("BARAKA Karapincha Plus","http://www.barakaoil.com/karapincha_pluscapsule.php","");

subInfo[15][1] = new Array("Baraka Memo Plus","http://www.barakaoil.com/memo_pluscapsules.php","");

subInfo[16][1] = new Array("Baraka Junior","http://www.barakaoil.com/junior_capsules.php","");

subInfo[17][1] = new Array("Baraka Virega Plus","http://www.barakaoil.com/virga_pluscapsules.php","");

subInfo[18][1] = new Array("Baraka Katurumuranga Plus","http://www.barakaoil.com/katurumurunga_pluscapsules.php","");

subInfo[19][1] = new Array("Baraka Ashwa","http://www.barakaoil.com/inhaler_capsules.php","");

subInfo[20][1] = new Array("Baraka Bee Honey","http://www.barakaoil.com/BeeHoney.php","");

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



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

