  // detects if things have changed in the Telerik editor box
 var bTelerikChanged=false;
 function SelectionChanged(editor)
  {
   editor.AttachEventHandler ("RADEVENT_SEL_CHANGED",
   function (e)
   {    
    bTelerikChanged=true;
   }
   );
  }
  // detects if things have changed in a form element (other than Telerik)
  // so that the user can be warned to save their data
  //(Javascript is modified from http://www.codeproject.com/aspnet/EWSWebPt2.asp)
function isDirty()
{
	var bChanged=false;
	if (bTelerikChanged)
	{ 
		bChanged=true;
	}
	// assumes that the form is named "Form1"

	var oForm = document.getElementById("Form1");
	var nElemCnt = oForm.elements.length;
	
	var oElem;
	for(nIdx = 0; !bChanged && nIdx < nElemCnt; nIdx++)
	{
		oElem = oForm.elements[nIdx];

		// Check for changes based on the control type
		if(oElem.type == "text" || oElem.tagName == "TEXTAREA")
		{
			
			if(oElem.value != oElem.defaultValue)
			{
				if (oElem.id.indexOf("Rad") == -1) // avoid checking RAD control, it always thinks it is changed
				{
					bChanged = true;
				}
			}
		}
		else
			if(oElem.type == "checkbox" || oElem.type == "radio")
			{
				if(oElem.checked != oElem.defaultChecked)
				bChanged = true;
			}
			else
				if(oElem.tagName == "SELECT")
				{
					oOptions = oElem.options;
					nNumOpts = oOptions.length;
					nDefSelIdx = nSelIdx = 0;

					// Search for a change in the default.  If nothing is
					// explicitly marked as the default, element zero is
					// assumed to have been the default.
					for(nOptIdx = 0; nOptIdx < nNumOpts; nOptIdx++)
					{
						oOpt = oOptions[nOptIdx];

						if(oOpt.defaultSelected)
						nDefSelIdx = nOptIdx;

						if(oOpt.selected)
						nSelIdx = nOptIdx;
					}

					if(nDefSelIdx != nSelIdx)
					bChanged = true;
				}
			}
			if (bChanged)
			{
			var a = document.getElementsByTagName("div");
			if (a.length==0)
			{
				a = document.getElementsByTagName("table");//some browsers render panels as tables
			} 
				for (var i=0; i< a.length; i++)
				{
					var s = a[i];
					if ( s)
					{
						if (s.id.substring(0,6)=='pnlWiz')
						{
							// we have the panel, put its name into the text box
							for(nIdx = 0; nIdx < nElemCnt; nIdx++)
							{
								oElem = oForm.elements[nIdx];
								if (oElem.name=='txtIsDirty')
								{
									oElem.value=s.id ; //put name of panel into txtIsDirty 
									break;
								}
							}
							break;
						}
					}
					
				}
				/*
				if ( confirm('Do you want to save your data before leaving this page?\n(Hit Cancel, then click Save to save your data, or Hit OK to continue without saving)'))
				{
				return true; // they want to continue without saving
				}  else
				{
				// do something to save
					return false;
				}
				*/
				return true;
			}
	}
function enrichOpen(resource_id) {
var wEnrich = null;
var url="PreviewResource.aspx?resource_id="+resource_id;
wEnrich = window.open(url,"enrichWindow","toolbar=yes,location=yes,directories=no, status=no,scrollbars=yes, resizable=yes,copyhistory=no, width=640, height=500");
}

			function winopen(url) {
			var popup = null;
			popup = window.open(url,"PopupWindow","toolbar=yes,location=no,directories=no, status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=650,height=650");
			}

			window.onerror=null
			
	