// JavaScript Document

//Default that comes
function antispam(name,domain, subject) {
	document.location = "mailto:" + name + "@" + domain + "?subject=" + subject;
}	
function sh_ql(id) {
	if(document.getElementById(id).style.display != 'block') {
		document.getElementById(id).style.display = 'block';
	} else {
		document.getElementById(id).style.display = 'none';
	}
}

function init () {
	if (!document.getElementById) {
		for (i=0;i<document.styleSheets.length;i++) {
			document.styleSheets(i).disabled = true;
		}
	}
}

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 showTabs(show) {
	var tabs = new Array("college-search","general-search","people-search");
	for(i=0; i<tabs.length;i++) {
		if(tabs[i]!=show) {
			document.getElementById(tabs[i]).style.display = 'none';
			document.getElementById(tabs[i]+'-link').className = '';
		}
	}
	document.getElementById(show).style.display = 'block';
	document.getElementById(show+'-link').className = 'active';
	document.getElementById(show+'-link').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>'
	}
}

