 /* 
 * $Id: utility.js,v 1.58 2005/03/31 22:07:15 oscar Exp $ 
 * General utilities available for all pages (standard) 
 * 
 */


/************************************************************************* 
 *** Author: Yovanis C�ceres L�pez
 *** Created: 07-18-06
 *** Comment: Show a message if the data returned from the server is empty
 *************************************************************************/
function RPCCallBack(id,len,field,value,realId, excMsgList){ /* LC, Sep '06: Added the realId parmeter, see note below */

    if (excMsgList.length){
	    excMsgStr = "";
	    for (i=0;i<excMsgList.length;i++)
			excMsgStr += excMsgList[i];			
		alert(excMsgStr);
		return false;
    }
    if(value.length == 0) {
        handlerRPCActions.runAction();
        return true;
    }
    if(len == 0) { 
        /* LC Sep '06: Changed the message and put the focus on the field if
         * there are errors. 
         * To achieve this I had to add the parameter realId, it receives the
         * actual Id for the field, this is also used to find a caption (if any)
         * and format the message accordingly. IMPORTANT ASSUMPTION: the id for
         * the caption is <id>_caption */
        var captionId = document.getElementById(realId + '_caption');
        if (captionId) {
            var theCaption = captionId.firstChild.nodeValue;
        }
        else { 
            captionId = document.getElementById(realId + '_col_head');
            if (captionId)
                var theCaption = captionId.firstChild.nodeValue;
            else
                theCaption = field.replace(/_/g,' ');
        }
        if (theCaption.lastIndexOf(':') != -1 )
            theCaption = theCaption.substr(0,theCaption.length - 1);
        /* LC, Sep '06: The message changed to the format (for example): 
         * "Province ID (the value entered by the user) does not exist!" */
        /* old message:
         * alert('Invalid '+field.replace(/_/g,' ')+' value!'); */ 
        alert(theCaption + ' "' + value + ' " does not exist!');
        if (realId) /* LC, Sep '06: Moving the focus */
            document.getElementById(realId).focus();
    }
    return !(len==0)
}
/************************************************************************* 
 *** Author: Yovanis C�ceres L�pez
 *** Created: 03-09-06
 *** Comment: Get the file name fron a unload-file widget
 *************************************************************************/
function getFileName(fullpath){
 var pathlist = fullpath.indexOf("/") >=0 ? fullpath.split("/") : fullpath.split("\\") ;  
 var result = fullpath;
 if(pathlist.length != 0) 
   result = pathlist[pathlist.length-1];
 return result;
}
/************************************************************************* 
 *** Author: Yovanis C�ceres L�pez
 *** Created: 03-09-06
 *** Comment:  to check if a rpc-process is running 
 *************************************************************************/
var auto_post_back_running = "";
var rpc_list_showed = 0;
var response_counter=0;

handlerRPCActions = {
    selecting : false,
    action    : null,
    execAction : false,
    setAction : function(func){        
        this.action = this.action || func;
    },
    runAction : function(){           
        if((auto_post_back_running.length == 0 )&& this.execAction && this.action) {		
            this.action();
            this.execAction = false;
            this.action = null;
            this.MessageWindow(false);
        }        
    },
    MessageWindow: function(show){
        var we = document.getElementById('RPC_StillRunning');
        display = show ? 'block' : 'none';
        if(show){
            var wsize = geWindowSize()
            if(wsize.width){
                var left = (wsize.width - 220) / 2; 
                we.style.left =left;
            }
        }
        
        we.style.display = display;
    }
}

var actionWaiting = null;
var exeActionWaiting = false;

function setActionWaiting(func){
   actionWaiting = func;
}

function isAutoPostBackRunning(to,e){    
  result = false;
  to = to+"";
  if(to.indexOf('luState=rpcmgr') == -1){
    if(handlerRPCActions.selecting) return false;
	var eList = document.getElementsByTagName("iframe");    	
    for(var i=0; i < eList.length; i++){	    
      if((eList[i].id.indexOf('autopostback_') >=0) && (eList[i].style.display == "block"))
      {
        handlerRPCActions.execAction = false;
	    alert("Data Selection not complete");
	    return true;
	  }    
	 }
	 var result = ((auto_post_back_running.length != 0));      
	 if(result) {
       handlerRPCActions.execAction = true;      
       handlerRPCActions.MessageWindow(true);
	   //alert("The action was aborted. A process is still running, Please wait...");
	   if(response_counter++ >= 1){
		 auto_post_back_running = "";
		 response_counter = 0;
	   }
	 }  
  }
  return result;
}
/************************************************************************* 
 *** Author: Yovanis C�ceres L�pez
 *** Created: 01-09-06
 *** Comment:  This code is the extention of the getElementById of the document object 
 ***           so, it check if the element has applicated a format
 *************************************************************************/
function dropFormat(value){
  var tmpValue = value  
  var re = /.*[a-zA-Z:\[\]\;\{\}\/]+.*/;        
  if(value.match(re)) return value;  
  tmpValue = tmpValue.replace(/([^0-9^\(^\)^.^-])/g,'');
   
  tmpValue = tmpValue.replace(/\((.*)\)/g,'-$1');
  tmpValue = tmpValue.replace(/([^-]*)(-)/g,'$2$1');

  re = new RegExp("[0-9]+");
  var m = re.exec(tmpValue);

  return m ? tmpValue : value
}
/* document.getElementById.prototype.getValue = "xxx"; */
function getElementById(name){       
  try{
  var e = document.getElementById(name);  
  if(e){  
    var value = (e.value)?e.value:e.innerHTML;
    e.getValue =  window.hasFormat ? (hasFormat(name) ? dropFormat(value) : value) : value;    
  }
  }catch(e){}
  return e
}

/************************************************************************* 
 *** Author: Yovanis C�ceres L�pez
 *** Created: 12-01-05
 *** Comment:  This Object is the handler all functionality over a text control
 ***           copy, paste, cut
 *************************************************************************/
 function editingFunctions(e){
   
   function CopyToClipboard() { 
     this.clipboard = this.e.value.toString().substr(this.e.selectionStart,this.e.selectionEnd-this.e.selectionStart);     
   }
   /*-------------------------------*/
   function PasteFromClipboard(){
     this.replace(this.e.selectionStart,this.e.selectionEnd,this.clipboard,true);
   } 
   /*-------------------------------*/
   function CutToClipboard(){    
    this.copy();    
    this.replace(this.e.selectionStart,this.e.selectionEnd,"",true);
   }    
   /*-------------------------------*/   
   this.removeTags = function(){        
     var text = this.e.value.toString().substr(this.e.selectionStart,this.e.selectionEnd-this.e.selectionStart);          
     text = text.replace(/<[a-zA-Z0-9_-]+>|<\/[a-zA-Z0-9_-]+>/g,"");          
     this.replace(this.e.selectionStart,this.e.selectionEnd,text,true);
   }   
   /*-------------------------------*/   
   this.addTag = function(tagname){
     var tag = "<name>text</name>";     
     var text = this.e.value.toString().substr(this.e.selectionStart,this.e.selectionEnd-this.e.selectionStart);          
     text = tag.replace(/name/g,tagname).replace(/text/g,text);     
     this.replace(this.e.selectionStart,this.e.selectionEnd,text,true);
   }
   /*-------------------------------*/   
   this.replace = function (selectionStart,selectionEnd,value,save){
    if(save)  this.push(this.e.value);
    
    this.e.value = this.e.value.substr(0,selectionStart)+value+this.e.value.substr(selectionEnd); 
   }
   /*-------------------------------*/   
   this.push =function(str){
    this.backUp[this.backUp.length]=str;
    this.backUpPos = this.backUp.length-1;
   }
   /*-------------------------------*/   
   this.pop = function(incdec){
   this.backUpPos = (incdec < 0 ? this.backUpPos-1 : this.backUpPos+1);   
    if(this.backUpPos < 0) {this.backUpPos = 0; return };
    if(this.backUpPos >= this.backUp.length) {this.backUpPos = this.backUp.length-1; return;};
    try{
    
    this.e.value=this.backUp[this.backUpPos];        
    }catch(e){}   
   }
   /*-------------------------------*/   
      /* properties */
   this.text;
   this.e = e;   
   
   /* methods */
   this.backUp = new Array();
   this.backUpPos = 0;
   this.backUp.push(this.e.value);
   this.clipboard=""
   this.copy = CopyToClipboard;
   this.paste = PasteFromClipboard;
   this.cut = CutToClipboard;   
   this.validHTML = function(){};
   this.preview = function(){};
   

 }
/************************************************************************* 
 *** Author: Yovanis C�ceres L�pez
 *** Created: 06-01-05
 *** Comment:  This Object is the handler to edit memo widget
 *************************************************************************/
function Memo(){

/* methods */
  this.showMemoEdit = function(field,caption){
     this.field = field;
     this.caption = caption;
     var eMemo = getElementById("tbleditmemo")
     if(eMemo){
       var winPos = ',top='+((screen.height - 50) / 2)+',left='+((screen.width - 50) / 2);

       eMemo.style.display = "block";
       var winsize = windowSize();
       eMemo.style.left = (winsize.width -  450) / 2+"px";
       eMemo.style.top = (winsize.height -  350) / 2+"px";       
       var eMemoTitle = getElementById("tbleditmemotitle");
       
       eMemoTitle.innerHTML = caption;       
       var element = getElementById(field)
       if(element){
         this.field = element;         
         var eMemoTitle = getElementById("tbleditmemotitle")    ;
         this.memoField = getElementById("memofield");         
         this.memoField.value = element.value;
       }
     }
  }

  this.saveMemoEdit = function(){
     if(this.memoField){
       this.field.value = this.memoField.value;
       displayElement = getElementById("memo_" + this.field.id)       
       displayElement.value = this.field.value;
       this.closeMemoEdit();
     }
     return;
  }

  this.closeMemoEdit = function(){
     var eMemo = getElementById("tbleditmemo")
     if(eMemo){
       eMemo.style.display = "none";

     }
     return;
  }

/* properties */
  this.memoField = "";
  this.field = "";
  this.caption = "";  
}
var editMemoFields = new Memo();

