try{if(!ALAB)ALAB = new Object();}
catch(er){ALAB = new Object();}

    var iframe = null;
    
    var sCurrentUri = '';
    var IsTheFirstTime = true;
    var IsUpdating = false;
    var ie = navigator.appName == 'Microsoft Internet Explorer';
    var CurrentUriContainer = null;
    function init()
    { 
        ad = document.getElementById('alertDiv');
        CurrentUriContainer = document.createElement('input');
        CurrentUriContainer.type = 'hidden';
        CurrentUriContainer.id = 'hdnCurrentUriContainer';
        CurrentUriContainer.name = 'hdnCurrentUriContainer';
        document.forms[0].appendChild(CurrentUriContainer);
       
        if(ie)
        {
            window.setInterval('checkUriIE();', 200);
            
            iframe = document.createElement('iframe');

            iframe.id = "DhtmlHistoryFrame";
            iframe.name = "DhtmlHistoryFrame";
            sCurrentUri = ('' + window.location.hash).replace('#', '');
            iframe.src = "blank.ashx?" + sCurrentUri;
            IsUpdating = true;
            iframe.style.border = "2px";
            iframe.style.bottom = "0px";
            iframe.style.height = "0";
            iframe.style.position = "absolute";
            iframe.style.right = "0";
            iframe.style.visibility = "hidden";
            iframe.style.width = "0";

            document.body.appendChild(iframe);
        }
        else
        {
            window.setInterval('checkUri();', 200);
        }
        
        var _doDefLoading = false;
        try { _doDefLoading = doDefaultLoading; } catch(er) { _doDefLoading = false; }
        
        if(IsTheFirstTime || _doDefLoading)
        {
            IsTheFirstTime = false;
            var s = ('' + window.location.hash).replace('#', '');
            if(s != '' || _doDefLoading)
            {
                try{ if (s == '' && doDefaultLocation != null) s = doDefaultLocation; }catch(er){};
                setLocationHash(s, true);
            }
        }
        
        // trying to call OverridenPageInit if it's overriden on a page
        try{ if(OverridenPageInit) OverridenPageInit(); } catch(er) {};
    }
    
    function checkUriIE()
    {
        if(IsUpdating)
            return;
            
        var oDocument = iframe.contentWindow || iframe.contentDocument;
        //if(oDocument.window.document.getElementById('test').value != 'ok')
          //  {alert(0); return;}
        
        var sPathToCompare = '' + oDocument.window.location.search;
        sPathToCompare = sPathToCompare.replace('?', '');

        if(!sPathToCompare)
            sPathToCompare = '';
            
        if(sPathToCompare != sCurrentUri)
        {//alert(sPathToCompare); alert(sCurrentUri);
            setLocationHash(sPathToCompare, true);
        }
    }
    
    function checkUri()
    {
        if(IsUpdating)
            return;

        if(('' + window.location.hash).replace('#', '') != sCurrentUri)
        {//alert(('' + window.location.hash).replace('#', ''));alert(sCurrentUri);
            sCurrentUri = ('' + window.location.hash).replace('#', '');
            setLocationHash(sCurrentUri, true);
        }
    }
    
    function activateClickEvent(obj)
    {
        if(navigator.appName.indexOf("Microsoft") != -1)
        {
            obj.click();
        }
        else
        {
            var evt = document.createEvent("MouseEvents");
            evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
            
            obj.dispatchEvent(evt);
        }
    }

    function setLocationHash(sNewUri, processCallback)
    {
        if(!ie)
            window.location.hash = '#' + sNewUri;
        else
        {
            if('' + (window.location.hash).replace('#', '') != '' || sNewUri != '')
                window.location.hash = sNewUri;
        }
        
        sCurrentUri = sNewUri;
        
        if(iframe)
        {//alert(sNewUri + ' ' + processCallback);
            var oDocument = iframe.contentWindow || iframe.contentDocument;
            IsUpdating = true;
            try {oDocument.window.document.style.backgroundColor = 'yellow';/*oDocument.window.document.getElementById('test').value = '';*/}catch(er){}
   //alert('new ' + sNewUri);
            iframe.src = "blank.ashx?" + sNewUri;
        }
        
        if(CurrentUriContainer)
            CurrentUriContainer.value = sNewUri;
        
        if(processCallback)
        {
            var _onPageMethodCustomRequest = null;
            try{_onPageMethodCustomRequest = onPageMethodCustomRequest;}catch(e){} ;
            if(_onPageMethodCustomRequest)
                _onPageMethodCustomRequest(sNewUri);
            else
            {
                //loading.innerHTML = 'Loading...';
                __doPostBack(btnGo.name, sNewUri);
            }
        }
    }
    
    function GGenerateGuid()
    {
        var result, i, j;
        result = '';
        for(j=0; j<32; j++)
        {
        if( j == 8 || j == 12|| j == 16|| j == 20)
        result = result + '-';
        i = Math.floor(Math.random()*16).toString(16).toUpperCase();
        result = result + i;
        }
        return result
    }     
    var GEmptyGuid = '00000000-0000-0000-0000-000000000000';
    var GEmptyGuidn = '00000000000000000000000000000000';
    
    function initializePopupEx(control, sSubmitControlID, sDialog)
    {
        if(sSubmitControlID != '')
            control.submitControl = $get(sSubmitControlID);
            
        control.dialog = sDialog;
        control.headerBar = $get(control.id + '_header_title');
        
        var c = control.getElementsByTagName('td');
        for(var i = 0; i < c.length; i++)
        {
            if(c[i].className == 'c')
            {
                for(var j = 0; j < c[i].childNodes.length; j++)
                {
                    if((c[i].childNodes[j].tagName || '').toLowerCase() == 'div')
                    {
                        control.cont = c[i].childNodes[j];
                        break;
                    }
                }
            }
        }
        
        control.showAndSubmit = function(value)
        {
            if(this.dialog)
            {
                this.show();
                
                if(this.submitControl)
                {
                    this.submitControl.submit(value);
                }
            }
        }

        control.show = function(okCallBackHandler)
        {
            if(this.dialog)
            {
                this.okCallBackHandler = okCallBackHandler;
                
                try{
                    var controller = Telerik.Web.UI.RadToolTipController.getInstance();
                    var tooltip = controller.get_activeToolTip();
                    if(tooltip && tooltip.isVisible())
                        tooltip.hide();
                        
                    
                }catch(e){}
                if(this.getAttribute('ptype') == 'help')
                    actM.addAction(new action(this, 0, 94, 'opacity', 200, 100));
                else if(this.cont)
                {
                    actM.addAction(new action(this.cont, 0, 100, 'opacity', 200, 100));
                }

                //document.body.style.filter = "progid:DXImageTransform.Microsoft.Blur(strength=17)";
                var modalPopupBehavior = $find(this.dialog);
                modalPopupBehavior.show();
                try{
                var items = this.cont.getElementsByTagName('input');
                for(var i = 0; i < items.length; i++)
                {
                    var it = items[i];
                    var tp = (it.type || '').toLowerCase();
                    if(tp == 'text' || tp == 'password')
                    {
                        it.focus();
                        break;
                    }
                }
                }catch(er){};
            }
        }
        control.hide = function(iStatus)
        {
            if(this.dialog)
            {
                if(this.getAttribute('ptype') == 'help')
                    actM.addAction(new action(this, 94, 0, 'opacity', 100, -100, function(){eval('closeModalPopup(\'' + sDialog + '\');');}));
                else if(this.cont)
                {
                    actM.addAction(new action(this.cont, 100, 0, 'opacity', 150, -100, function(){eval('closeModalPopup(\'' + sDialog + '\');');}));
                }
                else
                {
                    eval('closeModalPopup(\'' + sDialog + '\');');
                }
                if(iStatus == 1)//ok
                {
                    if(this.okCallbackHandler)
                    {
                        this.okCallbackHandler();
                    }
                }
            }
        }
    }
    function closeModalPopup(sDialogName)
    {
        var modalPopupBehavior = $find(sDialogName);
        modalPopupBehavior.hide();
        document.body.style.filter = "";
    }
    // --------------------------- new popup
    var currGreen = 0;
    var ad = null;
    var grInt = null;
    
    function showAlertNewMode(sMessage)
    {
        ad.innerHTML = sMessage;
        
        ad.style.top = '10px';
        ad.style.left = '10px';
        ad.style.display = '';
        
        currGreen = 255;
        
        if(grInt != null)
            window.clearInterval(grInt);
            
        grInt = window.setInterval('setGr();', 5);
    }
    
    function setGr()
    {
        ad.style.backgroundColor = '#' + RGBToHex(currGreen) + RGBToHex(255 + currGreen / 3 - 90) + RGBToHex(currGreen);
        currGreen -= 10;
        if(currGreen <= 0)
        {
            window.clearInterval(grInt);
            grInt = null;
            
            window.setTimeout('hiddingMsg(false)', 3000);
        }
    }
    
    function hiddingMsg(obj)
    {
        if(!obj)
        {
            if(grInt != null)
                window.clearInterval(grInt);
                
            currGreen = 0;
            grInt = window.setInterval('hiddingMsg(true);', 10);
        }
        else
        {
            ad.style.top = '' + (10 - currGreen) + 'px';
            
            if(currGreen++ >= 50)            
            {
                window.clearInterval(grInt);
                grInt = null;
            }
        }
    }
    
    function RGBToHex(rgb) 
    { 
        var char = "0123456789ABCDEF"; 
        return String(char.charAt(Math.floor(rgb / 16))) + String(char.charAt(rgb - (Math.floor(rgb / 16) * 16))); 
    } 

    /// emailing
    function insertAtCaret(obj, text) 
    {
        if(document.selection) {   

            // Go the IE way   
            
            /* First of all, focus the object, we want to work with  
               If we do not do so, it is possible, that the selection  
               is not, where we expect it to be  
            */  
            obj.focus();   
              
            /* Create a TextRange based on the document.selection  
               This TextRanged can be used to replace the selected  
               Text with the new one  
            */  
            var range = document.selection.createRange();   
              
            /* If the range is not part of our Object (remember the  
               textarea or input field), stop processing here  
            */  
            if(range.parentElement() != obj) {   
                return false;   
            }   
              
            /* Save the current value. We will need this value later  
               to find out, where the text has been changed  
            */  
            var orig = obj.value.replace(/rn/g, "n");   
              
            /* Replace the Text */  
            range.text = text;   
              
            /* Now get the new content and save it into  
               a temporary variable  
            */  
            var actual = tmp = obj.value.replace(/rn/g, "n");   
              
            /* Find the first occurance, where the original differs  
               from the actual content. This could be the startposition  
               of our text selection, but it has not to be. Think of the  
               selection "ab" and replacing it with "ac". The first  
               difference would be the "c", while the start position  
               is the "a"  
            */  
            for(var diff = 0; diff < orig.length; diff++) {   
                if(orig.charAt(diff) != actual.charAt(diff)) break;   
            }   
              
            /* To get the real start position, we iterate through  
               the string searching for the whole replacement  
               text - "abc", as long as the first difference is not  
               reached. If you do not understand that logic - no  
               blame to you, just copy & paste it ;)  
            */  
            for(var index = 0, start = 0;   
                tmp.match(text)   
                    && (tmp = tmp.replace(text, ""))   
                    && index <= diff;   
                index = start + text.length   
            ) {   
                start = actual.indexOf(text, index);   
            }  


        } else if(obj.selectionStart) {   
            // Go the Gecko way
            /* Find the Start and End Position */  
            var start = obj.selectionStart;   
            var end   = obj.selectionEnd;   
              
            /* Remember obj is a textarea or input field */  
            obj.value = obj.value.substr(0, start) + text + obj.value.substr(end, obj.value.length); 

        } else {   
            // Fallback for any other browser   
        }   
    }  
        /// emailing
    function getCaretPosition(obj) 
    {
        if(document.selection) {   

            // Go the IE way   
            
            /* First of all, focus the object, we want to work with  
               If we do not do so, it is possible, that the selection  
               is not, where we expect it to be  
            */  
            obj.focus();   
              
            /* Create a TextRange based on the document.selection  
               This TextRanged can be used to replace the selected  
               Text with the new one  
            */  
            var range = document.selection.createRange();   
              
            /* If the range is not part of our Object (remember the  
               textarea or input field), stop processing here  
            */  
            if(range.parentElement() != obj) {   
                return false;   
            }   

            // Move selection start to 0 position
            range.moveStart ('character', -obj.value.length);

            // The caret position is selection length
            return range.text.length;
                                                        
        } else if(obj.selectionStart) {   
            // Go the Gecko way
            /* Find the Start and End Position */  
            var start = obj.selectionStart;   
            //var end   = obj.selectionEnd;   
              
            return start == null ? 0 : start;//new Array(start, end);

        } else {   
            // Fallback for any other browser   
            return obj.value.length;
        }   
    }  
    
    function setCaretTo(obj, pos) {   
        if(obj.createTextRange) {   
            /* Create a TextRange, set the internal pointer to  
               a specified position and show the cursor at this  
               position  
            */  
            var range = obj.createTextRange();   
            range.move("character", pos);   
            range.select();   
        } else if(obj.selectionStart) {   
            /* Gecko is a little bit shorter on that. Simply  
               focus the element and set the selection to a  
               specified position  
            */  
            obj.focus();   
            obj.setSelectionRange(pos, pos);   
        }   
    }  

    /*function getWindowSize()
    {
        var _windowWidth = 0;
        var _windowHeight = 0;
        
        if( typeof( window.innerWidth ) == 'number' ) 
        {
          //Non-IE
          _windowWidth = window.innerWidth;
          _windowHeight = window.innerHeight;
        } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
          //IE 6+ in 'standards compliant mode'
          _windowWidth = document.documentElement.offsetWidth;
          _windowHeight = document.documentElement.offsetHeight;
        } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
          //IE 4 compatible
          _windowWidth = document.body.clientWidth;
          _windowHeight = document.body.clientHeight;
        }
        
        return new Array(_windowWidth, _windowHeight);
    }
    */
    function AddBrowserHandler(target,eventName,handlerName, dontRegisterForIE) 
    { 
        if ( target.addEventListener )
            target.addEventListener(eventName, handlerName, false);
        else if ( target.attachEvent )
        {
            if(!dontRegisterForIE)
              target.attachEvent("on" + eventName, handlerName);
        }
        else
          target["on" + eventName] = handlerName;
    }

