function PageBase() {

    this.Clipboard = null;
    this.LibraryHost = '';
    this.LibraryHostPath = '';
    this.FileHostPath = '';
    this.ExecFile = '';

    this._arr_div_window = new Array();
    this._arr_action_list = new Array();
    this._dic_action = new Object();
    this._interval_action_list = null;
    
    this.CallbackFunc = null;
    this.CountActiveCallback = 0;
    this.PendingAction = new Array();
    
    this.ant_obj1 = null;
    
    this.expand_ant_sel = new Object();
    
    this._arr_expression  = new Object();
    this._arr_expression_count = 0;
    
    this._int_sync1 = null;
    this._check_sync1 = new Object();
    
    //this._ActionRefRender = false;
    
    this.NewSync = new Array();
    
    this.SyncServerTime = false;
    
    this.Testing = null;
    this._AntTimeExp = null;
    
    this.DoRenderCompleto = true;
    this.DoSync = false;
    
	this._arr_callback = new Array();
	this._arr_callback_start = 0;
	this._arr_callback_count = 0;
	
	this._obj_height = new Array();
	this._obj_height_first = true;
	
	this.StatSessID = '';
	this.StatEmpresa = '';
	
	this.RedirectLink = '';
	this.CtrlToSync = new Array();
	this.CountToSync = 0;
	
	this.ActiveCompany = '';
	
	this.IsHoldScreen = false;
	
    this.CallbackFuncSync = function(aObjParam, aRetFunc, aUrl) {
		this._arr_callback[this._arr_callback_count] = new PageCallbackAction(aObjParam, aRetFunc, aUrl, this._arr_callback_count);
		this._arr_callback[this._arr_callback_count].DoAction(false);
		this._arr_callback_count++;
    }

    this.CallbackFuncSync2 = function(aObjParam, aData, aRetFunc, aUrl) {
		this._arr_callback[this._arr_callback_count] = new PageCallbackAction(aObjParam, aRetFunc, aUrl, this._arr_callback_count);
		this._arr_callback[this._arr_callback_count].DoAction(false, aData);
		this._arr_callback_count++;
    }

    window.ValidatorGetValue = function(aId) {
        var lcontrol;
        lcontol = document.getElementById(aId);
        if(lcontrol && typeof(lcontrol.value) == 'string') {
            return lcontrol.value;
        } else if(robj(aId) && robj(aId).get_Text) {
            return robj(aId).get_Text();
        }
        
        return window.ValidatorGetValueRecursive(lcontrol);
    }
    
    window.ValidatorOnChange = function(event) {
        if (!event) {
            event = window.event;
        }
        Page_InvalidControlToBeFocused = null;
        var targetedControl;
        if ((typeof(event.srcElement) != "undefined") && (event.srcElement != null)) {
            targetedControl = event.srcElement;
        }
        else {
            targetedControl = event.target;
        }
        var vals;
        if (typeof(targetedControl.Validators) != "undefined") {
            vals = targetedControl.Validators;
        }
        else {
            if (targetedControl.tagName.toLowerCase() == "label") {
                targetedControl = document.getElementById(targetedControl.htmlFor);
                vals = targetedControl.Validators;
            }
        }
        if(vals) {
            var i;
            for (i = 0; i < vals.length; i++) {
                ValidatorValidate(vals[i], null, event);
            }
            ValidatorUpdateIsValid();
        }
    }
    
    //document.write('<textarea>' + window.ValidatedTextBoxOnKeyPress + '</textarea>');
    /*for(att in window)
        if(att.indexOf('Key') != -1)
            alert(att + ' -> ' + window[att]);*/
        
    this.BeforeHandleCallback = function(aObjParam) {
    }
    
    this.HandleCallbackSync = function(aResp) {
        if(aResp !== false) {
            eval(aResp);
        }
        setTimeout('Page_obj.DoCallbackNewSync();',1700);
    }
    
    this.HandleCallbackSync2 = function(aResp) {
        if(aResp !== false) {
            //alert('Resp:' + aResp);
            eval(aResp);
            setTimeout('Page_obj.DoCallbackSync2();',1000);
        }
    }

    this.HandleCallbackCustomProc = function(aResp) {
        if(aResp !== false) {
            eval(aResp);
        }
    }

    this.HandleCallbackGetServerTime = function(aResp) {
        if(aResp !== false) {
            Page_obj.gblTime = (new Date()).getTime();
            eval(aResp);
        }
    }

    this.HandleCallback = function(aResp,aContext) {
        //alert(aResp);
        var lreg = new RegExp("<script id='proper'> (.*) </script>","m"); 
        var lscript = aResp.match(lreg);
        if(lscript && lscript[1])
            aResp = aResp.replace(lscript[0],'');
        if(lscript && lscript[1] != null) {
            var lnewdiv = document.createElement('div');
            var lscript_find = '';
            lnewdiv.innerHTML = aResp;
            var lnode = lnewdiv.firstChild;
            while(lnode != null)
            {
                var lnext = lnode.nextSibling;
                if(lnode.tagName != 'SCRIPT')
                {
                    var lid = lnode.id;
                    var lid_ref = document.getElementById(lid);
                    if(lid_ref) {
                        var lparent = lid_ref.parentNode;
                        var lhide = lid_ref.style.display;
                        lparent.replaceChild(lnode,lid_ref);
                        lid_ref = document.getElementById(lid);
                        if(lhide == 'none')
                            lid_ref.style.display = lhide;
                    }
                }
                else
            	    lscript_find += lnode.text;
        	    lnode = lnext;
            }
            //alert(lscript[1]);
            setTimeout((lscript&&lscript.length>0?lscript[1]:'') + lscript_find + 'Page_obj.ProcIntervalActionList();Page_obj.ProcessWindowAfterCallback();',3);
        } else if(Page_obj.ant_obj1 != null && aResp != '') {
            Page_obj.CountActiveCallback--;
            setTimeout('Page_obj.DoCallback(Page_obj.ant_obj1,Page_obj.ant_obj2,Page_obj.ant_obj3,Page_obj.ant_obj4);',50);
        }
    }
    
    this.ProcessWindowAfterCallback = function() {
        if(Page_obj._arr_div_window && Page_obj._arr_div_window.length > 0) {
        	var lid_win = Page_obj._arr_div_window[Page_obj._arr_div_window.length-1]; 
        	eval('robj("' + lid_win + '")._ant_element=null;');
        	for(var i = 0; i < Page_obj._arr_div_window.length; i++) {
        	    lid_win = Page_obj._arr_div_window[i];
        	    var lref = document.getElementById(lid_win);
        	    if(lref && Browser_obj.is_Msie()) 
        	        Util_obj.HideSelect(lref);
        	}
        }
        if(typeof(ValidaHeight) != 'undefined')
            ValidaHeight();
    }
    
    this.HandleCallbackError = function(aParam) {
        //alert(aParam);
        /*var larr = aParam.split('0|');
        if(larr.length > 0)
            alert(larr[0]);*/
        Page_obj.CountActiveCallback--;
    }
    
    this.DoCallback = function(aControlRef,aParam,aCommand,aRender) {  
        //alert('Paso1 ' + this._arr_expression_count);
        
        this.CountActiveCallback++;
        
        if(this._arr_expression_count > 0) {
            this.ProcIntervalExpression(0);
        }
        //alert('Paso2');
        
        if(!(typeof(aControlRef) == 'object' && aControlRef.length > 0))
            aControlRef = [aControlRef];

        if(typeof(aControlRef[0].get_Attr) != 'undefined' && aControlRef[0].get_Attr('c00') != null && this['GroupEC'] == null) {
            this['GroupEC'] = Page_obj.get_ElementsByAttribute(document.body, '*', 'c01', '1');
        }

        var lgroups = new Object();
        var lMyArr = new Array();
        
        var lobj = new Object();
        lobj.Command = aCommand;
        lobj.Render = aRender;
        lobj.ControlId = new Array();
        lCommandCtrl = aCommand.replace('NewCtrl__', '');
        for(var i = 0; i < aControlRef.length; i++) {
            aControlRef[i]._mytimeout = null;
            lobj.ControlId[lobj.ControlId.length] = aControlRef[i].UniqueId;
            if(aControlRef[i].PreRender && aRender)
                aControlRef[i].PreRender();
            if(aCommand.substr(0,9) != 'NewCtrl__') {
                var larr = aControlRef[i].RenderGroup.split(',');
                for(var j = 0; j < larr.length; j++)
                    lgroups[larr[j]] = 1;
            } else {
                lMyArr[lMyArr.length] = aControlRef[i];
                if(robj(lCommandCtrl))
                    lMyArr = robj(lCommandCtrl).get_ToArrayList(lMyArr);
                lgroups['NoGroup'] = lMyArr;
            }
        }
        //alert('Paso3');
        //alert(lgroups['NoGroup']);
        var lcount = 0;
        lobj.Cts = new Object();
        for(var att in lgroups) {
            var llist = att == 'NoGroup' ? lgroups[att] : this['Group' + att];
            if(llist && llist.length)
                for(var grp = 0; grp < llist.length + aControlRef.length; grp++) {
                    var lref = robj(grp < llist.length ? llist[grp] : aControlRef[grp - llist.length]);
                    if(lref.ClientId && document.getElementById(lref.ClientId) != null && !lobj.Cts[lref.UniqueId]) {
                    
                        if(lref.ProcessBridge) {
                            if(!aParam)
                                aParam = new Object();
                            if(!aParam[lref.ClientId])
                                aParam[lref.ClientId] = new Object();
                            lref.ProcessBridge(aParam[lref.ClientId]);
                        }
                        var lCalcObj = new Object();
                        if(robj(lref.ClientId).CdtID && robj(lref.ClientId).CdtID != '') {
                            var lcdt = robj(robj(lref.ClientId).CdtID);
                            lcdt.set_RowData(robj(lref.ClientId).CdtKey, robj(lref.ClientId).CdtCol, robj(lref.ClientId).get_Text());
                        }
                        if(lref.get_Frm && Designer_obj) {
                            lCalcObj['Frm'] = lref.get_Frm();
                        }
                        var lIdent = lref.get_Ident();
                        if(lIdent && lIdent.length > 0 && Designer_obj) {
                            lCalcObj['Ident'] = lIdent;
                        }
                        if(lref.ClientToServer) {
                            lref.ClientToServer(lCalcObj);
                        }

                        for(var lAtt in lCalcObj) {
                            lobj.Cts[lref.UniqueId] = lCalcObj;
                            break;
                        }
                        lcount++;
                    }
                }
        }
        //alert(lcount);
        //alert(aParam);
        if(aParam && typeof(aParam) == "object") {
            for(lclientid in aParam) {
                var lref = robj(lclientid);
                if(typeof(aParam[lclientid]) == "object" && ((lref && lref.UniqueId && document.getElementById(lref.ClientId) != null) || aParam[lclientid].ControlsToGetValue))
                    for(att in aParam[lclientid]) {
                        if(att == 'ControlsToGetValue') {
                            var lstr = aParam[lclientid][att];
                            if(lstr && lstr != '')
                            {
                                var larr = lstr.split(',');
                                for(var i = 0; i < larr.length; i++) {
                                    var lctrl = robj(larr[i]);
                                    if(lctrl) {
                                        lobj.Cts[lctrl.UniqueId] = new Object();
                                        for(var j = 0; j < lctrl.Cts.length; j++)
                                            lobj.Cts[lctrl.UniqueId][lctrl.Cts[j]] = eval('robj("' + larr[i] + '").get_'+lctrl.Cts[j]+'();');
                                    }
                                }
                            }
                        } else if(lobj.Cts[lref.UniqueId])
                            lobj.Cts[lref.UniqueId][att] = aParam[lclientid][att];
                    }
            }
        }
        //alert(this.Serialize(lobj));
        this.ant_obj1 = aControlRef;
        this.ant_obj2 = aParam;
        this.ant_obj3 = aCommand;
        this.ant_obj4 = aRender;
        this.CallbackFunc(lobj);
    }
    
    this.DoCallbackCustomProc = function(aDataSource, aField1, aField2, aField3, aField4, aField5, aField6, aField7, aField8, aExpVal1, aExpVal2, aExpVal3, aAction, aKeyValue, aSqlProc, aForm, aAfterKey, aAfterFieldSta, aAfterFieldDate, aAfterStaValue, aClientId, aValue1Out, aValue2Out, aValue3Out, aProcStat1, aUpdateCache) {
        var lData = aDataSource; //0
        lData += ':,:' + aField1; //1
        lData += ':,:' + aField2; //2
        lData += ':,:' + aField3; //3
        lData += ':,:' + aField4; //4
        lData += ':,:' + aField5; //5
        lData += ':,:' + aField6; //6
        lData += ':,:' + aField7; //7
        lData += ':,:' + aField8; //8
        lData += ':,:' + aExpVal1; //9
        lData += ':,:' + aExpVal2; //10
        lData += ':,:' + aExpVal3; //11
        lData += ':,:' + aAction; //12
        lData += ':,:' + aKeyValue; //13
        lData += ':,:' + aSqlProc; //14
        lData += ':,:' + aForm; //15
        lData += ':,:' + aAfterKey; //16
        lData += ':,:' + aAfterFieldSta; //17
        lData += ':,:' + aAfterFieldDate; //18
        lData += ':,:' + aAfterStaValue; //19
        lData += ':,:' + aClientId; //20
        lData += ':,:' + aValue1Out; //21
        lData += ':,:' + aValue2Out; //22
        lData += ':,:' + aValue3Out; //23
        lData += ':,:' + (aProcStat1 == '1' ? this.StatSessID : ''); //24
        lData += ':,:' + (aProcStat1 == '1' ? this.StatEmpresa : ''); //25
        lData += ':,:' + (aProcStat1 == '1' ? '1' : ''); //26
        lData += ':,:' + aUpdateCache; //27
        
        this.CallbackFuncSync(lData, this.HandleCallbackCustomProc, '/ProcessCustomProc.aspx');
    }
    
    this.DoCallbackGetTime = function() 
    {
        this.CallbackFuncSync('Time', this.HandleCallbackGetServerTime, '/ProcessGetServerTime.aspx');
        Page_obj.gblFirstTime = new Date().getTime();
    }
    
    this.DoCallbackNewSync = function()
    {
        this._int_sync1.DataKeys = null;
        var lArr = this._int_sync1.get_DataKeys();
        var lKeys1 = '';
        for(var i = 0; i < lArr.length; i++)
        {
            if(this._check_sync1['Key' + lArr[i]] == 1) {
                lKeys1 += (lKeys1 == '' ? '' : ',') + lArr[i];
            }
        }
        if(lKeys1.length > 0) {
            this.CallbackFuncSync('Blank:,:' + this._int_sync1.get_SyncFields() + ':,:' + lKeys1, this.HandleCallbackSync, '/ProcessSync.aspx');
        } else {
            setTimeout('Page_obj.DoCallbackNewSync();',1700);
        }
        this._check_sync1 = new Object();
    }
    
    this.DoCallbackSync2 = function() {
        var lParam = '';
        var lUrl = '';
        for(var i = 0; i < this.CtrlToSync.length; i++) {
            var lObj = this.CtrlToSync[i];
            var lTime = this.DoSync ? lObj.TimeClient : lObj.TimeServer;
            if(this.CountToSync % lTime == 0 || robj(lObj.Id).SyncNow) {
                /*if(this.CountToSync == 0 || this.CountToSync == 5)
                    alert(lObj.Id);*/
                var lRes;
                if(lObj.Cond != '' && this.CountToSync > 0 && !robj(lObj.Id).SyncNow)
                {
                    //alert(eval(lObj.Cond));
                    try {
                        lRes = eval(lObj.Cond);
                    } catch(e) {
                        lRes = false;
                    }
                } else
                    lRes = true;
                if(lRes && robj(lObj.Id)) {
                    var lFirstPart = lObj.Id + ':,:' + lObj.TimeServer + ':,:' + lObj.Key + ':,:' + robj(lObj.Id).get_RecordPage();
                    lParam += (lParam == '' ? '' : ':,:') + lFirstPart + ':,:' + lObj.Param + ':,:' + lObj.CustomParam + ':,:' + lObj.PageAreaId + ':,:' + lObj.PageFormat;
                    lUrl += (lParam == '' ? '' : ':,:') + lFirstPart;
                }
                robj(lObj.Id).SyncNow = false;
            }
        }
        if(lParam != '') {
            //alert(lParam.split(':,:').length);
            this.CallbackFuncSync2(lUrl, lParam, this.HandleCallbackSync2, '/ProcessSync2.aspx');
        } else
            setTimeout('Page_obj.DoCallbackSync2();',1000);
        this.CountToSync++;
    }
    
    this.SyncRefresh = function() 
    {
        if(this._int_sync1 != null)
            this._int_sync1.SyncRefresh();
    }

    this.Render = function(aControlRef,aParam,aCommand) {
        if(!aCommand)
            aCommand = '';
        this.DoCallback(aControlRef,aParam,aCommand,true);
    }
    
    this.AddActionHidden = function(aCtrl) {
    }
    
    this.ProcIntervalActionList = function() {
        Page_obj.CountActiveCallback--;
        if(Page_obj.CountActiveCallback == 0) {
            if(Page_obj.PendingAction.length > 0) {
                var lHidden = Page_obj.PendingAction.pop();
                lHidden.Execute();
            }
        }
        /*if(this._arr_action_list)
            for(var i = 0; i < this._arr_action_list.length; i++) {
                if(this._arr_action_list[i].OnUpdateStatus != null) {
                    var lstatus = this._arr_action_list[i].OnUpdateStatus();
                    if(lstatus != null) {
                        this._arr_action_list[i].ChangeStatus(lstatus);
                    }
                }
            }*/
    }
    
    this.AddExpression = function(aId) {
        this._arr_expression[aId] = 1;
        this._arr_expression_count += 1;
        if(robj(aId) && robj(aId).get_Type() == '3' && !Page_obj.SyncServerTime) {
            var lDifTime = 1000 - (new Date()).getMilliseconds();
            setTimeout('Page_obj.DoCallbackGetTime()',lDifTime);
            Page_obj.SyncServerTime = true;
        }
        if(this._arr_expression_count == 1) {
            var lDif = 1000 - (new Date()).getMilliseconds() + 1000;
            setTimeout('Page_obj.ProcIntervalExpression(1)',lDif);
        }
    }
    
    this.ProcIntervalExpression = function(aInterval) {
        //alert(this._arr_expression_count);
        //var lCount = 0;
        var lNow = (new Date()).getTime();
        this.DoRenderCompleto = true;
        this.DoSync = false;
        for(att in this._arr_expression) {
            if(this._arr_expression[att] == 1) {
                var lRef = document.getElementById(att);
                if(lRef) {
                    robj(lRef).Calculate(aInterval);
                } 
            }
        }
        if(aInterval) {
            var lDifExec = (new Date()).getTime() - lNow;
            lDif = 998 - lDifExec;
            //Page_obj._AntTimeExp = (new Date()).getTime();
            setTimeout('Page_obj.ProcIntervalExpression(1)',lDif);
        }
    }
    
    this.AddSync1 = function(aList) {
        if(this._int_sync1 == null) {
            this._int_sync1 = aList;
            setTimeout('Page_obj.DoCallbackNewSync();',1700);
            setTimeout('Page_obj.DoRenderCompletoFunc()', 240000);
        }
    }
    
    this.AddSync2 = function(aId, aTime, aCond, aKey, aParam, aCustomParam, aPageAreaId, aPageFormat) {
        var lArrTime = aTime.split(';');
        robj(aId).IsSync = true;
        this.CtrlToSync[this.CtrlToSync.length] = {Id: aId, TimeClient: lArrTime[0], TimeServer: lArrTime.length > 1 ? lArrTime[1] : lArrTime[0], Cond: aCond, Key: aKey, Param: aParam, CustomParam: aCustomParam, PageAreaId: aPageAreaId, PageFormat: aPageFormat};
        if(this.CtrlToSync.length == 1) {
            if(!Page_obj.SyncServerTime) {
                var lDifTime = 1000 - (new Date()).getMilliseconds();
                setTimeout('Page_obj.DoCallbackGetTime()',lDifTime);
                Page_obj.SyncServerTime = true;
            }
            $(document).ready(function() {
                Page_obj.DoCallbackSync2();
            });
        }
    }
    
    this.DoRenderCompletoFunc = function() {
        if(Page_obj.DoRenderCompleto) {
            if(Page_obj._int_sync1 != null)
                Page_obj._int_sync1.Render();
            setTimeout('Page_obj.DoRenderCompletoFunc()', 240000);
        } else
            setTimeout('Page_obj.DoRenderCompletoFunc()',15000);
    }
    
    
    //****** Version Vieja del Sync Height
    this.AddHeightSync = function(aCtrl1Id, aCtrl2Id, aType) {
       if(!Designer_obj)
            this._obj_height[this._obj_height.length] = {AntHeight:null,CtrlRef:aCtrl1Id,CtrlId:aCtrl2Id,Type:aType,SelCell:null};
       /*if(!Designer_obj)
            this.ProcessHeightSyncItem(aCtrl1Id);
       if(this._obj_height_first) {
            this._obj_height_first = false;
            if(!Designer_obj)
                setTimeout('Page_obj.ProcessHeightSync()', 500);
       }*/
    }
    
    this._HeightFirst = true;
    this.ProcessHeightSync = function() {
        var lChange = false;
        for(var i = this._obj_height.length - 1; i >= 0; i--)
            if(this.ProcessHeightSyncItem(i))
                lChange = true;
        if(lChange && typeof(GblGrid) != 'undefined')
            SyncronizeGglGrid();
        if(lChange && typeof(Effect2) != 'undefined')
            ProcEffect2();
        setTimeout('Page_obj.ProcessHeightSync()', this._HeightFirst ? 10 : 1000);
        this._HeightFirst = false;
    }
    
    this.ClearParentHeight = function(aId) {
        for(var i = this._obj_height.length - 1; i >= 0; i--) {
            if(this._obj_height[i].CtrlRef == aId)
                this._obj_height[i].AntHeight = null;
        }
    }

    this.ProcessHeightSyncItem = function(aIndex) {
        var lCtrl1Id = this._obj_height[aIndex].CtrlRef;
        var lCtrl2Id = this._obj_height[aIndex].CtrlId;
        var lAntHeight = this._obj_height[aIndex].AntHeight;
        var lActHeight = 0;
        var lref2 = null;
        if(lCtrl2Id == "BrowserWindow") {
            lActHeight = Util_obj.get_ClientHeight();
        } else if(lCtrl2Id == "ParentCtrl") {
            lref2 = document.getElementById(lCtrl1Id).parentNode;
            if(lref2.tagName == 'SPAN' && lref2.parentNode && lref2.parentNode.tagName == 'TD')
                lref2 = lref2.parentNode;
            if(lref2.parentNode && lref2.parentNode.cells) {
                lActHeight = parseInt(lref2.parentNode.cells[0].style.height);
            } else {
                lActHeight = parseInt(lref2.style.height);
            }
            if(isNaN(lActHeight))
                lActHeight = lref2.offsetHeight;
        } else {
            lref2 = document.getElementById(lCtrl2Id);
            lActHeight = lref2.offsetHeight;
        }
        if(lActHeight != lAntHeight) {
            //alert('Paso ' + aIndex);
            var lref1 = document.getElementById(lCtrl1Id);
            var lAntOffsetHeight = lActHeight;
            if(this._obj_height[aIndex].Type == '1' || this._obj_height[aIndex].Type == '3') {
                for(var i = 0; i <= aIndex - 1; i++)
                    if(this._obj_height[i].Type == '1') {
                        if(this._obj_height[i].SelCell != null)
                            this._obj_height[i].SelCell.style.height = '1px';
                        else {
                            document.getElementById(this._obj_height[i].CtrlRef).style.height = '1px';
                        }
                    }
                var lSum = 0;
                if(lref1.rows) {
                    var lSelCell = null;
                    lref1.style.height = '';//lAntOffsetHeight + 'px';
                    for(var i = 0; i < lref1.rows.length; i++) {
                        if(lref1.rows[i].cells[0].style.height == '' || lref1.rows[i].cells[0].style.height.indexOf('%') >= 0 || lref1.rows[i].cells[0].is_mymark) {
                            lSelCell = lref1.rows[i].cells[0];
                            lSelCell.style.height = '';
                            this._obj_height[aIndex].SelCell = lSelCell;
                            lref1.rows[i].cells[0].is_mymark = true;
                        } else
                            lSum += lref1.rows[i].cells[0].offsetHeight;
                        //alert(lref1.rows[i].cells[0].style.height);
                    }
                    if(lSelCell != null) {
                        //alert(lref1.cellPadding + ' - ' + lref1.cellSpacing);
                        if( this._obj_height[aIndex].Type == '1') {
                            if(lAntOffsetHeight > (isNaN(lSum)?0:lSum)) {
                                lSelCell.style.height = (lAntOffsetHeight - (isNaN(lSum)?0:lSum)) + 'px';
                                var lDif = lref1.offsetHeight - lActHeight;
                                if(lDif != 0 && lAntOffsetHeight - (isNaN(lSum)?0:lSum) - lDif - (Browser_obj.is_Firefox() ? 2 : 0) > 0) {
                                    lSelCell.style.height = (lAntOffsetHeight - (isNaN(lSum)?0:lSum) - lDif - (Browser_obj.is_Firefox() ? 2 : 0)) + 'px';
                                }
                            }
                        } else {
                            var lPosRef2 = Util_obj.get_ElementPosition(lref2);
                            var lPosRef1 = Util_obj.get_ElementPosition(lref1);
                            // lPosRef2.top + lref2.offsetHeight - lPosRef1.top
                            lSelCell.style.height = (lPosRef2.top + lref2.offsetHeight - lPosRef1.top - (isNaN(lSum)?0:lSum)) + 'px';
                            var lDif = lref2.offsetHeight - lActHeight;
                            if(lDif > 0)
                                lSelCell.style.height = (lPosRef2.top + lref2.offsetHeight - lPosRef1.top - (isNaN(lSum)?0:lSum) - lDif) + 'px';
                        }
                    }
                } else {
                    //alert(lAntOffsetHeight);
                    if(lAntOffsetHeight < 200)
                        lAntOffsetHeight = 500;
                    lref1.style.height = lAntOffsetHeight + 'px';
                    if(lAntOffsetHeight - (lref1.offsetHeight - lAntOffsetHeight) > 0) {
                        lref1.style.height = (lAntOffsetHeight - (lref1.offsetHeight - lAntOffsetHeight)) + 'px';
                    }
                }
                //alert(lActHeight);
                if(lCtrl2Id != "BrowserWindow" && lCtrl2Id != "ParentCtrl")
                    lAntOffsetHeight = lref2.offsetHeight;
            } else
                lref1.style.top = '-' + lAntOffsetHeight + 'px';
            this._obj_height[aIndex].AntHeight = lAntOffsetHeight;
            return true;
        }
        return false;
    }
    
    //*** Fin de la version vieja del SyncHeight
    
    //** Version Nueva del SyncHeight
    
     /*this.AddHeightSync = function(aCtrl1Id, aCtrl2Id, aType) {
       if(!Designer_obj)
            this._obj_height[this._obj_height.length] = {AntHeight:null,CtrlRef:aCtrl1Id,CtrlId:aCtrl2Id,Type:aType,SelCell:null};
    }
    
    this._HeightFirst = true;
    this.ProcessHeightSync = function() {
        var lChange = false;
        for(var i = 0; i < this._obj_height.length; i++)
        {
            var lCtrl1Id = this._obj_height[i].CtrlRef;
            var lCtrl2Id = this._obj_height[i].CtrlId;
            //alert(lCtrl1Id + ' - ' + lCtrl2Id + ' - ' + this._obj_height[i].Type);
            var lAntHeight = this._obj_height[i].AntHeight;
            var lActHeight = 0;
            var lref2 = null;
            if(lCtrl2Id == "BrowserWindow")
                lActHeight = $(window).height() - 1;
            else if(lCtrl2Id == "ParentCtrl") {
                lref2 = $('#' + lCtrl1Id).closest('tr');
                lActHeight = parseInt($(lref2).find('td:first').css('height')); //[0].style.height
                if(isNaN(lActHeight))
                    lActHeight = $(lref2).height();
            } else
                lActHeight = $('#' + lCtrl2Id).height();
            //alert($('#' + lCtrl2Id).length + ' - ' + lActHeight);
            //alert(lCtrl1Id + ' - ' + lCtrl2Id + ' - ' + lActHeight);
            if(lActHeight != lAntHeight) {
                lChange = true;
                break;
            }
        }
        if(lChange) {
            for(var i = 0; i <= this._obj_height.length - 1; i++)
                if(this._obj_height[i].Type == '1') {
                    if(this._obj_height[i].SelCell != null)
                        this._obj_height[i].SelCell.style.height = '1px';
                    else {
                        document.getElementById(this._obj_height[i].CtrlRef).style.height = '130px';
                    }
                }
            if(typeof(SyncronizeGblGridClean) != 'undefined')
                SyncronizeGblGridClean();
            for(var i = this._obj_height.length - 1; i >= 0; i--) {
                //alert('Paso');
                //alert(this._obj_height[i].CtrlRef + ' - ' + this._obj_height[i].CtrlId);
                this.ProcessHeightSyncItem(i)
            }
            setTimeout(function() { 
                if(typeof(SyncronizeGglGrid) != 'undefined')
                    SyncronizeGglGrid(); 
                if(typeof(Effect2) != 'undefined')
                    ProcEffect2();
            },200);
            //alert('Sync');
        }
        //setTimeout('Page_obj.ProcessHeightSync()', this._HeightFirst ? 800 : 1500);
        this._HeightFirst = false;
    }
    
    this.ClearParentHeight = function(aId) {
        for(var i = this._obj_height.length - 1; i >= 0; i--) {
            if(this._obj_height[i].CtrlRef == aId)
                this._obj_height[i].AntHeight = null;
        }
    }

    this.ProcessHeightSyncItem = function(aIndex) {
        var lCtrl1Id = this._obj_height[aIndex].CtrlRef;
        var lCtrl2Id = this._obj_height[aIndex].CtrlId;
        var lAntHeight = this._obj_height[aIndex].AntHeight;
        var lActHeight = 0;
        var lref2 = null;
        if(lCtrl2Id == "BrowserWindow") {
            lActHeight = $(window).height() - 0; // Util_obj.get_ClientHeight();
        } else if(lCtrl2Id == "ParentCtrl") {
            lref2 = $('#' + lCtrl1Id).closest('tr')[0];
            lActHeight = parseInt($(lref2).find('td:first').css('height')); //[0].style.height
            //alert(lActHeight);
            if(isNaN(lActHeight))
                lActHeight = $(lref2).height();
        } else {
            lref2 = $('#' + lCtrl2Id)[0];
            lActHeight = $(lref2).height();
        }
        if(lActHeight != lAntHeight) {
            //alert('Paso ' + aIndex);
            var lref1 = $('#' + lCtrl1Id)[0]; // Ctrl a ponerle la altura (tabla)
            var lAntOffsetHeight = lActHeight;
            if(this._obj_height[aIndex].Type == '1' || this._obj_height[aIndex].Type == '3') {
                var lSum = 0;
                if(lref1.rows) {
                    var lSelCell = null;
                    lref1.style.height = '';
                    for(var i = 0; i < lref1.rows.length; i++) {
                        if(lref1.rows[i].cells[0].style.height == '' || lref1.rows[i].cells[0].style.height.indexOf('%') >= 0 || lref1.rows[i].cells[0].is_mymark) {
                            lSelCell = lref1.rows[i].cells[0];
                            lSelCell.style.height = '';
                            this._obj_height[aIndex].SelCell = lSelCell;
                            lref1.rows[i].cells[0].is_mymark = true;
                        } else
                            lSum += $(lref1.rows[i].cells[0]).height();
                    }
                    if(lSelCell != null) {
                        if( this._obj_height[aIndex].Type == '1') {
                            //alert(lAntOffsetHeight + ' - ' + lSum);
                            if(lAntOffsetHeight > lSum) {
                                //alert(lAntOffsetHeight);
                                
                                $(lSelCell).height(lAntOffsetHeight - lSum - 14);
                                //alert('Paso' + lCtrl2Id + ' - ' + lAntOffsetHeight  + ' - ' + lSum + ' - ' + (lAntOffsetHeight - lSum));
                                //alert($(lref1).outerHeight() + ' - ' + lActHeight);
                                //lActHeight = $(lref2).innerHeight();
                                var lDif = $(lref1).height() - lActHeight;
                                //alert(lDif);
                                //alert($(lref1).height() + ' - ' + lActHeight + ' - ' + lDif);
                                if(lDif != 0 && lAntOffsetHeight - lSum - 14 - lDif > 0)
                                    $(lSelCell).height(lAntOffsetHeight - lSum - 14 - lDif);
                                //alert($(lref1).outerHeight() + ' - ' + lActHeight);
                            }
                        } else {
                            var lPosRef2 = Util_obj.get_ElementPosition(lref2);
                            var lPosRef1 = Util_obj.get_ElementPosition(lref1);
                            lSelCell.style.height = (lPosRef2.top + lref2.offsetHeight - lPosRef1.top - (isNaN(lSum)?0:lSum)) + 'px';
                            var lDif = lref2.offsetHeight - lActHeight;
                            if(lDif > 0)
                                lSelCell.style.height = (lPosRef2.top + lref2.offsetHeight - lPosRef1.top - (isNaN(lSum)?0:lSum) - lDif) + 'px';
                        }
                    }
                } else {
                    //alert(lAntOffsetHeight);
                    if(lAntOffsetHeight >= 130) {
                        lref1.style.height = lAntOffsetHeight + 'px';
                        if(lAntOffsetHeight - (lref1.offsetHeight - lAntOffsetHeight) > 0) {
                            lref1.style.height = (lAntOffsetHeight - (lref1.offsetHeight - lAntOffsetHeight)) + 'px';
                        }
                    } else {
                        lref1.style.height = '130px';
                        lAntOffsetHeight = 130;
                    }
                    //alert('Index:' + aIndex + ' - ' + lAntOffsetHeight);
                }
                //alert(lActHeight);
                if(lCtrl2Id != "BrowserWindow" && lCtrl2Id != "ParentCtrl")
                    lAntOffsetHeight = lref2.offsetHeight;
            } else {
                lref1.style.top = '-' + lAntOffsetHeight + 'px';
            }
            this._obj_height[aIndex].AntHeight = lAntOffsetHeight;
            return true;
        }
        return false;
    }*/
    
    //*** Fin de la version nueva del SyncHeight
    
	this.FocusNext = function(aElem) {
        var lref_form = document.forms[0];
        var larr = lref_form.elements;
        var lfind = typeof(aElem) == 'undefined' || aElem == null ? 1 : 0;
        for(var lind = 0;lind < larr.length; lind++) 
        {
            var lproc_elem = larr[lind];
            if(larr[lind].getAttribute('enter_focus'))
            {
                var ltmp_elem = document.getElementById(larr[lind].getAttribute('enter_focus'));
                if(ltmp_elem)
                    lproc_elem = ltmp_elem;
            }
	        if(lfind && lproc_elem.tabIndex != '-2' && lproc_elem.tabIndex != '-1' && !lproc_elem.disabled && !lproc_elem.readOnly && ((lproc_elem.tagName == 'INPUT' && lproc_elem.type != 'hidden') || lproc_elem.tagName == 'SELECT' || lproc_elem.tagName == 'BUTTON' || lproc_elem.tagName == 'TEXTAREA'))
	        {
	            try{document.selection.empty();}catch(e){}
		        try{
			        lproc_elem.focus();
		        }catch(e){
			        aElem.focus();
			        if(aElem.select)
				        aElem.select();
				    return true;
		        }
		        if(lproc_elem.select)
			        lproc_elem.select();
			    return true;
	        }
	        if(lproc_elem == aElem) lfind = 1;
        }
        return false;
	}

	this.ProcessEnter = function(aEvt,aBtn) {
	    aEvt = (aEvt) ? aEvt : ((window.event) ? event : null);
	    if (aEvt) {
	        var elem = (aEvt.target) ? aEvt.target : ((aEvt.srcElement) ? aEvt.srcElement : null);
	        var charCode = (aEvt.charCode) ? aEvt.charCode : ((aEvt.which) ? aEvt.which : aEvt.keyCode);
	        if(elem && charCode && charCode == 13 && ((elem.tagName == 'INPUT' && elem.type != 'image' && elem.type != 'button') || elem.tagName == 'SELECT'))
		    {
		        var lres = false;
		        if(aBtn != "") {
		            var lref = document.getElementById(aBtn);
		            if(lref) {
		                lref.click();
		                lres = true;
		            }
		        } else
		    	    lres = Page_obj.FocusNext(elem);
		    	if(lres) {
		    	    Util_obj.StopEvent(aEvt);
			        return false;						
		    	}
		    }
	    }
		return true;
	}
	
	this.GoUrl = function(aUrl) {
	    location.href = aUrl;
	}

	this.Serialize = function(aData) {
		if (aData == null) {
			return 'N;';
		}
		var type = typeof(aData);
		var code = '';
		var iterator = 0;
		var length = null;
		var key = null;
		if (type == 'boolean') {
			code += 'b:' + (aData ? 1 : 0) + ';';
		} else if (type == 'number') {
			if (Math.round(aData) == aData) {
				code += 'i:' + aData + ';';
			} else {
				code += 'd:' + aData + ';';
			}
		} else if (type == 'string') {
		    aData = aData.replace(/(\r\n)|\n|\r|"/g, function(aText){ return aText == '\r\n' ? '\\r\\n' : (aText == '\n' ? '\\n' : (aText == '\r' ? '\\r' : '\\"'))});
			code += 's:"' + aData + '";';
	    } else if (type == 'object' && aData.getDate) {
	        code += 't:' + aData.getFullYear() + '-' + (aData.getMonth()+1) + '-' + aData.getDate() + 'T' + aData.getHours() + ':' + aData.getMinutes() + ':' + aData.getSeconds() + ';';
		} else if (type == 'object') {
			length = 0;
			if ((typeof(aData.length) == 'number') && (((aData.length > 0) && (typeof(aData[0]) != 'undefined')) || aData.length == 0)) {
				for (iterator = 0; iterator < aData.length; iterator ++) {
					if (typeof(aData[iterator]) != 'function') {
						code += this.Serialize(aData[iterator]);
					}
				}
    			code = 'a:{' + code + '}';
			} else {
				for (key in aData) {
					if (typeof(aData[key]) != 'function') {
						if (/^[0-9]+$/.test(key)) {
							code += this.Serialize(parseInt(key));
						} else {
							code += this.Serialize(key);
						}
						code += this.Serialize(aData[key]);
					}
				}
    			code = 'h:{' + code + '}';
			}
		} else {
			code = 'N;'
		}
		return code;
	}
	
	this.ExecAction = function(aRef, aAttr, aEffect) {
	   var lCtrlAct = aRef.getAttribute(aAttr);
	   var lRef = robj(lCtrlAct);
	   if(lRef && lRef.Execute)
	        lRef.Execute(aRef, aEffect);
	}
	
	this.set_FontColor = function(aRef, aColor) {
        var lref = aRef;
        if(lref.style)
            lref.style.color = aColor;
        var lChild = lref.firstChild;
        while(lChild != null) {
            if(lChild.style)
                Page_obj.set_FontColor(lChild, aColor);
            lChild = lChild.nextSibling;
        }
	}
	
    this.set_Opacity = function(aObj, aValue) {
        aObj.setAttribute('t03', aValue);
        aObj.style.opacity = parseFloat(aValue) / 100;
        aObj.style.filter = "alpha(opacity=" + aValue + ")";
        //alert(aValue);
    }
    this.get_Opacity = function(aObj) {
        return aObj.getAttribute('t03') == '' ? '100' : aObj.getAttribute('t03');
    }
	
	
	this.get_XmlHttp = function() {
		var xmlHttp = null;
		try {
			xmlHttp = new XMLHttpRequest();
		} catch (e) {
			var progIds = ['MSXML2.XMLHTTP', 'Microsoft.XMLHTTP', 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0'];
			var success = false;
			for (var iterator = 0; (iterator < progIds.length) && ( ! success); iterator ++) {
				try {
					xmlHttp = new ActiveXObject(progIds[iterator]);
					success = true;
				} catch (e) {}
			}
			if ( ! success ) {
				return null;
			}
		}
		return xmlHttp;
	}
	
    this.get_ElementsByAttribute = function(oElm, strTagName, strAttributeName, strAttributeValue){
        var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
        var arrReturnElements = new Array();
        var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("(^|\\s)" + strAttributeValue + "(\\s|$)", "i") : null;
        var oCurrent;
        var oAttribute;
        for(var i=0; i<arrElements.length; i++){
            oCurrent = arrElements[i];
            oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName);
            if(typeof oAttribute == "string" && oAttribute.length > 0){
                if(typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))){
                    arrReturnElements.push(oCurrent);
                }
            }
        }
        return arrReturnElements;
    }
    
    this.ShowHoldScreen = function() {
        if(parent && parent.Page_obj && parent != window)
            parent.Page_obj.ShowHoldScreen();
        else {
            this.IsHoldScreen = true;
            if($('#HoldScreen').length == 0) {
                $('<div>', {
                    id:    'HoldScreen',
                    css:   {
                        position:         'absolute',
                        top:              '0px',
                        left:             '0px',
                        width:            '100%',
                        height:           ($(document).height()) + 'px',
                        backgroundColor:  '#000',
                        opacity:          0.50,
                        zIndex:           100000
                    }
                }).appendTo($(document.body));
                $('<img>', {
                    id: 'HoldImg', 
                    css: {
                        position: 'absolute',
                        top: (( $(window).height() - 32 ) / 2 + $(window).scrollTop()) + 'px',
                        left: (( $(window).width() - 32 ) / 2 + $(window).scrollLeft()) + 'px',
                        zIndex:           100000
                    }
                }).appendTo($(document.body));
                $('#HoldImg').attr('src', '/Images/HoldScreen.gif?Ver2');
            } else {
                $('#HoldScreen').css({display: '', height: ($(document).height()) + 'px'});
                $('#HoldImg').css({display: '', top: (( $(window).height() - 32 ) / 2 + $(window).scrollTop()) + 'px', left: (( $(window).width() - 32 ) / 2 + $(window).scrollLeft()) + 'px'})
            }
        }
    }
    
    this.HideHoldScreen = function() {
        if(parent && parent.Page_obj && parent != window)
            parent.Page_obj.HideHoldScreen();
        else {
            this.IsHoldScreen = false;
            setTimeout('Page_obj.HideHoldScreenTmp()',1000);
        }
    }
    
    this.HideHoldScreenTmp = function() {
        if($('#HoldScreen').length != 0) {
            $('#HoldScreen').css('display','none');
            $('#HoldImg').css('display','none');
        }
    }
    
    this.ShowBackPopup = function(aProp) {
        if(parent && parent.Page_obj && parent != window)
            parent.Page_obj.ShowBackPopup();
        else {
            if($('#BackPopup').length == 0) {
                $('<div>', {
                    id:    'BackPopup',
                    css:   {
                        position:         'absolute',
                        top:              '0px',
                        left:             '0px',
                        width:            '100%',
                        height:           ($(document).height()) + 'px',
                        zIndex:           50000
                    }
                }).insertBefore($('#DivFormExec'));
            } else {
                $('#BackPopup').css({display: '', height: ($(document).height()) + 'px'});
            }
            $('#BackPopup').css(eval('(' + aProp + ')'));
        }
    }
    
    this.HideBackPopup = function() {
        if(parent && parent.Page_obj && parent != window)
            parent.Page_obj.HideBackPopup();
        else {
            if($('#BackPopup').length != 0) {
                $('#BackPopup').css('display','none');
            }
        }
    }
    
    this.get_ExecUrl = function(aFormId, aAction, aKey, aToRender, aPopup, aStep, aUrl) {
        return Page_obj.ExecFile + '?Key=' + aFormId + (aKey ? '&KeyReg=' + aKey : '') + (aAction ? '&Status=' + aAction : '') + (aToRender ? '&ToRender=' + aToRender : '') + (aPopup ? '&Popup=' + aPopup : '') + (aStep ? '&Step=' + aStep : '') + (aUrl ? aUrl : ''); //'&Now=' + (new Date()).toString().replace(/\s/g,'') +
    }
}

