﻿function Launch(page, windowName) {
	OpenWin = this.open(page,windowName,"toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=772,height=500");
	if(OpenWin != undefined) {
		OpenWin.focus();
	} else {
		alert("There was a problem launching a new window.\nPlease ensure you do not have pop-ups blocked for this site.");
	}
}

function LaunchWithHeightWidth(page, windowName, height, width) {
	OpenWin = this.open(page,windowName,"toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width="+width+",height="+height);
	if(OpenWin != undefined) {
		OpenWin.focus();
	} else {
		alert("There was a problem launching a new window.\nPlease ensure you do not have pop-ups blocked for this site.");
	}
}

function TruncateParagraph(paragraphText, maxLength, endString) {
 
    var theText = paragraphText;
    
    if (paragraphText.length > 0) {
        var len = (maxLength || 250);
        var elipsis = (endString || "...");
        
        if (paragraphText.length > len) {

            /* Truncate the content of the P, then go back to the end of the
            previous word to ensure that we don't truncate in the middle of
            a word */
            paragraphText = paragraphText.substring(0, len);
            paragraphText = paragraphText.replace(/\w+$/, '');

            /* Add an ellipses to the end and make it a link that expands
            the paragraph back to its original size */
            paragraphText += elipsis;
        }
        
    }

    return paragraphText;

}

function RedirectOpener(newUrl, focusOnOpener) 
{
  if (focusOnOpener == undefined) focusOnOpener = false;
  var windowToRedirect = window.opener;
  
  if(windowToRedirect == null || windowToRedirect == undefined) {
    windowToRedirect = window;
  }
  
  windowToRedirect.location.href = newUrl;
  if (focusOnOpener) windowToRedirect.focus();
  
}