(function($) {
	$.fn.empty_value = function(empty_value, reset, class_name)
	{
		if (typeof empty_value 	!= 'string')  { empty_value = ''; }
		if (typeof reset 		!= 'boolean') { reset = true; }
		if (typeof class_name 	!= 'string')  { class_name = 'empty'; }
		
		return this.each(function()
		{
			$(this).focus(function()
			{
				if ($(this).hasClass(class_name))
				{
					$(this).removeClass(class_name);
					if (reset) { $(this).val('').attr('title', ''); }
				}
			}).blur(function()
			{
				var val = $(this).val();
				if (!val || val == empty_value)
				{
					$(this).addClass(class_name).val(empty_value).attr('title', $(this).val());
				}
			}).blur();
		});
	};
})(jQuery);


$(document).ready(function() {
    var isSafari = $.browser.safari;
	if (!isSafari)
	{
        $("input.search").safariSearch().empty_value('Поиск');
	}
	
	$('#comment_toggle').click(function (){ 
	    $('#comment_form').slideToggle()
	})
	
	$('#comment_form form').submit(function (e){
	    hash = 0
        hash = hash + $(this).find("#id_contacts").val().length
        hash = hash + $(this).find("#id_author").val().length
        $(this).find('#checker').val(hash)
	})
	
	if (self.document.location.hash.substring(1) === "add_comment") {
	    $('#comment_form').show()
	    $('#id_author').focus()
	}
	
});

