function toggle(nome) {
if(document.getElementById(nome).style.display=='none')
{
document.getElementById(nome).style.display = '';
document.getElementById(nome+"img").src="images/noncross.gif";
} else {
document.getElementById(nome).style.display = 'none';
document.getElementById(nome+"img").src="images/cross.gif";
}
}
function SetSize(obj, x_size, id) {
    var Link = document.getElementById(id);
        if (obj.offsetWidth > x_size) {
            obj.style.width = x_size;
            Link.style.display = '';
        };
};

var theSelection = false;

// Check for Browser & Platform1 for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version
var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
                && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
                && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
var is_moz = 0;

var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);
function Smilies(Smilie)
{
document.form1.content.value+=Smilie+" ";
document.form1.content.focus();
}



function Tags(Tag1, Tag2)
{

//	donotinsert = false;
	theSelection = false;


	if ((clientVer >= 4) && is_ie && is_win)
	{
		theSelection = document.selection.createRange().text; // Get text selection
		if (theSelection) {
			// Add tags around selection
			document.selection.createRange().text = Tag1 + theSelection + Tag2;
			//txtarea.focus();
			theSelection = '';
			return;
		}
	}
	else if (document.form1.content.selectionEnd && (document.form1.content.selectionEnd - document.form1.content.selectionStart > 0))
	{
	function mozWrap(txtarea, open, close)
{
	var selLength = txtarea.textLength;
	var selStart = txtarea.selectionStart;
	var selEnd = txtarea.selectionEnd;
	if (selEnd == 1 || selEnd == 2)
		selEnd = selLength;

	var s1 = (txtarea.value).substring(0,selStart);
	var s2 = (txtarea.value).substring(selStart, selEnd)
	var s3 = (txtarea.value).substring(selEnd, selLength);
	txtarea.value = s1 + open + s2 + close + s3;
	return;
}
		mozWrap(document.form1.content, Tag1, Tag2);
		return;
	}

	storeCaret(txtarea);
}


// 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, 'onkeydown',   function(e) { return th.onKeyPress(e, window.HTMLElement? 'down' : 'press') });
    addEvent(textarea, 'onkeypress',  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], ');
		}
		return false;
	},

	// Quote selected text
	onclickQuoteSel: function() {
		var sel = this.getSelection()[0];
		if (sel) {
			this.insertAtCursor('[quote]' + sel + '[/quote]\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 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;
      }
      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 form1 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/BistrieKlavishiDlyaOtpravkiform1.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);
    }

    // Tab.
    if (type == 'press' && e.keyCode == this.VK_TAB && !e.shiftKey && !e.ctrlKey && !e.altKey) {
      this.surround("\t", "");
      return this._cancelEvent(e);
    }

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

    // Hot keys (PHPbb-specific!!!).
    var form1 = this.textarea.form1;
    var submitter = null;
    if (e.keyCode == this.VK_PAGE_UP &&  e.shiftKey && !e.ctrlKey &&  e.altKey)
      submitter = form1.add_attachment_box;
    if (e.keyCode == this.VK_ENTER   &&!e.shiftKey && !e.ctrlKey &&  e.altKey)
      submitter = form1.preview;
    if (e.keyCode == this.VK_ENTER   && !e.shiftKey &&  e.ctrlKey && !e.altKey)
      submitter = form1.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.form1[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, 'onclick', function() { th.insertTag(id); return false; });
      }
      if (elt.tagName && elt.tagName.toUpperCase()=="SELECT") {
        addEvent(elt, 'onchange', function() { th.insertTag(id); return false; });
      }
    } else {
      if (id && id.indexOf('_') != 0) return alert("addTag('"+id+"'): no such element in the form1");
    }
  },

  // 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 form1 submitting.
function checkform1(form1) {
  var form1Errors = false;
  if (form1.message.value.length < 2) {
    form1Errors = "Пожалуйста, Введите сообщение.";
  }
  if (form1Errors) {
    setTimeout(function() { alert(form1Errors) }, 100);
    return false;
  }
  return true;
}

