document.documentElement.id = 'js';
$(function() {
	( function ( $ ) {

		$.fn.darkbox = function () {
			$( '<div class="darkbox"><div class="darkbox-shadow"></div><div class="darkbox-canvas"><img alt=""><div class="darkbox-button" title="Close"></div></div></div>' ).
				appendTo( 'body' );

			var shadowFadeInTime  = 200,
				shadowFadeOutTime = 100,

				imageFadeInTime       = 400,
				imageErrorFadeOutTime = 800,

				darkboxStateClasses =
					'darkbox-on darkbox-done darkbox-loaded darkbox-error',

				boxMargin = 50,

				buttonPlaceClass = /mac/i.test( navigator.platform ) ?
					'darkbox-button-left' :
					'darkbox-button-right',

				darkbox = $( 'div.darkbox' ),
				darkboxShadow = darkbox.children( 'div.darkbox-shadow' ),
				darkboxCanvas = darkbox.children( 'div.darkbox-canvas' ),
				darkboxImage  = darkboxCanvas.children( 'img' ),
				darkboxButton = darkboxCanvas.children( 'div.darkbox-button' ),
				spinnerAnimationIntervalId = 0, spinnerStep = 0;

			function resetCanvasBackgroundChanges() {
				clearInterval( spinnerAnimationIntervalId );
				darkboxCanvas.css( 'background-position', '24px 24px' );
			}

			function openBox ( e ) {
				e.preventDefault();

				var link = $( this );

				darkbox.addClass( 'darkbox-on' );

				darkboxCanvas.css( {
					'width': '',
					'marginLeft': '',
					'height': '',
					'marginTop': '',
					'opacity': 0.5
				} );

				spinnerAnimationIntervalId = setInterval( function () {
					var shift = 24 - ( 56 * spinnerStep ); 

					darkboxCanvas.css( 'background-position', '24px ' + shift + 'px' );

					spinnerStep = ( 7 <= spinnerStep ) ? 0 : spinnerStep + 1;
				}, 90 );

				darkboxImage.
					one( 'error', handleImageLoadError ).
					css( { 'width': '', 'height': '' } ).
					attr( 'src', link.attr( 'href' ) ).
					attr( 'alt', link.attr( 'title' ) );

				darkboxShadow.animate( { 'opacity': 0.6 }, shadowFadeInTime );
			}

			function closeBox() {
				resetCanvasBackgroundChanges();

				darkboxShadow.animate(
					{ opacity: 0 },
					shadowFadeOutTime,
					function () {
						darkbox.removeClass( darkboxStateClasses );

						darkboxCanvas.stop();

						darkboxImage.
							unbind( 'error', handleImageLoadError ).
							attr( 'src', '' );
					}
				);
			}

			function handleKey( e ) {
				if ( 27 === e.which || 32 === e.which ) {
					if ( 0 === $( 'div.darkbox:hidden' ).length ) {
						e.preventDefault();
						closeBox();
					}
				}
			}

			function handleImageLoadError() {
				resetCanvasBackgroundChanges();

				darkbox.addClass( 'darkbox-error' );
				setTimeout( closeBox, imageErrorFadeOutTime );
			}

			function handleImageLoad() {
				resetCanvasBackgroundChanges();

				var img = $( this ),
					ratio = 1,
					imgWidth = img.width(), imgHeight = img.height(),
					darkboxWidth = darkbox.width(),
					darkboxHeight = darkbox.height();

				if ( 0 === imgWidth && 0 === imgHeight ) {
					setTimeout( function (){ img.load(); }, 10 );
					return;
				}

				if (
					( imgWidth > darkboxWidth - boxMargin ) ||
					( imgHeight > darkboxHeight - boxMargin )
				) {
					ratio = Math.min(
						( darkboxWidth - boxMargin ) / imgWidth,
						( darkboxHeight - boxMargin ) / imgHeight
					);

					imgWidth = Math.round( imgWidth * ratio );
					imgHeight = Math.round( imgHeight * ratio );
				}

				darkbox.addClass( 'darkbox-loaded' );

				darkboxCanvas.
					animate( {
						width:      imgWidth,
						marginLeft: -imgWidth / 2,
						height:     imgHeight,
						marginTop:  -imgHeight / 2,
						opacity: 1
						}, imageFadeInTime,
						function () {
							darkbox.addClass( 'darkbox-done' );
						}
					);
			}

			darkboxShadow.
				css( { opacity: 0 } ).
				click( closeBox );

			darkboxButton.
				addClass( buttonPlaceClass ).
				click( closeBox );

			darkboxImage.load( handleImageLoad );

			$( document ).
				keypress( handleKey ).
				keydown( handleKey );

			this.click( openBox );

			return this;
		};
	} ( jQuery ) );
	
	$( 'a[rel=darkbox]' ).darkbox();
/* 
------------------------------------ */
$( '.aside .foot a' ).
		click(
			function () {
				$( this ).
					parents( '.aside' ).
						find( 'ol:visible+ol' ).
							show().
						end().
					end().
					parent().
						prev( 'ol:visible' ).
						next().
							children( 'a' ).
								remove().
							end().
						text('');
				var frame = /webkit/i.test( navigator.userAgent ) ? $( 'body' ) : $( 'html' );
					frame.animate({ scrollTop:frame.height() }, 1200);
			}
		);

/* 
------------------------------------ */
$( 'form.form-comment dl dt' ).
		click(
			function () {
				$( this ).
					parent().
						toggleClass( 'on' );
			}
		);
});
/* 
------------------------------------ */
(function($){$.fn.defaultvalue=function(){var elements=this;var args=arguments;var c=0;return(elements.each(function(){var el=$(this);var def=args[c++];el.val(def).focus(function(){if(el.val()==def){el.val("");}el.blur(function(){if(el.val()==""){el.val(def);}});});}));}})(jQuery)
document.documentElement.id = 'js'
var IE/*@cc_on=1@*/;

