﻿// JScript File
function show(obj)
{
    obj.style.display = 'inline';
}

function hide(obj)
{
    obj.style.display = 'none';
}


function mrug(obj)
{ 
    obj.style.display == 'none' ?  obj.style.display = 'inline' : obj.style.display = 'none';
}

function mrug1(obj)
{
    var images = document.getElementsByTagName('img');
    for(i=0; i<images.length; i++) if(images[i].className=='colorPalette' && images[i]!=obj) images[i].style.display = 'none';
    
    if(obj!=null)
        obj.style.display == 'none' ?  obj.style.display = 'inline' : obj.style.display = 'none';
}

function onItemDropped(container,item,position) 
{
    Service.SaveWidgetPosition(parseInt(container.getAttribute("ID").substring(6)), item.getAttribute("ID"), parseInt(position), $get('tabs_tab6_moveAllPlugins').checked);
}


function getStyleBySelector(selector)
{
   var sheetList = document.styleSheets;
   var ruleList;
   var i, j;

   for (i=sheetList.length-1; i >= 0; i--)
   {
       ruleList = sheetList[i].cssRules;
       for (j=0; j<ruleList.length; j++)
       {
           if (ruleList[j].type == CSSRule.STYLE_RULE && 
               ruleList[j].selectorText == selector)
           {
               return ruleList[j].style;
           }   
       }
   }
   return null;
}

function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

var PageRequestManagerEx =
{
    _initialized : false,

    init : function()
    {
        if (!PageRequestManagerEx._initialized)
        {
            var _callQueue = new Array();
            var _executingElement = null;
            var _prm = Sys.WebForms.PageRequestManager.getInstance();

            _prm.add_initializeRequest(initializeRequest);
            _prm.add_endRequest(endRequest);

            PageRequestManagerEx._initialized = true;
        }

        function initializeRequest(sender, args)
        {
            if (_prm.get_isInAsyncPostBack())
            {
                var postBackElement = args.get_postBackElement();
                if (_executingElement != postBackElement)
                {
                    args.set_cancel(true);
                    Array.enqueue(_callQueue, postBackElement);
                }
                _executingElement = null;
            }
        }

        function endRequest(sender, args)
        {
            if (_callQueue.length > 0)
            {
                _executingElement = Array.dequeue(_callQueue);
                _prm._doPostBack(_executingElement.id, '');
            }
        }
    }
}

function updateComponentEx(comp, timeStamp)
{
    PageRequestManagerEx.init();
    stamp = get_cookie("HistoryTimeStamp");
    if(timeStamp < stamp){
        __doPostBack(comp, '');
        
    }
}