/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder_cg2 = "buttons/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources_cg2 = new Array("button1up_cg2.png");

overSources_cg2 = new Array("button1over_cg2.png");

// SUB MENUS DECLARATION, YOU DONT NEED TO EDIT THIS
subInfo_cg2 = new Array();
subInfo_cg2[1] = new Array();


//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//
subInfo_cg2[1][1] = new Array("Board of Directors","http://www.californiagcsa.org/state_chap.htm","");
subInfo_cg2[1][2] = new Array("Committees Directory","http://www.californiagcsa.org/committee-dir.htm","");
subInfo_cg2[1][3] = new Array("Past Presidents","http://www.californiagcsa.org/past-presidents.htm","");


//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset_cg2 = 2;
var ySubOffset_cg2 = 24;



//*** NO MORE SETTINGS BEYOND THIS POINT ***//
var overSub_cg2 = false;
var delay_cg2 = 1000;
totalButtons_cg2 = upSources_cg2.length;

// GENERATE SUB MENUS
for ( x=0; x<totalButtons_cg2; x++) {
	// SET EMPTY DIV FOR BUTTONS WITHOUT SUBMENU
	if ( subInfo_cg2[x+1].length < 1 ) { 
		document.write('<div id="submenu' + (x+1) + '_cg2">');
	// SET DIV FOR BUTTONS WITH SUBMENU
	} else {
		document.write('<div id="submenu' + (x+1) + '_cg2" class="dropmenu_cg2" ');
		document.write('onMouseOver="overSub_cg2=true;');
		document.write('setOverImg_cg2(\'' + (x+1) + '\',\'_cg2\');"');
		document.write('onMouseOut="overSub_cg2=false;');
		document.write('setTimeout(\'hideSubMenu_cg2(\\\'submenu' + (x+1) + '_cg2\\\')\',delay_cg2);');
		document.write('setOutImg_cg2(\'' + (x+1) + '\',\'_cg2\');">');


		document.write('<ul>');
		for ( k=0; k<subInfo_cg2[x+1].length-1; k++ ) {
			document.write('<li>');
			document.write('<a href="' + subInfo_cg2[x+1][k+1][1] + '" ');
			document.write('target="' + subInfo_cg2[x+1][k+1][2] + '">');
			document.write( subInfo_cg2[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_cg2() {
	for ( x=0; x<totalButtons_cg2; x++ ) {
		buttonUp_cg2 = new Image();
		buttonUp_cg2.src = buttonFolder_cg2 + upSources_cg2[x];
		buttonOver_cg2 = new Image();
		buttonOver_cg2.src = buttonFolder_cg2 + overSources_cg2[x];
	}
}

// SET MOUSEOVER BUTTON
function setOverImg_cg2(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder_cg2 + overSources_cg2[But-1];
}

// SET MOUSEOUT BUTTON
function setOutImg_cg2(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder_cg2 + upSources_cg2[But-1];
}



//*** SUB MENU FUNCTIONS ***//
// GET ELEMENT ID MULTI BROWSER
function getElement_cg2(id) {
	return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null; 
}

// GET X COORDINATE
function getRealLeft_cg2(id) { 
	var el = getElement_cg2(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_cg2(id) {
	var el = getElement_cg2(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_cg2(objectID,x,y) {
	var el = getElement_cg2(objectID);
	el.style.left = x;
	el.style.top = y;
}

// MOVE SUBMENU TO CORRESPONDING BUTTON
function showSubMenu_cg2(subID, buttonID) {
	hideAllSubMenus_cg2();
	butX = getRealLeft_cg2(buttonID);
	butY = getRealTop_cg2(buttonID);
	moveObjectTo_cg2(subID,butX+xSubOffset_cg2, butY+ySubOffset_cg2);
}

// HIDE ALL SUB MENUS
function hideAllSubMenus_cg2() {
	for ( x=0; x<totalButtons_cg2; x++) {
		moveObjectTo_cg2("submenu" + (x+1) + "_cg2",-500, -500 );
	}
}

// HIDE ONE SUB MENU
function hideSubMenu_cg2(subID) {
	if ( overSub_cg2 == false ) {
		moveObjectTo_cg2(subID,-500, -500);
	}
}



//preload_cg2();

