/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder_services = LANG_ROOT+"/services/buttons_services/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources_services = new Array("button1up_services.png","button2up_services.png","button3up_services.png","button4up_services.png","button5up_services.png");

overSources_services = new Array("button1over_services.png","button2over_services.png","button3over_services.png","button4over_services.png","button5over_services.png");

// SUB MENUS DECLARATION, YOU DONT NEED TO EDIT THIS
subInfo_services = new Array();
subInfo_services[1] = new Array();
subInfo_services[2] = new Array();
subInfo_services[3] = new Array();
subInfo_services[4] = new Array();
subInfo_services[5] = new Array();


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


subInfo_services[3][1] = new Array("Oracle Database Services",LANG_ROOT+"/services/systems/oracle.php","");
subInfo_services[3][2] = new Array("Microsoft Technologies",LANG_ROOT+"/services/systems/microsoft.php","");
subInfo_services[3][3] = new Array("Java/Enterprise Edition",LANG_ROOT+"/services/systems/java.php","");
subInfo_services[3][4] = new Array("Web 2.0",LANG_ROOT+"/services/systems/web2.php","");


subInfo_services[5][1] = new Array("Enterprise Content Management",LANG_ROOT+"/services/competencies/contentmanagement.php","");
subInfo_services[5][2] = new Array("Business Intelligence",LANG_ROOT+"/services/competencies/datawarehouse.php","");
subInfo_services[5][3] = new Array("Security",LANG_ROOT+"/services/competencies/security.php","");


//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset_services = 155;
var ySubOffset_services = 0;



//*** NO MORE SETTINGS BEYOND THIS POINT ***//
var overSub_services = false;
var delay_services = 1000;
totalButtons_services = upSources_services.length;

var menu_html = '';
// GENERATE SUB MENUS
for ( x=0; x<totalButtons_services; x++) {
	// SET EMPTY DIV FOR BUTTONS WITHOUT SUBMENU
	if ( subInfo_services[x+1].length < 1 ) { 
		menu_html += '<div id="submenu' + (x+1) + '_services">';
	// SET DIV FOR BUTTONS WITH SUBMENU
	} else {
		menu_html += '<div id="submenu' + (x+1) + '_services" class="dropmenu_services" ';
		menu_html += 'onMouseOver="overSub_services=true;';
		menu_html += 'setOverImg_services(\'' + (x+1) + '\',\'_services\');"';
		menu_html += 'onMouseOut="overSub_services=false;';
		menu_html += 'setTimeout(\'hideSubMenu_services(\\\'submenu' + (x+1) + '_services\\\')\',delay_services);';
		menu_html += 'setOutImg_services(\'' + (x+1) + '\',\'_services\');">';


		menu_html += '<ul>';
		for ( k=0; k<subInfo_services[x+1].length-1; k++ ) {
			menu_html += '<li>';
			menu_html += '<a href="' + subInfo_services[x+1][k+1][1] + '" ';
			menu_html += 'target="' + subInfo_services[x+1][k+1][2] + '">';
			menu_html +=  subInfo_services[x+1][k+1][0] + '</a>';
			menu_html += '</li>';
		}
		menu_html += '</ul>';
	}
	menu_html += '</div>';
}
$(document).ready( function(){
	$('body').append(menu_html);
});




//*** MAIN BUTTONS FUNCTIONS ***//
// PRELOAD MAIN MENU BUTTON IMAGES
function preload_services() {
	for ( x=0; x<totalButtons_services; x++ ) {
		buttonUp_services = new Image();
		buttonUp_services.src = buttonFolder_services + upSources_services[x];
		buttonOver_services = new Image();
		buttonOver_services.src = buttonFolder_services + overSources_services[x];
	}
}

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

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



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

// GET X COORDINATE
function getRealLeft_services(id) { 
	var el = getElement_services(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_services(id) {
	var el = getElement_services(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_services(objectID,x,y) {
	var el = getElement_services(objectID);
	el.style.left = x+'px';
	el.style.top = y+'px';
}

// MOVE SUBMENU TO CORRESPONDING BUTTON
function showSubMenu_services(subID, buttonID) {
	hideAllSubMenus_services();
	butX = getRealLeft_services(buttonID);
	butY = getRealTop_services(buttonID);
	moveObjectTo_services(subID,butX+xSubOffset_services, butY+ySubOffset_services);
}

// HIDE ALL SUB MENUS
function hideAllSubMenus_services() {
	for ( x=0; x<totalButtons_services; x++) {
		moveObjectTo_services("submenu" + (x+1) + "_services",-500, -500 );
	}
}

// HIDE ONE SUB MENU
function hideSubMenu_services(subID) {
	if ( overSub_services == false ) {
		moveObjectTo_services(subID,-500, -500);
	}
}



//preload_services();