$(function(){
	$('#feedback-user').defaultvalue('Ваш логин');
	$('#feedback-pass').defaultvalue('Ваш пароль');
	$('#feedbacks-user').defaultvalue('Ваше имя');
	$('#feedbacks-email').defaultvalue('Ваш e-mail');
	$('#feedbacks-code').defaultvalue('xxxx');
	$('#search-text').defaultvalue(' Поиск...');
	$('#qsearch').defaultvalue('Здесь Вы можете ввести имя или фамилию');
	$('#nousers').defaultvalue('По вашему запросу ничего не найдено...');
	$('#nosimv').defaultvalue('Ваш запрос пуст...');
	$('dl.rules dt').click(function(){
		$(this).toggleClass('on').next().slideToggle(150);
	})
	$('dl.last dt').click(function(){
		$(this).toggleClass('on').next().slideToggle(150);
	})
	$('dl.laster dt').click(function(){
		$(this).toggleClass('on').next().slideToggle(150);
	})
	$('dl.sub dt').click(function(){
		$(this).toggleClass('on').next().slideToggle(150);
	})
	$('dl.b-box dt').click(function(){
		$(this).toggleClass('on').next().slideToggle(150);
	})
	$('#feedback-msg').one('focus',function(){
		$(this).animate({height:'15em'},100);
	})
	$('.reply').click(function(){
		$(this).toggleClass('on').next().slideToggle(100);
	})
	if(IE){
	$('q').each(function(){
		$(this).parents('q').length>0?$(this).prepend('«').append('»'):$(this).prepend('„').append('“');
	})
	}
});
/* 
------------------------------------ */
$(function(){
	var checks = form.getElementsByTagName('label');
	var checksLnt = checks.length;
	
	for(var i=0; i<checksLnt; i++) {
	var curr = checks[i];

	var box = curr.firstChild;
	box.className = 'lost';

	curr.className += box.type;
	curr.className += (box.checked) ? '-on' : '-off';

	box.onclick = function() {
	var label = this.parentNode;

	if(this.type == 'checkbox') {
	label.className = (label.className.indexOf('-on')+1) ? label.className.replace('-on','-off') : label.className.replace('-off','-on');
	}
	}
	}
});
