function showError(message)
{
	$('#errmsg').get(0).innerHTML = message;
	$('#errmsg').get(0).style.display = 'block';
}

$(document).ready
(
 	function()
	{

		$("ul.topnav li a").hover(function() {
			$(this).parent().find(".subnav").slideDown('fast').show();
  			$(this).parent().hover(function(){}, function() {
				$(this).parent().find("div.subnav").slideUp('slow');
				});  
			});
			
		$('#btn-register').click(function () {
			window.location = '/register';
		});

		$('#btn-edit-profile').click(function () {
			window.location = '/editprofile';
		});

		$('.lnk-logout').click(function () {
			$('form#frm-logout').submit();
		});

		$('.lnk-expand').click(function () {
			var div = $(this).parent();
			div.parent('div.moduleContent').children('div.itemWrapper').slideToggle(500, function() {
				if ($(this).is(':visible'))
					div.removeClass('header2').addClass('header3');
				else
					div.removeClass('header3').addClass('header2');
				});
		});

		$('a.cluetip').cluetip({
		//	splitTitle: '|',
		//	cluetipClass: 'jtip', // 'rounded'
			arrows: true,
			dropShadow: true
		});

		$('div.cluetip').cluetip({
		//	cluetipClass: 'jtip', // 'rounded'
			arrows: true,
			dropShadow: true,
			width: '550px'
		});

		$('a.sticker').cluetip({
			cluetipClass: 'jtip',
			arrows: true,
			dropShadow: true,
			width: '300px',
			positionBy:'mouse',
			activation: 'click',
			sticky: true,
			closePosition: 'title',
			closeText: '<img src="/img/cross.png" alt="закрыть" />'
		});

		var lightBoxOptionList = {
				overlayBgColor: 		'#999',		// (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color.
				overlayOpacity:			0.5,		// (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9
				// Configuration related to navigation
			//	fixedNavigation:		false,		// (boolean) Boolean that informs if the navigation (next and prev button) will be fixed or not in the interface.
				// Configuration related to images
				imageLoading:			'/img/lightbox-ico-loading.gif',	// (string) Path and the name of the loading icon
				imageBtnPrev:			'/img/lightbox-btn-prev.gif',		// (string) Path and the name of the prev button image
				imageBtnNext:			'/img/lightbox-btn-next.gif',		// (string) Path and the name of the next button image
				imageBtnClose:			'/img/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
				imageBlank:				'/img/lightbox-blank.gif',			// (string) Path and the name of a blank image (one pixel)
				// Configuration related to container image box
			//	containerBorderSize:	10,			// (integer) If you adjust the padding in the CSS for the container, #lightbox-container-image-box, you will need to update this value
			//	containerResizeSpeed:	400,		// (integer) Specify the resize duration of container image. These number are miliseconds. 400 is default.
				// Configuration related to texts in caption. For example: Image 2 of 8. You can alter either "Image" and "of" texts.
				txtImage:				'Фото',	// (string) Specify text "Image"
				txtOf:					'из'	// (string) Specify text "of"
			};

		$('#gallery a').lightBox(lightBoxOptionList);

		$('table.theThumbs').each(function () {
			$(this).find('td.img a').lightBox(lightBoxOptionList);
		});

		// preload gallery images
		var i1 = new Image();
		var i2 = new Image();
		var i3 = new Image();
		var i4 = new Image();
		i1.src = '/img/photo-over.png';
		i2.src = '/img/video-over.png';
		i3.src = '/img/photofun-over.png';
		i4.src = '/img/videofun-over.png';

		$('a.auto-hover').each(function () {
			var img = $(this).children('img');
			if (img.length)
			{
				var src = img.attr('src');
				var pos = src.lastIndexOf('.');
				var src_hover = src.substring(0, pos) + '_hover' + src.substring(pos);
				// preload image
				var i = new Image();
				i.src = src_hover;
				$(this).hover(
					function () { img.attr('src', src_hover); },
					function () { img.attr('src', src); }
				);
			}
		});

	}
);

