<!--
// ** $Id: fnCMSJavascript.js $

function fnCMSdisplayCalendarSelectBox(yearInput,monthInput,dayInput,hourInput,minuteInput,buttonObj) {

var myForm, myYear, myMonth, myDay;

	myForm=document.forms[document.forms.length - 1];

	myYear  = myForm.elements[yearInput];
	myMonth = myForm.elements[monthInput];
	myDay   = myForm.elements[dayInput]

	displayCalendarSelectBox(myYear,myMonth,myDay,hourInput,minuteInput,buttonObj);

	return true;
}


// *** FRONT END AND MENU ***

function highlight(tr,mode){
	if (mode=='1') {
		tr.style.cursor="hand";
		tr.style.backgroundColor="#CCCCDD";
	} else if (mode=='0') { // out
		tr.style.cursor="";
		tr.style.backgroundColor="";
	} else {
		window.location = mode;
	}
	
}

// *** Edit Entity

var askToUnload = false;
window.onbeforeunload= bunload;

function bunload() {

   if ( askToUnload ) {
	askToUnload = false;
	return "*** YOUR CHANGES WILL BE LOST!!! ***";
   }
}

function fnWindowConfirm(theMsg) { 
  return window.confirm(theMsg);
}

var	doCheck = true;


// ******* FIELD VALIDATIONS ****

var reWhitespace = /^\s+$/
var reLetter = /^[a-zA-Z]$/
var reAlphabetic = /^[a-zA-Z]+$/
var reAlphanumeric = /^[a-zA-Z0-9]+$/
var reDigit = /^\d/
var reLetterOrDigit = /^([a-zA-Z]|\d)$/
var reInteger = /^\d+$/
var reSignedInteger = /^(\+|\-)?\d+$/
var reFloat = /^((\d+(\.\d*)?)|((\d*\.)?\d+))$/
var reSignedFloat = /^(((\+|\-)?\d+(\.\d*)?)|((\+|\-)?(\d*\.)?\d+))$/
var reEmail = /^.+\@.+\..+$/
var digits = "0123456789";
var lowercaseLetters = "abcdefghijklmnopqrstuvwxyz"
var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var whitespace = " \t\n\r";
var phoneNumberDelimiters = "()- ";
var validUSPhoneChars = digits + phoneNumberDelimiters;
var validWorldPhoneChars = digits + phoneNumberDelimiters + "+";
var SSNDelimiters = "- ";
var validSSNChars = digits + SSNDelimiters;
var digitsInSocialSecurityNumber = 9;
var digitsInUSPhoneNumber = 10;
var ZIPCodeDelimiters = "-";
var ZIPCodeDelimeter = "-"
var validZIPCodeChars = digits + ZIPCodeDelimiters
var digitsInZIPCode1 = 5
var digitsInZIPCode2 = 9
var creditCardDelimiters = " "
var mPrefix = "You did not enter a value into the "
var mSuffix = " field. This is a required field. Please enter it now."
var sUSLastName = "Last Name"
var sUSFirstName = "First Name"
var sWorldLastName = "Family Name"
var sWorldFirstName = "Given Name"
var sTitle = "Title"
var sCompanyName = "Company Name"
var sCity = "City"
var sDateOfBirth = "Date of Birth"
var sExpirationDate = "Expiration Date"
var sEmail = "Email"
var sOtherInfo = "Other Information"
var iEmail = "This field must be a valid email address (like foo@bar.com). Please reenter it now."
var iDay = "This field must be a day number between 1 and 31.  Please reenter it now."
var iMonth = "This field must be a month number between 1 and 12.  Please reenter it now."
var iYear = "This field must be a 2 or 4 digit year number.  Please reenter it now."
var iDatePrefix = "The Day, Month, and Year for "
var iDateSuffix = " do not form a valid date.  Please reenter them now."
var pEntryPrompt = "Please enter a "
var pEmail = "valid email address (like foo@bar.com)."
var pDay = "day number between 1 and 31."
var pMonth = "month number between 1 and 12."
var pYear = "2 or 4 digit year number."
var defaultEmptyOK = false

