// Rewritten from script:
// Internal Site Search script II- By JavaScriptKit.com (http://www.javascriptkit.com)
// For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/


function Gsitesearch(curobj){
var client=curobj.client[curobj.client.selectedIndex].value;
alert(client);
var proxystylesheet=client[curobj.client.selectedIndex].value;
curobj.q.value=client+" "+curobj.qfront.value;
}


function popUpWindow(URLStr, left, top, width, height)

{

  if(popUpWin)

  {

    if(!popUpWin.closed) popUpWin.close();

  }

  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

}
//function to get relative path between documents using a shared parent directory as a temporary base url or "site root." Takes common parent directory as first argument. Takes new path from that directory as second argument. with thanks to Steven Levith and parseURI. It is used here to solve problems with having jump forms (see below) addressed by two different domains with different directory hierarchies. It is also used by the Google map script (uscripts/map.js).
function relPathReset(parentDir,newPath)
{ 
	if (parseUri(newPath).protocol=="")
	{
	var domain = location.host;
					//path to current file 
		 var homeurl = window.location.href;
		  var path = parseUri(homeurl).directory;
		  var trunc = path.split(parentDir); 
		  var endurl = trunc.pop();
		  var bbackurl = endurl.replace(/\/[0-9a-zA-Z_]*/, "");
		  var backurl = bbackurl.replace(/\/[0-9a-zA-Z_]*/g, "../");
		  var finPath =(backurl + newPath);
		  return finPath;
	}
	else{
	return newPath;
	}
}
		
/*a rework of the Macromedia jump script so I can call it from a remote directory and have it rewrite relative URIs from a common home directory . Works like a base url or temporary site root. uses Steven Levithans parseURI and my relPathReset*/
function MM_jumpMenuGo(objId,targ,restore){ //v9.0
  var selObj = null;  
  with (document) 
 	{ 
	  if (getElementById) selObj = getElementById(objId); 
		if(selObj.selectedIndex > -1){		
		 var newFile = eval('selObj.options[selObj.selectedIndex].value');
		 var goThere = relPathReset("patientcare",newFile);
		 if (selObj) eval(targ+".location='"+goThere+"'");
		}
		else {
		alert("choose a service");
		}
	  if (restore) selObj.selectedIndex=0; }
}


/*
addEvent function from http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
*/
function addEvent( obj, type, fn )
{
	if (obj.addEventListener)
		obj.addEventListener( type, fn, false );
	else if (obj.attachEvent)
	{
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}

function removeEvent( obj, type, fn )
{
	if (obj.removeEventListener)
		obj.removeEventListener( type, fn, false );
	else if (obj.detachEvent)
	{
		obj.detachEvent( "on"+type, obj[type+fn] );
		obj[type+fn] = null;
		obj["e"+type+fn] = null;
	}
}
/* remove target _blanks from code with thanks to Roger Johansson http://www.456bereastreet.com/archive/200605/opening_new_windows_with_javascript_version_11/
/* Create the new window */
function openInNewWindow(e) {
	var event;
	if (!e) event = window.event;
	else event = e;
	// Abort if a modifier key is pressed
	if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) {
		return true;
	}
	else {
		// Change "_blank" to something like "newWindow" to load all links in the same new window
	    var newWindow = window.open(this.getAttribute('href'), 'newWindow');
		if (newWindow) {
			if (newWindow.focus) {
				newWindow.focus();
			}
			return false;
		}
		return true;
	}
}

/*
Add the openInNewWindow function to the onclick event of links with a class name of "new-window"
*/
function getNewWindowLinks() {
	// Check that the browser is DOM compliant
	if (document.getElementById && document.createElement && document.appendChild) {
		// Change this to the text you want to use to alert the user that a new window will be opened
	//	var strNewWindowAlert = "_";
		// Find all links
		var links = document.getElementsByTagName('a');
		var objWarningText;
		var link;
		for (var i = 0; i < links.length; i++) {
			link = links[i];
			// Find all links with a class name of "new-window"
			if (/\bnew\-window\b/.test(link.className)) {
				// Create an em element containing the new window warning text and insert it after the link text
				//objWarningText = document.createElement("em");
//				//objWarningText.appendChild(document.createTextNode(strNewWindowAlert));
//				link.appendChild(objWarningText);
				link.onclick = openInNewWindow;
			}
		}
		objWarningText = null;
	}
}

addEvent(window, 'load', getNewWindowLinks);


//  first function opens nested menu
// second function marks current location--with alterations on v1.7 Copyright (c) 2006 TJKDesign - Thierry Koblentz
// For help with TJK_hank, visit http://www.tjkdesign.com/articles/navigation_links_and_current_location.asp
// To use OpenLink, add the function name to the body onload
// and send the number 1 and the exact name of the link to open as arguments 
// added function to untoggle toggled items that use cmswitch below
function OpenLink(mrk,theLink){ 
	var i,x,d,hr,ha,ef,a,ag;
	if(document.getElementById){
		d=document.getElementById('sidenav');
		if(d){
			ha=d.getElementsByTagName("A");
			if(ha&&ha.length){
				for(i=0;i<ha.length;i++){
					if(ha[i].firstChild&&ha[i].firstChild.data){
						if(ha[i].firstChild.data==theLink){
							if(mrk==1)
							{
							dis=document.getElementById('cm0');	
							ha[i].parentNode.className="on";
							ha[i].className="on";
								if(dis.parentNode.className=="on")
								{
									dis.style.display='block';		
								};
							}
							}
						}
				} 
			}
		}
	}
}
function TJK_hank(zMenu,defaultPage,classToApply,leaveItAlone){
if (document.getElementById && document.createElement && document.getElementById(zMenu)){
var strLocation = (top.location.pathname.lastIndexOf("/")+1 == top.location.pathname.length) ? top.location.hostname + top.location.pathname+defaultPage : top.location.hostname + top.location.pathname;
	var a = document.getElementById(zMenu).getElementsByTagName("a");
		for (var x=0,i=a.length;x<i;x++){
			var nothingToDo = (a[x] && a[x].className && a[x].className==leaveItAlone) ? true : false;
			if (!nothingToDo && a[x] && a[x].href && a[x].href.lastIndexOf("#")+1!=a[x].href.length){
				if (a[x].href.indexOf(strLocation,0)>0 || a[x].href == top.location.protocol + "//" + top.location.hostname + top.location.pathname){
					if (classToApply==""){
						var objNode = a[x];
						var strLink = objNode.firstChild.data;
						objNode.parentNode.innerHTML="<em>"+strLink+"</em>";
					}else{
						var objNode = a[x];
						objNode.parentNode.className += ""+classToApply;
						objNode.className += " "+classToApply;
					}
				}
			}
		}
	}
}