function PageCallbackAction(aObjParam, aCallbackFunc, aUrl, aIndex) {

	this.CallSuspender = function() {
		return {
			Suspend	: function() {
				this.Suspended = true;
			},
			Suspended	:	false
		}
	}

	this.CallResult = true;
	this.CallbackFunc = aCallbackFunc;
	this.Index = aIndex;
	this.XmlHttp = Page_obj.get_XmlHttp();
	this.Param_obj = aObjParam;
	this.Executed = false;

	this.RequestCompleted = function() {
		if (typeof(this.CallResult) == 'object') {
			if(this.CallResult.Suspended) {
				return false;
			}
		}
		if (this.XmlHttp.status != 200) {
			//throw {code:this.XmlHttp.status,message:this.XmlHttp.statusText};
			return false;
		} else {
			if (this.XmlHttp.responseText == null) {
				//throw {code:this.XmlHttp.status,message:'Empty response'};
				return false; 
			}
			return this.XmlHttp.responseText;
		}
		return false;
	}

	this.CallbackStateChange = function() {
		for(var i = Page_obj._arr_callback_start; i < Page_obj._arr_callback.length; i++) {
			var ref = Page_obj._arr_callback[i];
			if (ref != null && !ref.Executed && ref.XmlHttp.readyState == 4) {
				ref.Executed = true;
				ref.CallbackFunc(ref.RequestCompleted());
				Page_obj._arr_callback[i] = null;
				if(i == Page_obj._arr_callback_start)
					Page_obj._arr_callback_start++;
				else {
					while(Page_obj._arr_callback[Page_obj._arr_callback_start] == null && Page_obj._arr_callback_start < Page_obj._arr_callback.length) 
						Page_obj._arr_callback_start++;
				}
			}
		}
	}
	
	this.Url = aUrl ? aUrl : '/ProcessSync.aspx';
	
	this.DoAction = function(aSync, aData) {
	    if(aData) {
		    if(!aSync) {
			    this.XmlHttp.open('POST', this.Url + '?Key=' + robj('Key').get_Text() + '&Data=' + this.Param_obj + '&Now=' + (new Date()).getTime(), true);
		    } else {
			    this.XmlHttp.open('POST', this.Url + '?Key=' + robj('Key').get_Text() + '&Data=' + this.Param_obj + '&Now=' + (new Date()).getTime(), false);
		    }
		} else {
		    if(!aSync) {
			    this.XmlHttp.open('GET', this.Url + '?Key=' + robj('Key').get_Text() + '&Data=' + this.Param_obj + '&Now=' + (new Date()).getTime(), true);
		    } else {
			    this.XmlHttp.open('GET', this.Url + '?Key=' + robj('Key').get_Text() + '&Data=' + this.Param_obj + '&Now=' + (new Date()).getTime(), false);
		    }
		}
		var requestbody = aData ? aData : ''; //Page_obj.Serialize(aData)
		try {
		    if(aData)
			    this.XmlHttp.setRequestHeader('Content-Length', requestbody.length); 
			this.XmlHttp.setRequestHeader('Content-Type', 'text/plain; charset=UTF-8');
			this.XmlHttp.setRequestHeader('Accept-Charset', 'UTF-8');
		} catch(e) {}
		if(!aSync) {
			this.XmlHttp.onreadystatechange = this.CallbackStateChange;
		}
		this.XmlHttp.send(requestbody); 
		if(aSync) {
			this.CallbackFunc(this.RequestCompleted());
			Page_obj._arr_callback[this.Index] = null;
			if(this.Index == Page_obj._arr_callback_start)
				Page_obj._arr_callback_start++;
			else {
				while(Page_obj._arr_callback[Page_obj._arr_callback_start] == null && Page_obj._arr_callback_start < Page_obj._arr_callback.length) 
					Page_obj._arr_callback_start++;
			}
		} else {
			this.CallResult = new this.CallSuspender();
			return this.CallResult;
		}
	}
}

