function textchange(){
	var count = 140 /* максимальное количество вводимых символов в текстареа */
	a = document.form.post_text.value.length;
	if (a > count) {
		document.form.post_text.value = document.form.post_text.value.substring(0,count);
	}
	a = document.form.post_text.value.length;
	document.form.count_sym.value = count - a;
}
(function($) {
	$.fn.makeGallery = function(o) {
		o = $.extend( {
			interval : 2500, /* интервал вращения 1000 = 1секунда */
			speed : 1000, /* скорость перемещения 1000 = 1секунда */
			gallery_holder : 'ul',
			gallery_item : 'li'
		}, o || {});
		var steps = 1;
		$(this).each(
				function() {
					main_holder = $(this);
					main_holder.find(o.gallery_holder).css('position','absolute');
					main_holder.css('position','relative');
					var item_class = main_holder.find(o.gallery_item).attr('class');
					var step = ($(this).find(o.gallery_item+':first').height()+5) * steps;
					main_holder.find(o.gallery_holder).prepend('<'+o.gallery_item+' class="'+item_class+'">'+$(this).find(o.gallery_item+':last').html()+'</'+o.gallery_item+'>');
					main_holder.find(o.gallery_holder).find(o.gallery_item+':last').remove();
					main_holder.find(o.gallery_holder).css('top',(-1)*step);
					main_holder.find(o.gallery_holder).css('height',main_holder.find(o.gallery_item).size()*($(this).find(o.gallery_item).height()));
					main_holder.bind('mouseover',function(){
						clearTimeout(t);
					});
					main_holder.bind('mouseleave',function(){
						t = setTimeout( oneStep, o.interval);
					});
					t = setTimeout(oneStep, o.interval);
					
					function oneStep () {
						main_holder.find(o.gallery_holder).animate({top:0}, o.speed, function(){
							$(this).prepend('<'+o.gallery_item+' class="'+item_class+'">'+$(this).find(o.gallery_item+':last').html()+'</'+o.gallery_item+'>');
							$(this).find(o.gallery_item+':last').remove();
							var step = ($(this).find(o.gallery_item+':first').height()+5) * steps;
							$(this).css('top',(-1)*step);
						});
						t = setTimeout(oneStep, o.interval);
					};
					
				});
	};
})(jQuery);

$(document).ready(function(){
	$('.gallery-holder').makeGallery();
	$('.download a').click(function(){
		$('.download-form').slideDown(400);
		return false;
	})
});


function hideFormText() {
	var _inputs = document.getElementsByTagName('input');
	var _txt = document.getElementsByTagName('textarea');
	var _value = [];
	
	if (_inputs) {
		for(var i=0; i<_inputs.length; i++) {
			if (_inputs[i].type == 'text' || _inputs[i].type == 'password') {
				
				_inputs[i].index = i;
				_value[i] = _inputs[i].value;
				
				_inputs[i].onfocus = function(){
					if (this.value == _value[this.index])
						this.value = '';
				}
				_inputs[i].onblur = function(){
					if (this.value == '')
						this.value = _value[this.index];
				}
			}
		}
	}
	if (_txt) {
		for(var i=0; i<_txt.length; i++) {
			_txt[i].index = i;
			_value['txt'+i] = _txt[i].value;
			
			_txt[i].onfocus = function(){
				if (this.value == _value['txt'+this.index])
					this.value = '';
			}
			_txt[i].onblur = function(){
				if (this.value == '')
					this.value = _value['txt'+this.index];
			}
		}
	}
}
if (window.addEventListener)
	window.addEventListener("load", hideFormText, false);
else if (window.attachEvent)
	window.attachEvent("onload", hideFormText);
	
