//
// StMARY-UPTON - Top Menu Tab control by Walcam.co.uk
//
var tmenupics = new Array();
tmenupics['a'] = "url(img/aa-home.jpg)";
tmenupics['b'] = "url(img/ab-stmarys.jpg)";
tmenupics['c'] = "url(img/ac-thecentre.jpg)";
tmenupics['d'] = "url(img/ad-location.jpg)";
tmenupics['e'] = "url(img/ae-contact.jpg)";

function showmenu(pthis, pevent, pid) {
// ensure all tabs are color-less 
	for (var i=0;i<5;i++){
		tabname = 'tab'+String.fromCharCode(i+97);
		document.getElementById(tabname).style.backgroundColor = "";
	}
// color active tab
	tabbgc = '#993333';
	tabname = 'tab'+pid;
	document.getElementById(tabname).style.backgroundColor = tabbgc;
// set active picture
	if (docid() == 'index.php') {
   	 document.getElementById('ml').style.backgroundImage = tmenupics[pid];
	}
// activate active menu
	if (pid == 'a') {}
	if (pid == 'b') {dropdownmenu(pthis, pevent, menu1, '110px')}
	if (pid == 'c') {dropdownmenu(pthis, pevent, menu2, '110px')}
	if (pid == 'd') {dropdownmenu(pthis, pevent, menu3, '110px')}
	if (pid == 'e') {dropdownmenu(pthis, pevent, menu4, '110px')}
}

function colortab(pidchr) {
// ensure all tabs are color-less 
	for (var i=0;i<5;i++){
		tabname = 'tab'+String.fromCharCode(i+97);
		document.getElementById(tabname).style.backgroundColor = "";
	}
//ensure its lowercase
	pidchr = pidchr.toLowerCase();
// color active tab
//document.write('PROGRAM ID letter IS '+pidchr);
	tabname = 'tab'+pidchr;
	tabbgc = '#993333';
	tabfgc = '#ffffff';
	if (document.getElementById(tabname) != null) {
		document.getElementById(tabname).style.backgroundColor = tabbgc;
		document.getElementById(tabname).style.color = tabfgc;
	}
// set active picture
	if (docid() == 'index.php') {
   	 document.getElementById('ml').style.height = '510';
   	 document.getElementById('ml').style.backgroundImage = tmenupics[pidchr];
	}
}

function docid() {
// obtain the name ofthe current document
	var url = document.URL;
	var last = 0;
	for (var i=0;i<url.length;i++){
	  if (url.substring(i,i+1)=='/') {last=i}
	}
	var s = url.substring(last+1);
	p = s.indexOf('?');  //if contains following parameter - remove it
	if (p > -1) {s = s.substring(0,p);}

	if (s == ''){ s = 'index.php'}
	return s
}