/************************************************************************* 
 *** Author: Yovanis C�ceres L�pez
 *** Created: 08-23-05
 *** Comment:  This function return the current window size.
 *************************************************************************/

function windowSize(){
var winsize = {width:10, height:20};

if (window.innerWidth)
{
    winsize.width = window.innerWidth;
    winsize.height = window.innerHeight;
}
else if (document.documentElement && document.documentElement.clientWidth)
{
    winsize.width = document.documentElement.clientWidth;
    winsize.height = document.documentElement.clientHeight;;
}
else if (document.body)
{
    winsize.width = document.body.clientWidth;
    winsize.height = document.body.clientHeight;
}
return winsize;
}
/************************************************************************* 
 *** Author: Yovanis C�ceres L�pez
 *** Created: 06-01-05
 *** Comment:  This function show a alert window before run transition. 
 ***          The object is notify to the client that this transition going to executed
 *************************************************************************/
function groupData(name){
        this.name = name;
}
function dataStorage(){
    //Implementations
    function newGroupData(name){                
        for(var i = 0; i < this.list.length; i++){                        
        if(this.list[i].name == name){            
            return this.list[i];
        }
        }                
        var gdata = new groupData(name.toString());        
        this.list[this.list.length]=gdata;        
        return gdata;
    }
    function getGroupData(name){        
        for(var i = 0; i < this.list.length; i++){                
        if(this.list[i].name == name){            
            return this.list[i];
        }
        }                
        return false;
    }
    //properties
    this.list = new Array();
    //methods
    
    this.newGroupData =  newGroupData;            
    this.getGroupData =  getGroupData;
    this.setGroupData = function(gdata){
        for(var i = 0; i < this.list; i++){
            if(this.list[i].name == gdata.name)
                return this.list[i]=gdata;
        }
        return gdata;
    }
}
var datastorage = new dataStorage();

/*************************************************************************
 *** Author: Yovanis C�ceres L�pez
 *** Created: 01-01-05
 *** Comment:  
 *************************************************************************/
function popupAction(){
    this.action="";
    this.message = "";
    this.doAction = function(){    
        //document.write("<textarea >"+this.action+"</textarea>")   
        //newwindowsubmitform("Controller?Currency_Pid=220&&state=Currency&wpkey=e147737621e9b80f69f5f3a3d5651ddc&event=CurrencySetup&module=default&subprocess=update&sort_by=Currency_Id&sort_dir=ascending&sort_dir_fixed=ascending&goto_page=1",document.f1,"target__");
        //alert(document.title);             
        var result = eval(this.action);
    }
    
/*************************************************************************
 *** Author: Yovanis C�ceres L�pez
 *** Created: 01-15-05
 *** Comment:  This function show a alert window before run transition. 
 ***          The object is notify to the client that this transition going to executed
 *************************************************************************/

    this.alertWindow = function(){    
                            var _values = new Object();            
                            _values.message = "this the message to show";
                            
                            var winproperties = new Object();
                            winproperties.values = _values;
                            winproperties.name = "xxx";
                            winproperties.url = "alert.htm?x=1"        
                            winproperties.scroll = "no"
                            winproperties.center = "yes";
                            winproperties.resizable = "yes";
                            winproperties.left = (window.outerWidth -  450) / 2+"px";
                            winproperties.top = 200;
                            winproperties.width = 300;
                            winproperties.height = 110;    
                
                            ShowModalWindow(winproperties)
                        }
/*************************************************************************
/*** Author: Yovanis C�ceres L�pez
/*** Created: 01-15-05
/*** Comment:  This function show a ask to the clients if they are sure to execute 
/***          this transition. 
/*************************************************************************/

this.confirmWindow = function (){
                        var _values = new Object();            
                            _values.message = "this the message to show";
                            
                            var winproperties = new Object();
                            winproperties.values = _values;
                            winproperties.name = "xxx";
                            winproperties.url = "confirm.htm?x=1"        
                            winproperties.scroll = "no"
                            winproperties.center = "yes";
                            winproperties.resizable = "yes";
                            winproperties.left = (window.outerWidth -  450) / 2+"px";
                            winproperties.top = 200;
                            winproperties.width = 375;
                            winproperties.height = 110;            
                            ShowModalWindow(winproperties)
                        }

}

var popupOBJ = new popupAction();

/*************************************************************************
 *** Author: Yovanis C�ceres L�pez
 *** Created: 01-15-05
 *** Comment:  One object tracks the current modal dialog opened from this window.
 *************************************************************************/
var dialogWin = new Object();

/* Generate a modal dialog.
// Parameters:
//    url -- URL of the page/frameset to be loaded into dialog
//    width -- pixel width of the dialog window
//    height -- pixel height of the dialog window
//    returnFunc -- reference to the function (on this page)
//                  that is to act on the data returned from the dialog
//    args -- [optional] any data you need to pass to the dialog */

function fnopenDialog(url, width, height, returnFunc, args) {
if (!dialogWin.win || (dialogWin.win && dialogWin.win.closed)) {        
        /* Initialize properties of the modal dialog object. */
        
        dialogWin.returnFunc = returnFunc;
        dialogWin.returnedValue = "";
        dialogWin.args = args.values;
        dialogWin.url = url;
        dialogWin.width = width;
        dialogWin.height = height;
        /* Keep name unique so Navigator doesn't overwrite an existing dialog.
         * */
        dialogWin.name = (new Date()).getSeconds().toString();
        /* Assemble window attributes and try to center the dialog. */
        
        dialogWin.left =  ((window.screen.availWidth - dialogWin.width) / 2);                    
        dialogWin.top = ((window.screen.availHeight - dialogWin.height) / 2);
        var attr = "center:yes, chrome,alwaysRaised=1,modal=1,left=" + dialogWin.left + 
               ",top=" + dialogWin.top + ",scrollbars=no,status=no,statusbar=no,resizable=0,width=" + 
               dialogWin.width + ",height=" + dialogWin.height;            
        var attr = "status=no,location=no,scrollbars="+args.scroll+",menubar=no,directories=no,resizable="+ args.resizable +",left=" + dialogWin.left + ",top=" + dialogWin.top + ",width=" + dialogWin.width + ",height=" + dialogWin.height;            
        /* var attr = args.status;          */
        dialogWin.win=window.open(dialogWin.url, dialogWin.name, attr);            
        dialogWin.win.focus();
    } 
}

/*************************************************************************
 *** Author: Yovanis C�ceres L�pez
 *** Created: 01-15-05
 *** Comment:  Show a modal window 
 *************************************************************************/

function ShowModalWindow(xobj){        
        var left =  ((window.screen.availWidth - xobj.width) / 2);                    
    var top = ((window.screen.availHeight - xobj.height) / 2);
    var _status =    "status:no;"+
    (xobj.scroll ? "scrollbars:"+ xobj.scroll + ";" : "") + 
    (xobj.resizable ? "resizable:"+ xobj.resizable + ";": "") + 
    (xobj.center ? "center:"+ xobj.center + ";": "") + 
    (xobj.height ? "Height:"+ xobj.height +"px;":"") + 
    (xobj.width ? "Width:"+ xobj.width +"px;":"") + 
    (xobj.left ? "Left:"+ left +"px;":"") +          
    (xobj.top ? "Top:"+ top +"px;":"") 
    /*
    (xobj.height ? "dialogHeight:"+ xobj.height +"px;":"") + 
    (xobj.width ? "dialogWidth:"+ xobj.width +"px;":"") + 
    (xobj.left ? "dialogLeft:"+ left +"px;":"") +          
    (xobj.top ? "dialogTop:"+ top +"px;":"") 
    */
    xobj.status = _status;
    var thetime=new Date(); 
    var now = "now=" + thetime.getYear()+":"+ thetime.getMonth()+":"+ thetime.getDay()+":"+ thetime.getHours()+":"+ 
                        thetime.getMinutes()+":"+ thetime.getSeconds();     
    if(true){ //!window.showModalDialog
        var d = new Date();        
        fnopenDialog(xobj.url+"&"+now, xobj.width, xobj.height, "", xobj);        
        }
    else
        window.showModalDialog(xobj.url+"&"+now, xobj.values, _status);                
    }

/*************************************************************************
 *** Author: Yovanis C�ceres L�pez
 *** Created: 11-25-04
 *** Comment: This code is used for catching the close window event then we can do a submit 
 ***         to server with the window key, so there we can droping it from the session. 
 *** it isn't running yet
 *************************************************************************/
/*
window.onunload = function(e){
    if(isTheApplication){        
        if(location.href.match(/wkey=/g)){            
            var killurl = location.href.replace(/wkey=/g,"killsession=")
            submitform(killurl,"","RSIFrame");                
        }        
    }
    return false;
}
isTheApplication = (window.parent.isTheApplication ? false : true);
*/

/*************************************************************************
 *** Author: Yovanis C�ceres L�pez
 *** Created: 01-20-05
 *** Comment: This function could be executed when onload event is raised
 *************************************************************************/