// Cross-browser addEventListener()/attachEvent() replacement.
function addEvent(elt, name, handler, atEnd) {
  //name = name.replace(/^(on)?/, 'on');
  var prev = elt[name];
  var tmp = '__tmp';
  elt[name] = function(e) {
    if (!e) e = window.event;
    var result;
    if (!atEnd) {
      elt[tmp] = handler; result = elt[tmp](e); elt[tmp] = null; // delete() does not work in IE 5.0 (???!!!)
      if (result === false) return result;
    }
    if (prev) {
      elt[tmp] = prev; result = elt[tmp](e); elt[tmp] = null;
    }
    if (atEnd && result !== false) {
      elt[tmp] = handler; result = elt[tmp](e); elt[tmp] = null;
    }
    return result;
  }
  return handler;
}

// 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();
  });
}

// Copy text to clipboard. Originally got from decompiled `php_manual_en.chm`.
function copyText(from)
{
	if (!document.content.createTextRange) return false;
    contentRange = document.content.createTextRange();
    if (!contentRange.moveToElementText) return false;
    contentRange.moveToElementText(from);
    if (!contentRange.execCommand) return false;
    contentRange.execCommand("Copy");
    return true;
}

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 translit2win_t_table1 = "ABVGDEZIJKLMNOPRSTUFXCYabvgdezijklmnoprstufxcy'\"h";
var translit2win_w_table1 = "АБВГДЕЗИЙКЛМНОПРСТУФХЦЫабвгдезийклмнопрстуфхцыьъх";

// Two character letters
var translit2win_t_table2 = "EXSZYOJOZHCHSHYUJUYAJAexszyojozhchshyujuyajaExSzYoYoZhChShYuJuYaJa";
var translit2win_w_table2 = "ЭЩЁЁЖЧШЮЮЯЯэщёёжчшююяяЭЩЁЁЖЧШЮЮЯЯ";

// Strippable containers.
var translit2win_tags = new Array(
	'quote','eng','code','php','perl','html','apache','js','java','css','xml','c','cpp','asm','avbs','ajs','apls','vbs','jsp','mason','dtd','xslt','xslfo','xmls','wsc','wsf','csharp','sharp','pas','jsnet','vbnet','forth','fortran','tpro','vb','sql','1c','ada','cobol','cache','lisp','modula','py','tcl','bat','ini','prop','yac','make','reg','rtf','tex','vrml','dif','content','sdml','img','url'
);

// Tags not to touch.
var translit2win_const = new Array(
	'b', 'i', 'u', 'list', '*', 'size', 'color'
);

function translit2win(str)
{
	var ls = str.toLowerCase();
	var s = "";
	var opens = new Object();
	var inCont = false;
	var tags = translit2win_tags;
	var cons = translit2win_const;
	var t1 = translit2win_t_table1;
	var w1 = translit2win_w_table1;
	var t2 = translit2win_t_table2;
	var w2 = translit2win_w_table2;

	for(i=0; i<str.length; i++) {
		if (str.charAt(i) == '[') {
			var foundTag = false;
			// Open/close tags.
			for (var ti=0; ti<tags.length; ti++) {
				var t = tags[ti];
				var op = "["+t+"]";
				var cl = "[/"+t+"]";
				if (ls.indexOf(op, i) == i) {
					// Open tag.
					opens[t] = (opens[t]? opens[t] : 0) + 1;
					s += str.substr(i, op.length);
					i += op.length-1;
					foundTag = true;
					inCont = true;
					break;
				} else if (ls.indexOf(cl, i) == i) {
					// Close tag.
					if (opens[t] && opens[t]>0) opens[t]--;
					s += str.substr(i, cl.length);
		 i += cl.length - 1;
					foundTag = true;
					// We are still in container?..
					inCont = false;
					for (var t in opens) if (opens[t]) { inCont = true; break; }
					break;
				}
			}
			// Tag attributes & names.
			for (var ti=0; ti<cons.length; ti++) {
				var t = cons[ti];
				if (ls.indexOf('['+t, i) == i || ls.indexOf('[/'+t, i) == i) {
					var e = ls.indexOf(']', i);
					if (e >= 0) { s += str.substr(i, e-i); i = e-1; }
					foundTag = true;
					break;
				}
			}
			if (foundTag) continue;
		}

		// In container?..
		if(inCont) {
			s += str.charAt(i);
			continue;
		}

		// Check for 2-character letters
		is2char = false;
		if (i<str.length-1) {
			for (j=0; j<w2.length; j++) {
				if (str.substr(i,2)==t2.substr(j*2,2)) {
					s+= w2.charAt(j);
					i++;
					is2char=true;
					break;
				}
			}
		}
		if(!is2char) {
			// Convert one-character letter
			var c = str.substr(i,1);
			var pos = t1.indexOf(c);
			if (pos<0) s += c;
			else s += w1.charAt(pos);
		}
	}
	return s;
}


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

