// JavaScript Document
/* Domain */
var defhost = document.URL;
var defhost = defhost.substr(defhost.lastIndexOf('//')+2,defhost.length);
var defhost = defhost.substr(0,defhost.indexOf('/'));
//document.write(defhost);

/* Language */
var lang = 'en';

/* Words */
var words = new Array();

words.push(Array('personal-banking','Personal Banking'));
words.push(Array('deposits','Deposits'));
words.push(Array('current-account','Current Account'));
words.push(Array('ordinary-savings-account','Ordinary Savings Account'));
words.push(Array('peo-savings-account','Peo Savings Account'));
words.push(Array('fixed-deposit','Fixed Deposit'));
words.push(Array('call-account','Call Account'));
words.push(Array('diva-account','Diva Account'));
words.push(Array('payroll-account','Payroll Account'));
words.push(Array('cards','Cards'));
words.push(Array('classic-card','Classic Card'));
words.push(Array('gold-card','Gold Card'));
words.push(Array('latest-promotions','Latest Promotions'));
words.push(Array('loans','Loans'));
words.push(Array('home-loans','Home Loans'));
words.push(Array('personal-loans','Personal Loans'));
words.push(Array('bancassurance','Bancassurance'));
words.push(Array('botswana-life','Botswana Life'));
words.push(Array('mogomotsi-funeral-plan','Mogomotsi Funeral Plan'));
words.push(Array('mooki-hospital-cash-plan','Mooki Hospital Cash Plan'));
words.push(Array('thuto-boswa-education-plan','Thuto Boswa Education Plan '));
words.push(Array('metropolitan','Metropolitan'));
words.push(Array('botshelo-funeral-plan','Botshelo Funeral Plan'));
words.push(Array('kokelo-cash-plan','Kokelo Cash Plan'));
words.push(Array('bokamoso-education-plan','Bokamoso Education Plan'));
words.push(Array('',''));

words.push(Array('excel-banking','Excel Banking'));

words.push(Array('services','Services'));
words.push(Array('branch-banking-hours','Branch Banking Hours'));
words.push(Array('24-hour-access-to-your-money','24 Hour Access to your money'));
words.push(Array('online-banking','Online Banking'));
words.push(Array('mobile-banking','Mobile Banking'));
words.push(Array('e-statement','e-Statement'));
words.push(Array('contact-the-bank','Contact the Bank'));

words.push(Array('sme-banking','SME Banking'));
words.push(Array('cash-management','Cash Management'));
words.push(Array('cash-collection-services','Cash Collection Services'));
words.push(Array('straight2bank','Straight2Bank'));
words.push(Array('call-accounts','Call Accounts'));
words.push(Array('fixed-deposits','Fixed Deposits'));
words.push(Array('savings','Savings'));
words.push(Array('foreign-currency-account','Foreign Currency Account'));
words.push(Array('sme-treasury-services','SME Treasury Services'));
words.push(Array('foreign-exchange-currencies','Foreign Exchange & Currencies'));
words.push(Array('trade-finance','Trade Finance'));
words.push(Array('import-lines','Import Lines'));
words.push(Array('export-lines','Export Lines'));
words.push(Array('working-capital','Working Capital'));

words.push(Array('business-credit','Business Credit'));
words.push(Array('international-trade-account','International Trade Account'));
words.push(Array('sme-china-africa-network','SME China Africa Network'));
words.push(Array('',''));
words.push(Array('',''));
words.push(Array('',''));
words.push(Array('',''));
words.push(Array('',''));
words.push(Array('',''));



words.push(Array('business-guarantee','business Guarantee'));
words.push(Array('deposits-investments','Deposits & Investments'));
words.push(Array('flexi-deposit','Flexi Deposit'));
words.push(Array('business-saver','business $aver'));
words.push(Array('straight2bank-e-banking','Straight2Bank'));
words.push(Array('trade-facilities','Trade Facilities'));

words.push(Array('contact-us','Contact Us'));
words.push(Array('terms-conditions','Terms & Conditions'));
words.push(Array('investor-relations','Investor Relations'));
words.push(Array('data-protection-privacy-policy','Data Protection & Privacy Policy'));
words.push(Array('about-us','About Us'));

