function InputHelperIn (obj, text) {
  if (obj.value == text) {
    $(obj).val('');
  }
}

function InputHelperOut (obj, text) {
  if (obj.value == '' || obj.value == text) {
    $(obj).val(text);
  }
}

function InputHelperCreate (obj, text) {
  $(obj).focus(function () {InputHelperIn(this, text);});
  $(obj).blur(function () {InputHelperOut(this, text);});
  InputHelperOut(obj, text);
}

$(document).ready(function(){
  $('input[title]').each(function() {
    InputHelperCreate(this, this.title);
  });
  $('textarea[title]').each(function() {
    InputHelperCreate(this, this.title);
  });
  setTimeout(function() {
    fix_edit_block_link();
  }, 2000);
});

function fix_edit_block_link() {
	if ($('.ted').height()) {
		var p_tech = $('.block_content').children('p:last-child');
		if ($('.block_content').children('p:last-child').children('a').html() == 'Править') {
      p_tech.css('position', 'absolute').css('top', $('.ted').height() + 20 + 'px').css('right', '0px');
    }
	}
	if ($('div.contacts').height()) {
		var p_contacts = $('div.contacts').next();
		if ($('div.contacts').next().children('a').html() == 'Править') {
      p_contacts.css('position', 'absolute').css('top', $('div.contacts').height() + 'px').css('right', '0px');
		}
	}
}
