/* 
	Dynamic Serviceselector

	NOTE: add services and themesto the end of this file.

*/

var clientGroup = 'CORPORATES'; // or SME or INSTITUTES
var serviceList = new Array();
var themeList = new Array();
var indent = ' - ';

function setClientGroup( group ) {
	clientGroup = group.toUpperCase();
}
function addService( service, pathToService, subhome ) {

	if (pathToService == null) {
		pathToService = '' ;
	} 
	else if (pathToService.lastIndexOf('/') != (pathToService.length - 1) ) {
		pathToService += '/';
	}

	var i = serviceList.length;
	serviceList[i] = new Array();
	serviceList[i].clientGroup = clientGroup.toUpperCase();
	serviceList[i].service = service.toUpperCase();
	serviceList[i].path = pathToService;
	serviceList[i].subhome = subhome;
}

function addTheme( name, htmlFile ) {

	var j = serviceList.length - 1;
	if (j < 0) { return false; } // Logical Service-tree error!

	var i = themeList.length;
	themeList[i] = new Array();
	themeList[i].clientGroup = serviceList[j].clientGroup;
	themeList[i].service = serviceList[j].service;
	themeList[i].name = indent + name;
	themeList[i].htmlFile = serviceList[j].path + htmlFile;
}


function buildSelector( pathToServices, clientGroup ) {
	
	if (pathToServices == null) {
		pathToServices = '' ;
	} 
	else if (pathToServices.lastIndexOf('/') != (pathToServices.length - 1) ) {
		pathToServices += '/';
	}
	
	var uri;
	var sel = document.serviceSelectorForm.serviceSelector;
	
 	for (var i = 0; i < serviceList.length; i++ ) {
	
		if (clientGroup.toUpperCase() == serviceList[i].clientGroup) {
		
			sel.options[sel.options.length] = new Option( ' ', '', false, false); // white line
		
			uri = pathToServices + serviceList[i].path + serviceList[i].subhome;
			sel.options[sel.options.length] = 
				new Option( serviceList[i].service, uri, false, false);
		
		
			for (var j = 0; j < themeList.length; j++ ) { //add Themes
				if ((clientGroup.toUpperCase() == themeList[j].clientGroup) && (themeList[j].service == serviceList[i].service)) {
					uri = pathToServices + themeList[j].htmlFile;
					sel.options[sel.options.length] = 
						new Option( themeList[j].name, uri, false, false);
				} 
			} // for
		} // if
	} // for
}

function selectService() { // actionHandler

	var sel = document.serviceSelectorForm.serviceSelector;
	var uri = sel.options[ sel.selectedIndex ].value;
	if (uri.indexOf('.htm') < 0) return false; // skip hint
	document.location.href = uri;
	return true;
}

// build services tree ..................................................


//**********************  Corporates *****************************************************
setClientGroup( 'corporates' );

addService( 'Corporate Banking', 'corporates/corporate_banking/', 'index.html');
	addTheme( 'Credits and Loans', 'credits_and_loans.html');
	addTheme( 'Loan Syndication', 'loan_syndication.html');
	addTheme( 'Securitisation', 'securitisation.html');
	addTheme( 'Cash Management', 'cash_management_services.html');
	addTheme( 'Trade Services', 'trade_services.html');
	addTheme( 'Trade Finance', 'trade_finance.html');

addService( 'Corporate Finance', 'corporates/corporate_finance/', 'index.html');
	addTheme( 'Mergers and Acquisitions', 'mergers.html');
	addTheme( 'Equity Capital Markets', 'equity_capital_markets.html');
	addTheme( 'Structured Finance', 'structured_finance.html');
	addTheme( 'Project Finance', 'project_finance.html');
	addTheme( 'Acquisition Finance', 'acquisition_finance.html');
	addTheme( 'Leveraged Finance', 'leveraged_finance.html');

addService( 'Treasury', 'corporates/treasury/', 'index.html');

addService( 'Capital Markets', 'corporates/cap_markets/', 'index.html');
	addTheme( 'Credit Structuring', 'creditstructuring.html');
	addTheme( 'Investment Products', 'investmentproducts.html');
	addTheme( 'Risk Advisory', 'riskadvisory.html');

addService( 'Research', 'corporates/research/', 'index.html');
	addTheme( 'Financial Markets', 'index.html');
	addTheme( 'Treasury Strategy', 'index.html');
	addTheme( 'Dutch Equities', 'securities.html');
	addTheme( 'Food and Agri', 'foodagri.html');

addService( 'Venture Capital', 'corporates/venture_capital/', 'index.html');

addService( 'Insurance', 'corporates/insurance/', 'index.html');

addService( 'Asset Management', 'corporates/asset_management/', 'index.html');

addService( 'Leasing and trade finance', 'corporates/leasing/', 'index.html');
	
//**********************  institutes *****************************************************
setClientGroup( 'institutes' );

addService( 'Financial Markets', 'institutes/financial_markets/', 'index.html');
	addTheme( 'Asset Management', 'asset_management.html');
	addTheme( 'Equities', 'equities.html');
	addTheme( 'Equity Capital Markets', 'equity_capital_markets.html');
	addTheme( 'Equity Derivatives', 'equity_derivatives.html');
	addTheme( 'Participations', 'participations.html');
	
addService( 'Payment Services', 'institutes/payment_services/', 'index.html');
	addTheme( 'Cash Management', 'cash_management.html');
	addTheme( 'Correspondent Banking', 'correspondent_banking.html');

	
addService( 'Research', 'institutes/research/', 'index.html');
	addTheme( 'Financial Markets', 'index.html');
	addTheme( 'Treasury Strategy', 'index.html');
	addTheme( 'Dutch Equities', 'securities.html');
	addTheme( 'Food and Agri', 'foodagri.html');
	
addService( 'Capital Markets', 'institutes/cap_markets/', 'index.html');
	addTheme( 'Credit Structuring', 'creditstructuring.html');
	addTheme( 'Investment Products', 'investmentproducts.html');
	addTheme( 'Riks Advisory', 'riskadvisory.html');
	
addService( 'Advisory Services', 'institutes/advisory_services/', 'index.html');
	
addService( 'Treasury', 'institutes/treasury/', 'index.html');
	addTheme( 'Forward Looking Strategies', 'forwardlookingstrategies.html');
	addTheme( 'Global FX', 'globalfx.html');
	addTheme( 'Management Solutions', 'managementsolutions.html');

//**********************  SME *****************************************************
setClientGroup( 'SME' );

addService( 'Services', 'sme/services/', 'index.html');
	addTheme( 'Cash Management', 'cashman.html');
	addTheme( 'Credits and Finance', 'credits.html');
	addTheme( 'Franchchise Management', 'franchise.html');
	addTheme( 'Insurance', 'insurance.html');
	addTheme( 'Leasing', 'lease.html');
	addTheme( 'Mergers and Acquisitions', 'mergers.html');
	addTheme( 'Venture Capital', 'participations.html');
//	addTheme( 'Trade Services', 'tradeservices.html');
	addTheme( 'Treasury', 'treasury.html');