function DocNameExtract()
{
   wholeurl = window.location.href;
   x = wholeurl.length;
   while((wholeurl.substring(x,x-1)) != "."){ x--; } clipend = x;
   while((wholeurl.substring(x,x-1)) != "/"){ x--; } clipstart = x;
   return wholeurl.substring(clipend-1,clipstart);
}


/*
	parseUri 1.2.1
	(c) 2007 Steven Levithan <stevenlevithan.com>
	MIT License
*/

function parseUri (str) {
	var	o   = parseUri.options,
		m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
		uri = {},
		i   = 14;

	while (i--) uri[o.key[i]] = m[i] || "";

	uri[o.q.name] = {};
	uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
		if ($1) uri[o.q.name][$1] = $2;
	});

	return uri;
};

parseUri.options = {
	strictMode: false,
	key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
	q:   {
		name:   "queryKey",
		parser: /(?:^|&)([^&=]*)=?([^&]*)/g
	},
	parser: {
		strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
		loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
	}
};


// Macromedia's old jump menu script here for university branding only
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


//for loading XML files


//function loadXMLDoc(dname) 
//{
//try //Internet Explorer
//  {
//  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
//  }
//catch(e)
//  {
//  try //Firefox, Mozilla, Opera, etc.
//    {
//    xmlDoc=document.implementation.createDocument("","",null);
//    }
//  catch(e) {alert(e.message)}
//  }
//try 
//  {
//  xmlDoc.async=false;
//  xmlDoc.load(dname);
//  return(xmlDoc);
//  }
//catch(e) {alert(e.message)}
//return(null);
//}
// -------------------------------------------------------------------
// autoComplete (text_input, select_input, ["text"|"value"], [true|false])
// Use this function when you have a SELECT box of values and a text
// input box with a fill-in value. Often, onChange of the SELECT box
// will fill in the selected value into the text input (working like
// a Windows combo box). Using this function, typing into the text
// box will auto-select the best match in the SELECT box and do
// auto-complete in supported browsers.
// Arguments:
// field = text input field object
// select = select list object containing valid values
// property = either "text" or "value". This chooses which of the
// SELECT properties gets filled into the text box -
// the 'value' or 'text' of the selected option
// forcematch = true or false. Set to 'true' to not allow any text
// in the text box that does not match an option.
// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// -------------------------------------------------------------------
function autoComplete (field, select, property, forcematch) {
 	var found = false;
 	for (var i = 0; i < select.options.length; i++) {
 	if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
 	found=true; break;
 	}
 }
 	if (found) { select.selectedIndex = i; }
	 else { select.selectedIndex = -1; }
 		if (field.createTextRange) {
 		if (forcematch && !found) {
 		field.value=field.value.substring(0,field.value.length-1);
 	return;
 }
 	var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
		 if (cursorKeys.indexOf(event.keyCode+";") == -1) {
 	var r1 = field.createTextRange();
 	var oldValue = r1.text;
 	var newValue = found ? select.options[i][property] : oldValue;
	 if (newValue != field.value) {
 		field.value = newValue;
	 var rNew = field.createTextRange();
 		rNew.moveStart('character', oldValue.length) ;
 		rNew.select();
 			}
 		}
 	}
}

/*
collapsible lists
*/


if(window.attachEvent)window.attachEvent('onload',cm);
else if(window.addEventListener)window.addEventListener('load',cm,false);

function cm(){
 cmId=0;
 if(!document.getElementsByTagName)return; // reject non-compliant browsers
 a=document.getElementsByTagName('UL');
 for(i=0;a[i];i++){
  if(a[i].getElementsByTagName('UL')){
  }
 }
}

function cmSwitch(id){
 a=document.getElementById(id);
 a.style.display=(a.style.display=='block')?'none':'block';
}


// ALUMNI PAGES First function can be used to add a section to a form if a particular item is chosen. 
// this functions looks for attributes indicating the id of the section to display and the class to apply to it

function addform(addDiv,classToApply){
	if (document.getElementById && document.createElement && document.getElementById(addDiv)){
		var l = document.getElementById(addDiv);
		var objNode = l;
		if(objNode.className == "clearform"){
			objNode.className = " ";
			}
		objNode.className += " "+classToApply;
	}
}
//This removes a section of the form if the item is unselected. 
//It looks for attributes indicating the section id and field id
function clearform(clearDiv,fieldReset){
	if (document.getElementById && document.createElement && document.getElementById(clearDiv)){
		var c = document.getElementById(clearDiv);
		var cobjNode = c;
		if(cobjNode.className !== "clearform") {
			cobjNode.className = " ";
			cobjNode.className += "clearform";
			var v = document.getElementById(fieldReset);
			v.selectedIndex = 0;

			}
		}
	}
	