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];}
}
function Mid(str, start, len)
{
		// Make sure start and len are within proper bounds
		if (start < 0 || len < 0) return "";

		var iEnd, iLen = String(str).length;
		if (start + len > iLen)
				iEnd = iLen;
		else
				iEnd = start + len;

		return String(str).substring(start,iEnd);
}
function Len(str)
{  return String(str).length;  }

function InStr(strSearch, charSearchFor)
{
	for (i=0; i < Len(strSearch); i++)
	{
	    if (charSearchFor == Mid(strSearch, i, 1))
	    {
			return i;
	    }
	}
	return -1;
}
function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}
function textLimit(field, maxlen){
	if( field.value.length > maxlen ){
		field.value = field.value.substring(0,maxlen);
		alert('The limit of ' + maxlen + ' characters has been reached.');
	}
}
function isEmptyString(stringToCheck, trimFirst)
{	
	var returnValue = true;
	if (stringToCheck != null)
	{
		var afterTrim = stringToCheck;
		if (trimFirst)
		{
			afterTrim = trimWhiteSpace(afterTrim);
		}
		returnValue = afterTrim.length == 0;
	}
	return returnValue;
}

function equalsIgnoreCase(string1, string2)
{
	var returnValue = true;
	if (string1 != null)
	{
		if(string2 != null)
		{
			returnValue = string1.toLowerCase() == string2.toLowerCase();
		}
		else
		{
			returnValue = false;
		}
	}
	else
	{
		returnValue = (string2 == null);
	}
	return returnValue;
}

function trimWhiteSpace(stringToTrim)
{
	var returnValue = stringToTrim;
	if (stringToTrim != null)
	{
		returnValue = stringToTrim.replace(/^\s*|\s*$/g, "");
	}
	return returnValue;
}

function getElementValueById(baseDocument, elementId) {
	var returnValue = "";
	if (baseDocument != null)
	{
		var element = baseDocument.getElementById(elementId);
		if (element != null)
		{
			returnValue = element.value;
		}
	}
	return returnValue;
}

function getElementCheckedById(parent, elementId)
{
	var returnValue = false;
	var element = parent.getElementById(elementId);	
	//alert('getElementCheckedById : elementid=' + elementId + ', element=' + element);
	if (element != null)
	{
		//alert('getElementCheckedById : elementid=' + elementId + ', value=' + element.checked);
		returnValue = element.checked;
	}
	return returnValue;
}

function setElementAttributeById(baseDocument, elementId, attributeName, newValue) {	
	if (baseDocument != null)
	{
		var element = baseDocument.getElementById(elementId);
		if (element != null)
		{
			//alert('Set attribute ' + attributeName + ' to ' + newValue );
			element.setAttribute(attributeName, newValue);
		}
	}	
}

function setElementValueById(baseDocument, elementId, newValue)
{
	if (baseDocument != null)
	{
		var element = baseDocument.getElementById(elementId);
		if (element != null)
		{
			element.value = newValue;
		}
	}
}

function setFocusById(baseDocument, elementId, newValue)
{
	if (baseDocument != null)
	{
		var element = baseDocument.getElementById(elementId);
		if (element != null)
		{
			element.focus();
		}
	}
}

function isIE()
{
	return navigator.userAgent.indexOf("MSIE") != -1;
}

function setInnerText(element, textValue)
{
	if (element != null)
	{		
		if (isIE())
		{
			element.innerText = textValue;
		}
		else
		{
			element.textContent = textValue;
		}
	}
}