function Browser() {
	
	this._msie = null;
	this.is_Msie = function() {
		if(this._msie == null)
			this._msie = /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
		return this._msie;
	}
	
	this._msie5 = null;
	this.is_Msie5 = function() {
		if(this._msie5 == null)
			this._msie5 = this.is_Msie() && /msie 5\.0/i.test(navigator.userAgent);
		return this._msie5;
	}
	
	this._msie8 = null;
	this.is_Msie8 = function() {
		if(this._msie8 == null)
			this._msie8 = this.is_Msie() && /msie 8\.0/i.test(navigator.userAgent);
		return this._msie8;
	}

	this._opera = null;
	this.is_Opera = function() {
		if(this._opera == null)
			this._opera = /opera/i.test(navigator.userAgent);
		return this._opera;
	}
	
	this._safari = null;
	this.is_Safari = function() {
		if(this._safari == null)
			this._safari = /safari/i.test(navigator.userAgent);
		return this._safari;
	}

	this._firefox = null;
	this.is_Firefox = function() {
		if(this._firefox == null)
			this._firefox = /firefox/i.test(navigator.userAgent);
		return this._firefox;
	}

	this._khtml = null;
	this.is_Khtml = function() {
		if(this._khtml == null)
			this._khtml = /Konqueror|Safari|KHTML/i.test(navigator.userAgent);
		return this._khtml;
	}
}
var Browser_obj = new Browser();

