/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder_sd0323 = "buttons/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources_sd0323 = new Array("button1up_sd0323.png","button2up_sd0323.png");

overSources_sd0323 = new Array("button1over_sd0323.png","button2over_sd0323.png");

// SUB MENUS DECLARATION, YOU DONT NEED TO EDIT THIS
subInfo_sd0323 = new Array();
subInfo_sd0323[1] = new Array();
subInfo_sd0323[2] = new Array();


//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//
subInfo_sd0323[1][1] = new Array("Application except Affiliate","http://www.californiagcsa.org/bcwmember.app11108allpages.pdf","");
subInfo_sd0323[1][2] = new Array("Affiliate Application","http://www.californiagcsa.org/affiliateallpages0708.pdf","");

subInfo_sd0323[2][1] = new Array("Renewals except Affiliate","http://www.californiagcsa.org/superrenewal07.pdf","");
subInfo_sd0323[2][2] = new Array("Affiliate Renewal","affiliate renwal07.pdf","");


//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset_sd0323 = 124;
var ySubOffset_sd0323 = 0;



//*** NO MORE SETTINGS BEYOND THIS POINT ***//
var overSub_sd0323 = false;
var delay_sd0323 = 1000;
totalButtons_sd0323 = upSources_sd0323.length;

// GENERATE SUB MENUS
for ( x=0; x<totalButtons_sd0323; x++) {
	// SET EMPTY DIV FOR BUTTONS WITHOUT SUBMENU
	if ( subInfo_sd0323[x+1].length < 1 ) { 
		document.write('<div id="submenu' + (x+1) + '_sd0323">');
	// SET DIV FOR BUTTONS WITH SUBMENU
	} else {
		document.write('<div id="submenu' + (x+1) + '_sd0323" class="dropmenu_sd0323" ');
		document.write('onMouseOver="overSub_sd0323=true;');
		document.write('setOverImg_sd0323(\'' + (x+1) + '\',\'_sd0323\');"');
		document.write('onMouseOut="overSub_sd0323=false;');
		document.write('setTimeout(\'hideSubMenu_sd0323(\\\'submenu' + (x+1) + '_sd0323\\\')\',delay_sd0323);');
		document.write('setOutImg_sd0323(\'' + (x+1) + '\',\'_sd0323\');">');


		document.write('<ul>');
		for ( k=0; k<subInfo_sd0323[x+1].length-1; k++ ) {
			document.write('<li>');
			document.write('<a href="' + subInfo_sd0323[x+1][k+1][1] + '" ');
			document.write('target="' + subInfo_sd0323[x+1][k+1][2] + '">');
			document.write( subInfo_sd0323[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_sd0323() {
	for ( x=0; x<totalButtons_sd0323; x++ ) {
		buttonUp_sd0323 = new Image();
		buttonUp_sd0323.src = buttonFolder_sd0323 + upSources_sd0323[x];
		buttonOver_sd0323 = new Image();
		buttonOver_sd0323.src = buttonFolder_sd0323 + overSources_sd0323[x];
	}
}

// SET MOUSEOVER BUTTON
function setOverImg_sd0323(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder_sd0323 + overSources_sd0323[But-1];
}

// SET MOUSEOUT BUTTON
function setOutImg_sd0323(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder_sd0323 + upSources_sd0323[But-1];
}



//*** SUB MENU FUNCTIONS ***//
// GET ELEMENT ID MULTI BROWSER
function getElement_sd0323(id) {
	return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null; 
}

// GET X COORDINATE
function getRealLeft_sd0323(id) { 
	var el = getElement_sd0323(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_sd0323(id) {
	var el = getElement_sd0323(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_sd0323(objectID,x,y) {
	var el = getElement_sd0323(objectID);
	el.style.left = x;
	el.style.top = y;
}

// MOVE SUBMENU TO CORRESPONDING BUTTON
function showSubMenu_sd0323(subID, buttonID) {
	hideAllSubMenus_sd0323();
	butX = getRealLeft_sd0323(buttonID);
	butY = getRealTop_sd0323(buttonID);
	moveObjectTo_sd0323(subID,butX+xSubOffset_sd0323, butY+ySubOffset_sd0323);
}

// HIDE ALL SUB MENUS
function hideAllSubMenus_sd0323() {
	for ( x=0; x<totalButtons_sd0323; x++) {
		moveObjectTo_sd0323("submenu" + (x+1) + "_sd0323",-500, -500 );
	}
}

// HIDE ONE SUB MENU
function hideSubMenu_sd0323(subID) {
	if ( overSub_sd0323 == false ) {
		moveObjectTo_sd0323(subID,-500, -500);
	}
}



//preload_sd0323();

