
// File: nospam.js
// Desc: Definitions for "stealth" mailto tags
// Auth: Alexandros Labrinidis (labrinid@cs.pitt.edu)
// Date: Mon Dec 24 21:53:08 EST 2001
//

////// GENERAL EMAIL ADDRESSES ////////////////////////////////////////////////
function mailtag(x,y,z) {
    var e0 = x + '@' + y;

    var ret_str;
    ret_str = '<a href="mailto:' + e0 + '?subject=' + z + '">' + e0 + '</a>';
    return ret_str;
};


// JavaScript for Vertical Popup Nav
// javascript for IE/win, since it does not support li:hover

iewinHover = function() {
	var li = document.getElementById("nav").getElementsByTagName("li");
	for (var i=0; i<li.length; i++) {
		li[i].onmouseover=function() {
			if(this.className != "nosub") {
				this.className+="iewin";
			}
		}
		li[i].onmouseout=function() {
			if (this.className == "locationiewin") {
				this.className=this.className.replace(new RegExp("locationiewin\\b"), "location");
			}		
			else {
				this.className=this.className.replace(new RegExp("iewin\\b"), "");
			}
		}
	}
}

if (document.all) { // load only in IE
	if (window.attachEvent) window.attachEvent("onload", iewinHover);
 	else window.onload = iewinHover; // Mac IE5
}

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}

addLoadEvent(function() {
	l=window.location.toString(); s=l.split("/");
	// ********* CHANGE ME  ****************************************************************
	// this value is to highlight the section in the navigation bar that the current page is in
	f=s[3]; // Change this number to the number of slashes in the URL before the home page (http://cs.pitt.edu/index.php has 3 slashes)
	if (f == "index.php" || f == "") {
		return;
	}
	else {
		cn = "n-" + f;
	}
	var nli = document.getElementById(cn);
  /*
   * Band-aid to avoid script errors until this is properly set up.
   * 2006/01/30 crp11
   */
  if(nli)
  {
    nli.className+="location";
  }
})
addLoadEvent(function() {
   var ptElement = document.getElementById("page-title");

   /*
    * /index.php does not have a page-title element.
    * We could give it one (perhaps by simply making its title tag <title id="page-title">), but that would produce a repetitive title ("Department of Computer Science | Department of Computer Science ...").
    * So we give it its own title.
    * 2006/01/30 crp11
    */
   if(ptElement)
   {
      document.title = ptElement.innerHTML + " | Department of Computer Science | University of Pittsburgh";
   }
   else
   {
      document.title = "Department of Computer Science | University of Pittsburgh";
   }
})

/////////// For hiding and showing elements on a page ////////////
function Toggle(item) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")  
   if (visible) {
	 obj.style.display="none";
   } else {
	  obj.style.display="block";
   }
}
function ToggleInline(item) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")  
   if (visible) {
	 obj.style.display="none";
   } else {
	  obj.style.display="inline";
   }
}
function Show(item) {
   obj=document.getElementById(item);
   obj.style.display="block";
}
function ShowInline(item) {
   obj=document.getElementById(item);
   obj.style.display="inline";
}
function Hide(item) {
   obj=document.getElementById(item);
   obj.style.display="none";
}
