var feedback = function(form) {
	if ($Ajex.empty($('#msg').val())) return false;

	if (-1 != location.href.indexOf('/en/')) {
		$('input.submit').attr('value', '» Sending');
		$('#stat', $(form)).html('<i>Go Go Go! ...</i>');
	} else {
		$('input.submit').attr('value', '» Отправляем');
		$('#stat', $(form)).html('<i>Поехали! ...</i>');
	}

	$.post('?js=1',
			{
				name:	$('#name').val(),
				email:	$('#email').val(),
				site:	$('#site').val(),
				msg:	$('#msg').val()
			},
			function(reply) {
					$('#stat', $(form)).html(reply);
			}
		);
	return false;
}

function outForm() {
	document.write('<form method="post" onsubmit="return comment();">');
}

var comment = function() {
	if ($Ajex.empty($('#msg').val())) return false;
	$('#comment .s input').val('Please wait...').attr('disabled', 'disabled');

	$.post('?js=1',
			{
				author: $('#author').val(),
				email:	$('#email').val(),
				city:	$('#city').val(),
				msg:	$('#msg').val(),
				parent: $('#parent').val()
			},
			function(reply) {
				if (1 == reply.status) {
					$('#author').val('');
					$('#email').val('');
					$('#city').val('');
					$('#msg').val('');
					$('#parent').val('');
					$('#com').append(reply.html);

					$('#comment .s input').val('OK').removeAttr('disabled');
				}
			}
		, 'json');
	return false;
}



$(document).ready(function() {
	//$('#view').removeShadow();
	$('a[class="group"]').fancybox();

	if (-1 != location.href.indexOf('/portfolio/')) {
		var link = $('div[class="link"] > a', $('#portfolio'));
		link.attr('target', '_viewLive');
		if ($('#portfolio').width() < 540) {
			$('#view').attr('width', '265');
			$('#portfolio > div[class^="img"]').css('padding-top', '50px');
		}
		/*
		if (link && 'undefined' != link.attr('rel')) {
			var s = link.attr('rel').split('.');
			var zone = '.ru';
			var www = 'www.';
			if ('undefined' != typeof(s[2])) {www = s[0] + '.';zone = '.' + s[2];s[0] = s[1];} else {if ('undefined' != typeof(s[1])) {zone = '.' + s[1];}}
			link.html('<a href="http://' + www + s[0] + zone + '" target="_live" rel="nofollow">' + www + s[0] + zone + '</a>');
		}
		*/

		$('#isNext').click(function() {
			var o = $('#next');
			'none' == o.css('display')? o.show() : o.hide();
			return false;
		});
		//$('h2', $('#portfolio')).each(function() {$(this).textDropShadow('shadow');});
		//$('h2', $('#portfolio')).each(function() {$(this).dropShadow({left: 5, top: 6, blur: 2, opacity: 0.9});});
	}

	//if (-1 != location.href.indexOf('/blog/')) {
		$('#comment .var').each(function(o) {
			$('>input', $(this)).focus(function() {
				$(this).css('border-color', '#fd7600');
				$(this).parent().prev().css('color', '#fd7600');
			}).blur(function() {
				$(this).css('border-color', '#2b2b2b');
				$(this).parent().prev().css('color', '#fff');
			});
		});
	//}

	var h;
	if ($.browser.msie && 6 == parseInt($.browser.version)) {
		if ((h = $(document.body).height()) > $('#main').height()) {$('#content').css('height', (h - 291) + 'px');}
	} else {
		if ((h = $(window).height()) > $(document.body).height()) {$('#content').css('height', (h-475) + 'px');}
	}

	$('#view').dropShadow({left: 5, top: 6, blur: 2, opacity: 0.9});

	$('h1, h2, h3, h4, h5, h6, #nav>strong').each(function() {$(this).textDropShadow('shadow');});
});



(function($) {$.fn.textDropShadow = function(ShdwClass) {$(this).css('position','relative').html('<span class='+ShdwClass+'>'+$(this).html()+'</span><span style="position:relative;">'+$(this).html()+'</span>');return $(this);}})(jQuery);


