/* */
new function(){
  /** @id ra */
  var ra = {
    'event':
    /** @id ra.event */
    {
      'attach': document.addEventListener ?
      /** @id ra.event.attach */
      function(callback, eventType, rootEventNode){
        var handler = function(e){
          if((e.type=='click' || e.type=='mousedown') && e.button) return
          callback(e.target, {'X': e.pageX, 'Y': e.pageY}, e) === false && e.preventDefault()
        };
        rootEventNode.addEventListener(eventType, handler, false);
        return handler
      }:
      function(callback, eventType, rootEventNode){
        var handler = function(){
          var e = window.event,
          t = document.documentElement,
          o = {'X':'Left','Y':'Top'},
          pos = {}, k, scroll = 'scroll';
          for (k in o) {
            pos[k] = e['client'+k]+t[scroll+o[k]]
          }
          if (t = document.body) for (k in o) {
            pos[k] += t[scroll+o[k]]
          };
          callback(e.srcElement || document, pos, e) === false && (e.returnValue = false)
        };
        rootEventNode.attachEvent('on' + eventType, handler);
        return handler
      },
      'detach': document.addEventListener ?
      /** @id ra.event.detach */
      function(handler, eventType, rootEventNode){
        rootEventNode.removeEventListener(eventType, handler, false)
      }:
      function(handler, eventType, rootEventNode){
        rootEventNode.detachEvent('on'+eventType, handler)
      },
      'Watcher':
      /** @id ra.event.Watcher */
      function(eventType, fNodeSelectors, intoSelectorsMethod, outSelectorsMethod, rootNode){
        var thisObj = this, callback = function(currentNode, pos, e){
          var nods = fNodeSelectors(currentNode, pos, e),
          returnValue, i;
          if (nods) {
            if (intoSelectorsMethod) {
              for (i = nods.length; i--;) {
                thisObj[intoSelectorsMethod](nods[i], pos, e) === false && (returnValue = false)
              }
              return returnValue
            }
          } else if (outSelectorsMethod) {
            return thisObj[outSelectorsMethod](currentNode, pos, e)
          }
        },
        handler;
        (this.attach = function(){
          handler = ra.event.attach(callback, eventType, rootNode||document)
        })();
        this.detach = function(){
          ra.event.detach(handler, eventType, rootNode||document);
        }
      },
      'Selector':
      /** @id ra.event.Selector */
      function(){
        if (this == ra.event){
          return new ra.event.Selector()
        }
        this.order = []
      }
    },
    'getAttr':
    /** @id ra.getAttr */
    function(oNode, attrName){
      var getAttr='getAttribute', getAttrNode=getAttr+'Node';
      return oNode.nodeType == 1 && oNode[getAttr](attrName, 2)||((oNode[getAttrNode]&&(oNode=oNode[getAttrNode](attrName)))?oNode.nodeValue:'')
    },
    'contains': function(a, b){
      return (ra.contains = a.contains ?
      function (a, b){
        return a == b || a.contains(b)
      }:
      function (a, b){
        return a == b || (a.compareDocumentPosition(b) & 16)
      })(a, b)
    },
    'setText': function(nod,value){
      if(typeof nod.innerText != 'undefined')
        this.setText=function(nod,value){
          nod.innerText = value
        }
      else
        this.setText=function(nod,value){
          nod.textContent = value
        };
      this.setText(nod,value)
    },
    'getText': function(nod){
      if(typeof nod.innerText != 'undefined')
        this.getText=function(nod){
          return nod.innerText
        }
      else
        this.getText=function(nod){
          return nod.textContent
        };
      return this.getText(nod)
    }
  };
  ra.event.Selector.prototype = {
    'attrTest':
    /** @id ra.event.Selector.prototype.attrTest */
    function(name, re){
      var obj = this;
      obj.order[obj.order.length] = 'attrTest_';
      obj.order[obj.order.length] = arguments;
      return this
    },
    'attrTest_': function(){
      var a = this.order;
      a = a[++a.current];
      return a[1].test(ra.getAttr(this.currentNode, a[0]));
    },
    'attrContain':
    /** @id ra.event.Selector.prototype.attrContain */
    function(name, value){
      var obj = this;
      obj.order[obj.order.length] = 'attrContain_';
      obj.order[obj.order.length] = arguments;
      return this
    },
    'attrContain_': function(){
      var a = this.order;
      a = a[++a.current];
      return (' '+ra.getAttr(this.currentNode, a[0])+' ').indexOf(' '+a[1]+' ') != -1
    },
    'hasParentNode':
    /** @id ra.event.Selector.prototype.hasParentNode */
    function(name){
      var obj = this;
      obj.order[obj.order.length] = 'hasParentNode_';
      obj.order[obj.order.length] = name;
      return this
    },
    'hasParentNode_': function(){
      var obj = this,
      o = obj.order,
      name = o[++o.current];
      return (obj.currentNode = obj.currentNode.parentNode) &&
      (name == '*' || name == obj.currentNode.nodeName)
    },
    'store':
    /** @id ra.event.Selector.prototype.store */
    function(){
      var order = this.order;
      order[order.length] = 'store_';
      return this
    },
    'store_': function(){
      var a = this.storedNodes,
      b = a[a.length - 1];
      b[b.length] = this.currentNode;
      return true
    },
    'hasAncestorNode':
    /** @id ra.event.Selector.prototype.hasAncestorNode */
    function(name){
      var order = this.order;
      order[order.length] = 'hasAncestorNode_';
      order[order.length] = name;
      return this
    },
    'hasAncestorNode_': function(){
      var obj = this,
      node = obj.currentNode,
      a = obj.order,
      orderIndex = ++a.current,
      name = a[orderIndex++],
      isNotFound = true,
      i,
      getAll = obj.getAll,
      lastStoredNodes = obj.storedNodes,
      t = lastStoredNodes[lastStoredNodes.length-1];
      lastStoredNodes.length--;
      while ((node = node.parentNode) && (isNotFound || getAll) ) {
        if (name == '*' || name == node.nodeName) {
          if (a = obj.getPassed(node, getAll, orderIndex)) {
            for (i = a.length; i--;){
              lastStoredNodes[lastStoredNodes.length] = t.concat(a[i])
            }
            isNotFound = false
          }
        }
      }
      obj.order.current = obj.order.length;
      return !isNotFound && (obj.storedNodes = lastStoredNodes)
    },
    'getPassed':
    /** @id ra.event.Selector.prototype.getPassed */
    function(currentNode, getAll, orderIndex){
      this.currentNode = orderIndex && currentNode || {'parentNode':currentNode};
      this.getAll = getAll || false;
      this.order.current = orderIndex || 0;
      (this.storedNodes = [])[0]=[];
      for (
        var o = this.order,l = o.length;
        l > o.current;
        o.current++
      ) {
        if (!this[o[o.current]]()) return false
      }
      return this.storedNodes
    },
    'getFunc': function(){
      var t=this;
      return function(nod){
        return t.getPassed(nod)
      }
    }
  };
  var k, w = window;
  w.ra || (w.ra = {});
  for (var k in ra) {
    w.ra[k] || (w.ra[k] = ra[k]);
  }
};
ra.Dynamic=function(drawMethod,t){
  var play = ra.Dynamic.prototype.play;
  t || (t=this);
  t.play = function(){play(drawMethod,t)}
};
ra.Dynamic.runTicker = function(o,from,to,drawMethod){
  function ticker(){
    var timeInterval=20,interval=to-from;
    o[drawMethod](o.current=(from+o.type(ticker.currentTime/o.duration)*interval));
    if(ticker.currentTime < o.duration){
      (interval=o.duration-ticker.currentTime)<timeInterval && (timeInterval=interval);
      ticker.currentTime += timeInterval;
      o.timerID = setTimeout(ticker,timeInterval)
    }else{
      o.playBack=!o.playBack;
      o.current = null;
      o.timerID = null
    }
  };
  ticker.currentTime=0;
  ticker();
};
ra.Dynamic.prototype = {
  'play': function(drawMethod,t){
    var runTicker = ra.Dynamic.runTicker, a = ['from', 'to'];
    if (t.playBack) {
      a = a.reverse()
    }
    a[0] = t[a[0]];
    a[1] = t[a[1]];
    if (t.current == null) {
      runTicker(t, a[0], a[1],drawMethod)
    }
    else {
      t.playBack = !t.playBack;
      runTicker(t, t.current, a[0],drawMethod)
    }
  },
  'stop': function(){
    this.timerID != null && clearTimeout(this.timerID)
  },
  'timerID': null,
  'type': function(p){return 1-Math.sin(Math.acos(p))},
  'duration':110
};

