var clientIE6 = (navigator.userAgent.indexOf("MSIE 6") > -1);

jQuery.fn.outerHTML = function(s) {
	return ((s) ? this.before(s).remove() : jQuery("<p>").append(this.eq(0).clone()).html());
};

jQuery.fn.limitMaxlength = function(options)
{
	var settings = jQuery.extend({
		attribute: "maxlength",
		onLimit: function(){},
		onEdit: function(){}
	}, options);

	// Event handler to limit the textarea
	var onEdit = function(){
		var textarea = jQuery(this);
		var maxlength = parseInt(textarea.attr(settings.attribute));

		if(textarea.val().length > maxlength){
			textarea.val(textarea.val().substr(0, maxlength));

			// Call the onlimit handler within the scope of the textarea
			jQuery.proxy(settings.onLimit, this)();
		}

		// Call the onEdit handler within the scope of the textarea
		jQuery.proxy(settings.onEdit, this)(maxlength - textarea.val().length);
	}

	this.each(onEdit);

	return this.keyup(onEdit)
		.keydown(onEdit)
		.focus(onEdit);
}


$(document).ready(function() {
	// Make Lightbox gallery
	$('.gallery a').lightBox({
		imageLoading:	'/img/lightbox-ico-loading.gif',
		imageBtnPrev:	'/img/lightbox-btn-prev.gif',
		imageBtnNext:	'/img/lightbox-btn-next.gif',
		imageBtnClose:	'/img/lightbox-btn-close.png',
		imageBlank:		'/img/s.png',
		txtImage:		'Изображение',
		txtOf:			'от'
	});
});

