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 showbookmarks(){
	if (window.external || window.sidebar || window.opera)	{
	if (document.getElementById('bookmark')){
		  var bookmark = document.getElementById('bookmark');
		  bookmark.className = 'show';
		  }
	}
}

function bookmark(url,title){
	
if (window.sidebar) {
    window.sidebar.addPanel(title,url,"");
}else if (window.external) {
  	window.external.AddFavorite(url,title);
}else{
    alert("Please use CTRL-D to bookmark");
  }
}



 // this function is needed to work around 
  // a bug in IE related to element attributes
  function hasClass(obj) {
     var result = false;
     if (obj.getAttributeNode("class") != null) {
         result = obj.getAttributeNode("class").value;
     }
     return result;
  }   

 function stripe(id) {

    // the flag we'll use to keep track of 
    // whether the current row is odd or even
    var even = false;
  
    // if arguments are provided to specify the colours
    // of the even & odd rows, then use the them;
    // otherwise use the following defaults:
    var evenColor = arguments[1] ? arguments[1] : "#fff";
    var oddColor = arguments[2] ? arguments[2] : "#eee";
  
    // obtain a reference to the desired table
    // if no such table exists, abort
    var table = document.getElementById(id);
    if (! table) { return; }
    
    // by definition, tables can have more than one tbody
    // element, so we'll have to get the list of child
    // &lt;tbody&gt;s 
    var tbodies = table.getElementsByTagName("tbody");

    // and iterate through them...
    for (var h = 0; h < tbodies.length; h++) {
    
     // find all the &lt;tr&gt; elements... 
      var trs = tbodies[h].getElementsByTagName("tr");
      
      // ... and iterate through them
      for (var i = 0; i < trs.length; i++) {

        
        // get all the cells in this row...
        var tds = trs[i].getElementsByTagName("td");
        
          // and iterate through them...
          for (var j = 0; j < tds.length; j++) {
        
            var mytd = tds[j];
						mytd.style.backgroundColor =
            even ? evenColor : oddColor;
        }
        // flip from odd to even, or vice-versa
        even =  ! even;
      }
    }
  }