var funct2Exec = new Array();
var customOnLoad = new Array();
var MENUCONTEXT_index = -1;
var isonload = true;
var CheckTransitionStatus_forced = 'off';
function onLoadWindow(){    
        
    /* When a rcl call was sent to server the variable "rpcmgrIsComeBack" is set to 'true' by rmpmgr,*/
    /* then in this case we don't need to check the status condition of the buttons */
	if (!window.rpcmgrIsComeBack){	
              			
			CheckEditing();
			CheckTransitionStatus();      
    }
    /* Evalueting general function that were sending from the renders */
    runOnload(funct2Exec);
    /* Evalueting function that were sending from the custom java-script */
    runOnload(customOnLoad);
    
    for(var i = 0; i < top.frames.length; i++){
        if(top.frames[i].name =='MENUCONTEXT' && window.name != 'MENUCONTEXT'){        
            MENUCONTEXT_index = i;
            window.onmouseover = doAutoHide;
	    try{
	      top.frames[MENUCONTEXT_index].MenuContainer.loaded();
	    } catch(e){}
            //this.loading
            break;
        }  
    }    
}
function runOnload(functionList){
  for(var i=0; i<functionList.length;i++){
     eval(functionList[i]);
  }  
}
/*************************************************************************
 *** Author: Yovanis C�ceres L�pez
 *** Created: 03-01-05
 *** Comment: This function will be called from all events raised on the client part.
 *************************************************************************/
function CheckTransitionStatus(){
    /* also this function will be overwritten by the render UI if any
     * condition was defined in the flow    */
    return true;
}
function CancelEditing(){
	var e  = document.getElementById("ctrl_editing");
	if(e) e.value = "no";	
	if(window.parent.setEnabledButtons){
     window.parent.setEnabledButtons();
	 window.parent.changeFilterStatus('filterOn');
    }
}
function CheckEditing(){
  /*  check parent ctrl_editing to disabled any folder child */
  var result = true;
  var e = null;
  var level = null;

  result = check_editstatus('document');
  if ((window.parent) && (window.parent.document != window.document))  {      
    var e = window.parent.document.getElementById("ctrl_editing");  
    var level = window.parent.document.getElementById("level_number");  
    if (e && e.value == 'yes' && level && level.value*1 > 0){	  
      document.body.disabled = "yes";	  
      setDisabledButtons();
      result = false;	  
    }
    else{	
      if(window.parent.setDisabledButtons){	    
	    e  = getElementById("ctrl_editing");		          
      if(e && e.value != 'yes') 
      	{CancelEditing();}
    	else{ 
    		window.parent.setDisabledButtons((e ? e.value == 'yes':false));
			window.parent.changeFilterStatus('filterOff');
			}
	  }
    }
  }  
  return check_editstatus('document');    
}
function previousState(){
  this.fieldslist = new Array();
  this.bool = true;
  
  this.getState = function(field,state){
    var i=-1;    
    for(i=0; i < this.fieldslist.length;i++)
      if(this.fieldslist[i][0]==field) {
    return this.fieldslist[i][1]
      }          
    return state;
  }
  
  this.setState = function(field,state){
    var i=-1;        
    for(i=0; i < this.fieldslist.length;i++)
      if(this.fieldslist[i][0]==field) {        
		    this.fieldslist[i][1]=state;                  
		    return;
      }    
      this.fieldslist.push([field,state]);    
  }
}
var previousStateButton = new previousState();
function setDisabledButtons(childediting){
  var fieldName
  var className
  var e=document.getElementsByTagName("button");
  previousStateButton.bool = childediting == false ? true : check_editstatus('document');    
  if(childediting) previousStateButton.bool = false;    
  for(var i=0;i<e.length;i++){        
    fieldName =  "button"+i    ; 
    if (!previousStateButton.bool) previousStateButton.setState(fieldName,e[i].disabled);    
    e[i].disabled = previousStateButton.bool ? previousStateButton.getState(fieldName,e[i].disabled) : true;    	
    se = e[i].getElementsByTagName("span");
    for(var j=0;j<se.length;j++){
      if (!previousStateButton.bool) previousStateButton.setState(fieldName+"_class"+j,se[j].className);
      className = se[j].className.replace(/dis/g,"");
      se[j].className = previousStateButton.bool ? previousStateButton.getState(fieldName+"_class"+j,className) : className+"dis";   
    }    
  }  
}

function changeFilterStatus(filterClassName){
  var spans = document.getElementsByTagName("span");  
  for(var i=0;i<spans.length;i++){	
	if (spans[i].id.indexOf('filterbutton_') == 0 )
		spans[i].className = filterClassName;
  }  
}

/* This variable is going to have a list of buttons that are meant to be disabled following toolkit rules
   Widgetdef.xsl line-785 deal with conditions and create js code to populate it.
*/
var disabledButtons = new Array();

function setEnabledButtons(){
/* This function is called to enable or disable buttons after they were disabled by 
  editing in transition folders. It is always fired by the child folder
*/

  var fieldName
  var className
  var e=document.getElementsByTagName("button");
  var disButtonsStr = "," + disabledButtons.toString() + ",";
  var theButtonId;
  var isDisabled = false;
  
  for(var i=0;i<e.length;i++){        
    fieldName =  "button"+i    ;
    theButtonId = ",ref,".replace(/ref/, e[i].id ? e[i].id : 'noid');
    isDisabled = disButtonsStr.indexOf(theButtonId) == -1 ? false : true ;
    previousStateButton.setState(fieldName,isDisabled);    
    e[i].disabled = isDisabled;        
    if (!isDisabled){
      se = e[i].getElementsByTagName("span");
      for(var j=0; j < se.length;j++){          	
	className = se[j].className.replace(/dis/g,"");
	previousStateButton.setState(fieldName+"_class"+j,className);      
	se[j].className = className;   
      }    
    }  
  }  
  CheckTransitionStatus();
  
}
/*************************************************************************
 *** Author: Yovanis C�ceres L�pez
 *** Created: 03-01-05
 *** Comment: This function is checking witch element could be enabled when edit levels is enabled
 *************************************************************************/
var FiltersTransitionsList = new Array();
function checkElementStatus(){
   var e = getElementById("level_action")
   //alert(e);
}

function doAutoHide(){    
    if(MENUCONTEXT_index >=0)
        top.frames[MENUCONTEXT_index].MenuContainer.doAutoHide();                              
};                            

/*************************************************************************
 *** Author: Yovanis C�ceres L�pez
 *** Created: 11-27-04
 *** Comment: This Objects are used for controling menu in client side (DHTML based)
 *************************************************************************/