/* tabs */
    
    function TabManager()
    {
        this.tabsList = new Array();
        this.addTab = function(tabControlID, tabContentControlID, groupName, callbackOnActivation)
        {
            this.tabsList.push(new Array($get(tabControlID), $get(tabContentControlID), groupName, callbackOnActivation));
        }
        
        this.activateTab = function(sender)
        {
            var cb = null;
            for(var i = 0; i < this.tabsList.length; i++)
            {
                if(this.tabsList[i][0] == sender)
                {
                    for(var j = 0; j < this.tabsList.length; j++)
                    {
                        if(this.tabsList[i][2] == this.tabsList[j][2])
                        {
                            if(this.tabsList[j][0] == sender)
                            {
                                Extensions.AddCssClass(this.tabsList[j][0], 'act');
                                this.tabsList[j][1].style.display = '';
                                cb = this.tabsList[j][3];
                                
                            }
                            else
                            {
                                Extensions.RemoveCssClass(this.tabsList[j][0], 'act');
                                this.tabsList[j][1].style.display = 'none';
                            }
                        }
                    }
                    break;
                }
            }
            
            if(cb)
                cb(sender);
        }
    }
    
    var TabManagerInstance = new TabManager();
    
    function clearHTML(value)
    {
        return value.replace(/<[^>]+>/g,"").replace('&lt;', '<').replace('&gt;', '>').replace('&nbsp;', ' ');
    }
    
    function getElementOffset(item, parent)
    {
        var obj = new Object();
        
        obj.left = 0;
        obj.top = 0;
        
        obj.parentleft = 0;
        obj.parenttop = 0;
        
        obj.documentleft = 0;
        obj.documenttop = 0;
        
        if(item)
        {
            var p = item;
            var pp = parent;
              
            while(p != null)
            {
                var s = 0;
                if(!ie && Extensions.GetCssProperty(p, 'position') == 'absolute')
                {
                    s = parseInt(Extensions.GetCssProperty(p, 'border-left-width'));
                    if(isNaN(s))
                        s = 0;
                }
                obj.left += (p.offsetLeft || 0) + s;
                
                if(pp)
                    obj.parentleft += (p.offsetLeft || 0) + s;
                
                obj.top += p.offsetTop || 0;
                if(pp)
                    obj.parenttop += p.offsetTop || 0;
                
                p = p.offsetParent;
                if(pp == p)
                    pp = null;
            }
            
            p = item;
            pp = parent;
            while(p != null)
            {
                obj.left -= p.scrollLeft || 0;
                if(pp)
                    obj.parentleft -= p.scrollLeft || 0;
                    
                obj.top -= p.scrollTop || 0;
                if(pp)
                    obj.parenttop -= p.scrollTop || 0;
                    
                p = p.parentNode;
                if(pp == p)
                    pp = null;
            }
        }
        
        if( typeof( window.pageYOffset ) == 'number' ) {
          //Netscape compliant
          obj.documenttop = window.pageYOffset;
          obj.documentleft = window.pageXOffset;
        } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
          //DOM compliant
          obj.documenttop = document.body.scrollTop;
          obj.documentleft = document.body.scrollLeft;
        } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
          //IE6 standards compliant mode
          obj.documenttop = document.documentElement.scrollTop;
          obj.documentleft = document.documentElement.scrollLeft;
        }
        
        obj.documenttop = obj.documenttop || 0;
        obj.documentleft = obj.documentleft || 0;

        obj.left += obj.documentleft;
        obj.top += obj.documenttop;
        
        var w = getWindowSize();
        obj.w = new Object();
        obj.w.width = w.width;
        obj.w.height = w.height;

        return obj;
    }
    function getWindowSize()
    {
        var res = new Object();
        res.width = 0;
        res.height = 0;
        if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
            res.width = window.innerWidth;
            res.height = window.innerHeight;
        } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
            res.width = document.documentElement.clientWidth;
            res.height = document.documentElement.clientHeight;
        } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
            res.width = document.body.clientWidth;
            res.height = document.body.clientHeight;
        }
        return res;
    }
    
    function GSetDocumentScroll(iX, iY)
    {//alert(document.body);alert(window.pageYOffset);alert(document.documentElemen);
        if( document.body) {
          //DOM compliant
          if(iY || iY == 0) {document.body.scrollTop = iY;}
          if(iX || iX == 0) document.body.scrollLeft = iX;
        }
        if( typeof( window.pageYOffset ) == 'number' ) {
          //Netscape compliant
          window.scrollTo(iX || iX == 0 ? iX : window.pageXOffset, iY || iY == 0 ? iY : window.pageYOffset);
        }
        if( document.documentElement) {
          //IE6 standards compliant mode
          if(iY || iY == 0) document.documentElement.scrollTop = iY;
          if(iX || iX == 0) document.documentElement.scrollLeft = iX;
        }
    }
    
    function setActualWidth(element, value)
    {
        var tmp;
        tmp = parseInt(element.style.marginLeft);
        value -= tmp ? tmp : 0;
        tmp = parseInt(element.style.marginRight);
        value -= tmp ? tmp : 0;
        tmp = parseInt(element.style.paddingLeft);
        value -= tmp ? tmp : 0;
        tmp = parseInt(element.style.paddingRight);
        value -= tmp ? tmp : 0;
        element.style.width = (value < 0 ? 0 : value) + 'px';
    }
    
    function setActualHeight(element, value)
    {
        var tmp;
        tmp = parseInt(element.style.marginTop);
        value -= tmp ? tmp : 0;
        tmp = parseInt(element.style.marginBottom);
        value -= tmp ? tmp : 0;
        tmp = parseInt(element.style.paddingTop);
        value -= tmp ? tmp : 0;
        tmp = parseInt(element.style.paddingBottom);
        value -= tmp ? tmp : 0;
        element.style.height = (value < 0 ? 0 : value) + 'px';
    }
    
    Array.prototype.exists = function(value) 
    {
        var i;
        for (var i = 0, loopCnt = this.length; i < loopCnt; i++) 
        {
            if (this[i] == value) 
            {
                return true;
            }
        }
        return false;
    };
    Array.prototype.findObject = function(elementToCompareWith, sPropertyName) 
    {
        sPropertyName = sPropertyName || 'element';
        for (var i = 0; i < this.length; i++)
        {
            var it = this[i];
            if(it[sPropertyName] == elementToCompareWith)
            {
                return it;
            }
        }
        return null;
    };
    Array.prototype.equals = function(arr)
    {
        if(this.length != arr.length)
            return false;
        
        for (var i = 0; i < this.length; i++)
        {
            if(!GObjectsEqual(this[i], arr[i]))
                return false;
        }
        return true;
    }


    function CloneObject(o)
    {
         if(!o || 'object' !== typeof o)  {
           return o;
         }
         var c = 'function' === typeof o.pop ? [] : {};
         var p, v;
         for(p in o) {
         if(o.hasOwnProperty(p)) {
          v = o[p];
          if(v && 'object' === typeof v) {
            c[p] = CloneObject(v);
          }
          else {
            c[p] = v;
          }
         }
        }
         return c;    };
    Date.prototype.toCommonString = function ()
    {
        return (this.getDate() < 10 ? '0' : '') + this.getDate()
         + '/' + (this.getMonth() < 9 ? '0' : '') + (this.getMonth() + 1) 
         + '/' + this.getFullYear();
    }
    String.prototype.prepareUid = function ()
    {
        var res = '';

        for (var i = 0; i < this.length; i++)
        {
            var ch = this.charAt(i);
            if (ch.isDigitOrLetter())
                res += ch;
            else
                res += '-';
        }

        return res;
    }
    String.prototype.isDigitOrLetter = function()
    {
        return  /^[\d\w-]$/.test(this);
    }
    String.prototype.isEmail = function()
    {
        return  /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(this);
    }
    String.prototype.isLink = function()
    {
        return  /^https{0,1}:\/\/.+$/i.test(this);
    }
    String.prototype.trim = function()
    {
        return !this ? this : this.replace(/(^\s+)|(\s+$)/g, '');
    };
    AddBrowserHandler(document, 'mousemove', captureMousePosition);
    var xMousePos = 0;
    var yMousePos = 0;

    function captureMousePosition(ev) 
    {
        xMousePos = (ev ? (ev.pageX ? ev.pageX : ev.clientX) : window.event.clientX) + (document.documentElement.scrollLeft != null ? 
                                                                                    document.documentElement.scrollLeft : 
                                                                                    document.body.scrollLeft);
        yMousePos = (ev ? (ev.pageY ? ev.pageY : ev.clientY) : window.event.clientY) + (document.documentElement.scrollTop != null ? 
                                                                                    document.documentElement.scrollTop : 
                                                                                    document.body.scrollTop);
    }
    
    var transition = false;
    function gSIT(sender, e)
    {
        e = e || window.event;
        if(e)
            e.returnValue = false;
            
        if(transition) return;
        transition = transition;
        
        var p = sender.parentNode;
        var hdn = p.getElementsByTagName('input')[0];
        
        var tabs = p.getElementsByTagName('a');
        var tabsContainer = null;
        if(p.getAttribute('containerid'))
            tabsContainer = $get(p.getAttribute('containerid'));
        var tabsDivs = null;
        if(tabsContainer)
            tabsDivs = tabsContainer.getElementsByTagName('div');
        var tabHide = null;
        var tabShow = null;
        
        for(var i = 0; i < tabs.length; i++)
        {
            var tab = tabs[i];
            if(tab == sender)
            {
                if(Extensions.HasCssClass(tab, 'act'))
                    return;
                else
                {
                    Extensions.AddCssClass(tab, 'act');
                    if(tab.getAttribute('smode'))
                    {
                        if(tabsDivs)
                        {
                            for(var j=0;j<tabsDivs.length;j++)
                            {
                                var smode = tabsDivs[j].getAttribute('smode');
                                    if(smode != null && smode == hdn.value)
                                        tabHide = tabsDivs[j];
                                    else
                                        if(smode != null && smode == tab.getAttribute('smode'))
                                            tabShow = tabsDivs[j];	
                            }
                        }
                        
                    }
                }
                if(hdn)
                    hdn.value = tab.getAttribute('smode');
                    
            }
            else
            {
                Extensions.RemoveCssClass(tab, 'act');
            }            
        }
       
        if(tabHide)
        {
            actM.addAction( new action(tabHide, 100, 0, 'opacity', 150, 0, function(obj)
            {
                obj.style.display = 'none';
                
                actM.addAction( new action(tabShow, 1, 0, 'opacity', 0, 0, function(obj) {}));
                tabShow.style.display = '';
                actM.addAction( new action(tabShow, 0, 100, 'opacity', 150, 0, function(obj){transition = false;}));
            }));
        }
        else if(tabShow)
        {
            actM.addAction( new action(tabShow, 1, 0, 'opacity', 0, 0, function(obj) {}));
            tabShow.style.display = '';
            actM.addAction( new action(tabShow, 0, 100, 'opacity', 150, 0, function(obj){transition = false;}));
        }
    }
    
    function GSetCurrentTab(container, smode)
    {
        var tabs = container.getElementsByTagName('a');
        for(var i = 0; i < tabs.length; i++)
        {
            var it = tabs[i];
            if(it.getAttribute('smode') == smode)
            {
                gSIT(it, null);
                return;
            }
        }
    }
    
    function RemoveNodeEx(node)
    {
        if(node.removeNode)
            node.removeNode(true);
        else
        {
            var gc = document.getElementById('garbage');
            if(!gc)
            {
                gc = document.createElement('div');
                gc.style.display = 'none';
                gc.style.visibility = 'hidden';
            }

            gc.appendChild(node);
            gc.innerHTML = '';
            /*node.style.display = 'none';
            node.style.visibility = 'hidden';
            node.id = '';
            node.name = '';
            node.className = '';*/
        }
    }
    
    function SetElementTransparency(node, value) // in percents
    {
        if(ie)
        {
            if(value == null)
                node.style.filter = '';
            else
                node.style.filter = 'alpha(opacity=' + value + ')';
        }
        else
        {
            value = value == null ? value : value / 100;
            
            node.style.MozOpacity = value;
            node.style.opacity = value;
        }
    }
    
    function GObjectsEqual(obj1, obj2)
    {
        if(!obj1 || 'object' !== typeof obj1 || !obj2)
        {
            return obj1 == obj2;
        }
        else if(typeof(obj1) == 'array')
        {
            return obj1.equals(obj2);
        }
        else
        {
            for(var n in obj1)
            {
                if(!GObjectsEqual(obj1[n], obj2[n]))
                    return false;
            }
        }
        return true;
    }

    function GFormatSongLength(iSize)
    {
        var s = '';
        var i;
        if(iSize > 3600)
        {
            i = Math.floor(iSize / 3600);
            iSize -= i * 3600;
            s += (i > 9 ? '' : '0') + i + ':';
        }
        i = Math.floor(iSize / 60);
        iSize -= i * 60;
        s += (i > 9 ? '' : '0') + i + ':';
        i = Math.floor(iSize);
        s += (i > 9 ? '' : '0') + i;
        
        return s;
    }
    function GFormatFileSize(iSize)
    {
        if(iSize > 1000000)
        {
            return (Math.round(iSize / 1024 / 1024 * 10) / 10) + ' Mbytes';
        }
        else if(iSize > 1000)
        {
            return (Math.round(iSize / 1024 * 10) / 10) + ' Kbytes';
        }
        else return iSize + ' bytes';
    }
    
    function onGRequestError(obj, context)
    {
    }

    function copyToClipboard(s)
    {
	    if( window.clipboardData && clipboardData.setData )
	    {
		    clipboardData.setData("Text", s);
	    }
	    else
	    {   
	        var flashcopier = 'flashcopier';
            if(!document.getElementById(flashcopier)) {
              var divholder = document.createElement('div');
              divholder.id = flashcopier;
              document.body.appendChild(divholder);
            }
            document.getElementById(flashcopier).innerHTML = '';
            var divinfo = '<embed src="' + GAppRoot + '_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(s)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
            document.getElementById(flashcopier).innerHTML = divinfo;
   
	    }
    }

