// Used for Flash popups on the site
/* Example on usage:
 * Format:  <a href='javascript:popupFlash("EWCD Flash Image URL",height,width,"Pagetitle");'>LinkText</a>
 * Example: <a href='javascript:popupFlash("_CSEMBED...",640,480,"3M: Meeting &amp; Presentation Solutions");'>LinkText</a>
 */
var popupwin = null;

function popupFlash(fileURL,fileWidth,fileHeight,popupTitle) {
	// Width & Height of your Flash Document
	var sx = fileWidth;
	var sy = fileHeight;
	// Position the window in the Middle of the Screen
	var winl = (screen.width-sx)/2;
	var wint = (screen.height-sy)/2;
	// The following two lines prevents an IE error.
	popupwin=window.open("","NewWindow","top="+wint+",left="+winl+",width=200,height=200");
	popupwin.window.close();
	
	var flash_insert="<object classid='d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+sx+"' height='"+sy+"'><param name='movie' value='"+fileURL+"'><param name=quality value=high><embed src='"+fileURL+"' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='"+sx+"' height='"+sy+"'></embed></object>";
//	var flash_insert="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='"+sx+"' height='"+sy+"'><param name='movie' value='"+fileURL+"'><param name=quality value=high><embed src='"+fileURL+"' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='"+sx+"' height='"+sy+"'></embed></object>";
	popupwin=window.open("","NewWindow","toolbar=no,location=no,scrollbars=no,directories=no,status=no,menubar=no,top="+wint+",left="+winl+",width="+sx+",height="+sy+"");
	popupwin.document.write("<HTML><HEAD><TITLE>"+popupTitle+"</TITLE><style type='text/css'> HTML, BODY { overflow: hidden; margin:0;padding:0;color:#fff } </style></HEAD>"+flash_insert+"</HTML>");
	popupwin.window.focus();
}

// Used for File popups on the site WITHOUT SCROLLBARS
/* Example on usage:
 * Format:  <a href='javascript:popupFile("URL",width,height);'>LinkText</a>
 * Example: <a href='javascript:popupFile("http://www.3m.com/us/office/meetings/vo/vo.html",720,500);'>LinkText</a>
 */
function popupFile(fileURL,fileWidth,fileHeight) {
	// Width & Height of your Flash Document
	var sx = fileWidth;
	var sy = fileHeight;
	// Position the window in the Middle of the Screen
	var winl = (screen.width-sx)/2;
	var wint = (screen.height-sy)/2;
	// The following two lines prevents an IE error.
	popupwin=window.open("","NewWindow","top="+wint+",left="+winl+",width=200,height=200");
	popupwin.window.close();
	popupwin=window.open(fileURL,"NewWindow","toolbar=no,location=no,scrollbars=no,directories=no,status=no,menubar=no,top="+wint+",left="+winl+",width="+sx+",height="+sy+"");
	popupwin.window.focus();
}


// Used for File popups on the site WITH SCROLLBARS
/* Example on usage:
 * Format:  <a href='javascript:popupFile("URL",width,height);'>LinkText</a>
 * Example: <a href='javascript:popupFile("http://www.3m.com/us/office/meetings/vo/vo.html",720,500);'>LinkText</a>
 */
function popupFileScroll(fileURL,fileWidth,fileHeight) {
	// Width & Height of your Flash Document
	var sx = fileWidth;
	var sy = fileHeight;
	// Position the window in the Middle of the Screen
	var winl = (screen.width-sx)/2;
	var wint = (screen.height-sy)/2;
	// The following two lines prevents an IE error.
	popupwin=window.open("","NewWindow","top="+wint+",left="+winl+",width=200,height=200");
	popupwin.window.close();
	popupwin=window.open(fileURL,"NewWindow","location,menubar,toolbar,scrollbars,resizable,top="+wint+",left="+winl+",width="+sx+",height="+sy+"");
	popupwin.window.focus();
}



// Used for Gallery Image-popups on the site
/* Example on usage:
 * Format:  <a href='javascript:popupFlash("EWCD Flash Image URL",height,width,"Pagetitle");'>LinkText</a>
 * Example: <a href='javascript: popupImage("_CSEMBED...",135,130,"3M")'>LinkText</a>
 */

function popupImage(ImageURL,fileWidth,fileHeight,popupTitle) {
	// Width & Height of your Flash Document
	var sx = fileWidth;
	var sy = fileHeight;
	// Position the window in the Middle of the Screen
	var winl = (screen.width-sx)/2;
	var wint = (screen.height-sy)/2;
	// The following two lines prevents an IE error.
	popupwin=window.open("","NewWindow","top="+wint+",left="+winl+",width=200,height=200");
	popupwin.window.close();
	
	var image_insert="<img src='"+ImageURL+"' height='"+fileHeight+"' width='"+fileWidth+"'>";
	popupwin=window.open("","NewWindow","toolbar=no,location=no,scrollbars=no,directories=no,status=no,menubar=no,top="+wint+",left="+winl+",width="+sx+",height="+sy+"");
	popupwin.document.write("<HTML><HEAD><TITLE>"+popupTitle+"</TITLE><style type='text/css'> HTML, BODY { overflow: hidden; margin:0;padding:0;color:#fff } </style></HEAD>"+image_insert+"</HTML>");
	popupwin.window.focus();
}


// Checks any form field and returns a true or false
/* Examples on usage:
 * if (isblank(document.forms["FormName"].elements["FieldName"].value)) empty_fields += "FieldName is required\n";
 */
function isblank(s)
{
	if ((s == null) || (s == "")) return true;
	for(var i = 0; i<s.length; i++)
	{
		var c = s.charAt(i);
		if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
	}
	return true;
}


/* Sends user to selected page from any options menu
 * Example: 
 * <select name="Category" onChange="GoUrl(this)">
 *    <option value="_CSEMBED...">Option Title</option>
 * </select>
 */ 
	function GoUrl(s)
	{	var d = s.options[s.selectedIndex].value
		window.top.location.href = d
		s.selectedIndex=0
	}


//used to pass parameters to a page within EWCD
/* Examples on usage:
 * <a href="_CSEMBEDTYPE_=external&_univid_=1114272564701" onclick='pass_param("_CSEMBEDTYPE_=external&_univid_=1114272564701","paramName=paramValue"); return false;'>Link</a>
 */
function pass_param(page, param) {
	var pageAndParam = page+"?"+param;
	window.location.href=pageAndParam;
}


// Extract rp value from the URL for capture ** NEEDS CUSTOMIZATION
function extractParam()  {
	var rp="";
	var parm="";
	var parmindex=0;
	if( document.location.search != "" ) {
		str = document.location.search;
		
		parmindex=str.indexOf("rp=");
		if(parmindex != '-1') {
		keyval=str.substr(parmindex).split("=");
		parm=keyval[1];
		} else {
		parm = "noparm";
		}
	} else {
		parm = "noparm";
	}
	return parm;
}

//Dreamweaver image rollover code

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_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_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];}
}

//Rotate images functions

function canManipulateImages() {
	if (document.images)
		return true;
	else
		return false;
}

function loadSlide(imageURL) {
	if (gImageCapableBrowser) {
		document.slide.src = imageURL;
		return false;
	}
	else {
		return true;
	}
}