﻿//<![CDATA[
//PP by Enter
var sid
function enter1(sID) { 
sid=sID;
if (document.attachEvent) { document.attachEvent("onkeydown", enter2); }
else { document.addEventListener("keypress", enter2, true); }}
function enter2(event) { if (event.keyCode==13) {var ss=document.getElementById(sid);
if (ss!=null) {ss.EndEdit();ss.Update() }}}
// stuff related with the OK button on Editor
if ("undefined" == typeof(RadEditorToolInitializer)) {var RadEditorToolInitializer = {}; }
// RadEditorToolInitializer is a global object that contains initializer functions for custom tools 
RadEditorToolInitializer["ok_tool"] = function (toolArgs) 
{ function CustomRenderedTool(toolArgs) 
{ this.GetController = toolArgs.GetController; this.Name = toolArgs.Name; }
CustomRenderedTool.prototype.Create=function() { var oInput = document.createElement ("INPUT"); 
oInput.defaultValue = oInput.value="OK";oInput.style.paddingLeft='30px';oInput.style.paddingRight='30px';oInput.name = "editorOK";oInput.id = "editorOK"; 
oInput.type="button";oInput.className="ToolbarBtn"; oInput.onclick=function () { __doPostBack('editorOK',''); }
var oHolder=document.createElement ("DIV"); oHolder.appendChild (oInput);
return oHolder; }; 
var tool = new CustomRenderedTool (toolArgs); return tool; };
RadEditorToolInitializer["cancel_tool"] = function (toolArgs) 
{ function CustomRenderedTool(toolArgs) 
{ this.GetController = toolArgs.GetController; this.Name = toolArgs.Name; }
CustomRenderedTool.prototype.Create = function() { var oInput = document.createElement ("INPUT"); 
oInput.defaultValue = oInput.value = "Cancel"; oInput.name = "editor_cancel"; oInput.id = "editor_cancel"; 
oInput.type = "button"; oInput.className = "ToolbarBtn"; oInput.onclick = function () { __doPostBack('editor_cancel',''); }
var oHolder = document.createElement ("DIV"); oHolder.appendChild (oInput);
return oHolder; }; 
var tool = new CustomRenderedTool (toolArgs); return tool; };
RadEditorToolInitializer["clear_tool"] = function (toolArgs) 
{ function CustomRenderedTool(toolArgs) 
{ this.GetController = toolArgs.GetController; this.Name = toolArgs.Name; }
CustomRenderedTool.prototype.Create = function() { var oInput = document.createElement ("INPUT"); 
oInput.defaultValue = oInput.value = "Clear"; oInput.name = "editor_clear"; oInput.id = "editor_clear"; 
oInput.type = "button"; oInput.className = "ToolbarBtn"; oInput.onclick = function () { var ret = confirm('Are you sure you want to clear the text of this chapter?'); if(ret) {__doPostBack('editor_clear','');}; return false; }
var oHolder = document.createElement ("DIV"); oHolder.appendChild (oInput);
return oHolder; }; 
var tool = new CustomRenderedTool (toolArgs); return tool; };

//RadWindow
function RWShowModal(url,w,h,cbfunc) { 
var oMan = GetRadWindowManager(); oMan.CloseAll(); 
var oWnd = oMan.Open(url, null); 
oWnd.SetModal(true); //does not work with Opera
if (window.opera) { } else {oWnd.Hide()}; //Opera problem
oWnd.SetSize(w,h); oWnd.Center(); 
if (cbfunc != null) {oWnd.ClientCallBackFunction = cbfunc };
oWnd.Show(); }

// stuff related with Spread bug
//NUSED probably
var spreadID;
var aa = 0; var bb = 0;
function FF_clear_temp(id,a,b) { spreadID = id;
var ss = document.getElementById(id);
aa = a; bb = b
if (document.all) { } else { ss.addEventListener("EditStart", FF_edit, true); } }
function FF_edit() { var ss = document.getElementById(spreadID);
c = ss.GetActiveCol(); r = ss.GetActiveRow();
ss.SetSelectedRange(r,c,1,1);// select the cell to clear
if ((c >= aa) && (c <= bb)) {ss.Clear()}; 
ss.SetSelectedRange(r,-1,1,-1);//select the Row
}

function endRequest(sender, e) {
//works with the script on master, nb-apperr is not visible at txt1
var x = document.getElementById("apperr");
if (e.get_error()) { if (x != null) {x.innerText = e.get_error().description }; e.set_errorHandled(true); } }

function combochange(ssID,comboID,pp) { 
//used only for autopostback 
var ss = document.getElementById(ssID);
var cb = document.getElementById(comboID);       
if (document.all) { ss.SetValue(ss.ActiveRow,ss.ActiveCol,cb.options[cb.selectedIndex].value); }
else { ss.SetValue(ss.GetActiveRow(),ss.GetActiveCol(),cb.options[cb.selectedIndex].value); }
ss.UpdatePostbackData();
if (pp) { __doPostBack("",""); }
return false; }

function confirm_delete(msg) { if (confirm(msg)) return true; else return false; }

function resizeElement(elementID,cOther,cIE) { 
var e = document.getElementById(elementID);
if (e == null) return false;
var C = cOther;
if (document.all) C = cIE;
var d = document.body;
if (d.clientHeight - C > 1) {e.style.height = (d.clientHeight - C) + "px"; }  }