// Translit END


//////////////////////////TOOLTIPS
function unescape_op(text) {
	if(typeof(RegExp) == 'function') {
		re = /quot;/g;  
		newstr=text.replace(re, ''); 
		re = /&/g; 
		return newstr.replace(re, '"');  
	} 
	else return text;
}
/*
originally written by paul sowden <paul@idontsmoke.co.uk> | http://idontsmoke.co.uk
modified and localized by alexander shurkayev <alshur@narod.ru> | http://htmlcoder.visions.ru
*/
window.onerror = null;
var tooltip_attr_name = "tooltip";
var tooltip_blank_text = ""; // текст для ссылок с target="_blank" [(откроется в новом окне)]
var tooltip_newline_entity = "  "; // укажите пустую строку (""), если не хотите использовать в tooltip'ах многострочность; ежели хотите, то укажите тот символ или символы, которые будут заменяться на перевод строки
var tooltip_max_width = 0; // максимальная ширина tooltip'а в пикселах; обнулите это значение, если ширина должна быть нелимитирована

window.onload = function(e){
	if (document.createElement) tooltip.d();
}

tooltip = {

	t: document.createElement("DIV"),
	c: null,
	g: false,

	m: function(e){
		if (tooltip.g){
			oCanvas = document.getElementsByTagName(
			(document.compatMode && document.compatMode == "CSS1Compat") ? "HTML" : "content"
			)[0];
			x = window.event ? event.clientX + oCanvas.scrollLeft : e.pageX;
			y = window.event ? event.clientY + oCanvas.scrollTop : e.pageY;
			tooltip.a(x, y);
		}
	},

	d: function(){
		tooltip.t.setAttribute("id", "tooltip");
//		tooltip.t.style.filter = "alpha(opacity=85)"; // buggy in ie5.0
		document.content.appendChild(tooltip.t);
		a = document.all ? document.all : document.getElementsByTagName("*");
		aLength = a.length;
		for (var i = 0; i < aLength; i++){

		//if (a[i].tagName == "A" || a[i].tagName == "BUTTON" || (a[i].tagName == "INPUT" && (a[i].type == "submit" || a[i].type == "button" || a[i].type == "reset"))) a[i].onclick = self.focus;

			if (!a[i]) continue;

			tooltip_title = a[i].getAttribute("title");
			tooltip_alt = a[i].getAttribute("alt");
			tooltip_blank = a[i].getAttribute("target") && a[i].getAttribute("target") == "_blank" && tooltip_blank_text;
			if (tooltip_title || tooltip_blank){
				a[i].setAttribute(tooltip_attr_name, tooltip_blank ? (tooltip_title ? tooltip_title + " " + tooltip_blank_text : tooltip_blank_text) : tooltip_title);
				if (a[i].getAttribute(tooltip_attr_name)){
					a[i].removeAttribute("title");
					if (tooltip_alt && a[i].complete) a[i].removeAttribute("alt");
					tooltip.l(a[i], "mouseover", tooltip.s);
					tooltip.l(a[i], "mouseout", tooltip.h);
				}
			}else if (tooltip_alt && a[i].complete){
				a[i].setAttribute(tooltip_attr_name, tooltip_alt);
				if (a[i].getAttribute(tooltip_attr_name)){
					a[i].removeAttribute("alt");
					tooltip.l(a[i], "mouseover", tooltip.s);
					tooltip.l(a[i], "mouseout", tooltip.h);
				}
			}
			if (!a[i].getAttribute(tooltip_attr_name) && tooltip_blank){
				//
			}
		}
		document.onmousemove = tooltip.m;
		window.onscroll = tooltip.h;
		tooltip.a(-99, -99);
	},

	s: function(e){
		d = window.event ? window.event.srcElement : e.currentTarget;
		if (!d.getAttribute(tooltip_attr_name)) return;
		s = d.getAttribute(tooltip_attr_name);
		if (tooltip_newline_entity){
			s = s.replace(/\&/g,"&amp;");
			s = s.replace(/\</g,"&lt;");
			s = s.replace(/\>/g,"&gt;");
			s = s.replace(eval("/" + tooltip_newline_entity + "/g"), "<br />");
			tooltip.t.innerHTML = s;
		}else{
			if (tooltip.t.firstChild) tooltip.t.removeChild(tooltip.t.firstChild);
			tooltip.t.appendChild(document.createTextNode(s));
			//tooltip.t.innerText = s;
		}
		tooltip.c = setTimeout("tooltip.t.style.visibility = 'visible';", 500);
		tooltip.g = true;
	},

	h: function(e){
		tooltip.t.style.visibility = "hidden";
		if (!tooltip_newline_entity && tooltip.t.firstChild) tooltip.t.removeChild(tooltip.t.firstChild);
		clearTimeout(tooltip.c);
		tooltip.g = false;
		tooltip.a(-99, -99);
	},

	l: function(o, e, a){
		if (o.addEventListener) o.addEventListener(e, a, false); // was true--Opera7b workaround!
		else if (o.attachEvent) o.attachEvent("on" + e, a);
			else return null;
	},

	a: function(x, y){
		oCanvas = document.getElementsByTagName(
		(document.compatMode && document.compatMode == "CSS1Compat") ? "HTML" : "content"
		)[0];

		w_width = window.innerWidth ? window.innerWidth + window.pageXOffset : oCanvas.clientWidth + oCanvas.scrollLeft;
		w_height = window.innerHeight ? window.innerHeight + window.pageYOffset : oCanvas.clientHeight + oCanvas.scrollTop;

		tooltip.t.style.width = "auto";

		t_width = window.event ? tooltip.t.clientWidth : tooltip.t.offsetWidth;
		t_height = window.event ? tooltip.t.clientHeight : tooltip.t.offsetHeight;

		if ((tooltip_max_width) && (t_width > tooltip_max_width)){
			tooltip.t.style.width = tooltip_max_width + "px";
			t_width = window.event ? tooltip.t.clientWidth : tooltip.t.offsetWidth;
		}

		t_extra_width = 7; // CSS padding + borderWidth;
		t_extra_height = 5; // CSS padding + borderWidth;

		tooltip.t.style.left = x + 8 + "px";
		tooltip.t.style.top = y + 8 + "px";

		while (x + t_width + t_extra_width > w_width){
			--x;
			tooltip.t.style.left = x + "px";
			t_width = window.event ? tooltip.t.clientWidth : tooltip.t.offsetWidth;
		}

		while (y + t_height + t_extra_height > w_height){
			--y;
			tooltip.t.style.top = y + "px";
			t_height = window.event ? tooltip.t.clientHeight : tooltip.t.offsetHeight;
		}
	}
}

