function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
  
function P7_JumpMenu(selObj,restore){ //v1.3 by Project Seven
	var theFullString = selObj.options[selObj.selectedIndex].value;
	if (restore) selObj.selectedIndex=0;
	var theLength = theFullString.length;
	var endPos = theFullString.lastIndexOf("~");
	var theUrl, theTarget, theParent;
	if (endPos > 0) {theUrl = theFullString.substring(0,endPos);}
	else {theUrl = theFullString;}
	endPos++
	if (endPos < theLength) {theTarget = theFullString.substring(endPos,theLength)}
	else {theTarget = "window:Main";}
	if (theTarget == "window:New") {window.open(theUrl);}
	else if (theTarget == "window:Main") {eval("parent.location='"+theUrl+"'");}
	else {eval("parent.frames[\'"+theTarget+"\'].location='"+theUrl+"'");}
}

function MM_findObj(n, d) { //v3.0
  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); return x;
}

function P7_JumpMenuGo(selName,restore){ //v1.1 Beta Version by Project Seven
  var selObj = MM_findObj(selName); if (selObj) P7_JumpMenu(selObj,restore);
}

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
	  if(!a.title.match('^clr_'))
		a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function setColorScheme(color)
{
	if (document.getElementsByTagName)
		x = document.getElementsByTagName('link');
	else if (document.all)
		x = document.all.tags('link');
	else
	{
		alert('This script does not work in your browser');
		return;
	}
	for (var i=0;i<x.length;i++)
	{
//		alert('colorsc: ' + x[i].title + x[i].disabled);
		if (x[i].title.match('^clr_'))
		{
			x[i].disabled = true;
		}
		if (x[i].title == color)
		{
//			alert('works?' + x[i].disabled);
			x[i].disabled = false;
		}

	}
}

function getColorScheme() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled && a.title.match('^clr_')) return a.getAttribute("title");
  }
  return null;
}


function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled && !a.title.match('^clr_')) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);

  var color = readCookie("color");
  color = color ? color : 'clr_white';
  setColorScheme(color);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
  var color = getColorScheme();
  createCookie("color", color, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

var color = readCookie("color");
color = color ? color : 'clr_white';
setColorScheme(color);

var win = null;

function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}

function searchIt(formObj)
{
  var criteria = formObj.criteria.value;
  var divObj = document.getElementById('hid');
  for (var i = 0; i < formObj.length; i++)
  {
    el = formObj.elements[i];
    if (el.type == 'radio' && el.name=='engine' && el.checked)
    {
       var theVal = parseInt(el.value)
       switch (theVal)
       {
           case 0:
          divObj.innerHTML = '<input type="hidden" name="q" value="' +
criteria + '" />'
          formObj.method = 'get';
          formObj.action = 'http://www.google.com/u/tcnj' + '?q=' +
criteria;
          break;
         case 1:
            formObj.name = 'search';
            formObj.id = 'search';
            formObj.method = 'post';
               formObj.action=
'http://delphi.tcnj.edu:8500/prod/directories/index.cfm?field=lastname&crit='
+ criteria;
           break;
        case 2:
          divObj.innerHTML = '<input type="hidden" name="q" value="' +
criteria + '" />'
          formObj.method = 'get';
          formObj.action = 'http://www.google.com/search' + '?q=' +
criteria;
          break;
        }
     }
  }
  formObj.target = '_parent';
  return true;
}

	function updateList()
			{
					document.search.q.value= document.search.inputbox.value;
					document.search.crit.value= document.search.inputbox.value;
			}
			
			
			function changeSearch(param)
			{ 
				var param = param;
			
				// TCNJ Directory
				if(param == 'dir')
				{
					// Changes form action
					document.search.action = "http://directory.tcnj.edu/index.cfm";
			
					// Change class name
					document.getElementById('search-dir').className='search-active';
					
					// Change class name
					document.getElementById('search-tcnj').className='search-inactive';
					
					

				}

				// TCNJ Web
				if(param == 'tcnj')
				{
					// Changes form action
					document.search.action = "http://www.google.com/u/tcnj";
					document.search.sitesearch.value = "www.tcnj.edu";
						// Change class name
					document.getElementById('search-dir').className='search-inactive';
					
					// Change class name
					document.getElementById('search-tcnj').className='search-active';
				}
						
			 }