function setElementWidth(elementID,pp)
{ var e = document.getElementById(elementID);
if (e == null) return false;
var d = document.documentElement;
if (window.opera || (document.all && !(document.compatMode && document.compatMode == "CSS1Compat"))) 
{ d = document.body; };
e.style.width = (d.clientWidth * (pp / 100.0)) + "px";
//e.style.display = 'none';
//e.style.display = 'block'; 
}

var curTables = [];
function IsObjectInArray(elem, array)
{  if (!array || !array.length) return false;
for (var i=0; i < array.length; i++)
{ if (elem == array[i]) return true; }
return false; }

function OnClientCommandExecuting(editor, commandName, oTool)
{    if ("InsertTable" == commandName)
{ var A = editor.GetContentArea();
var t = A.getElementsByTagName("TABLE"); 
for (var i = 0; i < t.length; i++)
{ curTables[curTables.length] = t[i]; } } }

function OnClientCommandExecuted(editor, commandName, oTool)
{ if ("InsertTable" == commandName)
{   var A = editor.GetContentArea();
var tables = A.getElementsByTagName("TABLE");
for (var i=0; i < tables.length; i++)
{ var oT = tables[i];
//Check if this table existed before the InsertTable executed.
if( !IsObjectInArray(oT, curTables))
{   oT.border="1";
    oT.cellspacing="0";
    oT.cellpadding="3";
} } } }

//these are for Publish menu
function MM_reloadPage(init) {
return false;
 //reloads the window if Nav4 resized, nused?
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();}
MM_reloadPage(true);

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_showHideLayers() { //v6.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
obj.visibility=v; } }

function reposDiv(elemID,anchorID,d)
{ var e = document.getElementById(elemID); var a = document.getElementById(anchorID);
if (e == null) return false; if (a == null) return false;
e.style.left = (getPosLeft(a) + d) + "px"; }

function getPosLeft(Elem) {var X = 0; while(Elem != null) 
 {X += Elem.offsetLeft; Elem = Elem.offsetParent;} return X; }
 
function setSpreadScroll(id,row,col) 
//NUSED
{
 var spread = document.getElementById(id);
      spread.SetActiveCell(row,col); 
      var cell = spread.GetCellByRowCol(row,col); 
      var rowHeader = spread.all(spread.id + '_rowHeader');          
      var colHeader = spread.all(spread.id + '_colHeader'); 
      var view = spread.all(spread.id + '_view'); 
      
      if (view!=null) { 
       //view.scrollTop = cell.offsetTop; 
       //view.scrollLeft = cell.offsetLeft; 
      view.style.left = -100+'px';}
      if (rowHeader!=null) { 
        //rowHeader.scrollTop = cell.offsetTop; 
      rowHeader.style.left = "-100px";      }
      if (colHeader != null) { 
        //colHeader.scrollLeft= -100px;//cell.offsetLeft; 
      colHeader.style.left=-100+'px'; }
}
function TimerFontSize1(elemID) { var e = document.getElementById(elemID);
e.style.fontSize='14px'; 
window.setTimeout(function() { e.style.fontSize='13px'; }, 1400); 
window.setTimeout(function() { e.style.fontSize='12px'; }, 1435); } 
//nused currently

function resizeElementXXX(elementID,cOther,cIE) { 
var e = document.getElementById(elementID);
if (e == null) return false;
var C = cOther;
if (document.all) C = cIE;
var d = document.documentElement;
if (window.opera || (document.all && !(document.compatMode && document.compatMode == "CSS1Compat")))
{ d = document.body; }
if (d.clientHeight - C > 1) {e.style.height = (d.clientHeight - C) + "px"; }  }

function chkallboxes (master,prefix) { 
var f=document.forms[0];var m=document.getElementById(master);var state=m.checked;
prefix=new RegExp(prefix);
for (i=0;i<f.elements.length; i++) { 
var obj = f.elements[i];
if (obj.name.match(prefix)) { 
obj.checked=(state==false)?false:true; } } }

function unchkall (master,prefix) { 
var f=document.forms[0];var m=document.getElementById(master);
prefix=new RegExp(prefix);
m.checked=false;
for (i=0;i<f.elements.length; i++) { 
var obj = f.elements[i];
if (obj.name.match(prefix)) { 
obj.checked=false; } } }

function countchk (prefix) { 
var f=document.forms[0];prefix=new RegExp(prefix);var cnt=0;
for (i=0;i<f.elements.length; i++) { 
var obj = f.elements[i];
if ((obj.name.match(prefix)) && (obj.checked==true)) { 
cnt=cnt+1; } } 
return cnt; }


//function cboxchange(ssID) { 
//var ss = document.getElementById(ssID);
//var r =-1; var c =-1;
//if (document.all) {r=ss.ActiveRow; c=ss.ActiveCol; } else { r = ss.GetActiveRow(); c = ss.GetActiveCol(); }
//var cell = ss.GetCellByRowCol(r,c);
//var chk = cell.children[0].checked;
//ss.SetValue(r,c,chk,true);
//ss.EndEdit();
//ss.UpdatePostbackData();
//return false; }
// ]]>