function escapeStringForJavaScript(toEscape)
{
	var returnValue = toEscape;	
	if (returnValue != null)
	{
		returnValue = returnValue.replace(/'/g,  'xx_apos_xx');
		returnValue = returnValue.replace(/"/g,  'xx_quote_xx');
	}
	return returnValue;
}

function unescapeStringForJavaScript(toEscape)
{
	var returnValue = toEscape;	
	if (returnValue != null)
	{
		returnValue = returnValue.replace(/xx_apos_xx/g,  '\'');
		returnValue = returnValue.replace(/xx_quote_xx/g,  '"');
	}
	return returnValue;
}

function refreshParent()
{
	if (window.opener != null)
	{
		window.opener.location.href = window.opener.location.href;
	}
}

function isNumber(fieldValue)
{
	var returnValue = true;
	if (!isEmptyString(fieldValue, true))
	{	
		var testValue = trimWhiteSpace(fieldValue);
		var i=0;
		for (i=0; i< testValue.length;i++)
		{
			var currentCharCode = testValue.charCodeAt(i);
			if (currentCharCode < 48 || currentCharCode > 57)
			{
				returnValue = false;
				break;
			}
		}
	}	
	return returnValue;
}

function getSafeWindowName(windowName)
{
	var returnValue = windowName;
	if (!isEmptyString(windowName, false))
	{
		returnValue = returnValue.replace(/-/g, ''); 
	}
	return returnValue;
}

function openWindowAS(newWindowURL, newWindowName, newWindowFeatures, childArray, parentName)
{	
	var safeWindowName = getSafeWindowName(newWindowName);	
	var newWindow = window.open(newWindowURL, safeWindowName, newWindowFeatures);		
	newWindow.focus();
}

function addHttpProtocol(urlString)
{	
	var returnValue = urlString;
	if (!startsWithProtocol(urlString))
	{
		returnValue = addProtocol(urlString, "http://");
	}
	return returnValue;
}

function startsWithProtocol(urlString)
{
	var returnValue = startsWith(urlString, "http://", true);
	if (!returnValue)
	{
		returnValue = startsWith(urlString, "https://", true);
	}
	if (!returnValue)
	{
		returnValue = startsWith(urlString, "ftp://", true);
	}
	if (!returnValue)
	{
		returnValue = startsWith(urlString, "file://", true);
	}
	if (!returnValue)
	{
		returnValue = startsWith(urlString, "mailto:", true);
	}
	if (!returnValue)
	{
		returnValue = startsWith(urlString, "news:", true);
	}
	if (!returnValue)
	{
		returnValue = startsWith(urlString, "nntp://", true);
	}
	return returnValue;
}

function startsWith(stringToTest, stringToLookFor, trimFirst)
{
	var returnValue = false;
	var toTest = stringToTest;
	var toLookFor = stringToLookFor;
	if (trimFirst)
	{
		toTest = trimWhiteSpace(toTest);
		toLookFor = trimWhiteSpace(toLookFor);
	}		
	if (!isEmptyString(toTest, false))
	{
		if (!isEmptyString(toLookFor, false))
		{			
			returnValue = toTest.indexOf(toLookFor) == 0;
		}			
	}
	return returnValue;
}

function addProtocol(urlString, protocolString)
{
	var returnString = urlString;		
	if (!isEmptyString(urlString, true))
	{
		if (!startsWith(urlString, protocolString))		
		{
			returnString = protocolString.concat(trimWhiteSpace(urlString));
		}		
	}	
	//alert(urlString + ' converted to ' + returnString);
	return returnString;
}
function validateForm(form, showMessage)
{
	var returnValue = true;
	if (form != null)
	{
		var elementArray = form.elements;
		var i=0;
		for (i=0; i<form.elements.length;i++)
		{
			var element = form.elements[i];			
			var validated = validateElement(element, showMessage);				
			if (!validated)
			{
				returnValue = false;
				break;
			}
		}
	}	
	return returnValue;
}

function getValidationAttribute(element, attributeName)
{
	var returnValue = "";
	if (element != null)
	{
		var attributes = element.attributes;
		var j=0;
		for (j=0;j<attributes.length;j++)
		{
			if(equalsIgnoreCase(attributes[j].nodeName, attributeName))
			{
				returnValue = attributes[j].value;
				break;
			}
		}		
	}
	//alert('getValidationAttribute(' + element.nodeName + ',' + attributeName + ') returns ' + returnValue);
	return returnValue;
}

function getBooleanValidationAttribute(element, attributeName)
{
	var returnValue = false;
	var attribute = getValidationAttribute(element, attributeName);
	returnValue = equalsIgnoreCase(attribute, 'true');	
	return returnValue;
}

function getValidationName(element)
{
	return getValidationAttribute(element, 'asname');
}

function isRequiredElement(element)
{
	return getBooleanValidationAttribute(element, 'asrequired');
}

function disallowHighBitCharacters(element)
{
	return getBooleanValidationAttribute(element, 'ascheckhbc');
}

function isTextElement(element)
{
	var returnValue = false;
	var typeAttribute = getValidationAttribute(element, 'astype');
	returnValue = equalsIgnoreCase(typeAttribute, 'text');
	return returnValue;
}

function isEmailElement(element)
{
	var returnValue = false;
	var typeAttribute = getValidationAttribute(element, 'astype');
	returnValue = equalsIgnoreCase(typeAttribute, 'email');
	return returnValue;
}


function isNumericElement(element)
{
	var returnValue = false;
	var typeAttribute = getValidationAttribute(element, 'astype');
	returnValue = equalsIgnoreCase(typeAttribute, 'number');	
	return returnValue;
}

function isDecimalElement(element)
{
	var returnValue = false;
	var typeAttribute = getValidationAttribute(element, 'astype');
	returnValue = equalsIgnoreCase(typeAttribute, 'decimal');
	return returnValue;
}

function validateTextElement(element, showMessage)
{
	var returnValue = true;
	if (element != null)
	{
		if (disallowHighBitCharacters(element))
		{						
			returnValue = validateNoHbcElement(element, showMessage);			
		}			
	}
	return returnValue;
}

function getHighBitChars(stringToTest)
{
	var returnValue = "";
	if (stringToTest != null && stringToTest != "")
	{		
		var i=0;
		for (i=0;i<stringToTest.length;i++)
		{
			if (stringToTest.charCodeAt(i) > 127)
			{
				returnValue = returnValue + stringToTest.charAt(i);						
			}
		}						
	}
	return returnValue;
}

function validateNoHbcElement(element, showMessage)
{
	var returnValue = true;
	if (element != null)
	{
		var highBitChars = getHighBitChars(element.value);
		if (!isEmptyString(highBitChars, true))
		{
			returnValue = false;
			var fieldName = getValidationName(element);
			showValidationMessage(element, 'The value you have entered for the ' + fieldName + ' contains the following invalid characters:\n' + highBitChars + '\nPlease edit the ' + fieldName + ' and correct this.');
		}			
	}
	return returnValue;
}

function validateNumericElement(element, showMessage)
{
	var returnValue = true;
	if (element != null)
	{		
		var hbcValidated = true;
		if (disallowHighBitCharacters(element))
		{			
			hbcValidated = validateNoHbcElement(element, showMessage);										
		}					
		if (hbcValidated)
		{
			var isValidNumber = isNumber(element.value);	
			if (showMessage && !isValidNumber)
			{
				var fieldName = getValidationName(element);
				returnValue = false;				
				showValidationMessage(element, 'The value for ' + fieldName + ' must be a number.');
			}					
		}
		else
		{
			returnValue = false;
		}
	}
	return returnValue;
}

function validateDecimalFormat(decimalString, scale, precision)
{
	var validated = false;	
	if (!isEmptyString(decimalString))
	{		
		var stringExp = "(^[0-9]{0," + scale + "}\\.[0-9]{0," + precision + "}$)|(^[0-9]{0," + (scale) + "}$)";		
		var decRegExp = new RegExp(stringExp, "g");
		var decResult = decRegExp.exec(decimalString);					
		validated = (decResult != null);
		if (validated)
		{
			validated = !isNaN(decimalString);
		}
	}
	return validated;
}
function validateDecimalElement(element, showMessage)
{
	var returnValue = false;
	if (element != null)
	{		
		if (element.value != "")
		{
			var scale = getNumericValidationAttribute(element, 'asScale', 10);	
			var precision = getNumericValidationAttribute(element, 'asPrecision', 2);					
			returnValue = validateDecimalFormat(element.value, scale-precision, precision);
			if (!returnValue)
			{
				var fieldName = getValidationName(element);
				var errorMessage = "";
				var parsedValue = parseFloat(element.value);
				if (isNaN(parsedValue))
				{
					errorMessage = 'is not a valid decimal value.  It contains characters that cannot be converted to a number.'
				}
				else
				{
					errorMessage = 'is not a valid decimal value.  You may only specify ' + (scale-precision) + ' numbers to the right of the decimal and ' + precision + ' numbers to the left.'; 
				}
							
				showValidationMessage(element, 'The value you have entered for the ' + fieldName + ' ' + errorMessage + '\nPlease edit the ' + fieldName + ' and correct this.');
			}		
		}
		else
		{
			returnValue = true; //don't validate empty strings, that is for the required validation routine.
		}
	}	
	return returnValue;
}

function validateEmailElement(element, showMessage)
{
	var returnValue = false;
	if (element)
	{
		if (element.value != "")
		{
			returnValue = validateEmail(element.value, showMessage);
			if (!returnValue)
			{
				var fieldName = getValidationName(element);
				showValidationMessage(element, 'The value you have entered for the ' + fieldName + ' is not a valid email address\nPlease edit the ' + fieldName + ' and correct this.');
			}
		}
		else
		{
			returnValue = true;
		}
	}
	return returnValue;
}

function validateEmail(email)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return filter.test(email);				
}


function showValidationMessage(element, messageToShow)
{
	var returnValue = false;	
	if (element != null)
	{
		returnValue = true;
		try
		{
			element.focus();		
		}
		catch (err)
		{
			
		}
	}
	alert(messageToShow);
	return returnValue;
}

function validateRequiredElement(element, showMessage)
{
	var returnValue = true;
	if (element != null)
	{		
		returnValue = !isEmptyString(element.value, true);
	}		
	if (showMessage && !returnValue)
	{		
		var fieldName = getValidationName(element);
		showValidationMessage(element, 'You must fill out a value for ' + fieldName + '.');
	}	
	return returnValue;
}

function validateElement(element, showMessage)
{
	var returnValue = true;
	if (isRequiredElement(element))
	{
		returnValue = validateRequiredElement(element, showMessage);
		//alert('validateRequiredElement='+ returnValue);
	}
	
	if (returnValue)
	{
		if (isTextElement(element))

		{
			returnValue = validateTextElement(element, showMessage);
			//alert('validateTextElement='+ returnValue);
		}
		else if (isNumericElement(element))
		{
			returnValue = validateNumericElement(element, showMessage);
			//alert('validateNumericElement='+ returnValue);
		}
		else if (isEmailElement(element))
		{
			returnValue = validateEmailElement(element, showMessage);
		}
		else if (isDecimalElement(element))
		{
			returnValue = validateDecimalElement(element, showMessage);
		}
	}
	//alert('validateElement(' + element + ',' + showMessage + ')');
	return returnValue;
}

function buildContentSelectUrl(selectPageName, cpid, ctid, sortValue, searchName, category, mineOnly, thumbNails, mode, selectedId)
{
	var returnValue = selectPageName + "?CPID=" + cpid;
	returnValue = returnValue + "&schname=" + searchName;
	returnValue = returnValue + "&Sort=" + sortValue;
	returnValue = returnValue + "&CTID=" + ctid;
	returnValue = returnValue + "&Cat=" + category;
	returnValue = returnValue + "&My=" + mineOnly;
	returnValue = returnValue + "&Thumb=" + thumbNails;
	returnValue = returnValue + "&Mode=" + mode;
	returnValue = returnValue + "&sel=" + selectedId;	
	return returnValue;
}

function buildContentSelectUrlById(parent, selectPageName, cpidElementId, ctidElementId, sortElementId, searchElementId, categoryElementId, mineOnlyElementId, thumbNailsElementId, modeElementId, selectedElementId)
{	
	var cpidValue = getElementValueById(parent, cpidElementId);
	var ctidValue = getElementValueById(parent, ctidElementId);
	var sortValue = getElementValueById(parent, sortElementId);
	var searchValue = getElementValueById(parent, searchElementId);
	var selectedValue = getElementValueById(parent, selectedElementId);
	var highBitChars = getHighBitChars(searchValue, true, 'Search');
	if (highBitChars.length > 0)
	{
		searchValue = "";		
	}
	var categoryValue = getElementValueById(parent, categoryElementId);
	var myValue = getElementCheckedById(parent, mineOnlyElementId);			
	var thumbValue = getElementCheckedById(parent, thumbNailsElementId);
	var modeValue = getElementValueById(parent, modeElementId);
	return buildContentSelectUrl(selectPageName, cpidValue, ctidValue, sortValue, searchValue, categoryValue, myValue, thumbValue, modeValue, selectedValue);	 
}

function buildContentSelectUrlByDocument(parent, selectPageName)
{		
	return buildContentSelectUrlById(parent, selectPageName, 'CPID', 'CTID', 'Sort', 'schname', 'Cat', 'My', 'Thumb', 'mode', 'selectedId');
}
function hilightRow(rowElement, hilightOn)
{
	if (rowElement != null)
	{
		if (hilightOn)
		{
			rowElement.setAttribute('bgColor', '#EEEEEE');
		}
		else
		{
			rowElement.setAttribute('bgColor', '#FFFFFF');
		}
	}
}
var defaultDialogOptions = 'fullscreen=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,channelmode=no,directories=no';
function openMsgDetailPublic(messageid)
{
	openWindowAS('int_video_det_pop_public.asp?MID=' + messageid, 'msgdetailpublic' + messageid, defaultDialogOptions + ',width=440,height=280', null, null);
	return document.MM_returnValue;
}

function openMsgDetail(messageid)
{
	openWindowAS('int_video_det_pop.asp?MID=' + messageid, 'msgdetail' + messageid, defaultDialogOptions + ',width=440,height=250', null, null);
	return document.MM_returnValue;
}

function openMsgReport(messageid)
{
	openWindowAS('usr_message_views.asp?MSGID=' + messageid, 'msgreport' + messageid, defaultDialogOptions + ',width=575,height=436', null, null);
	return document.MM_returnValue;
}

function openMsgLinks(messageid)
{
	openWindowAS('usr_message_copy_link.asp?GUID=' + messageid, 'msglinks' + messageid, defaultDialogOptions + ',width=480,height=470', null, null);
	return document.MM_returnValue;
}

function openLibLinks(libraryid)
{
	openWindowAS('usr_library_copy_link.asp?GUID=' + libraryid, 'liblinks' + libraryid, defaultDialogOptions + ',width=480,height=470', null, null);
	return document.MM_returnValue;
}

function openMsgEditor(messageEditPage, messageid, layoutId)
{
	var openUrl = messageEditPage + '?Mode=M&MSGID=' + messageid + '&LYTID=' + layoutId;
	openWindowAS(openUrl, 'msgedit' + messageid, defaultDialogOptions + ',width=950,height=580', null, null);
	return document.MM_returnValue;
}

function openMsgCopy(messageid, sourceLibraryId)
{
	var openUrl = 'usr_message_copy_move.asp?MSGID=' + messageid + '&SLIBID=' + sourceLibraryId;
	openWindowAS(openUrl, 'msgcopy' + messageid, defaultDialogOptions + ',width=462,height=440', null, null);
	return document.MM_returnValue;
}

function openMsgMove(messageid, sourceLibraryId, targetLibraryId)
{
	var openUrl = 'usr_message_copy_move.asp?MSGID=' + messageid + '&SLIBID=' + sourceLibraryId + '&TLIBID=' + targetLibraryId + "&M=1";
	openWindowAS(openUrl, 'msgmove' + messageid, defaultDialogOptions + ',width=462,height=440', null, null);
	return document.MM_returnValue;
}

function openMsgDeleteConfirm(messageid)
{
	var openUrl = 'usr_message_delete_confirm.asp?MSGID=' + messageid;
	openWindowAS(openUrl, 'msgcopy' + messageid, defaultDialogOptions + ',width=640,height=480', null, null);
	return document.MM_returnValue;
}

function openMsgAdvHtml(messageid)
{
	var openUrl = 'usr_message_web_html.asp?MSGID=' + messageid;
	openWindowAS(openUrl, 'advhtml' + messageid, defaultDialogOptions + ',width=530,height=300', null, null);
	return document.MM_returnValue;
}

function openQuickRef(pageName)
{
	var qrefDialogOptions = 'fullscreen=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,channelmode=no,directories=no'
	openWindowAS(pageName, 'quickref', qrefDialogOptions + ',width=565,height=500', null, null);
	return document.MM_returnValue;
}

function openAppHelp(pageName)
{
	openWindowAS(pageName, 'AppHelp', 'width=755,height=580,resizable,scrollbars=1', null, null);
	return document.MM_returnValue;
}

function openFeedback()
{
	openWindowAS('usr_comments.asp', 'feedback', defaultDialogOptions + ',width=450,height=400', null, null);
	return document.MM_returnValue;
}

function openPrivacy()
{
	openWindowAS('usr_privacy.asp', 'privacy', defaultDialogOptions + ',width=500,height=500,resizable,scrollbars=1', null, null);
	return document.MM_returnValue;
}
function openTerms()
{
	openWindowAS('usr_terms.asp', 'terms', defaultDialogOptions + ',width=500,height=500,resizable,scrollbars=1', null, null);
	return document.MM_returnValue;
}
function openThemeSelector(urlParameters)
{
	openWindowAS("usr_theme_sel.asp?" + urlParameters, 'choosetheme', defaultDialogOptions + ',width=640,height=560', null, null);
	return document.MM_returnValue;
}
function openLibrarySelector(urlParameters)
{
	openWindowAS("usr_library_sel.asp?" + urlParameters, 'chooselibrary', defaultDialogOptions + ',width=640,height=560', null, null);
	return document.MM_returnValue;
}
function openContactProfileSelector(urlParameters)
{
	openWindowAS("usr_contact_profile_sel.asp?" + urlParameters, 'chooseprofile', defaultDialogOptions + ',width=640,height=560', null, null);
	return document.MM_returnValue;
}
function openStoryEditor(eventId, storyId)
{
	var openUrl = 'usr_event_story_edit.asp?eid=' + eventId + '&sid=' + storyId;
	openWindowAS(openUrl, 'storyedit' + eventId + storyId, defaultDialogOptions + ',width=660,height=570', null, null);
	return document.MM_returnValue;
}
function openPhotoNew(eventId)
{
	var openUrl = 'usr_event_photo_new.asp?eid=' + eventId;
	openWindowAS(openUrl, 'photonew' + eventId, defaultDialogOptions + ',width=640,height=300', null, null);
	return document.MM_returnValue;
}
function openStoryDelete(eventId, storyId)
{
	var openUrl = 'usr_event_story_del.asp?eid=' + eventId + '&sid=' + storyId;
	openWindowAS(openUrl, 'storydel' + storyId, defaultDialogOptions + ',width=600,height=400', null, null);
	return document.MM_returnValue;
}
function openPhotoEditor(photoId)
{
	var openUrl = 'usr_event_photo_edit.asp?pid=' + photoId;
	openWindowAS(openUrl, 'photoedit' + photoId, defaultDialogOptions + ',width=640,height=440', null, null);
	return document.MM_returnValue;
}
function openPhotoDelete(photoId)
{
	var openUrl = 'usr_event_photo_del.asp?rid=' + photoId;
	openWindowAS(openUrl, 'sphotodel' + photoId, defaultDialogOptions + ',width=600,height=400', null, null);
	return document.MM_returnValue;
}
function openSponsorNew(eventId)
{
	var openUrl = 'usr_event_sponsor_new.asp?eid=' + eventId;
	openWindowAS(openUrl, 'sponsornew' + eventId, defaultDialogOptions + ',width=620,height=350', null, null);
	return document.MM_returnValue;
}
function openSponsorEditor(sponsorId)
{
	var openUrl = 'usr_event_sponsor_edit.asp?sid=' + sponsorId;
	openWindowAS(openUrl, 'sponsoredit' + sponsorId, defaultDialogOptions + ',width=620,height=500', null, null);
	return document.MM_returnValue;
}
function openSponsorDelete(sponsorId)
{
	var openUrl = 'usr_event_sponsor_del.asp?sid=' + sponsorId;
	openWindowAS(openUrl, 'sponsordel' + sponsorId, defaultDialogOptions + ',width=550,height=260', null, null);
	return document.MM_returnValue;
}
function openArticleEditor(eventId, articleId)
{
	var openUrl = 'usr_event_article_edit.asp?eid=' + eventId + '&aid=' + articleId;
	openWindowAS(openUrl, 'articleedit' + eventId + articleId, defaultDialogOptions + ',width=640,height=570', null, null);
	return document.MM_returnValue;
}
function openAnnouncementEditor(eventId, announceId)
{
	var openUrl = 'usr_event_announcement_edit.asp?eid=' + eventId + '&aid=' + announceId;
	openWindowAS(openUrl, 'announceedit' + eventId + announceId, defaultDialogOptions + ',width=640,height=400', null, null);
	return document.MM_returnValue;
}
function openAnnouncementDelete(eventId, announceId)
{
	var openUrl = 'usr_event_announcement_del.asp?eid=' + eventId + '&aid=' + announceId;
	openWindowAS(openUrl, 'announcedel' + announceId, defaultDialogOptions + ',width=600,height=400', null, null);
	return document.MM_returnValue;
}
function openArticleDelete(eventId, articleId)
{
	var openUrl = 'usr_event_article_del.asp?eid=' + eventId + '&aid=' + articleId;
	openWindowAS(openUrl, 'articledel' + articleId, defaultDialogOptions + ',width=600,height=400', null, null);
	return document.MM_returnValue;
}
function openFundraiserEditor(eventId, fundraiserId)
{
	var openUrl = 'usr_event_fundraiser_edit.asp?eid=' + eventId + '&fid=' + fundraiserId;
	openWindowAS(openUrl, 'fundraiseredit' + eventId + fundraiserId, defaultDialogOptions + ',width=670,height=610', null, null);
	return document.MM_returnValue;
}
function openDocumentNew(eventId, resourceType)
{
	var openUrl = 'usr_event_document_new.asp?eid=' + eventId + '&RTC=' + resourceType;
	openWindowAS(openUrl, 'docnew' + eventId + resourceType, defaultDialogOptions + ',width=620,height=350', null, null);
	return document.MM_returnValue;
}
function openDocumentEditor(documentId)
{
	var openUrl = 'usr_event_document_edit.asp?rid=' + documentId;
	openWindowAS(openUrl, 'documentedit' + documentId, defaultDialogOptions + ',width=620,height=350', null, null);
	return document.MM_returnValue;
}
function openDocumentDelete(documentId)
{
	var openUrl = 'usr_event_document_del.asp?rid=' + documentId;
	openWindowAS(openUrl, 'documentdel' + documentId, defaultDialogOptions + ',width=600,height=400', null, null);
	return document.MM_returnValue;
}
function openFundraiserDelete(eventId, fundraiserId)
{
	var openUrl = 'usr_event_fundraiser_del.asp?eid=' + eventId + '&fid=' + fundraiserId;
	openWindowAS(openUrl, 'fundraiserdel' + fundraiserId, defaultDialogOptions + ',width=600,height=400', null, null);
	return document.MM_returnValue;
}
function getUniqueUrl(originalUrl)
{
	var returnValue = originalUrl;
	if (returnValue != null)
	{
		var currentDate = new Date();
		if (returnValue.indexOf("?") > -1)
		{
			returnValue += "&d=" + currentDate.getMilliseconds();
		}
		else
		{
			returnValue += "?d=" + currentDate.getMilliseconds();
		}
	}
	return returnValue;
	
}
function attribute(name, value)
{
	var returnValue = "";	
	if (!isEmptyString(String(value), true))
	{
		returnValue = " " + name + "=\"" + value + "\"";
	}
	return returnValue;
}
function generateMailToHtml(mailAddress, tagId)
{
	var returnValue = "";
	if (!isEmptyString(mailAddress, true))
	{
		returnValue = generateAnchorHtml(mailAddress, "mailto:" + mailAddress, "", tagId)
	}
	return returnValue;
}
function generateAnchorHtml(innerText, href, hrefTarget, id)
{
	var anchorBegin = "";
	var anchorEnd = "";
	if (!isEmptyString(href, true))
	{
		anchorBegin += "<a" + attribute("href", href);
		if (!isEmptyString(hrefTarget, true))
		{
			anchorBegin += attribute("target", hrefTarget);
		} 
		anchorBegin += attribute("id", id) + attribute("name", id) + ">";
		anchorEnd += "</a>";		
	}
	return anchorBegin + innerText + anchorEnd;
}
function updateContent(doc, contentDivId, contentHtml)
{
	if (doc != null)
	{
		var contentDiv = doc.getElementById(contentDivId);
		if (contentDiv != null)
		{		
			contentDiv.innerHTML = contentHtml; 
		} 
	}
}
function generatePromoLinkHtml(linkText, linkUrl)
{
	var returnValue = "<table" + attribute("class", "PromoLinkText") + "><tr><td>";
	returnValue += generateAnchorHtml(linkText, linkUrl, "_blank", "");
	returnValue += "</td></tr></table>"
	return returnValue;
}
function generateMessageHtmlForFlash(halign, valign, src, tableWidth, tableHeight, cellWidth, cellHeight)
{
	var returnValue = "<table";
	if (tableWidth > -1) { returnValue += attribute("width", tableWidth); }
	if (tableHeight > -1) { returnValue += attribute("height", tableHeight); }
	returnValue += "><tr><td";	
	if (cellWidth > -1) { returnValue += attribute("width", cellWidth); }
	if (cellHeight > -1) { returnValue += attribute("height", cellHeight); }	
	returnValue += attribute("align", halign) +  attribute("valign", valign) + ">";
	returnValue += "<object" + attribute("classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000");	
	returnValue += attribute("codebase", "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0");
	returnValue += attribute("width", cellWidth) + attribute("height", cellHeight);
	returnValue += ">";
	returnValue += "<param" + attribute("name", "movie") + attribute("value", src) + ">";
	returnValue += "<param" + attribute("name", "quality") + attribute("value", "high") + ">";
	returnValue += "<embed" + attribute("name", "hdrflashembed") + attribute("src", src);
	returnValue += attribute("quality", "high") + attribute("pluginspage", "http://www.macromedia.com/go/getflashplayer");
	returnValue += attribute("type", "application/x-shockwave-flash");
	returnValue += attribute("width", cellWidth) + attribute("height", cellHeight);
	returnValue += "></embed></object>";
	returnValue += "</td></tr></table>";
	return returnValue;
}
function generateMessageHtmlForImage(halign, valign, src, href, hrefTarget, tableWidth, tableHeight, cellWidth, cellHeight, id)
{	
	var anchorBegin = "";
	var anchorEnd = "";	
	var imgTag = "<img" + attribute("src", src);	
	if (!isEmptyString(String(href), true))
	{		
		anchorBegin += "<a" + attribute("href", addHttpProtocol(href)) + attribute("target", hrefTarget) + ">";
		anchorEnd += "</a>";
		imgTag += attribute("border", "0");
	}
	imgTag += ">";
	var returnValue = "<table"; 
	if (tableWidth > -1) { returnValue += attribute("width", tableWidth); }
	if (tableHeight > -1) { returnValue += attribute("height", tableHeight); }
	returnValue += "><tr><td";
	if (cellWidth > -1) { returnValue += attribute("width", cellWidth); }
	if (cellHeight > -1) { returnValue += attribute("height", cellHeight); }	
	returnValue += attribute("align", halign) +  attribute("valign", valign) + ">"
	returnValue += anchorBegin + imgTag + anchorEnd;	
	returnValue += "</td></tr></table>";
	return returnValue;
}
function updateImageFlashContent(doc, divId, flashId, imageId, contentSrc, contentHref, contentHrefTarget, contentJustH, contentJustV, tableWidth, tableHeight, cellWidth, cellHeight)
{
	var contentHtml = "";
	if (flashId == '-1')
	{
		contentHtml =  generateMessageHtmlForImage(contentJustH, contentJustV, contentSrc, addHttpProtocol(contentHref), contentHrefTarget, tableWidth, tableHeight, cellWidth, cellHeight, '');
	}
	else
	{
		contentHtml =  generateMessageHtmlForFlash(contentJustH, contentJustV, contentSrc, tableWidth, tableHeight, cellWidth, cellHeight);
	}
	//alert('updateImageFlashContent : content=' + contentHtml);
	updateContent(doc, divId, contentHtml);
}
function fireOnClick(doc, elementId)
{
	//alert('fireOnClick : doc=' + doc + ' : elementId=' + elementId);
	if (doc != null && elementId != null)
	{
		var element = doc.getElementById(elementId);
		//alert('fireOnClick : element=' + element);
		if (element != null && element.onclick)
		{
			//alert('fireOnClick : element.onclick=' + element.onclick);
			element.onclick();
		}
	}
}
function mainTabClick(url)
{	
	window.document.location.href = url;	
}

function mainTabHilight2(cell, hilight)
{
	if (cell != null)
	{	
		alert (cell.selected);
		if (cell.selected != "1")
		{
			var nodes = cell.childNodes;
			if (nodes != null)
			{
				var i=0;
				for (i=0; i<nodes.length; i++)
				{
					var cNode = nodes[i];
					if (cNode.id == 'left')
					{
						cNode.className = (hilight ? 'mtabhoverleft' : 'mtableft');
					}
					if (cNode.id == 'back')
					{
						cNode.className = (hilight ? 'mtabhoverback' : 'mtabback');
					}
					if (cNode.id == 'right')
					{
						cNode.className = (hilight ? 'mtabhoverright' : 'mtabright');
					}
				}
			}	
		}
	}
}

function mainTabHilight(cell, hilight, selectedTabId)
{
	if (cell != null)
	{	
		if (cell.id != selectedTabId)
		{
			var nodes = cell.childNodes;
			if (nodes != null)
			{
				var i=0;
				for (i=0; i<nodes.length; i++)
				{
					var cNode = nodes[i];
					if (cNode.id == 'left')
					{
						cNode.className = (hilight ? 'mtabhoverleft' : 'mtableft');
					}
					if (cNode.id == 'back')
					{
						cNode.className = (hilight ? 'mtabhoverback' : 'mtabback');
					}
					if (cNode.id == 'right')
					{
						cNode.className = (hilight ? 'mtabhoverright' : 'mtabright');
					}
				}
			}	
		}
	}
}
function updateFrame(frameId, frameSrc)
{
	var targetFrame = document.getElementById(frameId);
	if (targetFrame)
	{		
		if (targetFrame.src)
		{
			targetFrame.src = frameSrc;
		}
	}
}
function hilightRowSelection(tableId, currentRow)
{
	var table = document.getElementById(tableId);		
	if (table != null && table.rows)
	{
		for( var x = 0; x < table.rows.length; x++ ) 
		{
			var row = table.rows[x];		
			if (row.onclick)
			{
				row.className = "";
			}
		}
		currentRow.className = "selected";
	}	
}
function openLibAdd()
{
	openWindowAS('usr_lib_add_title_start.asp', 'libadd', defaultDialogOptions + ',width=320,height=240', null, null);
	return document.MM_returnValue;
}

function openMsgAddToLibSelect(libraryId)
{
	var openUrl = 'usr_lib_add_msg_sel.asp?LIBID=' + libraryId;
	openWindowAS(openUrl, 'msgadd' + libraryId, defaultDialogOptions + ',width=640,height=480', null, null);
	return document.MM_returnValue;
}

function openLibDelete(libraryId)
{
	var openUrl = "usr_lib_del_start.asp?LIBID=" + libraryId;
	openWindowAS(openUrl, 'libdel', defaultDialogOptions + ',width=400,height=240', null, null);
	return document.MM_returnValue;
}

function openPlnchgConfirm(newPlanID, CPID )
{
	var openUrl = "usr_plnchg_confirm_pop.asp?NPID=" + newPlanID + "&CPID=" + CPID ;
	openWindowAS(openUrl, 'confirm', defaultDialogOptions + ',width=500,height=240', null, null);
	return document.MM_returnValue;
}

function openOverageChange(currentOverage)
{
	var openUrl = "usr_overage_confirm_pop.asp?over=" + currentOverage;
	openWindowAS(openUrl, 'overage', defaultDialogOptions + ',width=400,height=240', null, null);
	return document.MM_returnValue;
}

function openPlanCancel(action,currentPlan,newPlan)
{
	var openUrl = "usr_cancel_confirm.asp?frm_ActionId=" + action + "&frm_CurPlanID=" + currentPlan + "&frm_NewPlanID=" + newPlan;
	openWindowAS(openUrl, 'cancel', defaultDialogOptions + ',width=400,height=240', null, null);
	return document.MM_returnValue;
}

function openLibEditor(libraryId)
{
	var openUrl = "usr_library_edit.asp?LID=" + libraryId;
	openWindowAS(openUrl, 'libedit' + libraryId, defaultDialogOptions + ',width=600,height=600', null, null); 
	return document.MM_returnValue;
}

function openMsgRemoveConfirm(libraryId, messageid)
{
	var openUrl = 'usr_message_remove_confirm.asp?LIBID=' + libraryId + '&MSGID=' + messageid;
	openWindowAS(openUrl, 'msgcopy' + messageid, defaultDialogOptions + ',width=640,height=480', null, null);
	return document.MM_returnValue;
}
function openThemeShare(themeId)
{
	var openUrl = 'usr_theme_share.asp?THMID=' + themeId;
	openWindowAS(openUrl, 'themeshare' + themeId, defaultDialogOptions + ',width=530,height=360', null, null);
	return document.MM_returnValue;
}
function openThemeFullSize(pageUrl)
{
	openWindowAS(pageUrl + '&SF=1', 'themefullpreview', defaultDialogOptions + ',width=710,height=580,resizable', null, null);	
}
function openContentFullSize(contentUrl, width, height)
{
	openWindowAS(contentUrl, 'contentfullpreview', defaultDialogOptions + ',width=' + width +',height=' + height + ',resizable', null, null);
}

function copyTheme(themeId)
{
	var windowUrl = "usr_theme_add.asp?STHMID=" + themeId;
	openWindowAS(windowUrl, 'copytheme' + themeId, defaultDialogOptions + ',width=465,height=500', null, null);
}
function openThemeEditor(themeEditPage, themeId)
{
	var openUrl = themeEditPage + '?THMID=' + themeId ;
	openWindowAS(openUrl, 'thmedit' + themeId, defaultDialogOptions + ',width=950,height=580', null, null);
	return document.MM_returnValue;
}
function openThemeDelete(themeId)
{
	var openUrl = 'usr_theme_del.asp?THMID=' + themeId ;
	openWindowAS(openUrl, 'thmdel' + themeId, defaultDialogOptions + ',width=530,height=220', null, null);
	return document.MM_returnValue;
}
function openContactEdit(contactId)
{
	var openUrl = 'usr_content_mgmt_contact_edit.asp?CID=' + contactId;
	openWindowAS(openUrl, 'contactedit' + contactId, defaultDialogOptions + ',width=630,height=460', null, null);
	return document.MM_returnValue;
}
function openContactDelete(contactId)
{
	var openUrl = 'usr_content_mgmt_contact_del.asp?CID=' + contactId;
	openWindowAS(openUrl, 'contactdel' + contactId, defaultDialogOptions + ',width=630,height=460', null, null);
	return document.MM_returnValue;
}
function setupDelayedRefresh(fn, millis)
{
	if (!millis) {millis = 100; }
	self.setTimeout(fn, millis);	
}
function unloadRefreshParent(delay)
{
	var isCloseField = document.getElementById('frm_IsWindowClose');
	//alert ('isCloseField.value = ' + isCloseField.value);
	if (isCloseField.value == "1")
	{
		refreshParent(10);
	}
}
function closeRefreshParent(delay)
{
	triggerParentRefresh(window.opener, delay);	
	self.close();
}
function closeSelf()
{
	self.close();
}
function closeSelfWithDelay(delay)
{
	self.setTimeout("closeSelf();", delay);	
}
function refreshParentUnconditional(delay)
{
	triggerParentRefresh(window.opener, delay)
}
function refreshParent(delay)
{
	var refreshParentField = document.getElementById('asRefreshParent');
	if (refreshParentField && refreshParentField.value == '1')
	{
		triggerParentRefresh(window.opener, delay)
	}
}
function refreshTop(delay)
{
	triggerParentRefresh(top, delay);
}
function setParentRefresh(enabled)
{
	var refreshParentField = document.getElementById('asRefreshParent');
	if (refreshParentField)
	{
		if (refreshParentField.value == "" && enabled)
		{
			refreshParentField.value = "1";
		}
	}
}
function triggerParentRefresh(docopener, millis)
{
	//alert ('docopener=' + docopener);
	if (docopener && docopener.document)
	{
		var trigger = docopener.document.getElementById('asRefresh');
		//alert('trigger = ' + trigger);
		if (trigger)
		{
			trigger.value = millis;
			//alert('trigger.value = ' + trigger.value + ' : trigger.onclick = ' + trigger.onclick);
			if (trigger.onclick)
			{				
				trigger.onclick();
			}
		}		
		else
		{
			//alert ('docopener.parent=' + docopener.parent);
			if (docopener.parent && docopener.parent != docopener)
			{				
				triggerParentRefresh(docopener.parent, millis);
			}
		}
	}
}
function showProgress(progressDivId, message, imageSrc, imageId)
{
	var progressDiv = document.getElementById(progressDivId);
	if (progressDiv)
	{		
		var html = '<table width="100%" height="100%" border="0">';
		html += '<tr valign="center"><td align="center">';
		html += '<table cellpadding="10" width="80%"><tr><td align="center">' + message + '</td></tr>';		
		html += '<tr><td align="center"><img id=' + imageId + ' src="" border="0"></td></tr>';
		html += '</table></td></tr></table>';	
		progressDiv.innerHTML = html;
		progressDiv.style.display = 'block';								
	}	
	setTimeout('document.images["' + imageId + '"].src = "' + imageSrc + '"', 100); 
}
function showProgress2(form, progressOn, progressDivId, message, imageSrc, imageId)
{
	if (form != null) {	document.form1.style.display = progressOn ? 'none' : 'block'; }
	var progressDiv = document.getElementById(progressDivId);
	if (progressDiv)
	{		
		if (progressOn)
		{
			var html = '<table width="100%" height="100%" border="0">';
			html += '<tr valign="center"><td align="center">';
			html += '<table cellpadding="10" width="80%"><tr><td align="center">' + message + '</td></tr>';		
			html += '<tr><td align="center">Depending on upload file size and your connection speed, the time to complete the can vary.  Please allow ample time for the upload to complete.</td></tr>'
			html += '<tr><td align="center"><img id=' + imageId + ' src="" border="0"></td></tr>';
			html += '</table></td></tr></table>';				
			progressDiv.innerHTML = html;
			progressDiv.style.display = 'block';
		}
		else
		{
			progressDiv.style.display = 'none';
		}				
	}	
	setTimeout('document.images["' + imageId + '"].src = "' + imageSrc + '"', 100); 
}
function updateRowSelection(tableId, currentRow, selectedId)
{
	var table = document.getElementById(tableId);		
	if (table != null && table.rows)
	{
		for( var x = 0; x < table.rows.length; x++ ) 
		{
			var row = table.rows[x];			
			if (row.onclick)
			{
				row.className = "";			
			}
		}
		currentRow.className = "selected";		
		var selectedIdField = document.getElementById('selectedId');		
		if (selectedIdField)
		{			
			selectedIdField.value = selectedId;
		}
	}	
}
function navigate(formId, validate, showMessage, offset)
{
	var indexField = document.getElementById('offset');	
	if (indexField)
	{
		indexField.value = offset;
	}	
	submitForm(formId, validate, showMessage);
}
function resort(formId, validate, showMessage, isort)
{
	var srchSortField = document.getElementById('sortorder');	
	if (srchSortField)
	{
		srchSortField.value = isort;
	}	
	submitForm(formId, validate, showMessage);
}
function submitForm(formId, validate, showMessage)
{
	//alert('formId=' + formId + ',validate='+ validate + ',showMessage=' + showMessage);
	if (validate)
	{		
		if (validateForm(document.forms[formId], showMessage))
		{
			document.forms[formId].submit();
		}
	}
	else
	{
		document.forms[formId].submit();
	}	
}
function sortSearch(formId, validate, showMessage)
{	
	submitForm(formId, validate, showMessage);
}

function createXMLHttpRequest()
{
	var returnValue = null;
	if (window.ActiveXObject && !window.XMLHttpRequest)
	{
		var msxmls = new Array('Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP');
		for (var i = 0; i < msxmls.length; i++) 
		{
		  try {	returnValue =  new ActiveXObject(msxmls[i]); } catch (e) {}
		}
	}
	else
	{
		try { returnValue =  new XMLHttpRequest(); } catch(e) {}
	}
	return returnValue;
}

var checkSessionRequest = createXMLHttpRequest();

function checkSession()
{	
	if (checkSessionRequest)
	{				
		try
		{
			checkSessionRequest.open("POST", "usr_session.asp");
			checkSessionRequest.send("");	
		}
		catch (e)
		{
			//alert('error' + e.message);
		}
	}
}

function setupCheckSession()
{
		window.setInterval('checkSession();', 60000 * 30);
}

function siteNavigate(url)
{		
	top.location.href = url;
}

function trackCharacterCount(field, maxlen)
{
	var teststring = field.value;
	var actlen = teststring.length;
	if( actlen > maxlen )
	{
		alert('The limit of ' + maxlen + ' characters has been reached.');
		teststring = teststring.substring(0,maxlen);
		var currentCharCode = teststring.charCodeAt(maxlen);
		if (currentCharCode ==10)
			teststring = teststring.substring(0,maxlen-1);
		actlen = teststring.length;
		field.value = teststring;
	}

	remlen = maxlen - actlen;
	msgField = field.name + '_cc';
	var feedbackField = document.getElementById(msgField);
	if(feedbackField != null)
	{
		feedbackField.innerHTML = remlen + ' of ' + maxlen + ' characters left';
	}
}

function getWindowInnerDimensions()
{
	var returnValue = null;
	try
	{
		if (window.innerWidth)
		{
			returnValue = new Object();
			returnValue.Width = window.innerWidth;
			returnValue.Height = window.innerHeight;
		}
		else if (document.body.parentNode.clientWidth)
		{
			returnValue = new Object();
			returnValue.Width = document.body.parentNode.clientWidth;
			returnValue.Height = document.body.parentNode.clientHeight;			
		}
		/*else if (document.body.offsetWidth)
		{
			returnValue = new Object();
			returnValue.Width = document.body.offsetWidth;
			returnValue.Height =document.body.offsetHeight;
		}*/
	}
	catch (err)
	{
		
	}
	return returnValue;
}
function fitWindow(x, y, maxX, maxY)
{
	var dimensions = getWindowInnerDimensions();	
	if (dimensions)
	{
		var width = x - dimensions.Width;
		var height = y - dimensions.Height;
		window.resizeBy(width, height);
	}		
	else
	{
		window.resizeTo(maxX, maxY);
	}	
}