/* this Object is used for handling the menu container*/
function objMenuContainer(){
    function show(name,type,noautohide){                    
        var e;
        var oldStatus = getElementById(name).style.display;
        if(type=="auto" && this.autohide){
            e = getElementById(name);
            if(e) e.style.display = "none";            
            window.onresize();                
            return
        }
        if(type == "table"){
            this.autohide= !this.autohide;            
            return;
        }
        if (type == "image") {
            this.selected = name;
            e = getElementById(name+"_image");
            if(e) e.style.display = "block";
            this.hide(name);            
        }
        else {
            e = getElementById(name+"_image");
            if(e) e.style.display = "none";
        }            
        e = getElementById(name+(type=="image" ? "" : "_icon"))
        if (e) e.style.display = "block";                    
        
        e = getElementById(name+(type=="image" ? "_icon" : ""));
        if (e) 
            e.style.display = "none";
        if (getElementById(name).style.display == "block" && oldStatus == "none")
            parent.document.body.cols = this.mc.offsetWidth + ',*';
        window.onresize();
    }
    function hide(name){
        for(e in this.elementslist){
            if(name != this.elementslist[e]){                
                var el = getElementById(this.elementslist[e]+"_image");
                if(el) el.style.display = "none";
                el = getElementById(this.elementslist[e]+"_icon");
                if(el) el.style.display = "block";
                el = getElementById(this.elementslist[e]);
                if(el) el.style.display = "none";
            }
        }
    }
    
    function doAutoHide(){    
        if(!this.selected) this.selected = this.elementslist[0];
        if(this.autohide && this.selected)
            this.show(this.selected,"auto");
        //this.selected = "";
    }
    function loaded(){
        this.loading.style.display="none";
    }
    function load(){
        this.loading.style.display="block";
        setTimeout("MenuContainer.loaded()",5000)
    }
    this.doAutoHide = doAutoHide;
    this.show = show;
    this.hide = hide;
    this.loaded = loaded;
    this.load = load;
    
    this.loading = getElementById("loading");       
    this.mc  = getElementById("menucontainer");       
    this.selected = "";    
    this.elementslist = new Array();    
    this.autohide= false;    
}
/* Object for the node's struct */
function objMenuNode(id,caption,description,url,target){
    //implementation
    function addItem(id,caption,description,url,target){
        var objnode = new objMenuNode(id,caption,description,url,target);
        this.nodelist[this.nodelist.length] = objnode;
        return objnode;
    }
    function getItems(){
        return this.nodelist;
    }
    function hasChild(){        
        return this.nodelist.length > 0 ? true : false;
    }
    //properties
    this.id = id;    
    this.caption = caption;
    this.description = description;
    this.url = url;
    this.target = target;
    this.icon = "";
    this.iconopen = "";
    this.state = "";
    this.nodelist = new Array();
    //metods
    this.addItem = addItem;
    this.getItems = getItems;
    this.hasChild = hasChild;
}
/* Object for handler the menu's area */
function menuArea(){
    var menucontext;
    var HTML = ""
    function clear(){
         menucontext = getElementById(this.area);
         HTML = "";
         menucontext.innerHTML = "";
    }
    function draw(){
        menucontext.innerHTML = HTML;
    }
    function write(str){
        HTML += str;    
    }        
    function html(){
        alert(HTML);
    }
    //methods
    this.area = "AppMenu"
    this.clear = clear;
    this.write = write;
    this.html = html;
    this.draw = draw;
}
/* Object for the menu's struct */
function objMenu(name,title,style){
    this.inheritFrom = objMenuNode;
    this.inheritFrom();
    this.inheritFrom = menuArea;
    this.inheritFrom();
    /* implementation  */
    function drawNode(id,node,marging,incoming) {
        var nodelist = node.getItems();        
        marging += "&#160;&#160;";
        for(var i=0; i < nodelist.length; i++) {
            xnode = nodelist[i];
            if(xnode.id == id) {
                this.selectednode = xnode;
                setCookieValue("menuopc",xnode.id,24);
            }
            if((id.indexOf(xnode.id) == 0)|| (xnode.id.indexOf(id) == 0) || !incoming || (node.id.indexOf(this.nodeparent)==0))
                if(xnode.hasChild() && (id.indexOf(xnode.id) == 0)){
                    this.write('<tr class="selected"><td align="center" valign="middle">');
                    this.write('<span class="downArrowOption"><\/span><\/td>');
                    this.write("<td nowrap='yes' title='"+ xnode.description +"' width='119' colspan='2'><a class='navi2' href='"+ xnode.url +"'  target='"+ (xnode.target.length > 0 ? xnode.target : "PAGECONTEXT") +"' onclick='return "+ this.objname +".selectNode(\""+xnode.id+"\","+xnode.hasChild()+")'>"+xnode.caption+"<\/a><\/td><\/tr>");
                }
                else{
                    if(!incoming){
                        this.write('<tr><td align="center" valign="middle"><span class="rightArrowOption"><\/span><\/td><td class="notselectedtop" width="119" nowrap="yes" colspan="2">');
                        this.write("<a class='navi' href='"+ xnode.url +"'  target='"+ (xnode.target.length > 0 ? xnode.target : "PAGECONTEXT") +"' onclick='return "+ this.objname +".selectNode(\""+xnode.id+"\","+xnode.hasChild()+");'>"+xnode.caption+"</a><\/td><\/tr>");
                        this.write('<tr><td width="139" colspan="3" bgcolor="4D76A0"/></tr>');

                    }
                    else {
                        this.write('<tr><td nowrap="yes"><\/td><td>');
                        if(xnode.id != id){
                          if(xnode.hasChild()) {
                            this.write('<span class="rightArrowOption"><\/span>');
                            this.write('<\/td><td class="notselected2" width="103">');
                          }
                          else {
                            this.write('<span class="circleOption"><\/span>');
                            this.write('<\/td><td width="103">');
                          }
                        }  
                        else {
                          this.write('<span class="rightArrowSelected"><\/span>');
                          this.write('<\/td><td class="selectedItem" width="103">');
                        }
                        this.write("<a class='navi3' href='"+ xnode.url +"'  target='"+ (xnode.target.length > 0 ? xnode.target : "PAGECONTEXT") +"' onclick='return "+ this.objname +".selectNode(\""+xnode.id+"\","+xnode.hasChild()+")'>"+ xnode.caption +"<\/a><\/td><\/tr>");
                    }
                }                    
            if(xnode.hasChild() && id.indexOf(xnode.id) == 0){                
                this.drawNode(id,xnode,marging,true);
            }
        }
    }
    
    function drawMenu(id,hasnodes) {
        /* if(this.selectednode == id) return true        */
        id = (!id ? "" : id);            
        var nodes = id.split('_');
        this.nodeparent = "";    
        if(!hasnodes) {
            for(var i = 1; i < nodes.length-2; i++)
                this.nodeparent += "_"+nodes[i];
            this.nodeparent +="_";        
        }
        else{
            this.nodeparent +="X_X";        
        }
        this.area = this.objname;
        this.clear();        
        var ediv = document.getElementById(this.area+'_div');
        /*
        if(ediv) e.div.style.height = '10px';
        var height = document.getElementById('menucontainer').offsetHeight;
        height = height < 100 ? 400 : height;
        */
        this.write('<table border="0" cellpadding="0" width="'+this.width+'"cellspacing="0" style="left=0">');
        this.write('<tbody><tr>');
        this.write('<td align="center" width="'+ this.width+'" colspan="3" title="'+ this.title+'"><div onclick="MenuContainer.show(\''+ this.area +'\',\'table\'); this.className = (MenuContainer.autohide ? \'pinleft\' : \'pin\')" title="Lock/Unlock menu" class="'+ (MenuContainer.autohide ? 'pinleft':'pin')+'">&#160;<\/div><b><span class="menuname" onclick="'+ this.objname +'.selectNode()" style="cursor:pointer">'+ this.name+'</span>');
        this.write('<\/b><\/td><\/tr>');
        this.write('<tr><td width="'+ this.width+'" colspan="3" valign="top"><div id="'+this.area+'_div" style="overflow:hidden;">');
        this.write('<table border="0" cellpadding="0"  width="'+this.width+'" cellspacing="0" style="left=0">');
        this.write('<tbody>');
        this.drawNode(id,this,"<br\/>",false);
        this.write('</tbody></table>');
        this.write('<\/div><\/td><\/tr>');    
        this.write('</tbody></table>');
        this.draw();
        //this.html();
    }
    
    function selectNode(id,hasnodes){        
	
        this.selectednode = null;
        this.drawMenu(id,hasnodes);       
		
        if(this.selectednode){
            if(this.selectednode.url.length > 0) {
                MenuContainer.load();                
                return true
            }
        }
        return false;
    }
    /* properties */
    this.nodeparent = ""
    this.selectednode = null;    
    this.name = name;
    this.title = title;    
    this.style = style;
    this.width = 139;
    /* methods    */
    this.objname = "AppMenu";
    this.drawNode = drawNode;
    this.drawMenu = drawMenu;
    this.selectNode = selectNode;
}

function clearHTML(eId,exp) {
    if (exp) {
        var e = getElementById(eId);
        if (e) e.innerHTML="";
    }
    return exp
}

function doActionCondition(cond, action) {
    if (cond){
        try{
            eval(action);
        }
        catch(e) {
            window.setTimeout(action,1000);  
        }
    }
    return cond
}

/*************************************************************************
 *** Author: Yovanis C�ceres L�pez
 *** Created: 11-26-04
 *** Comment: This Function is used for selecting the page selected
 *************************************************************************/
function gotoSelectedPage(){
    if(pagevalues.selected == currentpage) return;
    var argv = gotoSelectedPage.arguments;
    var argc = argv.length;    

    var paramarray ="";
    for (var i = 0; i < argc; i++) {    
        if(argv[i][0] == 'goto_page'){            
            argv[i][1] = pagevalues.selected;            
        }
        paramarray += (paramarray != "" ? ",":"")+"['"+argv[i][0]+"','"+argv[i][1]+"']"
    }
    paramarray = "doAction("+ paramarray +")"            
    try{
        x = eval(paramarray);    
        ErrorCount = 0;
    } catch(e){
        currentpage = 1;                        
    }
}
/*************************************************************************
 *** Author: Yovanis C�ceres L�pez
 *** Created: 11-25-04
 *** Comment: Handler response for lookup table
 *************************************************************************/
var HResponse;
function HandlerResponse(str){    
    switch(HResponse){
        case "HandlerResponseTable":            
            var e_tablesource = getElementById("tablesource");
            if(lookupBodyTable(str)){
                if(window.selectRow)
                  selectRow();
                else
                highlight();
            }                
            if(window.dpicker_obj) dpicker_refresh();
                        
    }        
    //submitform("about:blank","","RSIFrame");    
    runOnload(customOnLoad);
    if(window.CheckTransitionStatus)
      CheckTransitionStatus();
    return;
}
//-----------------------------------//
/*************************************************************************
 *** Author: Yovanis C�ceres L�pez
 *** Created: 02-19-05
 *** Comment: set and get the body of the table's. If the source attr is passed
 ***         then its will be the table's context. 
 ***         always table element is returned
 *************************************************************************/
function lookupBodyTable(source){
    var e_tablesource = getElementById("tablesource");
    if(e_tablesource){
        if(source) {		
            e_tablesource.innerHTML = source; 			
			source.evalScripts();			
        }
        return e_tablesource;
    }
    return false;
}
//-----------------------------------//
/*************************************************************************
 *** Author: Yovanis C�ceres L�pez
 *** Created: 11-25-04
 *** Comment: Remote Scripting with IFRAME
 *************************************************************************/
var IFrameObj; // our IFrame object
var IFrameURL="";
function callToServer(url) {
    isThereURL = url+"" != "undefined"	
    if(!isThereURL){        
        //IFrameURL +=IFrameURL.indexOf("xart_force_reload=1") < 0 ? "&xart_force_reload=1" : "";		
        url = IFrameURL;
    }
    url += url.indexOf("REMOTESCRIPT=1") < 0 ? "&REMOTESCRIPT=1" : "";	
    submitform(url+(!isThereURL ? "&xart_force_paging_reload=1" : ""),"","RSIFrame");        
    IFrameURL = url
    return false;                    
}
//-----------------------------------//
function getBodyHeightHF(){
    var adjHeight = 0;
    try{
        adjHeight = getElementById('pageheader').offsetHeight + getElementById('pagefooter').offsetHeight;
        return document.body.offsetHeight - adjHeight + 'px';
    }
    catch(e){
        return 0;
    }
}

// Function to move the elements's menu of folders

var mf_position = 1;
var mf_maxElements = 0;
var LookupState = "";

function setLookupState(state){
    LookupState = state;
}
function doMenuFolderScroll(updown){
    var i=1,e,rows=10;        
    // Setting mf_maxElements the first time
    while(mf_maxElements == 0){
        e = getElementById("scrollfolder_"+ i++);
        if(!e) mf_maxElements = --i
    }
    if((updown == 'up') && (mf_position > 1))
       mf_position--;
    else if ((updown == 'down') && (mf_position < (mf_maxElements-rows)))
       mf_position++;
    for(i = 1; i <= mf_maxElements; i++){
        e = getElementById("scrollfolder_"+ i);
        if((i >= mf_position) && (i <= mf_position+rows) && e){
          e.style.display="";          
        }
        else if(e) {
          e.style.display="none";
        }
    }        
    return;
}

