
function checkEnter(e) //, submitButton
{ 
	//e is event object passed from function invocation
	//submitButton is supposed to be the default button that should be simulated as pressed 
	//   when the Enter key is pressed. This doesn't currently work. Not sure why. Relies on
	//   the postback handling of the asp.net form system.

	var characterCode  //literal character code will be stored in this variable

	if (e && e.which) //NN4
	{
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	}
	else //IE4
	{							
		e = event						
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}
		
		
	if(characterCode == 13) //enter key
	{
		//document.forms[0].submit() //submit the form
		//__doPostBack(submitButton, "")
		return false 
	}
	else
	{
		return true 
	}
}


function checkCharacterTotal(sTextBox, lblCount, iMaxLength) //(multiline textbox, Current label count, multiline textbox maxlength)
{
	var oTextBox = document.getElementById(sTextBox);
	var olblCount = document.getElementById(lblCount);

	if (olblCount)
	{
		//if (lblCount > iMaxLength)
		if (oTextBox.value.length >= iMaxLength)
		{
			olblCount.innerHTML = iMaxLength - (oTextBox.value.length - 1);
			oTextBox.value = oTextBox.value.substring(0, iMaxLength);	
		}
		else
		{
			olblCount.innerHTML = iMaxLength - oTextBox.value.length;
		}	
	}		
}

function openWindow (sURL, iWidth, iHeight, sChrome) {

	// Open a window, centered onscreen. 
	// If available, retrieve the actual screen dimensions; otherwise, assume a default.

	// Chrome samples: menubar, resizable, scrollbars, status, toolbar
	
	var sWindowAttributes;
	var newWindow;
	var iTop;
	var iLeft;
	var sWindowName;
		
	// default screen dimensions...
	var iScreenWidth  = 320; 
	var iScreenHeight = 320;
		
	if ( window.screen ) {
		// IE4+ and NS4+ provide actual screen dimensions...
		iScreenWidth  = window.screen.width;  
		iScreenHeight = window.screen.height;
	}

	// Determine proper location of the new window
	iTop  = ( iScreenHeight / 2 ) -  ( iHeight / 2 );
	iLeft = ( iScreenWidth / 2 )  -  ( iWidth / 2 );
		
	sWindowAttributes = sChrome + ', resizable, ' + 
						'top=' + iTop + ',' + 
						'left=' + iLeft + ',' +
						'width=' + iWidth + ',' +
						'height=' + iHeight;
		
	sWindowName = new Date();
	sWindowName = sWindowName.getMilliseconds();
	sWindowName = sWindowName.toString();
	newWindow = window.open(sURL, sWindowName, sWindowAttributes);
	//newWindow.focus();
}


function openModal(sURL, sTitle, iWidth, iHeight, args, bScrolling) //sAdditionalAttributes
{
	var sAdditionalAttributes = 'status:no; scroll:off; center:yes; help:no; minimize:no; maximize:no; border:thin; statusbar:no; unadorned:yes; edge:raised;';
	var frameUrl = "/CRG/Admin/Global/ModalDialog.aspx?url=" + escape(sURL) + "&title=" + escape(sTitle) + "&scroll=" + ((bScrolling) ? "yes" : "no"); 
	var retVal = self.showModalDialog (frameUrl, args, 'dialogWidth:' + iWidth + 'px; ' + 'dialogHeight:' + iHeight + 'px; ' + sAdditionalAttributes);   
	return retVal;
}

function toggleCheckboxes(searchGroupID, bChecked) {
	oaElements = document.forms[0].elements

	for( i=0 ; i<oaElements.length; i++ ) 
	{
		elem = oaElements[i];

		if (!elem.disabled && elem.name.indexOf(searchGroupID) != -1 && elem.type == "checkbox") 
		{
			elem.checked = bChecked;
		}
	}
}

function showImageEditorDialog(RadEditorContentArea, editorID)
{
	//alert(editorID == null);
	var result = radEditorShowDialog(editorID, "/CRG/Admin/Content/ImageDisplay/DialogContainer.htm", null, 500, 600);
	//alert(result == null);
	
	if (result != null)
	{
		//Making the r.a.d.editor content area active.
		RadEditorContentArea.setActive();
		var range = document.selection.createRange();
		//Here we paste the HTML generated by the Custom Dialog.
		result = "<img src=\"/CRG/Content/Global/ShowImage.aspx?file=" + result + "&type=full\">";
		range.pasteHTML(result);
	}
}















