// workaround for absence of target attributes in xhtml strict

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}



function toggle(id) {
   var item = document.getElementById(id);

   if (item.style.display == "block")
      item.style.display = "none";
   else
      item.style.display = "block";
}



function validateAdmin() {
	var aMsg = new Array();
	var aMandatory = new Array('admUsername','admEmail','admFirstName','admLastName');
	var bMissing = false;
	var currField = '';

	resetLabels();

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			bMissing = true;
			highlightLabel(currField.previousSibling);
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	var fUsername = document.getElementById('admUsername');
	var sUsername = fUsername.value;
	if (sUsername != '' && (sUsername.length < 4 || sUsername.length > 16)) {
		aMsg[aMsg.length] = 'Username should be between 4 to 16 characters';
		highlightLabel(fUsername.previousSibling);
	}

	var fPassword1 = document.getElementById('admPassword1');
	var sPassword1 = fPassword1.value;
	if (sPassword1 != '' && (sPassword1.length < 8 || sPassword1.length > 32)) {
		aMsg[aMsg.length] = 'Password should be between 8 to 32 characters';
		highlightLabel(fPassword1.previousSibling);
	}

	var fPassword2 = document.getElementById('admPassword2');
	var sPassword2 = fPassword2.value;
	if (sPassword2 != sPassword1) {
		aMsg[aMsg.length] = 'Passwords do not match';
		highlightLabel(fPassword2.previousSibling);
	}

	var fEmail = document.getElementById('admEmail');
	var sEmail = fEmail.value;
	if (sEmail != '' && sEmail.length > 255) {
		aMsg[aMsg.length] = 'Email should be less than 255 characters';
		highlightLabel(fEmail.previousSibling);
	}
	else if (sEmail != '' && !validateEmail(sEmail)) {
		aMsg[aMsg.length] = 'Email is invalid';
		highlightLabel(fEmail.previousSibling);
	}

	var fFirstName = document.getElementById('admFirstName');
	var sFirstName = fFirstName.value;
	if (sFirstName != '' && sFirstName.length > 64) {
		aMsg[aMsg.length] = 'First name should be less than 64 characters';
		highlightLabel(fFirstName.previousSibling);
	}

	var fLastName = document.getElementById('admLastName');
	var sLastName = fLastName.value;
	if (sLastName != '' && sLastName.length > 64) {
		aMsg[aMsg.length] = 'Last name should be less than 64 characters';
		highlightLabel(fLastName.previousSibling);
	}

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validateEvent(type) {
	var aMsg = new Array();
	if (type == 'all')
		var aMandatory = new Array('catID','eventTitle','eventVenue','eventPrice','eventImgFilename','eventDesc');
	else
		var aMandatory = new Array('catID','eventTitle','eventVenue','eventPrice','eventDesc');
	var bMissing = false;
	var currField = '';

	resetLabels();

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			bMissing = true;
			highlightLabel(currField.previousSibling);
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	var fTitle = document.getElementById('eventTitle');
	var sTitle = fTitle.value;
	if (sTitle != '' && sTitle.length > 255) {
		aMsg[aMsg.length] = 'Title should be less than 255 characters';
		highlightLabel(fTitle.previousSibling);
	}

	var fTopic = document.getElementById('eventTopic');
	var sTopic = fTopic.value;
	if (sTopic != '' && sTopic.length > 255) {
		aMsg[aMsg.length] = 'Topic should be less than 255 characters';
		highlightLabel(fTopic.previousSibling);
	}

	var fTimeText = document.getElementById('eventTimeText');
	var sTimeText = fTimeText.value;
	if (sTimeText != '' && sTimeText.length > 255) {
		aMsg[aMsg.length] = 'Time (text) should be less than 255 characters';
		highlightLabel(fTimeText.previousSibling);
	}

	var fVenue = document.getElementById('eventVenue');
	var sVenue = fVenue.value;
	if (sVenue != '' && sVenue.length > 255) {
		aMsg[aMsg.length] = 'Venue should be less than 255 characters';
		highlightLabel(fVenue.previousSibling);
	}

	var fPrice = document.getElementById('eventPrice');
	var sPrice = fPrice.value;
	if (sPrice != '' && sPrice.length > 255) {
		aMsg[aMsg.length] = 'Price should be less than 255 characters';
		highlightLabel(fPrice.previousSibling);
	}

	var fFile = document.getElementById('eventImgFilename');
	var sFile = fFile.value;
	if (sFile != '' && !validateImgExt(sFile)) {
		aMsg[aMsg.length] = 'Image to be uploaded should be a gif, jpg, or png file';
		highlightLabel(fFile.previousSibling);
	}
/*
	var checkbox_toggle = document.getElementById('checkbox_toggle');
	if (checkbox_toggle.checked) {
		var fStartYear = document.getElementById('eventStartYear');
		var fStartMonth = document.getElementById('eventStartMonth');
		var fStartDay = document.getElementById('eventStartDay');
		var fStartHour = document.getElementById('eventStartHour');
		var fStartMin = document.getElementById('eventStartMin');
		var fStartSec = document.getElementById('eventStartSec');
		var dStart = new Date(fStartYear.value, fStartMonth.value, fStartDay.value, fStartHour.value, fStartMin.value, fStartSec.value, 0);

		var fEndYear = document.getElementById('eventEndYear');
		var fEndMonth = document.getElementById('eventEndMonth');
		var fEndDay = document.getElementById('eventEndDay');
		var fEndHour = document.getElementById('eventEndHour');
		var fEndMin = document.getElementById('eventEndMin');
		var fEndSec = document.getElementById('eventEndSec');
		var dEnd = new Date(fEndYear.value, fEndMonth.value, fEndDay.value, fEndHour.value, fEndMin.value, fEndSec.value, 0);

		if (Date.parse(dStart) > Date.parse(dEnd)) {
			aMsg[aMsg.length] = 'End date/time should be after Start date/time';
			highlightLabel(fEndDay.previousSibling);
		}
	}
*/
	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validateProfile(type) {
	var aMsg = new Array();
	if (type == 'all')
		var aMandatory = new Array('catID','profGivenName','profCountry','profImgFilename','profDesc');
	else
		var aMandatory = new Array('catID','profGivenName','profCountry','profDesc');
	var bMissing = false;
	var currField = '';

	resetLabels();

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			bMissing = true;
			highlightLabel(currField.previousSibling);
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	var fGivenName = document.getElementById('profGivenName');
	var sGivenName = fGivenName.value;
	if (sGivenName != '' && sGivenName.length > 255) {
		aMsg[aMsg.length] = 'Given Name should be less than 255 characters';
		highlightLabel(fGivenName.previousSibling);
	}

	var fSurname = document.getElementById('profSurname');
	var sSurname = fSurname.value;
	if (sSurname != '' && sSurname.length > 255) {
		aMsg[aMsg.length] = 'Surname should be less than 255 characters';
		highlightLabel(fSurname.previousSibling);
	}

	var fCountry = document.getElementById('profCountry');
	var sCountry = fCountry.value;
	if (sCountry != '' && sCountry.length > 255) {
		aMsg[aMsg.length] = 'Country should be less than 255 characters';
		highlightLabel(fCountry.previousSibling);
	}

	var fFile = document.getElementById('profImgFilename');
	var sFile = fFile.value;
	if (sFile != '' && !validateImgExt(sFile)) {
		aMsg[aMsg.length] = 'Image to be uploaded should be a gif, jpg, or png file';
		highlightLabel(fFile.previousSibling);
	}

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validatePressRelease(type) {
	var aMsg = new Array();
	if (type == 'all')
		var aMandatory = new Array('prTitle','prFilename','prExternalURL');
	else
		var aMandatory = new Array('prTitle','prExternalURL');
	var bMissing = false;
	var currField = '';

	resetLabels();

	var fFilenameRadio = document.getElementById('prFilenameRadio');
	var fExternalURLRadio = document.getElementById('prExternalURLRadio');

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			if (aMandatory[i] == 'prFilename' && fFilenameRadio.checked == false) {
			}
			else if (aMandatory[i] == 'prExternalURL' && fExternalURLRadio.checked == false) {
			}
			else {
				bMissing = true;
				highlightLabel(currField.previousSibling);
			}
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	var fTitle = document.getElementById('prTitle');
	var sTitle = fTitle.value;
	if (sTitle != '' && sTitle.length > 255) {
		aMsg[aMsg.length] = 'Title should be less than 255 characters';
		highlightLabel(fTitle.previousSibling);
	}

	var fFile = document.getElementById('prFilename');
	var sFile = fFile.value;
	if (sFile != '' && !validatePdfExt(sFile)) {
		aMsg[aMsg.length] = 'File to be uploaded should be a PDF file';
		highlightLabel(fFile.previousSibling);
	}

	var fExternalURL = document.getElementById('prExternalURL');
	var sExternalURL = fExternalURL.value;
	if (sExternalURL != '' && sExternalURL.length > 255) {
		aMsg[aMsg.length] = 'External URL should be less than 255 characters';
		highlightLabel(fExternalURL.previousSibling);
	}
	else if (sExternalURL != '' && !validateURL(sExternalURL)) {
		aMsg[aMsg.length] = 'External URL is invalid';
		highlightLabel(fExternalURL.previousSibling);
	}

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validateHomepage() {
	var aMsg = new Array();
	var aMandatory = new Array('homeHighlight1ID','homeHighlight2ID','homeHighlight3ID','homeNews');
	var bMissing = false;
	var currField = '';

	resetLabels();

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			bMissing = true;
			highlightLabel(currField.previousSibling);
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validateMailingList() {
	var aMsg = new Array();
	var aMandatory = new Array('mlName','mlEmail');
	var bMissing = false;
	var currField = '';

	resetLabels();

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			bMissing = true;
			highlightLabel(currField.previousSibling);
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in your name and email address';

	var fEmail = document.getElementById('mlEmail');
	var sEmail = fEmail.value;
	if (sEmail != '' && !validateEmail(sEmail)) {
		aMsg[aMsg.length] = 'Email address is invalid';
		highlightLabel(fEmail.previousSibling);
	}

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validateEmail(email) {
	var regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	if (regex.test(email))
		return true;
	else
		return false;
}

function validateURL(url) {
	var regex = /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/;

	if (regex.test(url))
		return true;
	else
		return false;
}

function validatePdfExt(filename) {
	var dotIndex = filename.lastIndexOf('.');
	var extension = '';

	if (dotIndex != -1) {
		extension = filename.substring(dotIndex+1);
		extension = extension.toLowerCase();
		if (extension == 'pdf')
			return true;
		else
			return false;
	}
	else
		return false;
}

function validateImgExt(filename) {
	var dotIndex = filename.lastIndexOf('.');
	var extension = '';

	if (dotIndex != -1) {
		extension = filename.substring(dotIndex+1);
		extension = extension.toLowerCase();
		if (extension == 'jpg' || extension == 'jpeg' || extension == 'gif' || extension == 'png')
			return true;
		else
			return false;
	}
	else
		return false;
}



function resetLabels() {
	var labels = document.getElementsByTagName('label');
	var currLabel = '';

	for (var i = 0; i < labels.length; i++) {
		currLabel = labels[i];
		currLabel.style.color = '';
	}
}

function highlightLabel(label) {
	if (label.nodeName.toLowerCase() == 'label') {
		label.style.color = 'red';
	}
}



function setHighlightSel(selID, value) {
	var highlightSel = document.getElementById(selID);
	highlightSel.options.length = null;
	highlightSel.options[highlightSel.length] = new Option('Select one', '');

	if (value != '') {
		for (var i = 0; i < events[value].length; i++) {
			if (events[value][i] != null) {
				highlightSel.options[highlightSel.length] = new Option(events[value][i], i);
				//alert('text: ' + events[value][i] + ' and value: ' + i);
			}
		}
	}
}



function toggleEndDate() {
	var aDateFields = new Array('eventEndDay','eventEndMonth','eventEndYear','eventEndHour','eventEndMin','eventEndSec');
	var currField = '';

	for (var i = 0; i < aDateFields.length; i++) {
		currField = document.getElementById(aDateFields[i]);
		if (currField.disabled)
			currField.disabled = false;
		else
			currField.disabled = true;
	}
}



function changePrLinkType(type) {
	var fFilename = document.getElementById('prFilename');
	var fExternalURL = document.getElementById('prExternalURL');

	if (type == 'filename') {
		fFilename.disabled = false;
		fExternalURL.disabled = true;
	}
	else {
		fFilename.disabled = true;
		fExternalURL.disabled = false;
	}
}



// eMail Obfuscator Script 1.31 by Tim Williams - freeware

function obfuscate(type) {

var obfuscated = '';

if (type == 'link_enquiries')

obfuscated = String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,
101,110,113,117,105,114,105,101,115,64,116,111,112,104,46,99,111,109,46,115,103,
34,62,
101,110,113,117,105,114,105,101,115,64,116,111,112,104,46,99,111,109,46,115,103,
60,47,97,62);

if (type == 'link_tickets')

obfuscated = String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,
116,105,99,107,101,116,115,64,116,111,112,104,46,99,111,109,46,115,103,
34,62,
116,105,99,107,101,116,115,64,116,111,112,104,46,99,111,109,46,115,103,
60,47,97,62);

if (type == 'link_see_lingling')

obfuscated = String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,
115,101,101,95,108,105,110,103,108,105,110,103,64,116,111,112,104,46,99,111,109,46,115,103,
34,62,
115,101,101,95,108,105,110,103,108,105,110,103,64,116,111,112,104,46,99,111,109,46,115,103,
60,47,97,62);

if (type == 'link_amira')

obfuscated = String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,
97,109,105,114,97,64,116,111,112,104,46,99,111,109,46,115,103,
34,62,
97,109,105,114,97,64,116,111,112,104,46,99,111,109,46,115,103,
60,47,97,62);

document.write(obfuscated);

}



function display_flash(filename, width, height) {

document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '">'
+ '<param name="allowScriptAccess" value="sameDomain" />'
+ '<param name="movie" value="' + filename + '" />'
+ '<param name="quality" value="high" />'
+ '<param name="wmode" value="transparent" />'
+ '<embed src="' + filename + '" width="' + width + '" height="' + height + '" quality="high" wmode="transparent" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
+ '</object>')

}



/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var menu_programmes=new Array()
menu_programmes[0]='<a href="programmes.php?id=3"><img src="img/menu2_programmes_thought_off.gif" class="menu2" alt="Thought Leaders" onmouseover="this.src=\'img/menu2_programmes_thought_on.gif\'; return true" onmouseout="this.src=\'img/menu2_programmes_thought_off.gif\'; return true" /></a>'
menu_programmes[1]='<a href="programmes.php?id=7"><img src="img/menu2_programmes_female_off.gif" class="menu2" alt="Female Writers" onmouseover="this.src=\'img/menu2_programmes_female_on.gif\'; return true" onmouseout="this.src=\'img/menu2_programmes_female_off.gif\'; return true" /></a>'
menu_programmes[2]='<a href="programmes.php?id=12"><img src="img/menu2_programmes_culinary_off.gif" class="menu2" alt="Culinary Personalities" onmouseover="this.src=\'img/menu2_programmes_culinary_on.gif\'; return true" onmouseout="this.src=\'img/menu2_programmes_culinary_off.gif\'; return true" /></a>'
menu_programmes[3]='<a href="programmes.php?id=18"><img src="img/menu2_programmes_music_off.gif" class="menu2" alt="Music Prodigies" onmouseover="this.src=\'img/menu2_programmes_music_on.gif\'; return true" onmouseout="this.src=\'img/menu2_programmes_music_off.gif\'; return true" /></a>'

var menuwidth='154px' //default menu width
var menubgcolor='white'  //menu bgcolor
var disappeardelay=50  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="no" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu2()" onMouseout="dynamichide2(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide2(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge2(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu2(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu2()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide2(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge2(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge2(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue2()
}

function clickreturnvalue2(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide2(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu2()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu2()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu2(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu2(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu



/***********************************************
* AnyLink CSS Menu script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var disappeardelay=50  //menu disappear speed onMouseout (in miliseconds)
var enableanchorlink=0 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
var hidemenu_onclick=1 //hide menu when user clicks within menu? (1=yes, 0=no)
var horizontaloffset=0 //horizontal offset of menu from default location. (0-5 is a good value)

/////No further editting needed

var ie5=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function showhide(obj, e, visible, hidden){
if (ie5||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x-obj.offsetWidth < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+(horizontaloffset*2) //no space to the right of page? Move menu over to the left
}
else{
var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move menu up?
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either? (position at top of viewable window then)
edgeoffset=dropmenuobj.y
}
}
return edgeoffset
}

function dropdownmenu(obj, e, dropmenuID){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
if (typeof dropmenuobj!="undefined") //hide previous menu
dropmenuobj.style.visibility="hidden"
clearhidemenu()
if (ie5||ns6){
obj.onmouseout=delayhidemenu
dropmenuobj=document.getElementById(dropmenuID)
if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
dropmenuobj.onmouseover=clearhidemenu
dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
showhide(dropmenuobj.style, e, "visible", "hidden")
//dropmenuobj.x=getposOffset(obj, "left")
//doesn't seem to work
dropmenuobj.x=0
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+horizontaloffset+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
}
return clickreturnvalue()
}

function clickreturnvalue(){
if ((ie5||ns6) && !enableanchorlink) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie5&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}



// run all necessary functions on page load

function loadAll() {
	externalLinks();
}
window.onload = loadAll;