// BBCode control. (based on bbcode.js from http://forum.dklab.ru)
function BBCode(textarea) { this.construct(textarea) }
BBCode.prototype = {
	VK_TAB:		 9,
	VK_ENTER:	 13,
	VK_PAGE_UP: 33,
	BRK_OP:		 '[',
  BRK_CL:     ']',
  textarea:   null,
  stext:      '',
  quoter:     null,
  collapseAfterInsert: false,
  replaceOnInsert: false,

  // Create new BBCode control.
  construct: function(textarea) {
    this.textarea = textarea
    this.tags     = new Object();
    // Tag for quoting.
    this.addTag(
      '_quoter',
      function() { return '[quote="'+th.quoter+'"]' },
      '[/quote]\n',
      null,
      null,
      function() { th.collapseAfterInsert=true; return th._prepareMultiline(th.quoterText) }
    );

    // Init events.
    var th = this;
    addEvent(textarea, 'keydown',   function(e) { return th.onKeyPress(e, window.HTMLElement? 'down' : 'press') });
    addEvent(textarea, 'keypress',  function(e) { return th.onKeyPress(e, 'press') });
  },

  // Insert poster name or poster quotes to the text.
  onclickPoster: function(name) {
    var sel = this.getSelection()[0];
		if (sel) {
			this.quoter = name;
			this.quoterText = sel;
			this.insertTag('_quoter');
		} else {
			this.insertAtCursor("[b]" + name + '[/b]\n');
		}
		return false;
	},

	// Quote selected text
	onclickQuoteSel: function() {
		var sel = this.getSelection()[0];
		if (sel) {
			this.insertAtCursor('[q]' + sel + '[/q]\n');
		}
		else {
			alert('Âûäåëèòå òåêñò äëÿ öèòèðîâàíèÿ');
		}
		return false;
	},

	// Quote selected text
	emoticon: function(em) {
		if (em) {
			this.insertAtCursor(' ' + em + ' ');
		}
		else {
			return false;
		}
		return false;
	},

	// For stupid Opera - save selection before mouseover the button.
	refreshSelection: function(get) {
    if (get) this.stext = this.getSelection()[0];
    else this.stext = '';
  },

  // Return current selection and range (if exists).
  // In Opera, this function must be called periodically (on mouse over,
  // for example), because on click stupid Opera breaks up the selection.
  getSelection: function() {
    var w = window;
    var text='', range;
    if (w.getSelection) {
      // Opera & Mozilla?
      text = w.getSelection();
    } else if (w.document.getSelection) {
      // the Navigator 4.0x code
      text = w.document.getSelection();
    } else if (w.document.selection && w.document.selection.createRange) {
      // the Internet Explorer 4.0x code
      range = w.document.selection.createRange();
      text = range.text;
    } else {
      return [null, null];
    }
    if (text == '') text = this.stext;
    text = ""+text;
    text = text.replace("/^\s+|\s+$/g", "");
    return [text, range];
  },

  // Insert string at cursor position of textarea.
  insertAtCursor: function(text) {
    // Focus is placed to textarea.
    var t = this.textarea;
    t.focus();
    // Insert the string.
    if (document.selection && document.selection.createRange) {
      var r = document.selection.createRange();
      if (!this.replaceOnInsert) r.collapse();
      r.text = text;
    } else if (t.setSelectionRange) {
      var start = this.replaceOnInsert? t.selectionStart : t.selectionEnd;
      var end   = t.selectionEnd;
      var sel1  = t.value.substr(0, start);
      var sel2  = t.value.substr(end);
      t.value   = sel1 + text + sel2;
      t.setSelectionRange(start+text.length, start+text.length);
    } else{
      t.value += text;
    }
    // For IE.
    setTimeout(function() { t.focus() }, 100);
  },

  // Surround piece of textarea text with tags.
  surround: function(open, close, fTrans) {
    var t = this.textarea;
    t.focus();
    if (!fTrans) fTrans = function(t) { return t; };

    var rt    = this.getSelection();
    var text  = rt[0];
    var range = rt[1];
    if (text == null) return false;

    var notEmpty = text != null && text != '';

    // Surround.
    if (range) {
      var notEmpty = text != null && text != '';
      var newText = open + fTrans(text) + (close? close : '');
      range.text = newText;
      range.collapse();
      if (text != '') {
        // Correction for stupid IE: \r for moveStart is 0 character.
        var delta = 0;
        for (var i=0; i<newText.length; i++) if (newText.charAt(i)=='\r') delta++;
        range.moveStart("character", -close.length-text.length-open.length+delta);
        range.moveEnd("character", -0);
      } else {
        range.moveEnd("character", -close.length);
      }
      if (!this.collapseAfterInsert) range.select();
    } else if (t.setSelectionRange) {
      var start = t.selectionStart;
      var end   = t.selectionEnd;
      var top   = t.scrollTop;
      var sel1  = t.value.substr(0, start);
      var sel2  = t.value.substr(end);
      var sel   = fTrans(t.value.substr(start, end-start));
      var inner = open + sel + close;
      t.value   = sel1 + inner + sel2;
      if (sel != '') {
        t.setSelectionRange(start, start+inner.length);
        notEmpty = true;
      } else {
        t.setSelectionRange(start+open.length, start+open.length);
        notEmpty = false;
      }
      t.scrollTop = top;
      if (this.collapseAfterInsert) t.setSelectionRange(start+inner.length, start+inner.length);
    } else {
      t.value += open + text + close;
    }
    this.collapseAfterInsert = false;
    return notEmpty;
  },

  // Internal function for cross-browser event cancellation.
  _cancelEvent: function(e) {
    if (e.preventDefault) e.preventDefault();
    if (e.stopPropagation) e.stopPropagation();
    return e.returnValue = false;
  },

  // Available key combinations and these interpretaions for phpBB are
  //     TAB              - Insert TAB char
  //     CTRL-TAB         - Next form field (usual TAB)
  //     SHIFT-ALT-PAGEUP - Add an Attachment
  //     ALT-ENTER        - Preview
  //     CTRL-ENTER       - Submit
  // The values of virtual codes of keys passed through event.keyCode are
  // Rumata, http://forum.dklab.ru/about/todo/BistrieKlavishiDlyaOtpravkiForm.html
  onKeyPress: function(e, type) {
    // Try to match all the hot keys.
    var key = String.fromCharCode(e.keyCode? e.keyCode : e.charCode);
    for (var id in this.tags) {
      var tag = this.tags[id];
      // Pressed control key?..
      if (tag.ctrlKey && !e[tag.ctrlKey+"Key"]) continue;
      // Pressed needed key?
      if (!tag.key || key.toUpperCase() != tag.key.toUpperCase()) continue;
      // OK. Insert.
      if (e.type == "keydown") this.insertTag(id);
      // Reset event.
      return this._cancelEvent(e);
    }

     // Ctrl+Tab.
    if (e.keyCode == this.VK_TAB && !e.shiftKey && e.ctrlKey && !e.altKey) {
      this.textarea.form.post.focus();
      return this._cancelEvent(e);
    }

    // Hot keys (PHPbb-specific!!!).
    var form = this.textarea.form;
    var submitter = null;
    if (e.keyCode == this.VK_PAGE_UP &&  e.shiftKey && !e.ctrlKey &&  e.altKey)
      submitter = form.add_attachment_box;
    if (e.keyCode == this.VK_ENTER   &&!e.shiftKey && !e.ctrlKey &&  e.altKey)
      submitter = form.preview;
    if (e.keyCode == this.VK_ENTER   && !e.shiftKey &&  e.ctrlKey && !e.altKey)
      submitter = form.post;
    if (submitter) {
      submitter.click();
      return this._cancelEvent(e);
    }

    return true;
  },

  // Adds a BB tag to the list.
  addTag: function(id, open, close, key, ctrlKey, multiline) {
    if (!ctrlKey) ctrlKey = "ctrl";
    var tag = new Object();
    tag.id        = id;
    tag.open      = open;
    tag.close     = close;
    tag.key       = key;
    tag.ctrlKey   = ctrlKey;
    tag.multiline = multiline;
    tag.elt       = this.textarea.form[id]
    this.tags[id] = tag;
    // Setup events.
    var elt = tag.elt;
    if (elt) {
      var th = this;
      if (elt.type && elt.type.toUpperCase()=="BUTTON") {
        addEvent(elt, 'click', function() { th.insertTag(id); return false; });
      }
      if (elt.tagName && elt.tagName.toUpperCase()=="SELECT") {
        addEvent(elt, 'change', function() { th.insertTag(id); return false; });
      }
    } else {
      if (id && id.indexOf('_') != 0) return alert("addTag('"+id+"'): no such element in the form");
    }
  },

  // Inserts the tag with specified ID.
  insertTag: function(id) {
    // Find tag.
    var tag = this.tags[id];
    if (!tag) return alert("Unknown tag ID: "+id);

    // Open tag is generated by callback?
    var op = tag.open;
    if (typeof(tag.open) == "function") op = tag.open(tag.elt);
    var cl = tag.close!=null? tag.close : "/"+op;

    // Use "[" if needed.
    if (op.charAt(0) != this.BRK_OP) op = this.BRK_OP+op+this.BRK_CL;
    if (cl && cl.charAt(0) != this.BRK_OP) cl = this.BRK_OP+cl+this.BRK_CL;

    this.surround(op, cl, !tag.multiline? null : tag.multiline===true? this._prepareMultiline : tag.multiline);
  },

  _prepareMultiline: function(text) {
    text = text.replace(/\s+$/, '');
    text = text.replace(/^([ \t]*\r?\n)+/, '');
    if (text.indexOf("\n") >= 0) text = "\n" + text + "\n";
    return text;
  }

}