String.prototype.verify_name = function (aName) {
	return /[^A-Za-z0-9]/.test(aName);
}

String.prototype.ltrim = function () {
	return this.replace( /^\s*/, "" );
}

String.prototype.rtrim = function () {
	return this.replace( /\s*$/, "" );
}
	
String.prototype.trim =	function () {
	return this.rtrim().ltrim();
}

String.prototype.setCharAt = function(aIndex,aChr) {
	if(aIndex > this.length-1) return this + aChr;
	return this.substr(0,aIndex) + aChr + this.substr(aIndex+1);
}

Date.stand_format = new Object();
Date.stand_format.s = '%Y-%m-%dT%H:%M:%S';

Date.parseDate = function(str, fmt) {
    if(this.stand_format[fmt])
        fmt = this.stand_format[fmt];
	var today = new Date();
	var y = 0;
	var m = -1;
	var d = 0;
	var a = str.split(/\W|T+/);
	var b = fmt.match(/%./g);
	var i = 0, j = 0;
	var hr = 0;
	var min = 0;
	var sec = 0;
	var hr_paso = false;
	var ampm_paso = false;
	var is_int = false;
	for (i = 0; i < b.length; ++i) {
		if (!a[i])
			continue;
		if(hr_paso && !ampm_paso) {
			if(/pm|p/i.test(a[i])) {
				if(!(hr >= 1 && hr <= 12))
					return null;
				if(hr < 12) hr += 12;
				a[i] = a[i].replace(/pm|p/i,'');
				ampm_paso = true;
			} else if(/am|a/i.test(a[i])) {
				if(!(hr >= 1 && hr <= 12))
					return null;
				if(hr >= 12) hr -= 12;
				a[i] = a[i].replace(/am|a/i,'');
				ampm_paso = true;
			}
		}
		is_int = /^\d+$/.test(a[i]);
		switch (b[i]) {
		    case "%d":
		    case "%e":
				d = is_int ? parseInt(a[i], 10) : Number.NaN;
			break;
		    case "%m":
				m = is_int ? parseInt(a[i], 10) - 1 : Number.NaN;
			break;
		    case "%Y":
		    case "%y":
				y = is_int ? parseInt(a[i], 10) : Number.NaN;
				!isNaN(y) && (y < 100) && (y += (y > 29) ? 1900 : 2000);
			break;
		    case "%H":
		    case "%I":
		    case "%k":
		    case "%l":
				hr = is_int ? parseInt(a[i], 10) : Number.NaN;
				hr_paso = true;
			break;
		    case "%P":
		    case "%p":
		    	if(!isNaN(hr) && hr_paso && !ampm_paso) {
					if(!(hr >= 1 && hr <= 12))
						return null;
					if (/pm/i.test(a[i]) && hr < 12)
						hr += 12;
					else if (/am/i.test(a[i]) && hr >= 12)
						hr -= 12;
					ampm_paso = true;
				}
			break;
		    case "%M":
				min = is_int ? parseInt(a[i], 10) : Number.NaN;
			break;
		    case "%S":
				sec = is_int ? parseInt(a[i], 10) : Number.NaN;
			break;
		}
	}
	if(isNaN(y) || isNaN(m) || isNaN(d) || isNaN(hr) || isNaN(min) || isNaN(sec))
		return null;
	if (y != 0 && m != -1 && d != 0) {
		var ret = new Date(y, m, d, hr, min, sec);
		return ret.getFullYear() == y && ret.getMonth() == m && ret.getDate() == d && ret.getHours() == hr && ret.getMinutes() == min && ret.getSeconds() == sec ? ret : null;
	}
	y = 0; m = -1; d = 0;
	hr_paso = false; ampm_paso = false;
	var min_paso = false;
	var sec_paso = false;
	var val_act = 0;
	for (i = 0; i < a.length; ++i) {
		if(hr_paso && !ampm_paso) {
			if(/pm|p/i.test(a[i])) {
				if(!(hr >= 1 && hr <= 12))
					return null;
				if(hr < 12) hr += 12;
				a[i] = a[i].replace(/pm|p/i,'');
				ampm_paso = true;
			} else if(/am|a/i.test(a[i])) {
				if(!(hr >= 1 && hr <= 12))
					return null;
				if(hr >= 12) hr -= 12;
				a[i] = a[i].replace(/am|a/i,'');
				ampm_paso = true;
			}
		}
		is_int = /^\d+$/.test(a[i]);
		val_act = parseInt(a[i], 10);
        if (is_int && val_act <= 12 && m == -1) {
			m = val_act-1;
		} else if (is_int && val_act > 31 && y == 0) {
			y = val_act;
			(y < 100) && (y += (y > 29) ? 1900 : 2000);
		} else if (is_int && d == 0) {
			d = val_act;
		} else if (is_int && d != 0 && m == 0) {
			m = val_act;
		} else if (is_int && m != 0 && y == 0) {
			y = val_act;
			(y < 100) && (y += (y > 29) ? 1900 : 2000);
		} else if (is_int && m != 0 && d != 0 && !hr_paso) {
			hr = val_act;
			hr_paso = true;
		} else if (is_int && m != 0 && d != 0 && !min_paso) {
			min = val_act;
			min_paso = true;
		} else if (is_int && m != 0 && d != 0 && !sec_paso) {
			sec = val_act;
			sec_paso = true;
		}
	}
	if (y == 0)
		y = today.getFullYear();
	if (m != -1 && d != 0) {
		var ret = new Date(y, m, d, hr, min, sec);
		return ret.getFullYear() == y && ret.getMonth() == m && ret.getDate() == d && ret.getHours() == hr && ret.getMinutes() == min && ret.getSeconds() == sec ? ret : null;
	}
	return null;
}