function makeArray(n) {
//*** BUG: If I put this line in, I get two error messages:
//(1) Window.length can't be set by assignment
//(2) daysInMonth has no property indexed by 4
//If I leave it out, the code works fine.
   for (var i = 1; i <= n; i++) {
      this[i] = 0
   } 
   return this
}

var daysInMonth = makeArray(12);
daysInMonth[1] = 31;
daysInMonth[2] = 29;   
daysInMonth[3] = 31;
daysInMonth[4] = 30;
daysInMonth[5] = 31;
daysInMonth[6] = 30;
daysInMonth[7] = 31;
daysInMonth[8] = 31;
daysInMonth[9] = 30;
daysInMonth[10] = 31;
daysInMonth[11] = 30;
daysInMonth[12] = 31;


function isEmpty(s)
{   
//HACK
//return false;

return ((s.value == null) || (s.value.length == 0))
}

function isWhitespace (s)
{       return (isEmpty(s) || reWhitespace.test(s));
}

function stripCharsInRE (s, bag)
{       return s.replace(bag, "")
}

function stripCharsInBag (s, bag)
{   var i;
    var returnString = "";

        
    for (i = 0; i < s.length; i++)
    {   
                var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}

function stripCharsNotInBag (s, bag)
{   var i;
    var returnString = "";
     
    for (i = 0; i < s.length; i++)
    {   
                var c = s.charAt(i);
        if (bag.indexOf(c) != -1) returnString += c;
    }

    return returnString;
}

function stripWhitespace (s)
{   return stripCharsInBag (s, whitespace)
}

function charInString (c, s)
{   for (i = 0; i < s.length; i++)
    {   if (s.charAt(i) == c) return true;
    }
    return false
}

function stripInitialWhitespace (s)
{   var i = 0;
    while ((i < s.length) && charInString (s.charAt(i), whitespace))
       i++;
    return s.substring (i, s.length);
}

function isLetter (c)
{   return reLetter.test(c)
}

function isDigit (c)
{   return reDigit.test(c)
}


function isLetterOrDigit (c)
{   return reLetterOrDigit.test(c)
}

function isInteger (s)
{   var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);
    return reInteger.test(s)
}

function isSignedInteger (s)
{   if (isEmpty(s)) 
       if (isSignedInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedInteger.arguments[1] == true);
    else {
       return reSignedInteger.test(s)
    }
}

function isPositiveInteger (s)
{   var secondArg = defaultEmptyOK;
    if (isPositiveInteger.arguments.length > 1)
        secondArg = isPositiveInteger.arguments[1];
    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) > 0) ) );
}


function isNonnegativeInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNonnegativeInteger.arguments.length > 1)
        secondArg = isNonnegativeInteger.arguments[1];
    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) >= 0) ) );
}

function isNegativeInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNegativeInteger.arguments.length > 1)
        secondArg = isNegativeInteger.arguments[1];
    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) < 0) ) );
}

function isNonpositiveInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNonpositiveInteger.arguments.length > 1)
        secondArg = isNonpositiveInteger.arguments[1];
    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) <= 0) ) );
}

function isFloat (s)

{   if (isEmpty(s)) 
       if (isFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isFloat.arguments[1] == true);
    return reFloat.test(s)
}

function isSignedFloat (s)

{   if (isEmpty(s)) 
       if (isSignedFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedFloat.arguments[1] == true);
    else {
       return reSignedFloat.test(s)
    }
}

function isAlphabetic (s)

{   var i;
    if (isEmpty(s)) 
       if (isAlphabetic.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphabetic.arguments[1] == true);
    else {
       return reAlphabetic.test(s)
    }
}

function isAlphanumeric (s)

{   var i;

    if (isEmpty(s)) 
       if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphanumeric.arguments[1] == true);
    else {
       return reAlphanumeric.test(s)
    }
}

function reformat (s)

{   var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}