/* Function to sets the values's parameter */
function doAction(){
    var argv = doAction.arguments;
    var argc = argv.length;
    var e,qstring="",s;
    var popup_window = "";
    var target = "";
    for (var i = 0; i < argc; i++) {                    
        if(((argv[i][0]+"").match(/^confirm$|^alert$/g)) && (argv[i][1].length > 5)){            
            popupOBJ.message = argv[i][1];
            popup_window = argv[i][0];
        }
        else if((argv[i][0] != "") && (argv[i][0] != 'parameters__') && (argv[i][0] != 'target__') && (argv[i][0] != 'handlerResponse')) {
            s = (qstring == "") ? "?" : "&"
            qstring += s + argv[i][0]+"="+argv[i][1];            
        }
        else{            
            switch(argv[i][0]){        
                case 'handlerResponse':                    
                    HResponse = argv[i][1];
                    break;
                case 'target__':
                    target=argv[i][1];                    
                    break;
            }
        }
        if(argv[i][0] == 'parameters__'){
            s = (qstring == "") ? "?" : "&"
            qstring += s + argv[i][1];
        }
        
        if (argv[i][0] == 'level_number') {
            var e = getElementById("level_number")
            if(e) e.value = argv[i][1];
        }
        
    }

    switch(true){
        case (target == 'RPC'):
            if(popup_window){
                popupOBJ.action = 'callToServer("Controller'+qstring+'")';            
            }
            else
                callToServer("Controller"+qstring);
            break;
        case (target == 'new'):
		    qstring = qstring.replace(/&calledBySubFolderTab=1/g,"");			
            target += (new Date()).getSeconds().toString();
			qstring += '&target=new';
            if(popup_window){			    
                popupOBJ.action = 'newwindowsubmitform("Controller'+qstring+'",document.f1,"'+target+'");'            
            }
            else			    
                newwindowsubmitform("Controller"+qstring,document.f1,target);
            break;
        case (target != 'same'):
            if(popup_window){
                popupOBJ.action = 'submitform("Controller'+qstring+'","","'+target+'");';            
            }
            else
                submitform("Controller"+qstring,"",target);				
            break;
        default:            
            if(popup_window){
                popupOBJ.action = 'submitform("Controller'+qstring+'");';            
            }
            else
                submitform("Controller"+qstring);
            break;            
    }
    
    if(popup_window){
        switch(popup_window.toLowerCase()){
            case "alert":
                popupOBJ.alertWindow();
                break;
            case "confirm":
                popupOBJ.confirmWindow();
                break;
        }
    }
    /*
    if ((argv[0][0] == 'target__') && (argv[0][1] != 'same')) {        
        newwindowsubmitform("Controller"+qstring,document.f1,argv[0][0]);
    }
    else       
        submitform("Controller"+qstring);
    */
}

var setWidgetsToSubmit = {
    fieldslist : new Array(),
    setEnabled : function(){
        var el = document.getElementsByTagName("input");
        for(var i = 0; i < el.length; i++){
            var e = el[i];
            if(el[i].disabled){
               this.fieldslist.push(el[i]);
               el[i].disabled = false;
            }
        }
    },
    resetState : function(){        
        for(var i = this.fieldslist.length-1; i >= 0; i--){
            this.fieldslist[i].disabled = true;            
        }           
        this.fieldslist = new Array();
    }
    
}

/* Functions to submit forms and to refresh locations */
function submitform(to,action,ftarget, e){        
    if(isAutoPostBackRunning(to,e)) return;	
    document.f1.action = to;
    document.f1.target = (ftarget ? ftarget : "");     
    if((ftarget+"").indexOf("autopostback_") >= 0)
    {
      document.f1.submit();
      return;
    }
    if (window.validateThisForm) {
        if (!validateThisForm(document.f1))
            return false;
        else
            isTheApplication = false;
    }
    isTheApplication = false;    
    setWidgetsToSubmit.setEnabled();
    document.f1.submit();
    window.setTimeout("setWidgetsToSubmit.resetState();",1000)    
}
function dosubmitform(action){
    if(isAutoPostBackRunning(action)) return;
    /* This is function is used by UIEditor App,
    it is slightly different to the one on top
    */
    if(action){
        var a = getElementById("action");    
        a.value = action;            
    } 
    var f = getElementById("f1");    
    if(window.validateThisForm){
        if (!validateThisForm(f)){                        
            return false
        }
        else isTheApplication = false;
    }
    isTheApplication = false;
    setWidgetsToSubmit.setEnabled();
    f.submit();
    window.setTimeout("setWidgetsToSubmit.resetState();",1000)    
    
    //submitform(parent.treeUI.location.href)           
}

function setValueCheckBox(id,value,position){
    var a = document.getElementsByName(id.substr(0,1) == '_' ? id.substr(1) : id);    
	var x = new Array();
	for(var i=0; i < a.length; i++)  if(a[i].type && a[i].type == "hidden") x.push(a[i]);	
    if(a && (x.length > 0)) x[x.length == 1 ? 0 : position ? position-1 : 0].value = value;    
}

function openNewWindow(url,name,msgbox,msg,winparam){   
    winparam = winparam ? winparam : 'copyhistory=no,directories=no,dependent=yes,height='+window.screen.height*3/4+',width='+window.screen.width*3/4+',location=no,status=yes,menubar=no,toolbar=no,resizable=yes';    
    popupOBJ.message = msg;
    msgbox +="";
    if(msgbox) popupOBJ.action = "window.open('"+url+"','"+name+"',);";            
    switch(msgbox.toLowerCase()){
        case "alert":
            popupOBJ.alertWindow();
            break;
        case "confirm":
            popupOBJ.confirmWindow();
            break;
        default:
            window.open(url,name,winparam); 
            break;
    }        
    return true; 
}

function newwindowsubmitform(to,theForm,target,winparam){
    if(isAutoPostBackRunning(to)) return;
    winparam = winparam ? winparam : 'copyhistory=no,directories=no,dependent=yes,height='+window.screen.height*3/4+',width='+window.screen.width*3/4+',location=no,status=yes,menubar=no,toolbar=no,scrollbars=yes,resizable=yes';    
    window.open('',target,winparam);
    theForm.target = target;
    theForm.action = to;
    theForm.submit();
}