function Util() {

	this._select = new Object();

	this.get_ElementPosition = function(aElem, aParent) {
		var offsetTrail = aElem;
		var offsetLeft = 0;
		var offsetTop = 0;
		while (offsetTrail && offsetTrail != aParent) 
		{
			offsetLeft += offsetTrail.offsetLeft;
			offsetTop += offsetTrail.offsetTop;
			offsetTrail = offsetTrail.offsetParent;
		}
		if (navigator.userAgent.indexOf('Mac') != -1 && 
			typeof document.body.leftMargin != 'undefined') 
		{
			offsetLeft += document.body.leftMargin;
			offsetTop += document.body.topMargin;
		}
		return {left:offsetLeft, top:offsetTop};
	}
	
    this.get_MousePosition = function(aEvent) {
        aEvent = this.get_Event(aEvent);
        var coords = {left:0, top:0};
        if(aEvent)
        {
            if (aEvent.pageX) {
                coords.left = aEvent.pageX;
                coords.top = aEvent.pageY;
            } else if (aEvent.clientX) {
                coords.left = 
                    aEvent.clientX + document.body.scrollLeft - document.body.clientLeft;
                coords.top = 
                    aEvent.clientY + document.body.scrollTop - document.body.clientTop;
                if (document.body.parentElement && document.body.parentElement.clientLeft) {
                    var bodParent = document.body.parentElement;
                    coords.left += bodParent.scrollLeft - bodParent.clientLeft;
                    coords.top += bodParent.scrollTop - bodParent.clientTop;
                }
            }
        }
        return coords;
    }

	this.get_Event = function(aEvent) {
		return aEvent ? aEvent : (window.event ? event : null);
	}
	
	this.get_EventElement = function(aEvent) {
	    if(!aEvent)
	        aEvent = this.get_Event(aEvent);
        return(aEvent.target) ? aEvent.target : 
          ((aEvent.srcElement) ? aEvent.srcElement : null);
	}
	
	this.StopEvent = function(aEvent) {
		if(this.get_Event(aEvent)) {
			if (Browser_obj.is_Msie()) {
				aEvent.cancelBubble = true;
				aEvent.returnValue = false;
			} else {
				aEvent.preventDefault();
				aEvent.stopPropagation();
			}
		}
	}
	
	this.AddEvent = function(aRef, aEventName, aFunc) {
		if(aRef) {
			if (Browser_obj.is_Msie()) {
				aRef.attachEvent('on' + aEventName, aFunc);
			} else {
				aRef.addEventListener(aEventName, aFunc, true);
			}
		}
	}
    
	this.RemoveEvent = function(aRef, aEventName, aFunc) {
		if(aRef) {
			if (Browser_obj.is_Msie()) {
				aRef.detachEvent('on' + aEventName, aFunc);
			} else {
				aRef.removeEventListener(aEventName, aFunc, true);
			}
		}
	}
	
	this.get_DivParent = function(aElement,aId) {
	    while(aElement != null && ((!aId && aElement.getAttribute('mydiv_id') == null) || (aId && aElement.getAttribute('mydiv_id') != aId)))
	        aElement = aElement.offsetParent;
	    return aElement;
	}
	
	this.is_ElementVisible = function(aElement) {
		while(aElement != null && aElement.style.visibility != 'hidden' && aElement.style.display != 'none')
			aElement = aElement.offsetParent;
		return aElement == null;
	}
	
	this.HideSelect = function(aRefDiv) {
		if(!this._select[aRefDiv.id]) {
			var lArr = document.getElementsByTagName('SELECT');
			var lParent = null;
			lDivPos = this.get_ElementPosition(aRefDiv);
			this._select[aRefDiv.id] = new Array();
			for(var i = 0; i < lArr.length; i++)
			{
				lParent = this.get_DivParent(lArr[i],aRefDiv.id);
				if(lArr[i].style.visibility != 'hidden' && lParent == null && this.is_ElementVisible(lArr[i]))
				{
					lComPos = this.get_ElementPosition(lArr[i]);
					if(
						(lComPos.left >= lDivPos.left && lComPos.left <= lDivPos.left + aRefDiv.offsetWidth) &&
						(lComPos.top >= lDivPos.top && lComPos.top <= lDivPos.top + aRefDiv.offsetHeight)
					)
					{
						lArr[i].setAttribute("elem_hidden",lArr[i].style.visibility);
						lArr[i].style.visibility = 'hidden';
						this._select[aRefDiv.id][this._select[aRefDiv.id].length] = lArr[i];
					}
					else if(
						(lComPos.left + lArr[i].offsetWidth >= lDivPos.left && lComPos.left + lArr[i].offsetWidth  <= lDivPos.left + aRefDiv.offsetWidth) &&
						(lComPos.top + lArr[i].offsetHeight >= lDivPos.top && lComPos.top + lArr[i].offsetHeight <= lDivPos.top + aRefDiv.offsetHeight)
					)
					{
						lArr[i].setAttribute("elem_hidden",lArr[i].style.visibility);
						lArr[i].style.visibility = 'hidden';
						this._select[aRefDiv.id][this._select[aRefDiv.id].length] = lArr[i];
					}
					else if(
						(lComPos.left + lArr[i].offsetWidth >= lDivPos.left && lComPos.left + lArr[i].offsetWidth  <= lDivPos.left + aRefDiv.offsetWidth) &&
						(lComPos.top >= lDivPos.top && lComPos.top <= lDivPos.top + aRefDiv.offsetHeight)
					)
					{
						lArr[i].setAttribute("elem_hidden",lArr[i].style.visibility);
						lArr[i].style.visibility = 'hidden';
						this._select[aRefDiv.id][this._select[aRefDiv.id].length] = lArr[i];
					}
					else if(
						(lComPos.left >= lDivPos.left && lComPos.left <= lDivPos.left + aRefDiv.offsetWidth) &&
						(lComPos.top + lArr[i].offsetHeight >= lDivPos.top && lComPos.top + lArr[i].offsetHeight <= lDivPos.top + aRefDiv.offsetHeight)
					)
					{
						lArr[i].setAttribute("elem_hidden",lArr[i].style.visibility);
						lArr[i].style.visibility = 'hidden';
						this._select[aRefDiv.id][this._select[aRefDiv.id].length] = lArr[i];
					}
				}
			}
		} else {
		    var larr = this._select[aRefDiv.id];
		    var lold = null;
		    if(larr && larr.length)
		        for(var i = 0; i < larr.length; i++) {
		            lold = larr[i];
		            larr[i] = document.getElementById(larr[i].id);
			        larr[i].style.visibility = 'hidden';
			        larr[i].setAttribute("elem_hidden",lold.getAttribute("elem_hidden"));
				}
		}
	}
	
	this.RestoreSelect = function(aRefDiv) {
		var larr = this._select[aRefDiv.id];
		if(larr && larr.length)
			for(var i = 0; i < larr.length; i++)
				larr[i].style.visibility = larr[i].getAttribute("elem_hidden");
		this._select[aRefDiv.id] = null;
	}
	
	this.ParseTime = function(aStr) {
    	var a = aStr.split(/\W+/);
    	var lhour = 0;
    	var lmin = 0;
    	var lsec = 0;
    	var lhour_paso = false;
    	var lampm_paso = false;
    	var is_int = false;
    	var val_act = 0;
    	for(var i = 0; i < a.length; i++) {
    	    if(a[i] == 'm')
    	        continue;
    	    if(lhour_paso && !lampm_paso) {
			    if(/pm|p/i.test(a[i])) {
				    if(!(lhour >= 1 && lhour <= 12))
					    return null;
				    if(lhour < 12) lhour += 12;
				    a[i] = a[i].replace(/pm|p/i,'');
				    lampm_paso = true;
			    } else if(/am|a/i.test(a[i])) {
				    if(!(lhour >= 1 && lhour <= 12))
					    return null;
				    if(lhour >= 12) lhour -= 12;
				    a[i] = a[i].replace(/am|a/i,'');
				    lampm_paso = true;
			    }
			}
			a[i] = a[i].trim();
		    is_int = /^\d+$/.test(a[i]);
		    val_act = parseInt(a[i], 10);
		    if(is_int) {
                if(i == 0) {
                    lhour = val_act;
                    lhour_paso = true;
                } else if(i == 1)
                    lmin = val_act;
                else
                    lsec = val_act;
            } else if(a[i] != '')
                return null;
    	}
    	if(lhour >= 0 && lhour <=23 && lmin >= 0 && lmin <= 59 && lsec >= 0 && lsec <= 59)
    	    return new Date(null,null,null,lhour,lmin,lsec);
    	else
    	    return null;
	}
	
	this.ValidatorTimeCheck = function(aSource, aArg) {
	    var ldate = this.ParseTime(aArg.Value);
	    aArg.IsValid = ldate != null;
	}
	
	this.ValidatorEMail = function(aSource, aArg) {
	    var lfilter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	    aArg.IsValid = aArg.Value == '-' || aArg.Value.substr(0,7) == 'nomail_' || lfilter.test(aArg.Value);
	}
	
	this.ValidatorPhone = function(aSource, aArg) {
	    var lfilter = /^(\+|)((\(\d{3}\)\s{0,1})|)(\d+(\s|-){0,1}){0,3}\d{3}(\s{1}(e|x|ex|ext)\s{0,1}\d+|)(\s*,\s*(\+|)((\(\d{3}\)\s{0,1})|)(\d+(\s|-){0,1}){0,3}\d{3}(\s{1}(e|x|ex|ext)\s{0,1}\d+|))*$/; //(\d{3}(-|\s))     (\+\d)*\s*((\(\d{3}\)\s*|(\d{3}-)))*\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}
	    aArg.IsValid = lfilter.test(aArg.Value);
	}
	
	this.ValidatorUrl = function(aSource, aArg) {
	    var lfilter = /https?:\/\/([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?/;
	    aArg.IsValid = aArg.Value == 'http://' || lfilter.test(aArg.Value);
	}

    this.get_ClientWidth = function(){
        //return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth : document.body.clientWidth;
        var e = window, a = 'inner';

        if ( !( 'innerWidth' in window ) )
        {
            a = 'client';
            e = document.documentElement || document.body;
        }

        return e[ a+'Width' ];
    }
    
    this.get_ClientHeight = function(){
        var e = window, a = 'inner';

        if ( !( 'innerWidth' in window ) )
        {
            a = 'client';
            e = document.documentElement || document.body;
        }

        return e[ a+'Height' ];
        //return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight : document.body.clientHeight;
    }

    this.RepeatString = function (s, n){
        var a = [];
        while(a.length < n){
            a.push(s);
        }
        return a.join('');
    }

    this.get_Rgb = function(aBlue, aGreen, aRed) {
        var decColor = aRed + 256 * aGreen + 65536 * aBlue;
        return decColor.toString(16);
    }
    
    this.get_Color = function(aColor) {
        if(aColor.substr(0,3) == 'rgb') {
            var larr = aColor.split(' rgb');
            var lhex = eval(larr[0].replace('rgb', 'Util_obj.get_Rgb'));
            lhex = this.RepeatString('0', 6 - lhex.length) + lhex;
            return '#' + lhex;
        } else {
            var larr = aColor.split(' ');
            return larr[0];
        }
    }
    
    this.SplitData = function(aValue) {
        return aValue.split('|-|');
    }
    
    this.PrepareData = function(aValue) {
        return aValue.replace(/|-|/g, '');
    }
    
    this.CreateDate = function(aValue,aCountDay) {
        if(aValue) {
            var lArr = aValue.replace('<SPAN class=skype_pnh_print_container>','').split(' ');
            var lArrDate = lArr[0].split('-');
            var lArrTime = lArr.length > 1 ? lArr[1].split(':') : new Array();
            if(typeof(aCountDay) == 'undefined')
                aCountDay = 0;
            return new Date(lArrDate[0],lArrDate[1]*1-1,lArrDate[2]*1 + aCountDay,lArrTime.length > 0 ? lArrTime[0] : 0,lArrTime.length > 1 ? lArrTime[1] : 0,lArrTime.length > 2 ? lArrTime[2] : 0);
        } else
            return new Date();
    }
    
    this.Call = function(aFunc) {
        return eval(aFunc);
    }

    this.CreateCookie = function(name,value,days) {
        if(days)
            $.cookie(name, value, {path: '/', expires: days});
        else
            $.cookie(name, value, {path: '/'});
    }

    this.ReadCookie = function(name) {
        return $.cookie(name);
    }

    this.DeleteCookie = function(name) {
        $.cookie(name, null);
    }
    
    this.MouseH = function(aRef,aImgOver,aColorOver,aBackOver,aAction) {
        if(aImgOver != '')
            aRef.style.backgroundImage='url(' + Page_obj.LibraryHost + aImgOver + ')';
        if(aColorOver != '')
            Page_obj.set_FontColor(aRef, aColorOver);
        if(aBackOver != '')
            aRef.style.backgroundColor=aBackOver;
        if(aAction != '')
            Page_obj.ExecAction(aRef,'t21');
    }
    
    this.MouseO = function(aRef,aImgBack,aColor,aBack,aAction,aEvt) {
        if(aImgBack != null)
            aRef.style.backgroundImage=aImgBack == '' ? '' : ('url(' + Page_obj.LibraryHost + aImgBack + ')');
        if(aColor != null)
            Page_obj.set_FontColor(aRef, aColor);
        if(aBack != null)
            aRef.style.backgroundColor=aBack;
        if(aAction)
            fixOnMouseOut(aRef,aEvt);
    }
    
    this.set_LinkTo = function(aId, aPage, aWidth, aHeight) {
        var lRef = document.getElementById(aId);
        if(lRef && lRef.parentNode.tagName != 'A') {
            if(lRef.tagName == 'IMG')
                lRef.border = '0';
            var lLink = document.createElement('a');
            if(aWidth || aHeight) {
                lLink.href = '#';
                lLink._lPage = aPage;
                lLink._lWidth = aWidth;
                lLink._lHeight = aHeight;
                $(lLink).bind('click', function(){
                    window.open(this._lPage, '', (this._lWidth ? 'width=' + this._lWidth : '') + (this._lWidth && this._lHeight ? ',' : '') + (this._lHeight ? 'height=' + this._lHeight : ''));
                    return false;                    
                })
            } else {
                lLink.href = aPage;
                lLink.target = '_blank';
            }
            lRef.parentNode.insertBefore(lLink, lRef);
            lLink.appendChild(lRef);
        }
    }
    
    this.InitExpand = function(aId, aCond) {
        var lRes = eval(aCond);
        if(lRes)
            robj(aId).OnExecute();
    }
    
    this.GetFileNameExt = function(aPath) {
        var m = aPath.toString().replace(/\\/gi,'/').match(/.*\/(.+?)\.(.*)/);
        if (m && m.length > 1) {
            return m[1] + '.' + m[2];
        }
        return '';
    }
    
    this.GenerateYoutube = function() {
        var lStr = "<object width='%width%' height='%height%' align='left'> "
                   + " <param id='Youtube'></param>"
                   + " <param name='Youtube' value='%path%'></param>"
                   + " <param name='allowFullScreen' value='true'></param> "
                   + " <param name='allowscriptaccess' value='always'></param> "
                   + " <embed src='%path%' width='%width%' height='%height%' align='center' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true'></embed>"
                   + " </object>";
        $('img[youtube]').each(function() {
            var lPath = $(this).attr('youtube');
            $(this).replaceWith(lStr.replace(/%path%/gi, lPath).replace(/%width%/gi, $(this).attr('width')).replace(/%height%/gi, $(this).attr('height')));
        }); 
    }
    
    this.set_AbsCenterY = function() {
        $('*[AbsCenterY]').each(function() {
            var lInfoArr = $(this).attr('AbsCenterY').split(';');
            var lHeight = lInfoArr[0]*1;
            var lTop = lInfoArr[1]*1;
            if($(window).height() > lHeight) {
                $(this).css('top', '50%');
                $(this).css('margin-top',(lHeight / 2 - lTop)*-1);
            } else {
                $(this).css('top', '0px');
                $(this).css('margin-top',lTop);
            }
        });        
    }
    $(document).ready(function(){
        Util_obj.set_AbsCenterY();
        $(window).bind('resize', Util_obj.set_AbsCenterY);
    });
}
var Util_obj = new Util();


var Designer_obj = null;

function derive(aClass1,aClass2) {
    var st = aClass2.toString();
    st = st.substring(st.indexOf(" ") + 1, st.indexOf("("));
    aClass1.prototype = new aClass2;
    aClass1.prototype.ClassBase = st;
    st = aClass1.toString();
    st = st.substring(st.indexOf(" ") + 1, st.indexOf("("));    
    aClass1.prototype.ClassName = st;
}
function override(aObj,aFunc) {
    aObj[aObj.ClassBase + '_' + aFunc] = aObj[aFunc]; 
}

function robjs(aStrId, aRef) {
    if(!aRef && aStrId != '') {
        aRef = document.getElementById(aStrId);
        if(aRef == null) {
            var jRef = $('*[t01=' + aStrId + ']');
            if(jRef.length > 0) {
                aRef = jRef[0];
                aStrId = aRef.id;
            }
        }
    }
    if(aRef != null) {
        if(window[aStrId + '_obj'] == null) {
            var lClassParam = aRef.getAttribute('c00');
            if(lClassParam != null) {
                var lArr = lClassParam.split('&');
                try {
                    window[aStrId + '_obj'] = eval('new ' + lArr[0] + '()');
                    window[aStrId + '_obj'].Init('&' + lArr[1] + '&' + lArr[2],'','EC',[],lArr.length > 3 ? lArr[3] : [],lArr.length > 4 ? lArr[4] : [],lArr.length > 5 ? lArr[5] : [],'');
                    aRef._robj = window[aStrId + '_obj'];
                } catch(lExcep) {
                    return null;
                }
                // lArr - Class, UniqueId, ContentId
                return aRef._robj;
            } else
                return null;
        } else {
            aRef._robj = window[aStrId + '_obj'];
            return aRef._robj;
        }
    } else
        return null;
}

function robj(aId) {
    if(typeof(aId) == 'object') {
        if(typeof(aId.UniqueId) != 'undefined')
            return aId;
        else if(typeof(aId._robj) != 'undefined')
            return aId._robj;
        else if(typeof(aId.id) != 'undefined')
            return robjs(aId.id, aId);
        else
            return aId;
    } else if(typeof(aId) == 'string') {
        return robjs(aId);
    } else
        return null;
}


function ClassBase() {

    this.ClientId = '';
    this.ParentId = '';
    this.ContenIdPart = '';
    this.UniqueId = '';
    this.RenderGroup = '';
    this.CtrlType = 0;
    this.Frm = new Array();
    this.SelectFormat = '';
    
    this.Property_Add = function(aPos, aCaption, aType, aGet, aSet, aParam1) {
       this.ArrProp['P' + aPos] = {Caption: aCaption, Type: aType, Get: aGet, Set: aSet, Param1: aParam1};
    }
    
    this.Init = function() {
        var lPar = arguments[0].split('&');
        this.ParentId = lPar[0];
        this.ClientId = lPar[1].replace(/\$/g,'_');
        this.ContenIdPart = lPar[2];
        this.UniqueId = lPar[1];
        this.RenderGroup = arguments[2];
        if(this.ContenIdPart != '')
            window[this.ClientId + this.ContenIdPart + '_obj'] = this;
        if(this.RenderGroup != '' && this.RenderGroup != null && (this.ClientToServerPass() || Designer_obj != null) && this.RenderGroup != 'EC') {
            larr = this.RenderGroup.split(',');
            for(var i = 0; i < larr.length; i++) {
                if(typeof(Page_obj['Group' + larr[i]]) == 'undefined')
                    Page_obj['Group' + larr[i]] = new Array();
                var arr_ref = Page_obj['Group' + larr[i]];
                arr_ref[arr_ref.length] = this;
            }
        }
        if(Designer_obj) {
            this.ArrProp = new Object();
            this.Property_Add(110, 'Width', 'Text', 'Width', 'Width');
            this.Property_Add(111, 'Height', 'Text', 'Height', 'Height');
            this.Property_Add(112, 'Font style', 'ComboTool', 'FontName', 'FontName');
            this.Property_Add(113, 'Font size', 'ComboTool', 'FontSize', 'FontSize');
            this.Property_Add(114, 'Bold', 'Checkbox', 'FontBold', 'FontBold');
            this.Property_Add(115, 'Italic', 'Checkbox', 'FontItalic', 'FontItalic');
            this.Property_Add(116, 'Underline', 'Checkbox', 'FontUnderline', 'FontUnderline');
            this.Property_Add(117, 'Strikethrough', 'Checkbox', 'FontStrikeout', 'FontStrikeout');
            this.Property_Add(118, 'Font color', 'PickColor', 'FontColor', 'FontColor');
            this.Property_Add(119, 'Background color', 'PickColor', 'BackColor', 'BackColor');
            this.Property_Add(120, 'Border style', 'ComboTool', 'BorderStyle', 'BorderStyle');
            this.Property_Add(121, 'Border width', 'ComboTool', 'BorderWidth', 'BorderWidth');
            this.Property_Add(122, 'Border color', 'PickColor', 'BorderColor', 'BorderColor');
            this.Property_Add(124, 'Background image', 'Image', 'BackImageUrl', 'BackImageUrl');
            this.Property_Add(125, 'Image horizontal align', 'Combo', 'BackImagePosH', 'BackImagePosH', 'Left,Center,Right');
            this.Property_Add(126, 'Image vertical align', 'Combo', 'BackImagePosV', 'BackImagePosV', 'Top,Center,Bottom');
            this.Property_Add(127, 'Image repeat', 'Combo', 'BackImageRepeat', 'BackImageRepeat', 'No-Repeat,Repeat,Repeat-X,Repeat-Y');
            this.Property_Add(133, 'Ctrl identification', 'Text', 'Ident', 'Ident');
            this.Property_Add(134, 'Hide', 'Checkbox', 'Hidden', 'Hidden');
            this.Property_Add(135, 'Tooltip', 'PlainText', 'ToolTip', 'ToolTip');
            this.Property_Add(136, 'Alpha', 'Text', 'Opacity', 'Opacity');
            this.Property_Add(137, 'Position', 'Text', 'Position', 'Position');
            this.Property_Add(138, 'Left', 'Text', 'Left', 'Left');
            this.Property_Add(139, 'Top', 'Text', 'Top', 'Top');
            this.FrmCount = 23;
        }
    }
    
    this.get_ClassName = function() {
        return this.ClassName;
    }
    
    this.ClientToServer = function(aArr) {
        var lRecPage = this.get_RecordPage();
        if(lRecPage != '') {
            aArr['RecordPage'] = lRecPage
        }
    }
    
    this.ClientToServerPass = function() {
        return this.get_RecordPage() != '';
    }

    this.get_Attr = function(aAttr) {
        var lref = document.getElementById(this.ClientId);
        return lref != null && lref.getAttribute(aAttr) != null ? lref.getAttribute(aAttr) : '';
    }
    this.set_Attr = function(aAttr, aValue) {
        var lref = document.getElementById(this.ClientId);
        if(lref)
            lref.setAttribute(aAttr, aValue);
    }
    this.get_ExistAttr = function(aAttr) {
        var lref = document.getElementById(this.ClientId);
        return lref ? lref.getAttribute(aAttr) != null : null;
    }
    
    this.set_RecordPageCount = function(aValue) {
        this.set_Attr('t16', aValue);
    }
    this.get_RecordPageCount = function(aValue) {
        return this.get_Attr('t16');
    }

    this.get_ReadOnly = function(aValue) {
        return this.get_Attr('t02') == '1';
    }

    this.set_RecordPage = function(aValue) {
        this.set_Attr('t15', aValue);
    }
    this.get_RecordPage = function(aValue) {
        return this.get_Attr('t15');
    }
    
    this.ChangeRecordPage = function(aValue) {
        if(this.get_RecordPage() != null && this.get_RecordPage() != aValue) {
            this.set_RecordPage(aValue);
            this.Render("Page");
        }
    }

    this.Render = function(aCommand, aParam) {
        if(aCommand == "Exec")
            this.IsExecCallBack = true;
        if(aCommand != "Exec" || Page_obj.CountActiveCallback == 0)
        {
            var lparam = null;
            if(aParam != null) {
                lparam = new Object();
                lparam[this.ClientId] = aParam;
            }
            if(aCommand == null)
                aCommand = '';
            if(aCommand == "Exec" && Page_obj.IsHoldScreen)
                aCommand = "ExecHold";
            Page_obj.DoCallback(this, lparam, aCommand, true);
        } else if(aCommand == "Exec") {
            Page_obj.PendingAction.push(this);
        }            
    }
    
    this.set_Visible = function(aValue) {
        document.getElementById(this.ClientId).style.display = aValue ? '' : 'none';
    }
    
    this.set_Disabled = function(aValue) {
        if(aValue)
            $('#' + this.ClientId).attr('disabled','disabled');
        else
            $('#' + this.ClientId).removeAttr('disabled');
    }
    
    this.InitDesignMode = function() {
        
    }
    
    this.set_DesignMarkNor = function() {
        if(Designer_obj) {
            var lref = document.getElementById(this.ClientId);
            Designer_obj.set_DesignMarkNor(lref);
        }
    }
    
    this.set_DesignMarkSel = function() {
        if(Designer_obj) {
            var lref = document.getElementById(this.ClientId);
            Designer_obj.set_DesignMarkSel(lref);
        }
    }
    
    this.set_DesignSelected = function() {
        if(Designer_obj) {
            Designer_obj.set_Selected(this.ClientId);
        }
    }
    
    this.get_Frm = function() {
        return this.Frm;
    }
    
    this.set_Ident = function(aValue) {
        var lRef = document.getElementById(this.ClientId);
        lRef.setAttribute('t01', aValue.replace(/[^a-zA-Z0-9.]/, ''));
    }
    this.get_Ident = function() {
        var lRef = document.getElementById(this.ClientId);
        return lRef.getAttribute('t01') != null ? lRef.getAttribute('t01') : '';
    }

	this.set_Width = function(aValue) {
	    if(aValue != null) {
            var lref = document.getElementById(this.ClientId + this.ContenIdPart);
            if(aValue!= '' && !/[a-zA-Z%]/.test(aValue))
                aValue += 'px';
            lref.style.width = aValue;
            this.Frm[0] = lref.style.width;
            this.SyncSize();
        }
        return 0;
	}
	
	this.set_Height = function(aValue) {
	    if(aValue != null) {
            var lref = document.getElementById(this.ClientId + this.ContenIdPart);
            if(aValue!= '' && !/[a-zA-Z%]/.test(aValue))
                aValue += 'px';
            lref.style.height = aValue;
            this.Frm[1] = lref.style.height;
            this.SyncSize();
        }
        return 0;
	}
	
    this.SyncSize = function() {
    }

    this.get_WidthConten = function() {
        var lref = document.getElementById(this.ClientId + this.ContenIdPart);
        return lref.offsetWidth + 'px';
    }

    this.get_HeightConten = function() {
        var lref = document.getElementById(this.ClientId + this.ContenIdPart);
        return lref.offsetHeight + 'px';
    }

    this.get_Width = function() {
        var lref = document.getElementById(this.ClientId + this.ContenIdPart);
        return lref.style.width;
    }

    this.get_Height = function() {
        var lref = document.getElementById(this.ClientId + this.ContenIdPart);
        return lref.style.height;
    }
    
	this.set_Hidden = function(aValue) {
	    if(Designer_obj)
	        this.Frm[17] = aValue;
	    else {
	        this.set_HiddenClient(aValue);
	    }
	}
	this.get_Hidden = function() {
	    if(Designer_obj) {
    	    return this.Frm[17];
	    } else {
	        var lref = document.getElementById(this.ClientId);
	        return lref.style.display == 'none';
	    }
	}
	
	this.set_HiddenClient = function(aValue) {
        var lref = document.getElementById(this.ClientId);
        lref.style.display = aValue ? 'none' : '';
	}
    
    this.set_FontName = function(aValue) {
        if(Designer_obj)
            this.Frm[2] = aValue;
        $('#' + this.ClientId + ' ' + this.SelectFormat).css('font-family', aValue);
    }
    this.get_FontName = function() {
        if(Designer_obj)
            return this.Frm[2];
        else 
            return $('#' + this.ClientId + ' ' + this.SelectFormat).css('font-family');
    }

    this.set_FontSize = function(aValue) {
        if(Designer_obj)
            this.Frm[3] = aValue;
        $('#' + this.ClientId + ' ' + this.SelectFormat).css('font-size', aValue);
    }
    this.get_FontSize = function() {
        if(Designer_obj)
            return this.Frm[3];
        else 
            return $('#' + this.ClientId + ' ' + this.SelectFormat).css('font-size');
    }
    
    this.set_FontBold = function(aValue) {
        if(Designer_obj)
            this.Frm[4] = aValue;
        $('#' + this.ClientId + ' ' + this.SelectFormat).css('font-weight', aValue ? 'bold' : 'normal');
    }
    this.get_FontBold = function() {
        if(Designer_obj)
            return this.Frm[4];
        else 
            return $('#' + this.ClientId + ' ' + this.SelectFormat).css('font-weight') == 'bold';
    }

    this.set_FontItalic = function(aValue) {
        if(Designer_obj)
            this.Frm[5] = aValue;
        $('#' + this.ClientId + ' ' + this.SelectFormat).css('font-style', aValue ? 'italic' : 'normal');
    }
    this.get_FontItalic = function() {
        if(Designer_obj)
            return this.Frm[5];
        else 
            return $('#' + this.ClientId + ' ' + this.SelectFormat).css('font-style') == 'italic';
    }
    
    this.set_FontUnderline = function(aValue) {
        if(Designer_obj)
            this.Frm[6] = aValue;
        var lvalue = $('#' + this.ClientId + ' ' + this.SelectFormat).css('text-decoration');
        if(!lvalue || lvalue == 'none')
            lvalue = '';
        var lpos = lvalue.indexOf('underline');
        if(aValue && lpos == -1)
            lvalue += ' underline';
        else if(!aValue && lpos >= 0)
            lvalue = lvalue.replace('underline', '');
        $('#' + this.ClientId + ' ' + this.SelectFormat).css('text-decoration', lvalue);
    }
    this.get_FontUnderline = function() {
        if(Designer_obj)
            return this.Frm[6];
        else 
            return $('#' + this.ClientId + ' ' + this.SelectFormat).css('text-decoration').indexOf('underline') >= 0;
    }

    this.set_FontStrikeout = function(aValue) {
        if(Designer_obj)
            this.Frm[7] = aValue;
        var lvalue = $('#' + this.ClientId + ' ' + this.SelectFormat).css('text-decoration');
        if(!lvalue || lvalue == 'none')
            lvalue = '';
        var lpos = lvalue.indexOf('line-through');
        if(aValue && lpos == -1)
            lvalue += ' line-through';
        else if(!aValue && lpos >= 0)
            lvalue = lvalue.replace('line-through', '');
        $('#' + this.ClientId + ' ' + this.SelectFormat).css('text-decoration', lvalue);
    }
    this.get_FontStrikeout = function() {
        if(Designer_obj)
            return this.Frm[7];
        else 
            return $('#' + this.ClientId + ' ' + this.SelectFormat).css('text-decoration').indexOf('line-through') >= 0;
    }

    this.set_FontColor = function(aValue) {
        if(Designer_obj)
            this.Frm[8] = aValue;
        $('#' + this.ClientId + ' ' + this.SelectFormat).css('color', aValue);
    }
    this.get_FontColor = function() {
        if(Designer_obj)
            return this.Frm[8];
        else 
            return Util_obj.get_Color($('#' + this.ClientId + ' ' + this.SelectFormat).css('color'));
    }

    this.set_BackColor = function(aValue) {
        if(Designer_obj)
            this.Frm[9] = aValue;
        $('#' + this.ClientId + ' ' + this.SelectFormat).css('background-color', aValue);
    }
    this.get_BackColor = function() {
        if(Designer_obj)
            return this.Frm[9];
        else 
            return Util_obj.get_Color($('#' + this.ClientId + ' ' + this.SelectFormat).css('background-color'));
    }

    this.set_BorderStyle = function(aValue) {
        if(Designer_obj)
            this.Frm[10] = aValue;
        $('#' + this.ClientId + ' ' + this.SelectFormat).css('border-style', aValue);
        this.SyncSize();
    }
    this.get_BorderStyle = function() {
        if(Designer_obj)
            return this.Frm[10];
        else {
            var lvalue = $('#' + this.ClientId + ' ' + this.SelectFormat).css('border-style');
            var larr = lvalue.split(' ');
            return larr[0].substr(0,1).toUpperCase() + larr[0].substr(1);
        }
    }

    this.set_BorderWidth = function(aValue) {
        if(Designer_obj)
            this.Frm[11] = aValue;
        $('#' + this.ClientId + ' ' + this.SelectFormat).css('border-width', aValue);
        this.SyncSize();
    }
    this.get_BorderWidth = function() {
        if(Designer_obj)
            return this.Frm[11];
        else {
            var lvalue = $('#' + this.ClientId + ' ' + this.SelectFormat).css('border-width');
            var larr = lvalue.split(' ');
            return larr[0];
        }
    }

    this.set_BorderColor = function(aValue) {
        if(Designer_obj)
            this.Frm[12] = aValue;
        $('#' + this.ClientId + ' ' + this.SelectFormat).css('border-color', aValue);
    }
    this.get_BorderColor = function() {
        if(Designer_obj)
            return this.Frm[12];
        else 
            return Util_obj.get_Color($('#' + this.ClientId + ' ' + this.SelectFormat).css('border-color'));
    }
    
    this.set_BackImageUrl = function(aValue) {
        if(Designer_obj)
            this.Frm[13] = aValue;
        $('#' + this.ClientId + ' ' + this.SelectFormat).css('background-image', 'url(' + Page_obj.LibraryHost + aValue + ')');
    }
    this.get_BackImageUrl = function() {
        if(Designer_obj)
            return this.Frm[13];
        else {
            var lvalue = $('#' + this.ClientId + ' ' + this.SelectFormat).css('background-image');
            return lvalue.replace('url(' + Page_obj.LibraryHost,'').replace(')','');
        }
    }
    
    this.HideBackImage = function(aId) {
        if(!aId)
            aId = this.ClientId + this.ContenIdPart;
        var lref = document.getElementById(aId);
        if(lref.style.backgroundImage != 'none') {
            lref._ant_back_img = lref.style.backgroundImage;
            lref.style.backgroundImage = 'none';
        }
    }

    this.ShowBackImage = function(aId) {
        if(!aId)
            aId = this.ClientId + this.ContenIdPart;
        var lref = document.getElementById(aId);
        lref.style.backgroundImage = lref._ant_back_img;
    }

    this.set_BackImagePosH = function(aValue) {
        if(Designer_obj)
            this.Frm[14] = aValue;
        $('#' + this.ClientId + ' ' + this.SelectFormat).css('background-position', aValue.toLowerCase() + ' ' + this.get_BackImagePosV().toLowerCase());
    }
    this.get_BackImagePosH = function() {
        return this.Frm[14];
    }
    
    this.set_BackImagePosV = function(aValue) {
        if(Designer_obj)
            this.Frm[15] = aValue;
        $('#' + this.ClientId + ' ' + this.SelectFormat).css('background-position', this.get_BackImagePosH().toLowerCase() + ' ' + aValue.toLowerCase());
    }
    this.get_BackImagePosV = function() {
        return this.Frm[15];
    }

    this.set_BackImageRepeat = function(aValue) {
        if(Designer_obj)
            this.Frm[16] = aValue;
        $('#' + this.ClientId + ' ' + this.SelectFormat).css('background-repeat', aValue.toLowerCase());
    }
    this.get_BackImageRepeat = function() {
        return this.Frm[16];
    }

    this.set_ToolTip = function(aValue) {
        this.Frm[18] = this.set_ValueLang(this.Frm[18], aValue); //aValue;
    }
    this.get_ToolTip = function() {
        return this.get_ValueLang(this.Frm[18]);
    }

    this.set_Opacity = function(aValue) {
        if(Designer_obj)
            this.Frm[19] = aValue;
        Page_obj.set_Opacity(document.getElementById(this.ClientId + (this.ContenIdPart != '' ? this.ContenIdPart : '')), aValue);
    }
    this.get_Opacity = function() {
        if(Designer_obj)
            return this.Frm[19];
        else
            return this.get_Attr('t03') == '' ? '100' : this.get_Attr('t03');
    }

    this.set_Position = function(aValue) {
        var lref = document.getElementById(this.ClientId + this.ContenIdPart);
        if(aValue.toLowerCase() == 'absolute') {
            lref.style.position = 'absolute';
        } else {
            lref.style.position = '';
        }
        this.Frm[20] = aValue;
    }
    this.get_Position = function() {
        return this.Frm[20];
    }

    this.set_Left = function(aValue) {
        var lref = document.getElementById(this.ClientId + this.ContenIdPart);
        lref.style.left = aValue;
        this.Frm[21] = lref.style.left;
    }
    this.get_Left = function() {
        return this.Frm[21];
    }

    this.set_Top = function(aValue) {
        var lref = document.getElementById(this.ClientId + this.ContenIdPart);
        lref.style.top = aValue;
        this.Frm[22] = lref.style.top;
    }
    this.get_Top = function() {
        return this.Frm[22];
    }
    
    this.set_Flag = function(aValue) {
        this.Frm[23] = aValue;
    }
    this.get_Flag = function() {
        return this.Frm[23];
    }
    this.set_FlagBit = function(aIndex, aValue) {
        this.Frm[23] = this.Frm[23].setCharAt(aIndex, aValue === true || aValue == '1' ? "1" : "0");
    }
    this.get_FlagBit = function(aIndex) {
        return this.Frm[23] && this.Frm[23].length > aIndex ? this.Frm[23].charAt(aIndex) == '1' : false;
    }
    this.set_FlagBit0 = function(aValue) {
        return this.set_FlagBit(0,aValue);
    }
    this.get_FlagBit0 = function(aIndex) {
        return this.get_FlagBit(0);
    }

    this.SyncronizeFrm = function() {
        var lref = document.getElementById(this.ClientId + this.ContenIdPart);
        this.Frm[0] = lref.style.width;
        this.Frm[1] = lref.style.height;
        this.Frm[21] = lref.style.left;
        this.Frm[22] = lref.style.top;        
        this.SyncSize();
    }

    this.get_AllowDrag = function() {
        return true;
    }
    
    this.get_AllowDrop = function() {
        return false;
    }

    this.get_AllowDropBefore = function() {
        return true;
    }
    
    this.get_ToArrayList = function(aArr) {
        if(!aArr)
            aArr = new Array();
        aArr[aArr.length] = this;
        var lRef = document.getElementById(this.ClientId);
        lRef = lRef.firstChild;
        while(lRef != null) {
            if(lRef.id && lRef.id.length > 0 && robj(lRef) && robj(lRef) != this && robj(lRef).ClientId + robj(lRef).ContenIdPart == lRef.id)
                robj(lRef).get_ToArrayList(aArr);
            lRef = lRef.nextSibling;
        }
        return aArr;
    }
    
    this.get_ValueLang = function(aValue) {
        if(Designer_obj) {
            var lLang = Designer_obj.get_Lang();
            if(!aValue)
                aValue = '';
            var lArr = aValue.split('*_*');
            if(lLang == 'fr')    
                return lArr[0];
            else if(lLang == 'en' && lArr.length > 1)
                return lArr[1];
            else if(lLang == 'es' && lArr.length > 2)
                return lArr[2];
            else
                return lArr[0];
        }
    }
    
    this.set_ValueLang = function(aValue, aValueSet) {
        if(Designer_obj) {
            var lLang = Designer_obj.get_Lang();
            var lArr = aValue.split('*_*');
            if(lArr.length == 1 && lLang == Designer_obj.get_DefaultLang())
                return aValueSet;
            else {
                /*alert(aValue);
                alert(aValueSet);
                alert(lLang);*/
                if(lLang == 'fr')
                    lArr[0] = aValueSet;
                else if(lLang == 'en')
                    lArr[1] = aValueSet;
                else if(lLang == 'es')
                    lArr[2] = aValueSet;
                if(lArr[0] == null)
                    lArr[0] = ''
                if(lArr[1] == null)
                    lArr[1] = '';
                if(lArr[2] == null)
                    lArr[2] = '';
                return lArr.join('*_*');
            }
        }
        return '';
    }
}

derive(ClassInput, ClassBase)
function ClassInput() {

    this.TextChanges = null;
    
    this.OnChange = null;
    
    //this.Text = '';
    this.CdtID = '';
    this.CdtKey = '';
    this.CdtCol = -1;

    override(this, 'Init');
    this.Init = function() {
        this.ClassBase_Init(arguments[0],arguments[1],arguments[2]);
        //this.TextChanges = arguments[3];
        this.CtrlType = 1;
        if(Designer_obj) {
            this.Property_Add(106, 'Action change', 'ActionList', 'ActChange', 'ActChange');
            //this.Property_Add(23, 'Tab order', 'Text', 'TabIndex', 'TabIndex');
            this.Property_Add(128, 'Auto save value', 'Combo', 'SaveValue', 'SaveValue', '1|Si,0|No');
            this.Property_Add(129, 'Default value', 'PlainText', 'TextDefault', 'TextDefault');
            this.Property_Add(132, 'Multilanguage', 'Checkbox', 'MultiLang', 'MultiLang');
            this.FrmCount = 28;
        }
    }

    override(this, 'ClientToServer');   
    this.ClientToServer = function(aArr) {
        this.ClassBase_ClientToServer(aArr);
        aArr['Text'] = this.get_Text();
        if(Designer_obj != null && this.get_TextDefault() != '')
            aArr['TextDefault'] = this.get_TextDefault()
    }

    this.ClientToServerPass = function() {
        return true;
    }

    this.set_Text = function(aValue) {
        this.set_Attr('t05', aValue);
    }
    this.get_Text = function() {
        return this.get_Attr('t05');
    }
    
    this.get_TabIndex = function() {
        return this.Frm[24];
    }
    this.set_TabIndex = function(aValue) {
        var lRef = document.getElementById(this.ClientId);
        lRef.tabIndex = aValue;
        this.Frm[24] = aValue;
    }
    
    this.get_SaveValue = function() {
        return this.Frm[25];
    }
    this.set_SaveValue = function(aValue) {
        this.Frm[25] = aValue;
    }

    this.get_TextDefault = function() {
        return this.get_ValueLang(this.Frm[26]);
    }
    this.set_TextDefault = function(aValue) {
        this.Frm[26] = this.set_ValueLang(this.Frm[26], aValue);
    }

    this.ChangeText = function(aValue) {
        if(this.get_Text() != aValue) {
            this.set_Text(aValue);
            this.ProcessTextChange();
        }
    }
    
    this.Load = function(aCallback, aIsTextRender) {
        try
        {
            if(this.CdtID != '' && robj(this.CdtID).get_Row(this.CdtKey) != null && robj(this.CdtID).get_RowData(this.CdtKey, this.CdtCol) != null) {
                this.set_Text(robj(this.CdtID).get_RowData(this.CdtKey, this.CdtCol));
            } else if(!aIsTextRender) {
                this.set_Text(this.get_Text());
            }
        } catch(aExcep) {
            this.set_Text(this.get_Text());
        }
    }
    
    this.set_Focus = function() {
        alert('Function set_Focus must be implemented.');
    }
    
    this.ControlsToGetValue = function(aIndex, aControls) {
        if(this.TextChanges[aIndex] && this.TextChanges[aIndex].Params)
            this.TextChanges[aIndex].Params.ControlsToGetValue = aControls;
    }
    
    this.ProcessTextChange = function(aEvent) {
        if((this.OnChange == null || this.OnChange(aEvent)) && this.TextChanges && this.TextChanges.length > 0) {
            var larr = new Array();
            var lparam = new Object();
            for(var i = 0; i < this.TextChanges.length; i++) {
                larr[larr.length] = robj(this.TextChanges[i].CtrlId);
                lparam[this.TextChanges[i].CtrlId] = this.TextChanges[i].Params;
            }
            //alert(larr[0].ClientId);
            Page_obj.DoCallback(larr,lparam,'Change',true);
        }
        if(this.get_ActChange() != '') {
            this.ExecActChange(document.getElementById(this.ClientId));
        }
    }

    this.set_ActChange = function(aValue) {
        this.set_Attr('t06', aValue);
        this.Frm[27] = aValue;
    }
    this.get_ActChange = function() {
        if(Designer_obj)
            return this.Frm[27];
        return this.get_Attr('t06'); 
    }
    this.ExecActChange = function(aRef) {
        if(this.get_ActChange() != '') {
            var lObj = robj(this.get_ActChange());
            if(lObj) {
                lObj.Execute(aRef);
            }
        }
    }

    this.set_MultiLang = function(aValue) {
        this.Frm[28] = aValue;
    }
    this.get_MultiLang = function() {
        if(Designer_obj)
            return this.Frm[28];
    }
}

derive(ClassDataInput, ClassInput)
function ClassDataInput() {

    this.SelectedIndex = null;
    this.DataKeys = null;
    
    this.EmptySelection = false;
    this.SetFocusOnChangePage = true;
    
    override(this, 'Init');
    this.Init = function() {
        this.ClassInput_Init(arguments[0],arguments[1],arguments[2],arguments[3]);
        if(Designer_obj) {
            //this.Property_Add(30, 'Fuente de datos', 'DataSourceFilter', 'DataSourceIDOne', 'DataSourceID');
            this.Property_Add(130, 'Data source', 'DataSourceFull', 'DataSourceFull');
            //this.Property_Add(31, 'Fuente Sql', 'PlainText', 'DataSourceSql', 'DataSourceSql');
            this.FrmCount = 35;
        }
    }

    override(this, 'ClientToServer');   
    this.ClientToServer = function(aArr) {
        this.ClassInput_ClientToServer(aArr);
        if(!this.get_ReadOnly()) {
            aArr['SelectedIndex'] = this.get_SelectedIndex();
            aArr['DataKeys'] = this.get_DataKeys();
        }
        if(this.get_DataSql() != '')
            aArr['DataSql'] = this.get_DataSql();
    }

    this.set_SelectedIndex = function(aValue) {
        this.RenderSelection(false);
        this.SelectedIndex = aValue;
        this.RenderSelection(true);
    }
    this.get_SelectedIndex = function() {
        if(this.SelectedIndex == null) {
            if(this.get_ExistAttr('t10'))
                this.SelectedIndex = this.get_Attr('t10').split('#');
            else
                this.SelectedIndex = parseInt(this.get_Attr('t11'));
        }
        return this.SelectedIndex;
    }
    this.set_SelectedIndexEmpty = function() {
        var lsel_index = this.get_SelectedIndex();
        this.set_SelectedIndex(typeof(lsel_index) == 'object' ? new Array() : -1);
    }
    
    this.get_DataKeys = function() {
        if(this.DataKeys == null) {
            if(this.get_Attr('t12') != '')
                this.DataKeys = this.get_Attr('t12').split('#');
            else {
                this.DataKeys = new Array();
            }
        }
        return this.DataKeys;
    }
    this.set_DataKeys = function(aValue, aIndex) {
        this.DataKeys = aValue;
        if(aIndex)
            this.set_SelectedIndex(aIndex);
    }
    
    this.set_TextForce = function(aValue) {
        if(aValue == null)
            this.set_Text('');
        else
            this.set_Text(aValue);
        if(this.get_Text() != aValue || this.DataKeys.length == 0 || aValue == null) {
            if(aValue != null)
                this.set_DataKeys([aValue], 0);
            ListRender_obj.AddItem(this);
        }
    }
    
    this.get_DataSql = function() {
        return this.get_Attr('t13');
    }
    this.set_DataSql = function(aValue) {
        this.set_Attr('t13', aValue);
    }

    this.get_ItemsCount = function() {
        this.DataKeys = null;
    	return this.get_DataKeys() != null ? this.DataKeys.length : 0;
    }
    
    this.set_Text = function(aValue) {
        var lsel_index = this.get_SelectedIndex();
        if(typeof(lsel_index) == 'object') {
            var larr = aValue.split('|');
            var lres = new Array();
            for(var i = 0; i < larr.length; i++) {
                var lindex = this.IndexOfDataKey(larr[i]);
                if(lindex != -1)
                    lres[lres.length] = lindex;
            }
            this.set_SelectedIndex(lres);
        } else {
            this.set_SelectedIndex(this.IndexOfDataKey(aValue));
        }
    }
    this.get_Text = function() {
        if(this.get_ReadOnly()) {
            if(this.get_ItemsCount() == 0)
                return '';
            else
                return this.get_DataKeys()[0];
        }
        var lsel_index = this.get_SelectedIndex();
        if(typeof(lsel_index) == 'object') {
            var lres = '';
            for(var i = 0; i < lsel_index.length; i++)
                if(this.get_DataKeys()[lsel_index[i]])
                    lres += (lres == '' ? '' : '|') + this.get_DataKeys()[lsel_index[i]];
            return lres;
        } else {
            if(lsel_index >= 0 && lsel_index < this.get_DataKeys().length)
                return this.get_DataKeys()[lsel_index];
            else
        	    return '';
        }
    }
    
    this.get_TextMultiple = function(aIndex) {
        var lsel_index = this.get_SelectedIndex();
        if(typeof(lsel_index) == 'object') {
        	return typeof(lsel_index[aIndex]) != 'undefined' && typeof(this.get_DataKeys()[lsel_index[aIndex]]) != 'undefined' ? this.get_DataKeys()[lsel_index[aIndex]] : '';
        } else {
            if(lsel_index >= 0 && lsel_index < this.get_DataKeys().length)
                return this.get_DataKeys()[lsel_index];
            else
        	    return '';
        }
    }

    this.IndexOfDataKey = function(aValue) {
        var lindex = -1;
        for(var i = 0; i < this.get_DataKeys().length; i++)
            if(this.get_DataKeys()[i] == aValue) {
                lindex = i;
                break;
            }
        return lindex;
    }
    
    this.ChangeSelectedIndex = function(aValue) {
        var lsel_index = this.get_SelectedIndex();
        if(lsel_index != aValue) {
            this.set_SelectedIndex(aValue);
            this.ProcessTextChange();
        } else if(this.EmptySelection) {
            this.set_SelectedIndexEmpty();
            this.ProcessTextChange();
        }
    }
    
    this.ChangeRecordPage = function(aValue) {
        if(this.get_RecordPage() != null && this.get_RecordPage() != aValue) {
            this.set_SelectedIndexEmpty();
            this.set_RecordPage(aValue);
            this.Render("Page",{SetFocus: this.SetFocusOnChangePage});
        }
    }
    
    this.ProcessSelection = function(aIndex,aEvent) {
        var lsel_index = this.get_SelectedIndex();
        var lant_sel_index = lsel_index;
        if(typeof(lsel_index) == 'object') {
            var lfind = false;
            var larr;
            if(lsel_index.length == 1 && lsel_index[0] === '')
                lsel_index = new Array();
            for(var i = 0; i < lsel_index.length; i++) {
                if(aIndex < lsel_index[i]) {
                    lfind = true;
                    larr = lsel_index.slice(0,i).concat(aIndex,lsel_index.slice(i));
                    break;
                } else if(lsel_index[i] !== '' && aIndex == lsel_index[i]) {
                    lfind = true;
                    if(this.EmptySelection)
                        larr = lsel_index.slice(0,i).concat(lsel_index.slice(i+1));
                    else {
                    	larr = new Array();
                    	larr.concat(lsel_index);
                    }
                    break;
                }
            }
            if(!lfind)
                larr = lsel_index.concat(aIndex);
            larr = this.VerifySelection(larr,aIndex,aEvent,lant_sel_index);
            this.ChangeSelectedIndex(larr);        
        } else
        	this.ChangeSelectedIndex(aIndex);
    }
    
    this.Load = function() {
        this.DataKeys = null;
        this.SelectedIndex = null;
        if(this.CdtID && this.CdtID != '' && robj(this.CdtID).get_Row(this.CdtKey) != null && robj(this.CdtID).get_RowData(this.CdtKey, this.CdtCol) != null) {
            this.set_Text(robj(this.CdtID).get_RowData(this.CdtKey, this.CdtCol));
        } else
            this.set_SelectedIndex(this.get_SelectedIndex());
    }
    
    this.VerifySelection = function(aSelectedIndex,aIndex,aEvent) {
        return aSelectedIndex;
    }
    
    this.RenderSelection = function(aMark) {
    }
    
    this.get_DataSourceFull = function() {
      return this.get_DataSourceID() == '' ? '' : (
        this.get_DataSourceID() + '/*/' + 
        this.get_DataSourceFilter() + '/*/' + 
        this.get_DataSourceOrder() + '/*/' + 
        this.get_DataSourceTop() + '/*/' +
        this.get_DataSourceType() + '/*/' +
        this.get_DataSourceKey()
      );
    }
    
    this.set_DataSourceFull = function(aValue) {
        lArr = aValue.split('/*/');
        this.set_DataSourceID(lArr.length > 0 ? lArr[0] : '');
        this.set_DataSourceFilter(lArr.length > 1 ? lArr[1] : '');
        this.set_DataSourceOrder(lArr.length > 2 ? lArr[2] : '');
        this.set_DataSourceTop(lArr.length > 3 ? lArr[3] : '');
        this.set_DataSourceType(lArr.length > 4 ? lArr[4] : '');
        this.set_DataSourceKey(lArr.length > 5 ? lArr[5] : '');
    }

    this.set_DataSourceID = function(aValue) {
        this.Frm[29] = aValue;
    }
    this.get_DataSourceID = function() {
        return this.Frm[29];
    }
    this.get_DataSourceIDOne = function() {
        return this.Frm[29].split(',')[0];
    }

    this.set_DataSourceFilter = function(aValue) {
        this.Frm[30] = aValue;
    }
    this.get_DataSourceFilter = function() {
        return this.Frm[30];
    }

    this.set_DataSourceOrder = function(aValue) {
        this.Frm[31] = aValue;
    }
    this.get_DataSourceOrder = function() {
        return this.Frm[31];
    }
    
    this.set_DataSourceTop = function(aValue) {
        this.Frm[32] = aValue;
    }
    this.get_DataSourceTop = function() {
        return this.Frm[32];
    }

    this.set_DataSourceType = function(aValue) {
        this.Frm[33] = aValue;
    }
    this.get_DataSourceType = function() {
        return this.Frm[33];
    }

    this.set_DataSourceSql = function(aValue) {
        this.Frm[34] = aValue;
    }
    this.get_DataSourceSql = function() {
        return this.Frm[34];
    }

    this.set_DataSourceKey = function(aValue) {
        this.Frm[35] = aValue;
    }
    this.get_DataSourceKey = function() {
        return this.Frm[35];
    }

}

function EffectLib() {

    this.TmpIntVar1 = 0;
    this.TmpStrVar1 = '';
    this.TmpTimeout = null;
    
    this.TmpDelay = 0;
    this.TmpFunc = '';
    
    this.VerifyExec = function() {
        if(this.TmpFunc != '') {
            eval(this.TmpFunc);
            setTimeout('EffectLib_obj.VerifyExec()',this.TmpDelay);
        }
    }

    this.ChangeImgEffect1 = function(aObjId, aObjImgId, aChgImgId, aSpeed, aStep, aNoFirst) { // Cambiar imagen con el efecto opacidad desaparece y aparece
        if(typeof(aNoFirst) == 'undefined') {
            this.TmpIntVar1 = 0;
        }
        var lRefObj = document.getElementById(aObjId);
        if(lRefObj) {
            if (this.TmpIntVar1 == 0) {
                if (Page_obj.get_Opacity(lRefObj) > 0) {
                    var lNewOpacity = Page_obj.get_Opacity(lRefObj) * 1 - aStep * 1;
                    Page_obj.set_Opacity(lRefObj, lNewOpacity < 0 ? 0 : (lNewOpacity > 100 ? 100 : lNewOpacity));
                    if (Page_obj.get_Opacity(lRefObj) * 1 <= aStep) {
                        var lRefImg1 = document.getElementById(aObjImgId);
                        var lRefImg2 = document.getElementById(aChgImgId);
                        if(lRefImg1 && lRefImg2) {
                            lRefImg1.src = lRefImg2.src;
                        }
                        this.TmpIntVar1 = 1;
                    }
                    if(typeof(aNoFirst) == 'undefined') {
                        this.TmpFunc = "EffectLib_obj.ChangeImgEffect1('" + aObjId + "','" + aObjImgId + "','" + aChgImgId + "'," + aSpeed + "," + aStep + ", true)";
                        this.TmpDelay = aSpeed;
                        setTimeout('EffectLib_obj.VerifyExec()',aSpeed);
                    }
                }
            } else if (this.TmpIntVar1 == 1) {
                if (Page_obj.get_Opacity(lRefObj) < 100) {
                    var lNewOpacity = Page_obj.get_Opacity(lRefObj) * 1 + aStep * 1;
                    Page_obj.set_Opacity(lRefObj, lNewOpacity < 0 ? 0 : (lNewOpacity > 100 ? 100 : lNewOpacity));
                } else
                    this.TmpFunc = '';
            }
        }
    } 
}
EffectLib_obj = new EffectLib();

function ListRender() {
    this.List = new Array();
    this.Timeout = null;
    this.AddItem = function(aItem) {
        if(this.Timeout != null)
            clearTimeout(this.Timeout);
        this.List[this.List.length] = aItem;
        this.Timeout = setTimeout(function(){ListRender_obj.Render()}, 500);
    }
    this.Render = function() {
        this.Timeout = null;
        Page_obj.Render(this.List);
        this.List = new Array();
    }
}
ListRender_obj = new ListRender();

if(typeof(Page_IsValid) == 'undefined')
    Page_IsValid = true;

function is_child_of(parent, child) {
    if (child != null) {
        while (child.parentNode) {
            if ((child = child.parentNode) == parent) {
                return true;
            }
        }
    }
    return false;
}
function fixOnMouseOut(element, event) {
    var current_mouse_target = null;
    if (event.toElement) {
        current_mouse_target = event.toElement;
    } else if (event.relatedTarget) {
        current_mouse_target = event.relatedTarget;
    }
    if (!is_child_of(element, current_mouse_target) && element != current_mouse_target) {
        Page_obj.ExecAction(element, 't22');
    }
}
function AfterLoadImageView(aRef, aWidth, aHeight) {
    aWidth = parseInt(aWidth);
    aHeight = parseInt(aHeight);
    if (aWidth > 0 || aHeight > 0) {
        var limg = new Image();
        limg.src = aRef.src;
        if (aWidth == 0)
            $(limg).width($(aRef).width());
        if (aHeight == 0)
            $(limg).height($(aRef).height());
        var lRatio = 0;
        var lNewWidth = limg.width;
        var lNewHeight = limg.height;
        if(aWidth > 0) {
            if(limg.width > aWidth) {
                lRatio = ( limg.height / limg.width );
                lNewWidth = aWidth;
                lNewHeight = aWidth * lRatio;
            }
        }
        if(aHeight > 0) {
            if(lNewHeight > aHeight) {
                lRatio = ( lNewWidth / lNewHeight );
                lNewWidth = aHeight * lRatio;
                lNewHeight = aHeight;
            }
        }
        if(!Designer_obj) {
            $(aRef).width(lNewWidth);
            $(aRef).height(lNewHeight);
        }
    }
}
function CloseMenuFloat() {
    if(typeof(gblLastGroup) != 'undefined') {
        if(Page_obj.expand_ant_sel['Grp' + gblLastGroup] != null) {
            Page_obj.expand_ant_sel['Grp' + gblLastGroup].style.display = 'none';
        }
    }
}
function UIE(aId, aCond) {
    setTimeout("Util_obj.InitExpand('" + aId + "','" + aCond.replace(new RegExp("'",'gi'),"\\'") + "')",800);
}

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString();
        }
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { 
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

jQuery.fn.choose = function(f) {
	$(this).bind('choose', f);
};

jQuery.fn.file = function() {
	return this.each(function() {
		var btn = $(this);
		var pos = btn.offset();
								
		function update() {
			pos = btn.offset();
			file.css({
				'top': pos.top,
				'left': pos.left,
				'width': btn.width() + 18,
				'height': btn.height() + 5
			});
		}

		btn.mouseover(update);

		var hidden = $('<div></div>').css({
			'display': 'none'
		}).appendTo('body');

		var file = $('<div></div>').appendTo(document.forms[0]).css({
			'position': 'absolute',
			'overflow': 'hidden',
			'-moz-opacity': '0',
			'filter':  'alpha(opacity: 0)',
			'opacity': '0',
			'z-index': '10000'		
		});
		
		function reset() {
			var input = $('<input class=tmpfile type="file" multiple>').appendTo(file);
			input.change(function(e) {
				btn.trigger('choose', [input]);
				input.unbind();
				input.detach();
				reset();
			});
		};
		
		reset();		

		function placer(e) {
		    if(offset.width < 0) {
		        offset = {
			        width: file.width() - 15,
			        height: file.height() / 2
		        };
		        update();
		    }
			file.find('.tmpfile').css('margin-left', e.pageX - pos.left - offset.width);
			file.find('.tmpfile').css('margin-top', e.pageY - pos.top - offset.height + 3);					
		}

		function redirect(name) {
			file[name](function(e) {
				btn.trigger(name);
			});
		}

		file.mousemove(placer);
		btn.mousemove(placer);

		redirect('mouseover');
		redirect('mouseout');
		redirect('mousedown');
		redirect('mouseup');

		var offset = {
			width: file.width() - 15,
			height: file.height() / 2
		};
        
        if(offset.width > 0)
		    update();
		else {
            file.css({
				'top': '-500px',
				'left': '-500px'
			});
		}
	});
};