words.push(Array('client-charter','Client Charter'));

words.push(Array('sitemap','Site Map'));

words.push(Array('usefullink','Useful Links'));

words.push(Array('deposit-interest-rates','Deposit Interest Rates '));
words.push(Array('whats-new','What‘s new '));
words.push(Array('atms-and-branches','ATMs &amp; Branches'));

words.push(Array('latest-news','Latest News'));
words.push(Array('demo-online-banking','Online Banking'));
words.push(Array('account','Account'));
words.push(Array('authorize-transaction','Authorize transaction'));
words.push(Array('existing-customer-account','Existing customer account'));
words.push(Array('forgot-password','Forgot password'));
words.push(Array('fund-transfer','Fund transfer'));
words.push(Array('instant-registration','Instant registration'));
words.push(Array('mail-box','Mail box'));
words.push(Array('market-watch','Market watch'));
words.push(Array('personal-home','Personal home'));
words.push(Array('personal-update','Personal update'));
words.push(Array('standing-order','Standing order'));

words.push(Array('search','Search Result'));
words.push(Array('application-forms','Application Forms'));
words.push(Array('personal-loan','Personal Unsecured Loan'));
words.push(Array('phone-banking-services','Phone Banking Services'));
words.push(Array('sme-banking-centers','SME Banking Centre'));

words.push(Array('',''));

///////////////////////////////////////////////////////////////////////////////////////////

/* URL domain */
var ud = new String();
ud = document.URL;
var ud = ud.substr(ud.lastIndexOf('http://')+7,ud.length);
//document.write('<p><strong>The URL is: </strong>'+ud+'</p>');
var ua = new Array();
ua = ud.split('/');
//document.write('<p><strong>The URL array is: </strong>'+ua+'</p>');
ua.splice(1,ua.length);
//document.write('<p><strong>The URL array modified as: </strong>'+ua+' and total <strong>'+ua.length+'</strong> array item inside.</p>');
//ua[0] = 'www.standardchartered.com.hk';

/* URL path */
var up = new String();
up = document.location.pathname;
//document.write('<p><strong>URL path = </strong>'+up+'</p>');

/* Array link */
var al = new Array();
al = up.split('/');
//al.splice(0,1);
al.splice(al.length-2,2);
al[0] = ua[0];
//document.write('<p><strong>Array of link = </strong>'+al+'<br /><strong>Total array(s): </strong>'+al.length+'</p>');

/* Array */
var ap = new Array();
ap = up.split('/');
//ap.splice(0,1);
ap.splice(ap.length-2,2);
ap[1] = 'Home';
//document.write('<p><strong>Array of path = </strong>'+ap+'<br /><strong>Total array(s): </strong>'+ap.length+'</p>');

var ta = new Number(ap.length);

/* Value converstion */
//document.write('<p><strong>Converted array(s) as below: </strong><br />');
for (i=1; i<ta; i++) {
	var tmpvalue = ap[i];
	for (j=0; j<words.length;j++) {
		if (tmpvalue == words[j][0]) {
			ap[i] = words[j][1];
			//document.write(tmpvalue+' &gt; '+ap[i]+'<br />');
		}
	}
}
//document.write('</p><p>');