// Called before form submitting.
function checkForm(form) {
  var formErrors = false;
  if (form.message.value.length < 2) {
    formErrors = "Please enter the message.";
  }
  if (formErrors) {
    setTimeout(function() { alert(formErrors) }, 100);
    return false;
  }
  return true;
}

// Emulation of innerText for Mozilla.
if (window.HTMLElement && window.HTMLElement.prototype.__defineSetter__) {
  HTMLElement.prototype.__defineSetter__("innerText", function (sText) {
     this.innerHTML = sText.replace(/\&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
  });
  HTMLElement.prototype.__defineGetter__("innerText", function () {
     var r = this.ownerDocument.createRange();
     r.selectNodeContents(this);
     return r.toString();
  });
}

function AddSelectedText(BBOpen, BBClose) {
 if (document.post.message.caretPos) document.post.message.caretPos.text = BBOpen + document.post.message.caretPos.text + BBClose;
 else document.post.message.value += BBOpen + BBClose;
 document.post.message.focus()
}

function InsertBBCode(BBcode)
{
	AddSelectedText('[' + BBcode + ']','[/' + BBcode + ']');
}

function storeCaret(textEl) {
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

// Translit START

// One character letters
var t_table1 = "ABVGDEZIJKLMNOPRSTUFXHCYWabvgdezijklmnoprstufxhcyw'#";
var w_table1 = "ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÕÖÛÙàáâãäåçèéêëìíîïðñòóôõõöûùüú";

// Two character letters
var t_table2 = "EHSZYOJOZHCHSHYUJUYAJAehszyojozhchshyujuyajaEhSzYoJoZhChShYuJuYaJa";
var w_table2 = "ÝÙ¨¨Æ×ØÞÞßßýù¸¸æ÷øþþÿÿÝÙ¨¨Æ×ØÞÞßß";

var tagArray = [
	'code',  '',
	'img',   '',
	'quote', "(=[\"']?[^"+String.fromCharCode(92,93)+"]+)?",
	'email', "(=[\"']?[a-zA-Z0-9_.-]+@?[a-zA-Z0-9_.-]+[\"']?)?",
	'url',   "(=[\"']?[^ \"'"+String.fromCharCode(92,93)+"]*[\"']?)?"
];

function translit2win (str)
{
  var len = str.length;
  var new_str = "";

  for (i = 0; i < len; i++)
  {
  /* non-translatable text must be in ^ */
  if(str.substr(i).indexOf("^")==0){
    end_len=str.substr(i+1).indexOf("^")+2;
    if (end_len>1){
      new_str+=str.substr(i,end_len);
      i += end_len - 1;
      continue;
    }
  }

  /* Skipping emoticons */
  if(str.substr(i).indexOf(":")==0){
    iEnd = str.substr(i+1).indexOf(":")+2;
    if (iEnd > 1 && str.substr(i,iEnd).match("^:[a-zA-Z0-9]+:$")){
      new_str += str.substr(i,iEnd);
      i += iEnd - 1;
      continue;
    }
  }

  /* Skipping http|news|ftp:/.../ links */
  rExp = new RegExp("^((http|https|news|ftp|ed2k):\\/\\/[\\/a-zA-Z0-9%_?.:;&#|\(\)+=@-]+)","i");
  if (newArr = str.substr(i).match(rExp)){
    new_str += newArr[1];
    i += newArr[1].length - 1;
    continue;
  }

  /* Skipping FONT, COLOR, SIZE tags */
  rExp = new RegExp("^(\\[\\/?(b|i|u|s|font(=[a-z0-9]+)?|size(=[0-9]+)?|color(=#?[a-z0-9]+)?)\\])","i");
  if (newArr = str.substr(i).match(rExp)){
    new_str += newArr[1];
    i += newArr[1].length - 1;
    continue;
  }

  /* Skipping [QUOTE]..[/QUOTE], [IMG]..[/IMG], [CODE]..[/CODE], [SQL]..[/SQL], [EMAIL]..[/EMAIL] tags */
  bSkip = false;
  for(j = 0; j < tagArray.length; j += 2){
    rExp = new RegExp("^(\\["+tagArray[j]+tagArray[j+1]+"\\])","i");
    if (newArr = str.substr(i).match(rExp)){
      rExp = new RegExp("\\[\\/" + tagArray[j] + "\\]", "i");
      if (iEnd = str.substr(i + newArr[1].length + 2).search(rExp)){
        end_len = iEnd + newArr[1].length + tagArray[j].length + 4;
        new_str += str.substr(i,end_len);
        i += end_len - 1;
        bSkip = true;
      }
    }
    if(bSkip)break;
  }
  if(bSkip)continue;

  // Check for 2-character letters
  is2char=false;
  if (i < len-1) {
   for(j = 0; j < w_table2.length; j++)
   {
    if(str.substr(i, 2) == t_table2.substr(j*2,2)) {
     new_str+= w_table2.substr(j, 1);
     i++;
     is2char=true;
     break;
    }
   }
  }

  if(!is2char) {
    // Convert one-character letter
    var c = str.substr(i, 1);
    var pos = t_table1.indexOf(c);
    if (pos < 0)
      new_str+= c;
    else
      new_str+= w_table1.substr(pos, 1);
  }
 }

//  document.REPLIER.Post.focus();
  return new_str;
}

function transliterate (msg, e)
{
	if (e) e.disabled = true;
	setTimeout(function() {
	 if (!bbcode.surround('', '', translit2win)) {
			msg.value = translit2win(msg.value);
		}
		if (e) e.disabled = false;
	}, 1);
}

// Translit END



/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

// sprintf.js
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('15.1l.1c=q(){p Z=1d.J();p C=q(V,19,T){p K=\'\';13(p i=0;i<t.A(T);i++){K+=19}m T>0?V+K:K+V};p z=q(a,b,7,9){p W=q(a,9,7){h(9>=0){h(a.r(\' \')>=0){7=\' \'+7}F h(a.r(\'+\')>=0){7=\'+\'+7}}F{7=\'-\'+7}m 7};p D=B(b,10);h(b.18(0)==\'0\'){p L=0;h(a.r(\' \')>=0||a.r(\'+\')>=0){L++}h(7.n<(D-L)){7=C(7,\'0\',7.n-(D-L))}m W(a,9,7)}7=W(a,9,7);h(7.n<D){h(a.r(\'-\')<0){7=C(7,\' \',7.n-D)}F{7=C(7,\' \',D-7.n)}}m 7};p l=[];l.c=q(a,b,j,9){h(17(9)==\'1g\'){m 15.1h(9)}F h(17(9)==\'1i\'){m 9.18(0)}F{m\'\'}};l.d=q(a,b,j,9){m l.i(a,b,j,9)};l.u=q(a,b,j,9){m l.i(a,b,j,t.A(9))};l.i=q(a,b,j,9){p k=B(j,10);p 7=((t.A(9)).J().11(\'.\'))[0];h(7.n<k){7=C(7,\' \',k-7.n)}m z(a,b,7,9)};l.E=q(a,b,j,9){m(l.e(a,b,j,9)).U()};l.e=q(a,b,j,9){k=B(j,10);h(N(k)){k=6}7=(t.A(9)).O(k);h(7.r(\'.\')<0&&a.r(\'#\')>=0){7=7.Y(/^(.*)(e.*)$/,\'$1.$2\')}m z(a,b,7,9)};l.f=q(a,b,j,9){k=B(j,10);h(N(k)){k=6}7=(t.A(9)).Q(k);h(7.r(\'.\')<0&&a.r(\'#\')>=0){7=7+\'.\'}m z(a,b,7,9)};l.G=q(a,b,j,9){m(l.g(a,b,j,9)).U()};l.g=q(a,b,j,9){k=B(j,10);H=t.A(9);v=H.O();w=H.Q(6);h(!N(k)){P=H.O(k);v=P.n<v.n?P:v;R=H.Q(k);w=R.n<w.n?R:w}h(v.r(\'.\')<0&&a.r(\'#\')>=0){v=v.Y(/^(.*)(e.*)$/,\'$1.$2\')}h(w.r(\'.\')<0&&a.r(\'#\')>=0){w=w+\'.\'}7=v.n<w.n?v:w;m z(a,b,7,9)};l.o=q(a,b,j,9){p k=B(j,10);p 7=t.12(t.A(9)).J(8);h(7.n<k){7=C(7,\' \',k-7.n)}h(a.r(\'#\')>=0){7=\'0\'+7}m z(a,b,7,9)};l.X=q(a,b,j,9){m(l.x(a,b,j,9)).U()};l.x=q(a,b,j,9){p k=B(j,10);9=t.A(9);p 7=t.12(9).J(16);h(7.n<k){7=C(7,\' \',k-7.n)}h(a.r(\'#\')>=0){7=\'1e\'+7}m z(a,b,7,9)};l.s=q(a,b,j,9){p k=B(j,10);p 7=9;h(7.n>k){7=7.1k(0,k)}m z(a,b,7,0)};M=Z.11(\'%\');I=M[0];14=/^([-+ #]*)(?:(\\d*)\\$|)(\\d*)\\.?(\\d*)([1b])(.*)$/;13(p i=1;i<M.n;i++){y=14.1f(M[i]);h(!y){1j}p S=y[2]?y[2]:i;h(1a[S-1]){I+=l[y[5]](y[1],y[3],y[4],1a[S-1])}I+=y[6]}m I};',62,84,'|||||||rs||arg|flags|width||||||if||precision|iPrecision|converters|return|length||var|function|indexOf||Math||rse|rsf||fps|processFlags|abs|parseInt|pad|iWidth||else||absArg|retstr|toString|ps|ec|farr|isNaN|toExponential|rsep|toFixed|rsfp|my_i|len|toUpperCase|str|pn||replace|fstring||split|round|for|fpRE|String||typeof|charAt|ch|arguments|cdieEfFgGosuxX|sprintf|this|0x|exec|number|fromCharCode|string|continue|substring|prototype'.split('|'),0,{}));

// prototype $
function $p() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1)
      return element;

    elements.push(element);
  }

  return elements;
}

// from http://www.dustindiaz.com/rock-solid-addevent/
function addEvent( obj, type, fn ) {
	if (obj.addEventListener) {
		obj.addEventListener( type, fn, false );
		EventCache.add(obj, type, fn);
	}
	else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
		EventCache.add(obj, type, fn);
	}
	else {
		obj["on"+type] = obj["e"+type+fn];
	}
}

var EventCache = function(){
	var listEvents = [];
	return {
		listEvents : listEvents,
		add : function(node, sEventName, fHandler){
			listEvents.push(arguments);
		},
		flush : function(){
			var i, item;
			for(i = listEvents.length - 1; i >= 0; i = i - 1){
				item = listEvents[i];
				if(item[0].removeEventListener){
					item[0].removeEventListener(item[1], item[2], item[3]);
				};
				if(item[1].substring(0, 2) != "on"){
					item[1] = "on" + item[1];
				};
				if(item[0].detachEvent){
					item[0].detachEvent(item[1], item[2]);
				};
				item[0][item[1]] = null;
			};
		}
	};
}();
if (document.all) { addEvent(window,'unload',EventCache.flush); }