function isEmail (s)

{   if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);
    
    else {
       return reEmail.test(s)
    }
}

function isYear (s)
{   if (isEmpty(s)) 
       if (isYear.arguments.length == 1) return defaultEmptyOK;
       else return (isYear.arguments[1] == true);
    if (!isNonnegativeInteger(s)) return false;
    return ((s.length == 2) || (s.length == 4));
}


function isIntegerInRange (s, a, b)
{   if (isEmpty(s)) 
       if (isIntegerInRange.arguments.length == 1) return defaultEmptyOK;
       else return (isIntegerInRange.arguments[1] == true);

            if (!isInteger(s, false)) return false;

                    var num = parseInt (s);
    return ((num >= a) && (num <= b));
}


function isMonth (s)
{   if (isEmpty(s)) 
       if (isMonth.arguments.length == 1) return defaultEmptyOK;
       else return (isMonth.arguments[1] == true);
    return isIntegerInRange (s, 1, 12);
}

function isDay (s)
{ 
	if (isEmpty(s)) 
		if (isDay.arguments.length == 1) return defaultEmptyOK;
			else return (isDay.arguments[1] == true);  

    return isIntegerInRange (s, 1, 31);
}

function daysInFebruary (year)
{           return (  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
}

function isDate (year, month, day)
{       if (! (isYear(year, false) && isMonth(month, false) && isDay(day, false))) return false;

            var intYear = parseInt(year);
	    var intMonth = parseInt(month);
	    var intDay = parseInt(day);

        if (intDay > daysInMonth[intMonth]) return false; 

    if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return false;

    return true;
}

function prompt (s)
{   window.status = s
}

function promptEntry (s)
{   window.status = pEntryPrompt + s
}

function warnEmpty (theField, s)
{   theField.focus()
    alert(mPrefix + s + mSuffix)
    return false
}

function warnInvalid (theField, s)
{   theField.focus()
    theField.select()
    alert(s)
    return false
}

function checkString (theField, s, emptyOK)
{           if (checkString.arguments.length == 2) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    if (isWhitespace(theField.value)) 
       return warnEmpty (theField, s);
    else return true;
}


function checkEmail (theField, emptyOK)
{   if (checkEmail.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else if (!isEmail(theField.value, false)) 
       return warnInvalid (theField, iEmail);
    else return true;
}


function checkYear (theField, emptyOK)
{   if (checkYear.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    if (!isYear(theField.value, false)) 
       return warnInvalid (theField, iYear);
    else return true;
}

function checkMonth (theField, emptyOK)
{   if (checkMonth.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    if (!isMonth(theField.value, false)) 
       return warnInvalid (theField, iMonth);
    else return true;
}

function checkDay (theField, emptyOK)
{   if (checkDay.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    if (!isDay(theField.value, false)) 
       return warnInvalid (theField, iDay);
    else return true;
}

function checkDate (yearField, monthField, dayField, labelString, OKtoOmitDay)
{           if (checkDate.arguments.length == 4) OKtoOmitDay = false;
    if (!isYear(yearField.value)) return warnInvalid (yearField, iYear);
    if (!isMonth(monthField.value)) return warnInvalid (monthField, iMonth);
    if ( (OKtoOmitDay == true) && isEmpty(dayField.value) ) return true;
    else if (!isDay(dayField.value)) 
       return warnInvalid (dayField, iDay);
    if (isDate (yearField.value, monthField.value, dayField.value))
       return true;
    alert (iDatePrefix + labelString + iDateSuffix)
    return false
}

function isFGDCDate (s) {

    if ( s.value.length < 10 ) return false;

    if ( s.value.substring(4,5) != "/" || s.value.substring(7,8) != "/" ) return false;

    var year  = s.value.substring(0,4);
    var month = s.value.substring(5,7);
    var day   = s.value.substring(8,10);

	if ( isNaN(year) || isNaN(month) || isNaN(day) ) return false;

	if ( month.substring(0,1) == "0" ) { month = month.substring(1,2) };
	if ( day.substring(0,1) == "0"   ) { day = day.substring(1,2) };

     var intYear  = parseInt(year);
     var intMonth = parseInt(month);
     var intDay   = parseInt(day);

    if (intYear < 1 || intYear > 2999) return false; 

    if (intDay < 1 || intDay > daysInMonth[intMonth]) return false; 

    if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return false;

    if ( s.value.length > 10 ) {

	    if ( s.value.substring(10,11) != " " ) return false;

	    var theHour  = parseInt(s.value.substring(11,13));
	    var theMinute = parseInt(s.value.substring(14,16));

		//alert(theHour + ':' + theMinute);

		 if (theHour < 0 || theHour > 23) return false; 
		 if (theMinute < 0 || theMinute > 59) return false; 

		 if ( s.value.substring(13,14) != ":" ) return false;
     } 

    if ( s.value.length > 16 ) return false;

    return true;
}

function isSelected (s) {

var x = s.selectedIndex;

	if (x >= 0 )
		if ( s.options[x].text != "" ) {
			// an non-blank option is selected
			return true;
		} else {
			return false;
		}
	else	
		// no option is selected
		return false;
}


// ******* DHTML EDIT ****


//Constants.
SEP_PADDING = 5
HANDLE_PADDING = 7

var yToolbars = new Array();  // Array of all toolbars.

var oW, oH, oL, oT;

var maxzindex = 5;

// Initialize everything when the document is ready
var YInitialized = false;


// Initialize a toolbar button
// Its preety easy to understand.
function InitBtn(btn) {
  btn.onmouseover = BtnMouseOver;
  btn.onmouseout = BtnMouseOut;
  btn.onmousedown = BtnMouseDown;
  btn.onmouseup = BtnMouseUp;
  btn.ondragstart = YCancelEvent;
  btn.onselectstart = YCancelEvent;
  btn.onselect = YCancelEvent;
  btn.YUSERONCLICK = btn.onclick;
  btn.onclick = YCancelEvent;
  btn.YINITIALIZED = true;
  return true;
}

//Initialize a toolbar. 
function InitTB(y) {
  // Set initial size of toolbar to that of the handle
  y.TBWidth = 0;
    
  // Populate the toolbar with its contents
  if (! PopulateTB(y)) return false;
  
  // Set the toolbar width and put in the handle
  y.style.posWidth = y.TBWidth;
  
  return true;
}


// Hander that simply cancels an event
function YCancelEvent() {
  event.returnValue=false;
  event.cancelBubble=true;
  return false;
}

// Toolbar button onmouseover handler
function BtnMouseOver() {

  if (event.srcElement.tagName != "IMG") return false;
  var image = event.srcElement;
  var element = image.parentElement;
  
  // Change button look based on current state of image.
  if (image.className == "Ico") element.className = "BtnMouseOverUp";
  else if (image.className == "IcoDown") element.className = "BtnMouseOverDown";

  event.cancelBubble = true;
}

// Toolbar button onmouseout handler
function BtnMouseOut() {

  if (event.srcElement.tagName != "IMG") {
    event.cancelBubble = true;
    return false;
  }

  var image = event.srcElement;
  var element = image.parentElement;
  yRaisedElement = null;
  
  element.className = "Btn";
  image.className = "Ico";

  event.cancelBubble = true;
}

// Toolbar button onmousedown handler
function BtnMouseDown() {
  if (event.srcElement.tagName != "IMG") {
    event.cancelBubble = true;
    event.returnValue=false;
    return false;
  }

  var image = event.srcElement;
  var element = image.parentElement;

  element.className = "BtnMouseOverDown";
  image.className = "IcoDown";

  event.cancelBubble = true;
  event.returnValue=false;
  return false;
}

// Toolbar button onmouseup handler
function BtnMouseUp() {
  if (event.srcElement.tagName != "IMG") {
    event.cancelBubble = true;
    return false;
  }

  var image = event.srcElement;
  var element = image.parentElement;

  if (element.YUSERONCLICK) eval(element.YUSERONCLICK + "anonymous()");

  element.className = "BtnMouseOverUp";
  image.className = "Ico";

  event.cancelBubble = true;
  return false;
}

// Populate a toolbar with the elements within it
function PopulateTB(y) {
  var i, elements, element;

  // Iterate through all the top-level elements in the toolbar
  elements = y.children;
  for (i=0; i<elements.length; i++) {
    element = elements[i];
    if (element.tagName == "SCRIPT" || element.tagName == "!") continue;
    
    switch (element.className) {
    case "Btn":
      if (element.YINITIALIZED == null) {
	if (! InitBtn(element)) {
	  alert("Problem initializing:" + element.id);
	  return false;
	}
      }
      
      element.style.posLeft = y.TBWidth;
      y.TBWidth += element.offsetWidth + 1;
      break;
      
    case "TBGen":
      element.style.posLeft = y.TBWidth;
      y.TBWidth += element.offsetWidth + 1;
      break;
      
    case "TBSep":
      element.style.posLeft = y.TBWidth + 2;
      y.TBWidth += SEP_PADDING;
      break;
      
    case "TBHandle":
      element.style.posLeft = 2;
      y.TBWidth += element.offsetWidth + HANDLE_PADDING;
      break;
      
    default:
      alert("Invalid class: " + element.className + " on Element: " + element.id + " <" + element.tagName + ">");
      return false;
    }
  }

  y.TBWidth += 1;
  return true;
}

function DebugObject(obj) {
  var msg = "";
  for (var i in TB) {
    ans=prompt(i+"="+TB[i]+"\n");
    if (! ans) break;
  }
}

// Lay out the docked toolbars
function LayoutTBs(mytext) {
  NumTBs = yToolbars.length;

  // If no toolbars we're outta here
  if (NumTBs == 0) return;

  //Get the total size of a TBline.
  var i;
  var ScrWid = (mytext.document.body.offsetWidth) - 6;
  var TotalLen = ScrWid;
  for (i = 0 ; i < NumTBs ; i++) {
    TB = yToolbars[i];
    if (TB.TBWidth > TotalLen) TotalLen = TB.TBWidth;
  }

  var PrevTB;
  var LastStart = 0;
  var RelTop = 0;
  var LastWid, CurrWid;

  //Set up the first toolbar.
  var TB = yToolbars[0];
  TB.style.posTop = 0;
  TB.style.posLeft = 0;

  //Lay out the other toolbars.
  var Start = TB.TBWidth;
  for (i = 1 ; i < yToolbars.length ; i++) {
    PrevTB = TB;
    TB = yToolbars[i];
    CurrWid = TB.TBWidth;

    if ((Start + CurrWid) > ScrWid) { 
      //TB needs to go on next line.
      Start = 0;
      LastWid = TotalLen - LastStart;
    } 
    else { 
      //Ok on this line.
      LastWid = PrevTB.TBWidth;
      //RelTop -= TB.style.posHeight;
      RelTop -= TB.offsetHeight;
    }
      
    //Set TB position and LastTB width.
    TB.style.posTop = RelTop;
    TB.style.posLeft = Start;
    PrevTB.style.width = LastWid;

    //Increment counters.
    LastStart = Start;
    Start += CurrWid;
  } 

  //Set width of last toolbar.
  TB.style.width = TotalLen - LastStart;
  
  //Move everything after the toolbars up the appropriate amount.
  i--;
  TB = yToolbars[i];
  var TBInd = TB.sourceIndex;
  var A = TB.document.all;
  var item;
  for (i in A) {
    item = A.item(i);
    if (! item) continue;
    if (! item.style) continue;
    if (item.sourceIndex <= TBInd) continue;
    if (item.style.position == "absolute") continue;
    item.style.posTop = RelTop;
  }
}

//Lays out the page.
function DoLayout(mytext) {
  LayoutTBs(mytext);

}

//Lays out the page.
function expand(mytextdiv_Contents,mytext) {

  if ( mytextdiv_Contents.style.position != "absolute" ) {

	mytextdiv_Contents.style.position = "absolute";

	oW = mytextdiv_Contents.style.width;
	oH = mytextdiv_Contents.style.height;
  	oL = mytextdiv_Contents.style.posLeft;
	oT = mytextdiv_Contents.style.posTop;

	mytextdiv_Contents.style.width = 580;
	mytextdiv_Contents.style.height = 445;
  	mytextdiv_Contents.style.posLeft = 3;
	mytextdiv_Contents.style.posTop  = -54;

	mytext.frameElement.style.height = 445;


	mytextdiv_Contents.style.visibility = "visible";

	document.all.EE.style.visibility = "hidden";
	document.all.EEF.style.visibility = "hidden";

	mytextdiv_Contents.style.zIndex = maxzindex;
	maxzindex = maxzindex + 1;

	window.scrollTo(0, 0);

  } else {

	mytextdiv_Contents.style.position = "relative";

  	mytextdiv_Contents.style.width =  oW;
	mytextdiv_Contents.style.height = 248;

	mytext.frameElement.style.height = 200;

  	mytextdiv_Contents.style.posLeft = oL ;
	mytextdiv_Contents.style.posTop  = oT ;

  if (false) {
	for (i=0; i<document.all.tags["div"].length; i++)
	{
	        obj=document.all.tags["div"][i];
		obj.style.visibility = "visible";
	}

   }

	document.all.EE.style.visibility = "visible";
	document.all.EEF.style.visibility = "visible";

	window.scrollTo(0, mytextdiv_Contents.offsetTop);


	// The ones below work
	//alert(document.parentWindow.top.screenTop);
	//parent.document.all[window.name].style.height=document.body.scrollHeight
	// This resizes the browser!
	//window.resizeTo(430,250);

   }
}


// Check if toolbar is being used when in text mode
function isRTextMode(mytext,bTextMode) {
  if (! bTextMode) return true;
  alert("Please uncheck the \"HTML Source\" checkbox.");
  mytext.focus();
  return false;
}

//Formats text in mytext.
function RunCom(mytext,bTextMode,what,opt) {
  if (!isRTextMode(mytext,bTextMode)) return;
  
  if (opt=="removeFormat") {
    what=opt;
    opt=null;
  }

  if (opt==null) mytext.document.execCommand(what);
  else mytext.document.execCommand(what,"",opt);
  
  mytext.focus();
}

//Switches between text and html mode.
function setMode(mytext,newMode) {
  var cont;

  if (newMode) {
    	cleanHtml(mytext);
	cleanHtml(mytext);
	cont=mytext.document.body.innerHTML;
	mytext.document.body.innerText=cont;

  } else {
	cont=mytext.document.body.innerText;
	mytext.document.body.innerHTML=cont;
  }
  
  mytext.focus();
}

//Finds and returns an element.
function getEl(sTag,start) {
 //Copy the selected character to "start" string while start!=NULL && tagName doesn't have 'A' 
  while ((start!=null) && (start.tagName!=sTag)) start = start.parentElement;
  return start;
}

function createLink(mytext,bTextMode) {
  //Is View Source is Checked!
  if (!isRTextMode(mytext,bTextMode)) return;
  
  
  var isA = getEl("A",mytext.document.selection.createRange().parentElement());
  
  var str=parent.prompt("Enter URL :", isA ? isA.href : "http:\/\/");
  
  //if str selection type is None!(If the user didn't block the string) then
  // get the string and add the <A HREF and paste it.  
  if ((str!=null) && (str!="http://")) {

    if (mytext.document.selection.type=="None") {    	
      var sel=mytext.document.selection.createRange();
      sel.pasteHTML("<A HREF=\""+str+"\">"+str+"</A> ");
      sel.select();
    }

	if ( str == "" ) {
	      var sel=mytext.document.selection.createRange();
	      sel.pasteHTML(sel.text);
	      sel.select();
	}

    else 
    //If user had selected/blocked the string  just pass this command.
    RunCom(mytext,bTextMode,"CreateLink",str);
  }
  else 
  {
      var sel=mytext.document.selection.createRange();
      //sel.pasteHTML(sel.getText());
      sel.select();

	  //If nothing entered just Focust in our IFRAME.
	  mytext.focus();
  }
}

//Sets the text color.
function foreColor(mytext) {
  if (! isRTextMode(mytext)) return;
  //var arr = showModalDialog("page.htm", "", "font-family:Verdana; font-size:12; dialogWidth:30em; dialogHeight:35em");
  alert("in TODO List");  
}

//Sets the background color.
function backColor(mytext) {
  if (!isRTextMode(mytext)) return;
  alert("in TODO List");  
}

function cleanHtml(mytext) {
  var fonts = mytext.document.body.all.tags("FONT");
  var curr;
  for (var i = fonts.length - 1; i >= 0; i--) {
    curr = fonts[i];
    if (curr.style.backgroundColor == "#ffffff") curr.outerHTML = curr.innerHTML;
  }
}

function getPureHtml(mytext) {
  var str = "";
  var paras = mytext.document.body.all.tags("P");
  if (paras.length > 0) {
    for (var i=paras.length-1; i >= 0; i--) str = paras[i].innerHTML + "\n" + str;
  } else {
    str = mytext.document.body.innerHTML;
  }
  return str;
}

function fnViewElementInfo(X){
  win = window.open("/cms.net/help.asp?PF=1&ElementName=" + X , "HELP","scrollbars=yes,status=no,toolbar=no,location=no,menu=no,resizable=yes,width=640,height=420");
}

function fnCMSOpenAttributeDetails(X,Y) {
    win = window.open("/cms.net/popup.aspx?PF=1&Action=Attributes&EntityCode=DETAIL&HeaderKey=" + X + "&EntityKey="+Y , "CMSAttributeDetail"+Y,"scrollbars=yes,status=no,toolbar=no,location=no,menu=no,resizable=yes,width=400,height=350");
}

function CMS_InsertImageFromGallery(editor,htmlmode,folder)
{
	if (htmlmode) return;
	editor.focus();

	var CMS_HelperFilesPath = "cms.net/";
	var CMS_HelperFilesParameters = "";

	var galleryscript = CMS_HelperFilesPath + 'imagegallery.cms.aspx?rif='+folder+'&cif='+folder;
	if (CMS_HelperFilesParameters != '') galleryscript += '&' + CMS_HelperFilesParameters;
	imgArr = showModalDialog(galleryscript,window,'dialogWidth:710px; dialogHeight:600px;help:0;status:0;resizeable:1;');

	if (imgArr != null) {
		imagestring = imgArr['filename'];
		editor.value = imagestring;
	}
        else
        {
		alert("You did not select an image, please double click an image from the gallery.");
	}
}

function CMS_InsertFileFromGallery(editor,htmlmode,folder)
{
	if (htmlmode) return;
	editor.focus();

	var CMS_HelperFilesPath = "cms.net/";
	var CMS_HelperFilesParameters = "";

	var galleryscript = CMS_HelperFilesPath + 'filegallery.cms.aspx?rif='+folder+'&cif='+folder;
	if (CMS_HelperFilesParameters != '') galleryscript += '&' + CMS_HelperFilesParameters;
	imgArr = showModalDialog(galleryscript,window,'dialogWidth:560px; dialogHeight:500px;help:0;status:0;resizeable:1;');

	if (imgArr != null) {
		imagestring = imgArr['filename'];
		editor.value = imagestring;
	}
        else
        {
		alert("You did not select an image, please double click an image from the gallery.");
	}
}



function copyToClipboard(s)
{
	if( window.clipboardData && clipboardData.setData )
	{
		if ( clipboardData.setData("Text", s) ) {
			return true;
		} else {
			return false;
		}
	}
	else
	{
		alert('Please set the permissions to access the clipboard');
		return false;
	}
}


//-->




