function activesearch(){
	// July 17, 2007 - Rommil Santiago
	// Added a cookie to preserve tab choice
	
	// Feb 21, 2007 - Rommil Santiago - rommil.santiago@concordia.ca
	// Activates the search options	
	
	// Read from the cookie if it exists
	
	var searchtabcookie = readCookie('searchtab');
	if (searchtabcookie){
		document.getElementById('search_selected').setAttribute('name',searchtabcookie);
		document.getElementById('search_option_list').className = searchtabcookie;
	}
	
	var search_option_list = document.getElementById('search_option_list').getElementsByTagName('li');
	for (var i = 0; i < search_option_list.length; i++){
		search_option_list[i].getElementsByTagName('a')[0].onclick = function(){
			document.getElementById('search_selected').setAttribute('name',this.id);
			document.getElementById('search_option_list').className = this.id;
			
			// Write to cookie to preserve tab choice
			createCookie('searchtab', document.getElementById('search_option_list').className, 365);
		};
		search_option_list[i].getElementsByTagName('a')[0].href = '#searchoption';

	}
	// Javascript is active - so allow javascript version of Custom Google Search
	
	if (document.getElementById("javascript_enabled")){
		var js_on = document.getElementById("javascript_enabled");
		js_on.setAttribute('value',true);
	}	
}

function queryclick(){
	var search_toplevel_query = document.getElementById('search_toplevel_query');
	if (search_toplevel_query.value == '')
		search_toplevel_query.value = 'Enter your Query here';
	search_toplevel_query.onclick = function(){
		this.value='';		
		this.onclick = function(){return false;};
		}
	}
	
function queryclick_media(){
	if (document.getElementById('expertsearch_query')){
		var expertsearch_query = document.getElementById('expertsearch_query');
	
		if (expertsearch_query.value == '')
			expertsearch_query.value = 'Enter a Phrase or Keyword';
		expertsearch_query.onclick = function(){
			this.value='';		
			this.onclick = function(){return false;};
			}
		}
	}
	
function breakawaynav_arrows(){	
	if (document.getElementById('breakawaynav')){
		var bodyclasses = document.body.className.split(' ');
		for (var i = 1; i < bodyclasses.length; i++){
				if (document.getElementById(bodyclasses[i])){
					var target = document.getElementById(bodyclasses[i]).getElementsByTagName("a")[0];
					target.className = "list_header_link";
					var last_target = target;
				}
			}
		}
		if (last_target){
			if (last_target.parentNode.getElementsByTagName("ul").length == 0)
				last_target.className="list_header_link active_with_no_arrow";
			else
				last_target.className="list_header_link active_with_arrow";
			}			
	}
function tablelinks(){
	var table;
	var tablelinksexist = document.getElementsByTagName("table");
	var tablenumber = tablelinksexist.length;
	var j;
	if (tablenumber > 0){
		for (table = 0; table < tablenumber; table ++){
			if (tablelinksexist[table].className == 'expertlist'){
				var row = tablelinksexist[table].getElementsByTagName("tr");
				for (j = 0; j < row.length; j++){
					
					if (row[j].className == 'vcard expertentry'){
						row[j].onclick = function(){window.open(this.getElementsByTagName("td")[0].getElementsByTagName("a")[0].href,"_self");}
					}
				}
						
			}
		}
	}
}
function populateForm (netname, first, last, email, extension, perm) {

	if( netname == '' || netname == null) {

		alert("Netname must be provided");

		return;

	}

	if(chkValid(perm) == false) {

		alert("Please select permissions");

		return;

	}

	document.userform.netname.value = netname;

	document.userform.firstname.value = first;

	document.userform.lastname.value = last;

	document.userform.email.value = email;

	document.userform.extension.value = extension;	

	document.userform.access.options[perm].selected = true;

	

}

function chkValid(strString) {

	var strValidChars = "012";

	var strChar;

	var blnResult = true;

	if (strValidChars.indexOf(strString) == -1){

		blnResult = false;

	}

	return blnResult;

}

function myVoid() { }
function myOpen(URL,properties) {
    windowHandle = window.open(URL,'address_display',properties);
        if (!windowHandle.opener) windowHandle.opener=self;
        windowHandle.focus();
}

function replaceShareThis(){
	var span = document.getElementsByTagName("span");
	var links = document.getElementsByTagName("a");
	var i;
	var k;

	//for (i = 0; i < span.length; i++){
//		if (span[i].className == "stbuttontext")
//			span[i].innerHTML = "Share This";
//	}
	
	for (k = 0; k < links.length; k++){
		if (links[k].className == "stbutton stico_default"){
			links[k].innerHTML = '<span class="stbuttontext">Share This</span>';
			links[k].className = "";
		}
	}
	
// Now replace the email link
	if (document.getElementById("emaillink") && document.getElementById("sharethis_0")){
		$("#emaillink").replaceWith($("#sharethis_0"));
	}

}