$(function(){
	jQuery.fn.fadeToggle = function(speed, easing, callback){
		return this.animate({opacity: 'toggle'}, speed, easing, callback);
	};
	$(document).bind('click', function(e){
		$('div.more').fadeOut('fast');
	});
	if ($('dl.go dd div.important p').text() == 'Все поля обязательны для заполнения.') {
		$('dl.go dd').hide();
	};
	$('dl.go dt strong').click(function(){
		$('dl.go dd').slideToggle('fast');
	});
	if ($('div.more').length > 0) {
		$('div.more').addClass('more-js');
	};
	$('a.more').click(function(){
		$('div.more').fadeToggle('fast');
		return false;
	});
	$('#go_phone').mask('+7 (999) 999-99-99');
	$('div.notcool div.scroll > ul > li:nth-child(6n)').each(function(i){
		var nine = $(this);
		var nineOffset = nine.offset().top;
		nine.after('<li class="sub"><ul></ul></li>');
		$('div.notcool div.scroll > ul > li:not(.sub)').each(function(){
			if (($(this).offset().top < nineOffset) && (!$(this).parent('ul').parent('li.sub').length > 0)){
				$(this).appendTo(nine.next('li.sub').children('ul'));
			}
		});
	});
	if ($('div.notcool div.scroll > ul > li:last-child:not(.sub)').length > 0) {
		$('div.notcool div.scroll > ul > li:last-child').after('<li class="sub sub-last"><ul></ul></li>');
		$('div.notcool div.scroll > ul > li:not(.sub)').appendTo('li.sub-last ul');
	};
	$('div.badass div.scroll').scrollable({
		clickable:false,
		items:'div.badass>div.scroll>ul',
		next:'i#next1',
		prev:'i#prev1',
		size:1,
		easing:'linear'
	}).mousewheel();
	$('div.notcool div.scroll').scrollable({
		clickable:false,
		items:'div.notcool>div.scroll>ul',
		next:'i#next2',
		prev:'i#prev2',
		size:1,
		easing:'linear'
	}).mousewheel();
	$('div.notcool div.scroll > ul').css('width','20000em');
	$('div.scroll dl').hover(function(){
		$(this).toggleClass('hover');
	},function(){
		$(this).toggleClass('hover');
	});
	$('a[rel^="prettyPhoto"]').prettyPhoto({
		theme:'dark_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
		animationSpeed:'normal', /* fast/slow/normal */
		padding:40, /* padding for each side of the picture */
		opacity:0.75, /* Value betwee 0 and 1 */
		showTitle:true, /* true/false */
		allowresize:true, /* true/false */
		counter_separator_label:'/' /* The separator for the gallery counter 1 "of" 2 */
	});
});
