﻿ 
 editors = new Array;
 
 function resizeContentArea(editor,setHeight)
 {
 InitialHeight = 0;
 InitialWidth = 0;
 if(setHeight=='true'){
 InitialHeight = document.getElementById(editor.Id + 'Cell').offsetHeight;
 }

  var targetHeight = editor.Document.body.scrollHeight;
  if (targetHeight < InitialHeight){
  targetHeight = InitialHeight;
  }
   var theIFrame = document.getElementById("RadEContentIframe" + editor.Id);
   theIFrame.style.height = parseInt(targetHeight) + "px";
    var theTXTArea = document.getElementById("RadEContentTextarea" + editor.Id);
   theTXTArea.style.height = parseInt(targetHeight) + "px";
  }

 function sizeContainersOnLoad(CtId){
RadE = GetRadEditor(CtId);
resizeContentArea(RadE,'true');
}


currentEditor = "";

 function attachResizeEvents(editor)
 {
  editor.InitialHeight = -1;
  editor.GetContentArea().style.overflow = "hidden";
  var resizeFnRef = function anon(){resizeContentArea(editor,'false')};
  editor.AttachEventHandler("RADEVENT_SEL_CHANGED", resizeFnRef)
  editor.AttachEventHandler("keydown", resizeFnRef)
     RadEditorCommandList["AddControl"] = function(addControl, editor, oTool)
     {
            currentEditor = editor;
            loadMaxObject(oTool.GetSelectedValue(),editor.GetWidth())
      };
        RadEditorCommandList["Forms"] = function(addControl, editor, oTool)
     {
            currentEditor = editor;
            loadFormObject(oTool.GetSelectedValue(),editor.GetWidth())
      };
RadEditorCommandList["SavePage"] = function(addControl, editor, oTool)
     {
           runEditorSave();
      };
  editors.push(editor)
 }
 
 function getId(input,nvalue){
 str = input.split(":");
 return str[nvalue];
 }
 
callbackItems = new Array();
callbackIds = new Array();
function runEditorSave(){

document.getElementById("SaveButton").click();
}




function loadImage(imageFile,controlId)
{
src = '<img src=\"' + imageFile + '\" controlid=\"' + controlId + '\" />';
currentEditor.PasteHtml(src);
resizeContentArea(currentEditor,'false');
}

function loadMaxObject(input,width)
{
ThePageManager.AjaxRequest("loadMaxObject," + input + "," + width);
}
function loadFormObject(input,width)
{
ThePageManager.AjaxRequest("loadFormObject," + input + "," + width);
}



function showAlert(){
tDiv = document.getElementById("alertDiv");
tDiv.innerHTML = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"300\" height=\"80\" id=\"alert\" align=\"middle\"><param name=\"allowScriptAccess\" value=\"sameDomain\" /><param name=\"movie\" value=\"../images/alert.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"wmode\" value=\"transparent\" /><param name=\"bgcolor\" value=\"#ffffff\" /><embed src=\"../images/alert.swf\" quality=\"high\" wmode=\"transparent\" bgcolor=\"#ffffff\" width=\"300\" height=\"80\" name=\"alert\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /></object>"
}

function hideAlert(){
tDiv = document.getElementById("alertDiv");
tDiv.innerHTML = ""
}


function stretchTheEditors()
{
   for(i=0;i<editors.length;i++){
        resizeContentArea(editors[i],'true');
  }
}


function editControlItem(ControlId){
alert(ControlId);
}



function checkMenuPage(pageid){
var temp = "";
temp = String(window.parent.frames[0].location);
    if(temp.toLowerCase().indexOf("editpage.aspx?pageid=" + pageid)>0){
    }else{
    window.parent.frames[0].location = "../page/editpage.aspx?PageId=" + pageid
    }
}