ra.offset = document.documentElement.getBoundingClientRect?
function(elem) {
  var doc = elem.ownerDocument,
  rootNode = doc.documentElement,
  box = elem.getBoundingClientRect(),
  result={'Left':box.left,'Top':box.top},
  k, t;
  for (k in result){
    t='scroll'+k;
    result[k] += Math.max(rootNode[t], doc.body[t]);
    result[k] -= rootNode['client'+k]
  }
  return {
    'top': parseInt(result.Top),
    'left': parseInt(result.Left)
  }
}:
function(elem){
  var doc = elem.ownerDocument,
  rootNode = doc.documentElement,
  body = doc.body,
  getStyle=doc.defaultView.getComputedStyle,
  results={'top':0, 'left':0},
  parent = elem, 
  offsetChild = elem,
  offsetParent = elem,
  userAgent = navigator.userAgent.toLowerCase(),
  safari = /webkit/.test( userAgent ),
  mozilla = /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ),
  safari2 = safari && parseInt((userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1]) < 522 && !/adobeair/i.test(userAgent),
  fixed,
  border=ra.offset.border,
  add=ra.offset.add;
  t = getStyle(elem, null)['borderLeftWidth']
  // Initial element offsets
  add( elem.offsetLeft, elem.offsetTop, results );
  // Get parent offsets
  while ( offsetParent = offsetParent.offsetParent ) {
    // Add offsetParent offsets
    add( offsetParent.offsetLeft, offsetParent.offsetTop, results );
    // Mozilla and Safari > 2 does not include the border on offset parents
    // However Mozilla adds the border for table or table cells
    if ( mozilla && !/^T(ABLE|D|H)$/.test(offsetParent.nodeName) || safari && !safari2 )
      border( offsetParent, results );
    // Add the document scroll offsets if position is fixed on any offsetParent
    if ( !fixed && getStyle(offsetParent, null)['position'] == "fixed" )
      fixed = true;
    // Set offsetChild to previous offsetParent unless it is the body element
    offsetParent!=body && (offsetChild=offsetParent)
  }
  // Get parent scroll offsets
  while ( (parent = parent.parentNode) && parent != body && parent != rootNode) {
    // Remove parent scroll UNLESS that parent is inline or a table to work around Opera inline/table scrollLeft/Top bug
    if ( !/^inline|table.*$/i.test(getStyle(parent, null)['display']) )
      // Subtract parent scroll offsets
      add( -parent.scrollLeft, -parent.scrollTop, results );
    // Mozilla does not add the border for a parent that has overflow != visible
    if ( mozilla && getStyle(parent, null)['overflow'] != "visible" )
      border( parent, results );
  }
  // Safari <= 2 doubles body offsets with a fixed position element/offsetParent or absolutely positioned offsetChild
  // Mozilla doubles body offsets with a non-absolutely positioned offsetChild
  if ( (safari2 && (fixed || getStyle(offsetChild, null)['position'] == "absolute")) || 
    (mozilla && getStyle(offsetChild, null)['position'] != "absolute") )
      add( -body.offsetLeft, -body.offsetTop, results );
  // Add the document scroll offsets if position is fixed
  if ( fixed )
    add(Math.max(doc.documentElement.scrollLeft, body.scrollLeft, results),
      Math.max(doc.documentElement.scrollTop,  body.scrollTop));
  // Return an object with top and left properties
  return results
};
ra.offset.add = function(l, t, o) {
  o.left += parseInt(l) || 0;
  o.top += parseInt(t) || 0;
};
ra.offset.border = function(elem, o) {
  var style=elem.ownerDocument.defaultView.getComputedStyle(elem,null);
  ra.offset.add( style['borderLeftWidth'], style['borderTopWidth'], o)
};
new function(){
  var f=function(){}, o = f.prototype,
  w = window,
  getXMLHttpRequest=!window.XMLHttpRequest ?
    function() {
      return new ActiveXObject('Microsoft.XMLHTTP');
    } :
    function() {
      return new XMLHttpRequest();
    };
  o.requestHeaders={};
  o.send = function(url, callback, aSessionParams, postParams){
    var request = getXMLHttpRequest(), t, h={
      'X-Requested-With': [1,'XMLHttpRequest'],
      'Connection': [request.overrideMimeType,'close']
    }, k;
    if (postParams){
      h['Content-type'] = [1,'application/x-www-form-urlencoded']
    }
    request.open( typeof postParams != 'undefined' ? 'POST': 'GET', url, true);
    request.onreadystatechange = (
      function(obj) {
        var notready = 1; //fix duble execute
        return function() {
          if(request.readyState == 4 && notready) {
            notready = 0;
            (callback.constructor==Function?callback:obj[callback])(request, aSessionParams)
          }
        }
      }
    )(this);
    t=this.requestHeaders;
    for (k in h)
      if(typeof t[k] == 'undefined' && h[k][0])
        t[k] = h[k][1]
    for (k in t) {
      request.setRequestHeader(k, t[k])
    }
    request.send(typeof postParams != 'undefined'? postParams: null)
  };
  w.ra || (w.ra = {});
  ra.HttpRequest=f
};
/*
*/
new function(){
  var httpRequest = new ra.HttpRequest(),
  paparazziImgsBox;
  if (paparazziImgsBox = document.getElementById('paparazziImgsBox')){
    httpRequest.drawPaparazziImgs=function(request, nod){
      var list, i = 0, l,
      a = ['<','table cellspacing="0"><','tr>'],
      b = ['</','tr><','tr class="info">'],
      h, title;
      if (list = request.responseXML.getElementsByTagName('item'))
        for(l = list.length;i<l&&i<20;i++){
          a[a.length]=[
            '<','td><','a alt="',
            title = list[i].getElementsByTagName('title')[0].firstChild.data,
            '" title="',
            title,
            '" href="',
            h = list[i].getElementsByTagName('link')[0].firstChild.data,
            '"><','img src="',
            list[i].getElementsByTagName('description')[0]
            .firstChild.data.replace(
              /^.*img\s+src\s*=\s*("|'|&quot;)(http:\/\/.*?)\1.*$/,
              '$2'
            ),
            '" /><','/td>'
          ].join('');
          b[b.length]=[
            '<','td><','a href="',
            h,
            '">',
            title,
            '<','/td>'
          ].join('');
        }
      b[b.length]=['</','tr><','/table>'].join('');
      nod.innerHTML = a.concat(b).join('');
    };
    httpRequest.send(
      '/users/rambler-paparazzi/_/_/photo_rss.html',
      'drawPaparazziImgs',
      paparazziImgsBox
    );
  }
};

new function(){
  var k,
  o={
    'draw': function(pos){
      this.nod.scrollLeft=Math.round(pos)
    },
    'duration': 100,
    'to': 0,
    'date': new Date(),
    'type': function(p){return p}
  },
  scrollList = new ra.event.Watcher(
    'mousemove',
    ra.event.Selector()
    .hasAncestorNode('TD').store()
    .hasAncestorNode('DIV').attrTest('class', /(?:^| )box(?: |$)/).store()
    .hasParentNode('DIV').attrTest('class',/(?:^| )scrollContainer(?: |$)/)
    .getFunc(),
    'onMove'
  );
  scrollList.dynamicScroll = new ra.Dynamic('draw');
  scrollList.dynamicItem = new ra.Dynamic('draw');
  for (k in o) {
    scrollList.dynamicScroll[k]=o[k]
  }
  k = navigator.userAgent.toLowerCase();
  o = /msie/.test(k) && !/opera/.test(k)? {
    'draw': function(pos){
      var s = this.nod.style;
      s.filter = (s.filter || '').replace(/alpha\([^)]*\)/, '') +
        'alpha(opacity='+ Math.round(pos) +')';
    },
    'duration': 160,
    'from': 60,
    'to': 100
  }:{
    'draw': function(pos){
      this.nod.style.opacity=pos
    },
    'duration': 160,
    'from': 0.6,
    'to': 1
  }
  for (k in o) {
    scrollList.dynamicItem[k]=o[k]
  }
  scrollList.dynamicItem.nod = null;
  scrollList.onMove = function (nod, pos){
    var o, t = this.dynamicScroll, d = new Date(),
    blockWidth, ditem = this.dynamicItem,
    firstWidth, lastWidth, x;
    if (d-t.date < 50) return;
    t.nod = nod[1];
    nod = nod[0].parentNode;
    firstWidth = nod.firstChild;
    while (firstWidth.nodeName != 'TD' && (firstWidth=firstWidth.nextSibling));
    firstWidth = firstWidth.offsetWidth>>1;
    lastWidth = nod.lastChild;
    while (lastWidth.nodeName != 'TD' && (lastWidth=lastWidth.previousSibling));
    lastWidth = lastWidth.offsetWidth>>1;
    blockWidth = t.nod.offsetWidth;
    t.date = d;
    x = pos.X-ra.offset(t.nod).left;
    t.to = (x-firstWidth) * (nod.offsetWidth - blockWidth) /
      (blockWidth - firstWidth - lastWidth);
    t.from = t.nod.scrollLeft;
    t.playBack = false;
    t.current = null;
    t.stop();
    t.play();
    nod = nod.firstChild;
    while(nod.nodeName != 'TD' && (nod=nod.nextSibling));
    d = nod;
    firstWidth = -t.to;
    do {
      if (nod.nodeName == 'TD') {
        firstWidth += nod.offsetWidth;
        d = nod;
      }
    } while (firstWidth < x && (nod=nod.nextSibling));
    if (ditem.nod != d) {
      ditem.nod && ditem.draw(ditem.from);
      ditem.nod = d;
      ditem.playBack = false;
      ditem.current = null;
      ditem.stop();
      ditem.play()
    }
  };
}