function reply(element){
   var username=$(element).text();
   $('#comment').val("@"+username+", ");
}

$(function() {
	function focusIn() {
		var
			$this = $(this),
			defVal = $this.attr('title')
		;
		if ($this.val() == defVal) {
			$this.val('');
			$this.removeClass('def-text').addClass('n-text');
			if ($this.hasClass('passwd')) {
				var pass = $('<input type="password" name="password"  class="' + $this.attr('class') + '" title="' + $this.attr('title') + '" value="" />');
				$this.hide().after(pass);
				pass.focus();
				pass.bind('focusout', focusOutPass);
			}
		}
	}
	function focusOut() {
		var
			$this = $(this),
			defVal = $this.attr('title')
		;
		if ($this.val() == '' || $this.val() == defVal) {
			$this.val(defVal);
			$this.removeClass('n-text').addClass('def-text');
		}
	}
	function focusOutPass() {
		var
			$this = $(this),
			defVal = $this.attr('title')
		;
		if ($this.val() == '' || $this.val() == defVal) {
			var t = $this.prev('input.passwd[type="text"]');
			$this.remove();
			t.show();
			t.val(defVal).removeClass('n-text').addClass('def-text');
		}
	}
	$('input[type="text"]').live('focusin', focusIn).bind('focusout', focusOut);
});

var CORE = new Object();


CORE.SetAnchor = function(anchor)
 {
  window.location.replace('#' + anchor);
 }

CORE.GetAnchor = function()
 {
  return window.location.hash.substr(1);
 }

CORE.LoadTwitter = function(id, twitter, common_hash)
 {
  new Ajax.Updater(id,
                   '/ajax/twitter.html',
                   { asynchronous: true,
                     method: 'GET',
                     parameters: 'twitter=' + encodeURIComponent(twitter) + '&common_hash=' + encodeURIComponent(common_hash),
                     onSuccess: Tooltips.rescan_delayed });
 }

CORE.ShareOnFacebook = function(url, title)
 {
  var w = window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(url) + '&t=' + encodeURIComponent(title), 'rpodshr', 'width=700,height=400,left=100,top=10,resizable=yes,scrollbars=yes,status=no');

  if ((w == null) || (w == undefined))
   {
   }
  else 
   {
    try {w.focus();} catch (wtf) {}}

  return false;
 }

CORE.ShareOnBuzz = function(url, title)
 {
  var w = window.open('http://www.google.com/reader/link?url=' + encodeURIComponent(url) + '&title=' + encodeURIComponent(title), 'rpodshr', 'width=700,height=400,left=100,top=10,resizable=yes,scrollbars=yes,status=no');

  if ((w == null) || (w == undefined))
   {
   }
  else 
   {
    try {w.focus();} catch (wtf) {}}

  return false;
 }

CORE.ShareOnVK = function(url, title)
 {
  var w = window.open('http://vkontakte.ru/share.php?url=' + encodeURIComponent(url), 'rpodshr', 'width=700,height=400,left=100,top=10,resizable=yes,scrollbars=yes,status=no');

  if ((w == null) || (w == undefined))
   {
   }
  else 
   {
    try {w.focus();} catch (wtf) {}}

  return false;
 }

CORE.ShareOnYaRu = function(url, title)
 {
  var w = window.open('http://wow.ya.ru/posts_add_link.xml?URL=' + encodeURIComponent(url) + '&title=' + encodeURIComponent(title), 'rpodshr', 'width=700,height=400,left=100,top=10,resizable=yes,scrollbars=yes,status=no');

  if ((w == null) || (w == undefined))
   {
   }
  else 
   {
    try {w.focus();} catch (wtf) {}}

  return false;
 }

CORE.ShareOnMyMail = function(url, title)
 {
  var w = window.open('http://connect.mail.ru/share?share_url=' + encodeURIComponent(url), 'rpodshr', 'width=700,height=400,left=100,top=10,resizable=yes,scrollbars=yes,status=no');

  if ((w == null) || (w == undefined))
   {
   }
  else 
   {
    try {w.focus();} catch (wtf) {}}

  return false;
 }