function submitformConfirm(to,theMsg){
    if(isAutoPostBackRunning(to)) return;
    if (window.confirm(theMsg) ) {
        document.f1.action = to;
        if (window.validateThisForm) {
            if (validateThisForm(document.f1)){                            
                isTheApplication = false;
                return ;
            }
        }
        isTheApplication = false;
        document.f1.submit();
    }
}
function parserValue(value){   
   var re = /"/g;
   var re1 = /'/g;
   value += ""; 
   value = value.replace(re,"(quot)").replace(re1,"(apos)");     
   return escape(value).replace(/\+/g, '%2C').replace(/\"/g,'%22').replace(/\'/g, '%27');
}

function refresh(to){
    isTheApplication = false
    location.href = to;

}

function submit_index_request(to){
    if(isAutoPostBackRunning(to)) return;
    document.f1.indexPlace.value = to;
    document.f1.submit();
}
function refreshLastAction(){    
    if(!IFrameURL){   	
	    var url = window.location.href.toString().replace(/\&subprocess=\w+/g,"");
        window.refresh(url); 		
	}
    else 
        callToServer();
}

function refreshParentWhenDeleted(){
    refreshLastAction();
}

function refreshParentWhenChanged(){    
    theFlag = getCookieValue("isModified");    
    if ((theFlag == "1") && window.opener){
        setCookieValue("isModified","0",24);        
        if(window.opener.refreshLastAction)
            window.opener.refreshLastAction()
        //window.opener.refresh(window.opener.location.href); /* parent.location.href */
    }

}



/* 
 * Steps back through the opener chain looking for windows that should
 * be reloaded for this activity type.  These windows include:
 *   - the main list windows for the type (i.e. events_iframe, etc)
 *   - Any followUp lists encountered
 *
 * NOTE: this only works as long as the chain is not broken (i.e.
 *       closing an intermediate window
 * TODO: Could not find a way to enumerate windows not based on the
 *       current window or opener chain.  The top property only points
 *       to the highest window in trhis browser, not other browser
 *       windows.  So for now this has to rely on the opener chain
*/

function reloadActivityWindowsByType(sType) {
  var oWindow = window.opener;
  var oReloadWindow = null;

  theFlag = getCookieValue("isModified");
  if (theFlag == "1") {
    setCookieValue("isModified","0",24);
    /* a string list of the matches to be used for finding main windows */
    sListOfMainWindows = 'cal_event_dayview|cal_task_view|cal_call_view';
    while (oWindow != null) {
      oReloadWindow = null;
      sServletPath = oWindow.location.pathname;
      sServletSplit = sServletPath.split('/');
      sServletName = sServletSplit.pop().toLowerCase();
      /*alert('Servlet = ' + sServletPath + '\nSplit=' + sServletSplit + '\nName=' + sServletName);*/
      if (sServletName == 'followevent') {
        /*alert('Found followevent');*/
        oReloadWindow = oWindow;
      }
      else if (sListOfMainWindows.indexOf(sServletName) > -1) {
        /*alert('Found Main Window');*/
        if ( (sType[0] == 'E') || (sType[0] == 'e') ) {
          oReloadWindow = oWindow.parent.events_iframe;
          /*alert('Found E Window: name="' + oReloadWindow.location + '"');*/
        }
        else if ( (sType[0] == 'T') || (sType[0] == 't') ) {
          oReloadWindow = oWindow.parent.tasks_iframe;
          /*alert('Found T Window: name="' + oReloadWindow.location + '"');*/
        }
        else if ( (sType[0] == 'C') || (sType[0] == 'c') ) {
          oReloadWindow = oWindow.parent.calls_iframe;
          /*alert('Found C Window: name="' + oReloadWindow.location + '"');*/
        }
      }

      if (oReloadWindow != null) {
        /*oReloadWindow.location.reload();*/
        if (oReloadWindow.location.search != "") {
            var searchStr = oReloadWindow.location.search;
            if (searchStr.indexOf('xart_force_reload') < 0) 
                searchStr += '&xart_force_reload=1';
        }
        else
            var searchStr = '&xart_force_reload=1';
        oReloadWindow.location.assign('http://' + oReloadWindow.location.hostname + oReloadWindow.location.pathname + searchStr);
      }

      oWindow = oWindow.opener;
    }

  }

}



/*************************************************************************
 *** Author: Yovanis C�ceres L�pez
 *** Created: 02-24-04
 *************************************************************************/
function fillback(blank){
    var theCaller = window.opener ? window.opener : window.parent;
    try{        	    
	    rpc_list_showed--;	
        var lookupid = getLookupId();
        var rowIndex = getRowIndex();
        
        if(lookupid.length != 0){    
            var strfunction = "window." + (window.opener ? 'opener' : 'parent') + ".fillData_"+ lookupid +"(fillArray(blank), rowIndex);"        
            eval(strfunction);
			
        }
        else {
            //window.opener.setLookupState(getState());           
            window.opener ? window.opener.fillData(fillArray(blank, rowIndex)) : window.parent.fillData(fillArray(blank, rowIndex));
        }
        theCaller.handlerRPCActions.selecting = true;
        window.opener ? window.opener.CheckTransitionStatus() : window.parent.CheckTransitionStatus();
        //window.opener ? window.opener.setTimeout("CheckTransitionStatus()",1) : window.parent.setTimeout("CheckTransitionStatus()",1);
		// Check if the event 'onFillBack' is defined on either parent or opener;
		// then run it.	
        
		
		if (theCaller['onFillBack'])  theCaller['onFillBack'](lookupid);
        theCaller.handlerRPCActions.selecting = false;
		
    } catch(e){return}
	
    window.opener ? window.close() : closeListValues();	
}

function closeListValues(){    
  window.parent.document.getElementById(autopostback_frame_name).style.display="none"; 
  window.location.href = "about:blank";    
    
}
/*************************************************************************
 *** Author: Yovanis C�ceres L�pez
 *** Created: 02-2-04
 *************************************************************************/

function SetParentField(fieldname,value){    
	if(pageChanged){
	 lookupBodyTable(selectedPageBody);    
	 currentpage = pagevalues.selected;    
	 pageChanged = false;
	}
	var e = getElementById(lastRowId+"_"+fieldname);	
	if(e) {                   
		e.innerHTML = value;				
	}
	else SetFieldData(fieldname,value);
}

/*************************************************************************
 *** Author: Yovanis C�ceres L�pez
 *** Created: 02-2-04
 *************************************************************************/

function SetRowFieldData(fieldname,value){    
    var e = getElementById(lastRowId+"_"+fieldname);
    if(e) {                   
    gotoSelectedPage();
    e.innerHTML = value;          
    }
}

/*************************************************************************
 *** Author: Yovanis C�ceres L�pez
 *** Created: 02-2-04
 *************************************************************************/
function SetFieldData(fieldname,value){    
    var e = getElementById(fieldname);    
    if(e) {
     if(e.value+"" != "undefined")  e.value = value;
     else {		 	 
		 e.innerHTML = value;
		 e = document.f1[fieldname];		 
		 if(e) {
			 e.value = window.hasFormat ? (hasFormat(fieldname) ? dropFormat(value) : value) : value;		 
		 }
	 }
    }   
}

/*************************************************************************
 *** Author: Yovanis C?res L??
 *** Created: 02-2-04
 *************************************************************************/

function GetListFieldData(listfield,doaction_forced){    
 var result = "";    
 
 if(pageChanged && (doaction_forced != true)){
    lookupBodyTable(selectedPageBody);    
    currentpage = pagevalues.selected    
 }
 
 for(var i = 0; i < listfield.length; i++){
    result += GetRowFieldData(listfield[i])+"&";             
 } 
 return result;
}

/*************************************************************************
 *** Author: Yovanis C?res L??
 *** Created: 07-3-04
 *************************************************************************/
function clearLevelAction(){
  var e = document.getElementById("level_action");
  if(e) e.value = "";
}
function valid_edit_level(level,action,url,e){
    
  var levelaction = getElementById("level_action");
  var levelnumber = getElementById("level_number");
  var x = (action == 'edit') ? 1 : 0;
        
  if(((level > 0) && check_editstatus(x)) || (x < 1)){    
    levelnumber.value = level;    
    levelaction.value = action;    
    
    submitform(url,null,null,e);
  }  
    return true;
}

/*************************************************************************
 *** Author: Yovanis C?res L??
 *** Created: 19-04-04
 *************************************************************************/
function getEditStatus(){
  var e = null;
  if(window.rpcmgrIsRunning) return true;
  if(window.parent)
    var e = window.parent.getElementById("ctrl_editing");  
  else 
    var e = getElementById("ctrl_editing");
  return (e && e.value == 'yes') ? false : true 
}

/*************************************************************************
 *** Author: Yovanis C?res L??
 *** Created: 19-04-04
 *************************************************************************/
var element_clicked = 0;
function saveFocus(el){
var savefocus; 
  try{
      if(window.parent){    
        window.parent.document.element_clicked = el;    
      }
      else 
        element_clicked = el;    
  }catch(e){}  
}

/*************************************************************************
 *** Author: Yovanis C?res L??
 *** Created: 19-04-04
 *************************************************************************/
function returnFocus(){
var savefocus; 
  try{
    if(window.parent)
        var savefocus = window.parent.document.element_clicked;  
    else 
        var savefocus = document.element_clicked;        
    savefocus.focus();
    }
    catch(e){}
    
}

/*************************************************************************
 *** Author: Yovanis C?res L??
 *** Created: 19-04-04
 *************************************************************************/

function check_editstatus(paramediting){ 
var result = true;
var e = null;
  if(window.parent)
    e  = window.parent.getElementById("ctrl_editing");  
  if(!e) e  = getElementById("ctrl_editing");
  if(e){
  switch(true){
      case paramediting > 0:
        if (e.value == 'yes') result = false;
        
        break;
      case paramediting == 0:
        e.value = "no";
        break; 
      default:
        if ((e.value == 'yes') && (paramediting == 'document')) result = false;
  }  
  
  if(paramediting == "INPUT" && result && window.event.srcElement.id){
    saveFocus(window.event.srcElement); 
  }
  else {
    returnFocus();
  }

  }  
  return result
}

/*************************************************************************
 *** Author: Yovanis C?res L??
 *** Created: 02-2-04
 *************************************************************************/
function GetRowFieldData(field,withoutName,blank){    
 var result = "";     
    if(withoutName != "yes") 
        result = field + "="        
    
    if(blank=="blank") return result+="";
    var e = getElementById(lastRowId+"_"+field);
    if(e) {                   
        result += e.innerHTML;
        SetFieldData(field,e.innerHTML)
    }
    else {        
        e = getElementById(field);
		if(e){
			if(e.value +"" != "undefined")
				result += e.value;
			else
				result += e.innerHTML;
		}
        else result += "None";
    }   
 return result;
}

/*************************************************************************
 * Functions to highlight rows in tables and handle double click effects *
 *************************************************************************/

var lastRowId;
var pagevalues = {name:"",bizflow:"",rowdata:"",rowid:"",selected:""}
var selectedPageBody = "";
var pageChanged = false;

function highlight(rowid,name,BizFlow,rowdata) { 

    if (!window.currentpage) return;
    var x = 1;
    if(!rowid){
        pageChanged= true;        
        if(currentpage == pagevalues.selected){                
            name= pagevalues.name;
            BizFlow=  pagevalues.bizflow;
            rowdata=  pagevalues.rowdata;            
            var rowelement =getElementById(pagevalues.rowid);
            if (!rowelement) {     
                pagevalues.rowid = pagevalues.rowid.replace(/_row[0-9]+$/g,"_row1");
				rowelement = getElementById(pagevalues.rowid);
                if (!rowelement) {
                    CheckTransitionStatus();
                    return;
                }
            }
            rowid =  pagevalues.rowid;
            rowelement.onclick();
            return;            
        }
        else             
           return;        
    }    
    pagevalues.rowid = rowid;
    pagevalues.selected=currentpage;
    pagevalues.name=name;
    pagevalues.bizflow=BizFlow;
    pagevalues.rowdata=rowdata;    
    if(!isonload && !getEditStatus()) return false;
    /* lastRowId holds the id of the last selected row; rowid holds the id for
     * the currently clicked row. Thus, if rowid is the same as lastrowid
     * nothing sholud be done */    
    try{
        if (lastRowId && (lastRowId != rowid) && getElementById(lastRowId)) {            
            if (getElementById(lastRowId).className == 'highlightedEven')
                getElementById(lastRowId).className = "rowEven";
            else
                getElementById(lastRowId).className = "rowOdd";
        } 

        if (getElementById(rowid)) {
            if (getElementById(rowid).className == 'rowEven')
                getElementById(rowid).className = "highlightedEven";
            else
                getElementById(rowid).className = "highlightedOdd";   
            setCookieValue(name+"_highliRow",rowid,12);
            getElementById(BizFlow).value = rowdata;
            selectedPageBody = lookupBodyTable().innerHTML;            
        }
        
    if ((lastRowId == rowid) && (pageChanged == false)) {/* Need to do anything? */                    
          return false;
       }       
	lastRowId=rowid;   
	getWkeyLine();
	//updateCurrentRec(rowid.replace(/.*_row/,""));
	CheckTransitionStatus();
	pageChanged = false;
	if (!isonload) {
		refreshTab();       
		}
    }
    catch(e){}    
    isonload = false;
}
function getWkeyLine(){
  var result = 0;
  try{      
    var e = getElementById("idx_"+pagevalues.rowid);    
    result = e.innerHTML;
  } catch(e){}  
  updateCurrentRec(result);
  return pagevalues.rowid.replace(/.*_row/,"");
}
function updateCurrentRec(line){
	try{
	var e = getElementById(wkey_line);
	if(e) e.value = line;
	} catch(e){}
}
function getCurrentRec(){
    try{    
        var e = getElementById(wkey_line);
        return e.value*1;
    } catch(e){}
}

function getCookieValue(name) {
  var cookieData = new String(document.cookie);
  var cookieStart = cookieData.indexOf(name+"=");
  var cookieEnd = cookieData.indexOf(";",cookieStart);
  if (cookieEnd == -1)
    cookieEnd = cookieData.length;
  if (cookieStart != -1) 
    return cookieData.substring(cookieStart + name.length + 1,cookieEnd);
  else
    return "";
}

function setCookieValue(name,value,expiresIn) {
  //alert('setCookieValue: '+name+' ----- '+value);
  var cookieDate = new Date();
  cookieDate.setTime(cookieDate.getTime() + expiresIn * 60 * 60 * 1000);
  document.cookie = name + "=" + value + ";expires=" + cookieDate.toGMTString();
}

function delCookie(name){
  var cookieDate = new Date();
  cookieDate.setTime(cookieDate.getTime() - 24 * 60 * 60 * 1000);
  document.cookie = name + "=;expires=" + cookieDate.toGMTString();
}

function returnId(name) {
  objId = getCookieValue(name+"_highliRow");
 
  if (objId) {
    return objId;
  }
  else {
      
  }
    return "";
}

function doDoubleClick(rowid,name,simpleId) {
  highlight(rowid,name);
  return simpleId;
    }

function rehighlight(name) {  
  levelnumber = getElementById("level_number");  
  
  if(levelnumber && (levelnumber.value > 0)){
    oldObjId = name+"_l_row"+ levelnumber.value
  }
  else  oldObjId = getCookieValue(name+"_highliRow"); 
  
  if (oldObjId) {
    if(getElementById(oldObjId)){          
        try{eval(getElementById(oldObjId).onclick())}catch(e){
            try{eval(getElementById(name+"_l_row1").onclick())}catch(e){}
            } 
        return       
    }
  }
  try{eval(getElementById(name+"_l_row1").onclick())}catch(e){}        
  
    //Loading folders if they were rendered
    /*
      if(window.loadFolders){    
          try{
              //we use it for creating Folders' Object and 
              //the previously selected folder if it exist in the cookies session .
              loadFolders(); 
      }catch(e){}
      
    }*/
}

/******************************************************************************
 * functions to check/uncheck all check boxes within a table */

function check(field)
{
  var i;
  try{
  if (eval(field[0].checked))
    {
      for (i=0;i<field.length;i++)
        field[i].checked=true;
      LL(field); 
      return "Uncheck All";
    } 
  else
    { 
      for(i=0;i<field.length;i++)
        field[i].checked=false;
      UU(field); 
      return "Check All";
    } 
  } catch(e){}	
}

function LL(field){field.disabled=true;}

function UU(field){field.disabled=false;}

/******************************************************************************
 * Auxiliary functions in rendered forms with time inputs */

function setHiddenTimeValue(hiddenField,hourField,minuteField){
  var newValue = "('" + hourField.value + "','" + minuteField.value + "')";
  hiddenField.value = newValue;
}

function increaseHour (theField,amount,showsTime){
  if (isNaN(theField.value))
    return;
  var newValue = Number(theField.value) + amount;
  if (newValue >= 24 && showsTime)
    newValue = newValue % 24;
  else if (newValue < 0)
    if (showsTime)
      newValue = 24 + newValue;
    else
      newValue = 0;
  if (newValue < 10)
    theField.value = "0" + newValue;
  else
    theField.value = newValue;
}

function increaseMinute (theField,amount){
  if (isNaN(theField.value))
    return;
  var newValue = Number(theField.value) + amount;
  if (newValue >= 60)
    newValue = newValue % 60;
  else if (newValue < 0)
    newValue = 60 + newValue;
  if (newValue < 10)
    theField.value = "0" + newValue;
  else
    theField.value = newValue;
}

function adjustHours(theField,showsTime){
  if (isNaN(theField.value))
    return;
  var current = Number(theField.value);
  if (showsTime){
    current = current % 24;
    theField.value = current;
  }
  if (current < 10)
    theField.value = "0" + current;
}

function adjustMinutes(theField,hoursField,showsTime){
  if (isNaN(theField.value) || isNaN(hoursField.value))
    return;
  var current = Number(theField.value);
  var currHours = Number(hoursField.value);
  if (current >= 60){
    hours = Math.floor(current / 60) + currHours;
    current = current % 60;
    theField.value = current;
    hoursField.value = hours;
    if (showsTime)
      adjustHours(hoursField,showsTime);
    else
      if (hours < 10)
        hoursField.value = '0' + hours;
  }
  if (current < 10)
    theField.value = "0" + current;
}

/******************************************************************************
 * Auxiliary function in lookup functionality */

function fillData(anArray){

  for (var cnt = 0; cnt < anArray[0].length; cnt++){      
    var theObjects = getElementById(anArray[0][cnt]);
    if ( theObjects ){
       try{
       if(theObjects.type == "checkbox"){ // Checkboxes must be handled differently
           theObjects.checked = anArray[1][cnt] ? true:false;
       }
       theObjects.value = anArray[1][cnt];  
       if(!theObjects.type)
         theObjects.innerHTML = anArray[1][cnt];                        
       var theObjects = getElementById(anArray[0][cnt]+'_field');
       if(theObjects)
           theObjects.value = anArray[1][cnt];
       } catch(e){}
       
    }
  }
}

/******************************************************************************/

/*
Submit Once form validation- 
� Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

function submitonce(theform)
{
  //if IE 4+ or NS 6+
  if (document.all||getElementById)
    {
      //screen thru every element in the form, and hunt down "submit" and "reset"
      for (i=0;i<theform.length;i++)
    {
      var tempobj=theform.elements[i]
        if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
          {
        //disable em
        tempobj.disabled=true;
          }
    }
    }
}

/* Function for clicking clock. objId defines the object which will
 * display the clock. format24 with a value of 1 will display the time using a
 * 24 hour format, otherwise uses AM/PM format.
 * */
function showclock(objId,format24) {
    var Digital = new Date();
    var hours = Digital.getHours();
    var minutes = Digital.getMinutes();
    var seconds = Digital.getSeconds();
    var dn = "AM";
    var theObject = getElementById(objId); /* should be returning a widget that I can change its inner HTML */
	if(theObject){
		if (hours >= 12 && format24 != 1){
			dn = "PM";
			hours = hours - 12;
		}
		if (format24 == 1)
			dn = "";
		if (hours == 0)
			hours = 12;
		if (minutes <= 9)
			minutes = "0" + minutes;
		if (seconds <= 9)
			seconds = "0" + seconds;
		theObject.innerHTML = hours + ":" + minutes + ":" + seconds + " " + dn;
		setTimeout("showclock('" + objId + "'," + format24 +")",1000);
	}
}

/************************************************************************* 
 *** Author: Yovanis C�ceres L�pez
 *** Created: 08-23-05
 *** Comment:  This function show a tab-view depending of the current edit-level.
 *** parameters: obj --> Object that holder the view (viewtabs' name)
 ***             view --> View's reference (ref)
 ***             level --> Level Number to show the view (level)
 *************************************************************************/
function showViewLevel(obj,view,level){
  if(level_number == level)  {    
    setTimeout(obj+".selectFolder('"+view+"');",10);
  }  
}

/* Function to deal with AppGenerator */
function XUIE_Action(nodeid,action,etype){
try{
      switch(action){            
        case "newElement":                
          var vetype = getElementById("elementtype")    
          vetype.value = etype;
                  var e = getElementById("toNode");
                  e.value = nodeid;                         
                  dosubmitform(action);
                  break;
            case "down":
            case "up":  
                  var e = getElementById("fromNode");
                  e.value = nodeid;             
                  dosubmitform(action);
                  break;
            case "del":             
                  var e = getElementById("fromNode");
                  e.value = nodeid;             
                  dosubmitform("del");
                  break;
            case "cut":  
			      
            case "copy":
                  var e = getElementById("fromNode");
                  e.value = nodeid;                  
                  break;
            case "paste":
			      if(window.top.getLastAction() == ""){
				    alert("An element need to be selected for Cut or Paste Action");
					return; 
				  }				  
			      var e = getElementById("action");
                  e.value = window.top.getLastAction();				  
				  if(e.value == "cut") {
				    var e = getElementById("fromNode");
                    e.value = window.top.getFromNode();
					window.top.setLastAction("copy");
				  }							  
                  var e = getElementById("toNode");
                  e.value = nodeid;						  
                  dosubmitform();				  
                  break;            
            case "refresh":
                  dosubmitform("refresh");
                  break;
            case "apply":
                  dosubmitform("apply");
                  break;
            case "save" :
                  dosubmitform("save");
                  break;
        case "refresh" :
                  dosubmitform("refresh");
                  break;
      }
      }catch(e){alert("Action not allowed on this context !!!");}      
}

/* Function to show/hide traceback in exception manager 
*/
function shExcTB(){
    var theDiv = getElementById('excTraceback');
    var statusOn = getElementById('tbstatuson'); /* represents the current status */
    var statusOff = getElementById('tbstatusoff'); /* same as above */
    if (theDiv.style.visibility=="visible") {
        theDiv.style.visibility = "hidden";
        statusOff.style.display = "none";
        statusOn.style.display = "inline";
    }
    else {
        theDiv.style.visibility = "visible";
        statusOff.style.display = "inline";
        statusOn.style.display = "none";
    }
}

/* Function to show/hide overview in all pages (where available)
*/
function shOverview(theId, thisAnchor, theProtectionId) {
    var theDiv = getElementById(theId);
    var theProt = getElementById(theProtectionId);

    if (theDiv.style.display == 'block') {
        theDiv.style.display = 'none';
        if (navigator.appName.indexOf("Microsoft")!=-1)
            theProt.style.display = 'none';
        thisAnchor.className = '';
    }
    else {
        theDiv.style.display = 'block';
        if (navigator.appName.indexOf("Microsoft")!=-1) {
            theProt.style.width = theDiv.offsetWidth + 'px';
            theProt.style.height = theDiv.offsetHeight + 'px';
            theProt.style.display = 'block';
        }
        thisAnchor.className = 'overviewselected';
    }
}

/* Function for export combo box in multi pages (grids) 
*/
function doExportAction(attrList, theObj) {
    var selectors = document.getElementsByName('ExportSelect');
    var theIndex = theObj.selectedIndex;
    var cnt;
    for (cnt = 0; cnt < selectors.length; cnt++) {
        if (selectors[cnt] != theObj)
            selectors[cnt].selectedIndex = theIndex;
    }
    if (attrList != 'None') {
        var theArray = eval(attrList);
        doAction(['target__',theArray[1]],['parameters__',''+theArray[4]+''],['state',theArray[0]],['wpkey',theArray[3]],['event',theArray[2]],['alert',''],['confirm',''],['subprocess','']);
    }
}

/* Funtion for get a time string to paste in URL's call*/
function getTime(){
 var time =   (new Date()).toString().replace(/ /g,"");
  return time;
}

/*This function is use to go back to the previus windows or close it if it's the first window*/
function GoBackOrCloseWindow(){    
    if (history.length) history.back();
    else window.close();
}


/* Funtion to aid in the login screen (visual effects) */
function enablePasswordChange(checked,NormalLabel,ChgLabel) {
    var theRow1 = document.getElementById('login_new_pwd_row');
    var theRow2 = document.getElementById('login_new_pwd_retype_row');
    var theButton = document.getElementById('login_btn');
    if (checked) {
        theRow1.style.display = 'table-row';
        theRow2.style.display = 'table-row';
        theButton.value = ChgLabel;
    }
    else {
        theRow1.style.display = 'none';
        theRow2.style.display = 'none';
        theButton.value = NormalLabel;
    }
}

function resizefolders(e){
}

function geWindowSize(){
    if (self.innerWidth)
    {
        frameWidth = self.innerWidth;
        frameHeight = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientWidth)
    {
        frameWidth = document.documentElement.clientWidth;
        frameHeight = document.documentElement.clientHeight;
    }
    else if (document.body)
    {
        frameWidth = document.body.clientWidth;
        frameHeight = document.body.clientHeight;
    }
    else return {width:0, height:0};
    return {width:frameWidth, height:frameHeight}
}

function getResizeWindow()
{
    var winsize = geWindowSize();
    
    frameWidth = winsize.width;
    frameHeight = winsize.height;
    
    if (self.screen.width < frameWidth *2 || self.screen.height < frameHeight *2)
    {
        newWidth = self.screen.width/2;
        newHeight = self.screen.height/2;
        if (document.layers)
        {
            tmp1 = parent.outerWidth - parent.innerWidth;
            tmp2 = parent.outerHeight - parent.innerHeight;
            newWidth -= tmp1;
            newHeight -= tmp2;
        }
        parent.window.resizeTo(newWidth,newHeight);
        parent.window.moveTo(self.screen.width/4,self.screen.height/4);
    }
    else
    {
        alert('No resize necessary');
    }
}

// Sacha May 15 2006
// This returns the value of varStr found in the query string of the URL
function extractUrlVar(varStr){
	var location = String(window.location);
	var addressIndex = location.indexOf(varStr)
	
	location = location.slice(addressIndex);
	ampersand = location.indexOf('&')
	varValue = location.slice(varStr.length+1, (ampersand >= 0)? ampersand:location.length+1)
	
	return varValue;
}


/************************************************************************* 
 *** Author: Yovanis C�ceres L�pez
 *** Created: 05-20-06
 *** Comment: This function is the handler to select all elements to copy in UI-Editor
 *************************************************************************/
function updateCheckBoxStatus(e, all){    
    if(all >= 100){        
        e = document.getElementById(e);	
	if(!e) return;
	if(all == 100){
	   if(e.disabled) return;
	   e.checked = !e.checked;
	   all = 101;
	}	
    }
    var eList = document.getElementsByName(e.name);
    for(var i=0; i < eList.length; i++){	    
      if(eList[i].className == e.value) {
	eList[i].disabled = !e.checked || e.disabled;
        if(all == 101) {	  
	  eList[i].checked = e.checked;	  
	}	
	if(!all) all = 102;
	updateCheckBoxStatus(eList[i].id, all);	
      }
    }    
    getAllElemChecked();
}
function getAllElemChecked(){
    var allchecked = ",";
    var eList = document.getElementsByTagName("input");    
    for(var i=0; i < eList.length; i++){	    
      if(eList[i].checked && !eList[i].disabled) allchecked+= eList[i].value+",";
    }        
    var e = window.parent.document.getElementById("checkbox");    
    if(e) e.value = allchecked;
    
    return allchecked;
}

/************************************************************************* 
 *** Author: Javier Andalia
 *** Created: 08-07-06
 *** Comment: Overriding default behaviour for 'back' property of js history object.
 *************************************************************************/
history.back = function(){
                          try{
						      lastURL = getCookieValue('lastURL')
                			  if (lastURL.length > 0) {
									location.href = lastURL;
									delCookie('lastURL');
								}
							  else {history.go(-1);}							  
						  }
						  catch(e){alert(e)}
}
/************************************************************************* 
 *** Author: Yovanis C�ceres L�pez
 *** Created: 08-15-06
 *** Comment: Filter rows based on the criterial, this function is used by AppDesigner
 *************************************************************************/
 function selectRows(id,criterial){
   var counter =0;
   var elementTable = dojo.widget.manager.getWidgetById(id)   
   if(!elementTable["originalData"]){
     elementTable["originalData"] = elementTable.data;
   }
   var data= new Array();
   var counter = 0;
   if(elementTable) {           
     for(var i =0; i< elementTable["originalData"].length; i++){                     
        var celldata = "";
        for(cell in elementTable["originalData"][i])
          if(elementTable["originalData"][i][cell][0] != "<")
            celldata += elementTable["originalData"][i][cell]+"|";
        
        if((celldata.toLowerCase().indexOf(criterial.toLowerCase()) != -1) || (criterial=="") ){          
          elementTable["originalData"][i]["index"] = ++counter;
          data.push(elementTable["originalData"][i]);
        }         
     }          
     elementTable.parseData(data);
     elementTable.render(true);
   }
 }
 
/*--------------------------------------------------------------------*/
/*--- This Editor's session 
/*--------------------------------------------------------------------*/
function saveSpec(){
	try{		
		var txt_SpecNotes = document.getElementById('txt_SpecNotes');
		var replaceSCharacters = "editor.getHtml().replace(_[12]_g,\"'\").replace(_[34]_g,'\"').replace(_5_g,\"..\").replace(_[67]_g,\"!\").replace(_@_g,\"@\");";
		replaceSCharacters = replaceSCharacters.replace(/_/g,"/");
		replaceSCharacters = replaceSCharacters.replace(/1/g,unescape("%u2018").toString()).replace(/2/g,unescape("%u2019").toString());
		replaceSCharacters = replaceSCharacters.replace(/3/,unescape("%u201C")).replace(/4/,unescape("%u201D"));
		replaceSCharacters = replaceSCharacters.replace(/5/,unescape("%u2026"));
		replaceSCharacters = replaceSCharacters.replace(/6/,unescape("%21")).replace(/7/,unescape("%A1"));

		if(editor && txt_SpecNotes) {
   			txt_SpecNotes.value = eval(replaceSCharacters);
  }
	} catch(e){}
}
/*--------------------------------------------------------------------*/
var editorRendered = false;
var editor = false;
function checking_IfEditorRendered(value){
  if(!editorRendered){	  
	  var editorArgs = {items: ["formatblock", "|", "insertunorderedlist", "insertorderedlist", "|", "bold", "italic", "underline", "strikethrough", "|", "createLink", "insertimage", "inserthorizontalrule", "|", "justifyleft", "justifycenter", "justifyright", "|", "forecolor", "hilitecolor"]};	  
      editor = dojo.widget.fromScript("Editor", editorArgs, document.getElementById("editor"));	  
	  editorRendered = true;	  
  }
}
/********************************************************************** 
 *** Author: Yovanis Caceres Lopez
 *** Created: 08-16-06
 *** Comment: All methods to work with toolbar need to be in the object below
/*--------------------------------------------------------------------*/
/* ToolBar Objects                                                    */
/*--------------------------------------------------------------------*/
var dojoToolBar = {	
	setDisabled : function(itemId, state){
	        if(!dojo.widget || !dojo.widget.manager) return false;
		var item = dojo.widget.manager.getWidgetById(itemId);
		if(item) {
			if(state) 
				item.disable(); 
			else 
				item.enable();
		}
	}
}
/*--------------------------------------------------------------------*/
document.write("<script type='text/JavaScript' language='JavaScript' src='\/SentaiStatic\/rules.js'><\/script>");
document.write('<script src="/SentaiStatic/prototype.js" type="text/javascript" language="JavaScript"><\/script>');
