function openWindow(url)
{
	var width = 480;
	var height = 309;
	var windowTreatments = ",scrollbars=no,resizable=no,status=no";
	
	if (arguments.length > 1)
	{
		width = arguments[1];
	}
	
	if (arguments.length > 2)
	{
		height = arguments[2];
	}
	
	if (arguments.length > 3)
	{
		windowTreatments = "," + arguments[3];
	}
	
	window.open(url, "newwindow", "width=" + width + ",height=" + height + windowTreatments);
}

//used on faculty home page to run slimbox and show larger pic when click on magnifying glass button in slideshow

//function init(pic, text)
//{
//	jQuery.slimbox(pic, text);
//}



//Rollovers

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//javascript used to strip html coding from title attribute so it does not show on hover, but also to replace html after mouseOut or onClick so html can be used by light box.  note that Flash coding has a function to replace the html entity version of < and > (required for inline use by Ephox) with the < > required by Flash.  note that the js regular expression to find html coding requires \x followed by two char hex code for < >.  note that for IE must add title to img and change it in js; otherwise it shows the img alt on hover


                        var ct_target;
                        var ct_original;
                        var ct_stripped;
                       
                        function changeTitle(elem_id) {
                                ct_target = document.getElementById(elem_id);
                                ct_original = ct_target.title;
                                ct_stripped = ct_original.replace(/\x3C(?:.|\s)*?\x3E/g, "");
                                ct_target.title = ct_stripped;
                        };
                        function restoreTitle() {
                                ct_target.title = ct_original;
                        }
						
						
//jQuery plugin to manipulate cookies.  Used by randomContent function below; stores random number as session cookie so can increment and show all content in order.

/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}expires='; expires='+date.toUTCString();}var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}return cookieValue;}};


//jQuery plugin to pull content from XML file and rotate display on each page load. Starts with random number, stores to session cookie, then increments to display all items. Cookie added as random not effective at switching with small number of items. Used in facility home page.

/*-------------------------------------------------------------------------------
	adapted from
	jQuery Random Content Generator - Powered by Chuck Norris
	Version 1.0
	By Jon Cazier
	jon@3nhanced.com
	10.23.08
	requires jquery.cookie.js
-------------------------------------------------------------------------------*/

jQuery.fn.randomContent = function(options){

	var defaults = {
		xmlPath: "randomContent.xml",
		nodeName: "content",
		cookieName: "cookieName"
	};
	
	var options = jQuery.extend(defaults, options);
	
	var cookieNum = jQuery.cookie(defaults.cookieName);
	
	var contentArray = new Array();
	
	var rc = this;
	jQuery.get(defaults.xmlPath, {}, function(xml){
		jQuery(defaults.nodeName, xml).each(function(i) {			
				contentArray.push(jQuery(this).text());
		 });
	
	getRandom = function() {
			var num = contentArray.length;		
			var randNum
				if(!cookieNum) {
					randNum = Math.floor(Math.random()*num);
					jQuery.cookie(defaults.cookieName, randNum);
				} else if(cookieNum>=(num-1)) {
					randNum = 0;
					jQuery.cookie(defaults.cookieName, randNum);
				} else {
					randNum = parseInt(jQuery.cookie(defaults.cookieName))+1;
					jQuery.cookie(defaults.cookieName, randNum);
				};
				
			var content = "";			
			for(x in contentArray){
				if(x==randNum){
					content = contentArray[x];
				}
			};		
			return content;
		};
			
		rc.each(function(){
			jQuery(this).replaceWith(getRandom());
		});
		
	});
};

/*jquery to open popup window*/
(function(jQuery){ 		  
	jQuery.fn.popupWindow = function(instanceSettings){
		
		return this.each(function(){
		
		jQuery(this).click(function(){
		
		jQuery.fn.popupWindow.defaultSettings = {
			centerBrowser:0, // center window over browser window? {1 (YES) or 0 (NO)}. overrides top and left
			centerScreen:0, // center window over entire screen? {1 (YES) or 0 (NO)}. overrides top and left
			height:500, // sets the height in pixels of the window.
			left:0, // left position when the window appears.
			location:0, // determines whether the address bar is displayed {1 (YES) or 0 (NO)}.
			menubar:0, // determines whether the menu bar is displayed {1 (YES) or 0 (NO)}.
			resizable:0, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable.
			scrollbars:0, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}.
			status:0, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}.
			width:500, // sets the width in pixels of the window.
			windowName:null, // name of window set from the name attribute of the element that invokes the click
			windowURL:null, // url used for the popup
			top:0, // top position when the window appears.
			toolbar:0 // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}.
		};
		
		settings = jQuery.extend({}, jQuery.fn.popupWindow.defaultSettings, instanceSettings || {});
		
		var windowFeatures =    'height=' + settings.height +
								',width=' + settings.width +
								',toolbar=' + settings.toolbar +
								',scrollbars=' + settings.scrollbars +
								',status=' + settings.status + 
								',resizable=' + settings.resizable +
								',location=' + settings.location +
								',menuBar=' + settings.menubar;

				settings.windowName = this.name || settings.windowName;
				settings.windowURL = this.href || settings.windowURL;
				var centeredY,centeredX;
			
				if(settings.centerBrowser){
						
					if (jQuery.browser.msie) {//hacked together for IE browsers
						centeredY = (window.screenTop - 120) + ((((document.documentElement.clientHeight + 120)/2) - (settings.height/2)));
						centeredX = window.screenLeft + ((((document.body.offsetWidth + 20)/2) - (settings.width/2)));
					}else{
						centeredY = window.screenY + (((window.outerHeight/2) - (settings.height/2)));
						centeredX = window.screenX + (((window.outerWidth/2) - (settings.width/2)));
					}
					window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + centeredX +',top=' + centeredY).focus();
				}else if(settings.centerScreen){
					centeredY = (screen.height - settings.height)/2;
					centeredX = (screen.width - settings.width)/2;
					window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + centeredX +',top=' + centeredY).focus();
				}else{
					window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + settings.left +',top=' + settings.top).focus();	
				}
				return false;
			});
			
		});	
	};
})(jQuery);