/* Store array */
var defuse = 0;
var sa = new Array();
for (k=1; k<ta; k++) {
	var tmppath = ap[k];
	if (tmppath == 'products') {
		continue;
	}
	////////////////////////////////////////////////////////////////
	// BEGIN Special treat for don't link to any pages
	if (tmppath == 'Deposits' && pre == 'Personal Banking') {
		sa.push(Array(tmppath,"/bw/personal-banking/deposits/ordinary-savings-account/"));
		continue;
	}
	if (tmppath == 'Services' && pre == 'SME Banking') {
		sa.push(Array(tmppath,"#"));
		continue;
	}
	
	if (tmppath == 'Services' && pre == 'Personal Banking') {
		sa.push(Array(tmppath,"/bw/personal-banking/services/branch-banking-hours/"));
		continue;
	}
	if (tmppath == 'Loans' && pre == 'Personal Banking') {
		sa.push(Array(tmppath,"/bw/personal-banking/loans/home-loans/"));
		continue;
	}
	
	if (tmppath == 'Savings Accounts') {
		sa.push(Array(tmppath,"#"));
		continue;
	}
	if (tmppath == 'Cards'&& pre == 'Personal Banking') {
		sa.push(Array(tmppath,"/bw/personal-banking/cards/classic-card/"));
		continue;
	
	}
	if (tmppath == 'Bancassurance'&& pre == 'Personal Banking') {
	sa.push(Array(tmppath,"/bw/personal-banking/bancassurance/botswana-life/mogomotsi-funeral-plan/"));
		continue;
	}
	if (tmppath == 'Metropolitan' && pre == 'Personal Banking') {
	sa.push(Array(tmppath,"/bw/personal-banking/bancassurance/metropolitan/botshelo-funeral-plan/"));
		continue;
	}
	if (tmppath == 'Botswana Life' && pre == 'Personal Banking') {
	sa.push(Array(tmppath,"/bw/personal-banking/bancassurance/botswana-life/mogomotsi-funeral-plan/"));
		continue;
	}
	
	if (tmppath == 'Wealth Management') {
		sa.push(Array(tmppath,"#"));
		continue;
	}
	if (tmppath == 'Electronic Banking') {
		sa.push(Array(tmppath,"#"));
		continue;
	}
	if (tmppath == 'Credit Facilities') {
		sa.push(Array(tmppath,"#"));
		continue;
	}
	if (tmppath == 'Excel and Priority Banking') {
		sa.push(Array(tmppath,"#"));
		continue;
	}
	// END special treat
	/////////////////////////////////////////////////////////////////
	var pre = tmppath;
	var tmplink = 'http://';
	for (m=0; m<=k; m++) {
		if (al[m] == 'personal-banking') {
			if (defuse) {
				tmplink += al[m];
				tmplink += '/';
			} else {
				defuse = true;
			}
		} else {
			tmplink += al[m];
			tmplink += '/';
		}
	}
	//document.write('<strong>ID '+k+': </strong> '+tmppath+' : '+tmplink+'<br />');
	sa.push(Array(tmppath,tmplink));
}
//document.write('</p>');

var counted = false;

/* Special case(s) */
// Repeat the statement block for each case(s)
for (n=1; n<ta-1; n++) {
	var chkstr = sa[n-1][0];
	var chklink = sa[n-1][1];
	// Insert specific condition(s) here
	if (chkstr == 'Personal Loans' && chklink.indexOf('/personal-loans/personal-loans/')) {
		if (counted) {
			sa.splice(n-1,1);
		} else {
			counted = true;
		}
	}
}

/* Trace updated array */
/*document.write('<p>');
for (s=0; s<sa.length; s++) {
	document.write('<strong>'+sa[s][0]+'</strong> : '+sa[s][1]+'<br />');
}
document.write('</p>');
*/

document.write('<ul>');

/* Output */
var pageTitle = '';
for (r=0; r<sa.length; r++) {
	if (r != 0) {
		pageTitle += sa[r][0] + " - ";
	}
	
	if (r == sa.length-1) {
		document.write('<li><span>'+sa[r][0]+'</span></li>');
	} else {
		if (r==0) {
			if (document.URL.indexOf('/excel-and-priority-banking/priority-banking') != -1) {
				document.write('<li id="firstlink"><a href="'+sa[r][1]+lang+'/"><img src="/bw/personal-banking/excel-and-priority-banking/priority-banking/_images/stan_logo_breadcrumb.gif" alt="'+sa[r][0]+'" /></a></li>');	
			}
			else {
				document.write('<li id="firstlink"><a href="'+sa[r][1]+lang+'/"><img src="/bw/_images/stan_logo_breadcrumb.gif" alt="'+sa[r][0]+'" /></a></li>');	
			}
		} else {
		document.write('<li><a href="'+sa[r][1]+lang+'/">'+sa[r][0]+'</a></li>');
		}
	}
}
document.write('</ul>');

//pageTitle += "Standard Chartered Bank Botswana";
//document.title = pageTitle;
//document.write('<p>The <strong>Home</strong> will be replaced by the domain name.</p>');

