// JavaScript Document
function init() {
        var footerHeight=57;
        var headerHeight=document.getElementById('stlheheader').offsetHeight;
	var version = "7";
	var browser=navigator.appName;
	if(navigator.appName == "Microsoft Internet Explorer") {
		var b_version=navigator.appVersion;
		version=parseFloat(b_version.substring(b_version.indexOf('MSIE')+5));
	}
	if(version > 6) {

		menuHeight = document.getElementById('menu-20-80').offsetHeight;
		contentHeight = document.getElementById('container').offsetHeight;
		windowHeight = document.body.offsetHeight - (headerHeight + footerHeight);
		

		largestHeight = menuHeight > contentHeight ? menuHeight : contentHeight;
		
		if(largestHeight < windowHeight ) {
                       largestHeight = windowHeight ;  
                } 
		document.getElementById('content-20-80').style.height = largestHeight + "px";
	}
}

function showTab(show,hide) {
	hideContent = document.getElementById(hide);
	hiddenContentLink = document.getElementById(hide+'-link');
	showContent = document.getElementById(show);
	visibleContentLink = document.getElementById(show+'-link');
	hideContent.style.display = 'none';
	hiddenContentLink.className = '';
	showContent.style.display = 'block';
	visibleContentLink.className = 'active';
	visibleContentLink.blur();	
}
function hem(id,text) {
	if(id!="" || text!="") {
		id_a = id.split(".");
		str = "";
		for(i=0;i<id_a.length;i++) {
			str += String.fromCharCode(id_a[i]/5);
		}
		str2 = text == "" ? str : text;
		return "<a href=\"mailto:" + str + "\">" + str2 + "</a>";
	} else {
		return "";
	}
}
error_msg = " -- error: required field -- ";
function checkform(action,name) {
	var error=false;
	for(i=0;i<document.forms[name].length-2;i++) {
		if(document.forms[name].elements[i].getAttribute('rel')!="optional") {
			if(document.forms[name].elements[i].value=="" || document.forms[name].elements[i].value==error_msg) {
				document.forms[name].elements[i].style.border='solid #FF0000 1px';
				document.forms[name].elements[i].style.borderColor='#FF0000';
				if(document.forms[name].elements[i].type!="file" && document.forms[name].elements[i].type!="password" && action!='rec_form') {
					document.forms[name].elements[i].value=error_msg;
				} else if(document.forms[name].elements[i].type=="file"){
					alert ("The highlighted file field does not containt a path to your file.");
				} else if(document.forms[name].elements[i].type=="password"){
					alert ("The highlighted field is empty.");
				}
				error=true;
			} else if(document.forms[name].elements[i].id=="email") {
				mail_str = document.forms[name].elements[i].value;
				if(mail_str.indexOf(".", mail_str.indexOf("@")) < mail_str.indexOf("@") + 2
					|| mail_str.indexOf(".") < 1
					|| mail_str.indexOf(".") > mail_str.length-2
					|| mail_str.indexOf("@") < 1
					|| mail_str.indexOf("@") > mail_str.length-2)
					{
					error = true;
					document.forms[name].elements[i].style.borderColor='#FF0000';
					document.forms[name].elements[i].value="-- error: invalid email address --";
				}
				
			} else {
				document.forms[name].elements[i].style.borderColor='#C9D8D3';
				if(action=='rec_form') {
					document.forms[name].elements[i].style.border='solid #000000 0px';
				}
			}
		}
	}
	
	if(error) {
		alert("Please ensure that all highlighted fields are completed.");
		return false;
	}

}

function clear_error(field) {
	if(field.value==error_msg || field.value=='-- error: invalid email address --') {
		field.value="";
	}
}
function update_breadcrumbs(xml) {
   document.getElementById('breadcrumbs').innerHTML = xml;

}
function bio_change() {
	if(document.getElementById('bio_fr').style.display=='none' || document.getElementById('bio_fr').style.display=='') {
		document.getElementById('bio_en').style.display='none';
		document.getElementById('bio_fr').style.display='block';
		document.getElementById('bio_fe').innerHTML='<a onclick="bio_change()" href="#">English</a> | French'
	} else {
   		document.getElementById('bio_en').style.display='block';
		document.getElementById('bio_fr').style.display='none';
		document.getElementById('bio_fe').innerHTML='English | <a onclick="bio_change()" href="#">French</a>'
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function expand(id) {
	if(document.getElementById(id).style.display != "block") {
		document.getElementById(id).style.display="block";
	} else {
		document.getElementById(id).style.display="none";
	}
init();
}
