
$(document).ready(function() {
	//$('div.corner').corner('5px');
	$('a[class*="gallery"]').fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'easingIn'      : 'easeOutBack',
		'easingOut'     : 'easeInBack',
		'titlePosition'  : 'inside'
	});

	$('div.shadow, div.photo a.gallery, #text div.people div.i')
		.mouseover(function() {
			$(this).stop().animate({shadow: '3px 4px 6px #999'});
		})
		.mouseout(function() {
			$(this).stop().animate({shadow: '3px 4px 6px #333'});
	});
	$('div.shadow, div.photo a.gallery, #text div.people div.i').stop().animate({shadow: '3px 4px 6px #333'});
	
	$('#pBack a')
		.mouseover(function() {
			$('#portret').animate({left: '+=50'}, 750, function() {});
		})
		.mouseout(function() {
			$('#portret').animate({left: '-=50'}, 750, function() {});
		});
	$('#pNext a')
		.mouseover(function() {
			$('#portret').animate({left: '-=50'}, 750, function() {});
		})
		.mouseout(function() {
			$('#portret').animate({left: '+=50'}, 750, function() {});
		});

	$('a.fulltp', '#tab').click(function() {
		var fullp = $(this).prev();
		if (fullp.is(':visible')) {
			fullp.hide();
			$(this).text('Текст полностью');
		} else {
			fullp.show();
			$(this).text('Скрыть полный текст');
		}
		return false;
	});
	
	$('a.fullPh', '#tab').click(function() {
		var fullp = $(this).prev();
		if (fullp.is(':visible')) {
			fullp.slideUp();
		} else {
			fullp.slideDown();
		}
		return false;
	});
	
	
/*
	$("#flip").jFlip(950, 500, {
			background: '#232323',
			cornersTop: false,
			gradientColors : ['#515151', '#979797', '#232323'],
			curlSize : 0.1
		})
		.bind("flip.jflip", function(event, index, total) {
		});
*/
});


function feedBack() {
	var t = $('#message').val();
	if ('' == t) { $('#error').html(''); $('#message').focus(); return false; }

	var n = $('#fb_name').val();
	if ('' == n) { $('#error').html('Как вас зовут?'); $('#fb_name').focus(); return false; }

	var c = $('#fb_city').val();
	if ('' == c) { $('#error').html('Откуда будете?'); $('#fb_city').focus(); return false; }

	$('input, textarea', '#fForm').attr('disabled', 'disabled');
	$('#error').html('<b>Подождите</b>, думаю...');
	$.post(location.href, {
			name: n,
			city: c,
			text: t,
			real: 1
		}, function(response) {
			if (1 == response) {
				$('#error').html('<b>Спасибо</b> за отзыв.');
				$('input[type="text"], textarea', '#fForm').val('');
				$('input, textarea', '#fForm').removeAttr('disabled');
				location.replace(location.href);
			}
	});

	return false;
}
function feedBack_init() {
	var form = '';
	form +='<div class="form">';
	form +='<form method="post" onsubmit="return feedBack()">';
	form +='<span class="h">Оставьте свой отзыв</span>';
	form +='<textarea id="message" name="message" tabindex="1"></textarea>';
	form +='<div class="row">';
	form +='<div class="fl">';
	form +='<div class="f">Ваше имя</div><input type="text" id="fb_name" name="name" value="" tabindex="2" />';
	form +='</div>';
	form +='<div class="fr">';
	form +='<div class="f">Город</div><input type="text" id="fb_city" name="city" value="" tabindex="3" />';
	form +='</div>';
	form +='</div>';
	form +='<br />';
	form +='<input type="submit" value="Отправить" class="submit" tabindex="4" />';
	form +='<div id="error"></div>';
	form +='</form>';
	form +='</div>';

	$('#fForm').append(form);
	return;
}

var cssFix = function() {
	var u = navigator.userAgent.toLowerCase(),
	is = function(t) {
		return (u.indexOf(t) != -1);
	};
	$("html").addClass([(!(/opera|webtv/i.test(u)) && /msie (\d)/.test(u)) ? ('ie ie' + RegExp.$1)
		: is('firefox/2') ? 'gecko ff2'	: is('firefox/3') ? 'gecko ff3'	: is('gecko/') ? 'gecko'
		: is('chrome/') ? 'chrome'
		: is('opera/9') ? 'opera opera9'	: /opera (\d)/.test(u) ? 'opera opera' + RegExp.$1
		: is('konqueror') ? 'konqueror'
		: is('applewebkit/') ? 'webkit safari'
		: is('mozilla/') ? 'gecko'
		: '',
		(is('x11') || is('linux')) ? ' linux' : is('mac') ? ' mac' : is('win') ? ' win'
	: ''].join(''));
}();


