$( document ).ready ( function ( ) {

	/**
	 * Вешаем события на форму архива номеров
	 */
	var archive_form = $( '#archive-form' );

	var archive_year = archive_form.find ( '#archive-year' );
	var archive_month = archive_form.find ( '#archive-month' );
	var archive_number = archive_form.find ( '#archive-number' );
	
	archive_form.bind ( 'submit', function ( ) {
		window.location = '/archive/number:'+ archive_number.find ( ':selected' ).val ( ) +'/';

		return false;
	} );
	
	archive_year.bind ( 'change', function ( ) {
		window.location = '/archive/year:'+ archive_year.find ( ':selected' ).val ( ) +'/';
	} );
	
	archive_month.bind ( 'change', function ( ) {
		window.location = '/archive/year:'+ archive_year.find ( ':selected' ).val ( ) +'/month:'+ archive_month.find ( ':selected' ).val ( ) +'/';
	} );
	
	archive_number.bind ( 'change', function ( ) {
	        archive_form.submit ( );
	} );

	
	/**
	 * Обновляем проверочное изображение в случае запроса
	 */
	var captcha = $( '#registration-captcha-update' );
	if ( captcha )
	{
		captcha.bind ( 'click', function ( ) {
			var date = new Date ( );
                        $( '#captcha-image' ).attr ( 'src', '/captcha_'+ date.getSeconds ( ) +'0'+ date.getMilliseconds ( ) +'.png' )
                        
                        return false;
		} );
	}//if
	

	/**
	 * Отображаем закомментированную для поисковиков рекламу
	 */
	$( 'div.ads, #footer-ads, #partners-ads, #header .weather' ).each ( function ( ) {

	        var new_html = $( this ).html ( ).replace ( '<!--', '' );
	        new_html = new_html.replace ( '-->', '' );
		$( this ).html ( new_html );
	} );

	
	/**
	 * Перенаправляем реальных пользователей на invest-catalog.ru, в это же время поисковики остаются на сайте
	 */
	$( '.navigation-add a[href="/invest-catalog-new/number:fresh/"]' ).attr( 'href', 'http://invest-catalog.ru/' );


//	$( '#yandex-results-outer iframe' ).bind ( 'onload', function ( ) { alert ( 'change' ); } );


	/**
	 * Убираем лишние элементы
	 */
	var tl = $( '.footer-copyright ul' );
	var link = tl.find ( 'a' );
	var text = tl.find ( 'small' );
	var host = tl.find ( 'b' );
	
	$( '.footer-copyright' ).find ( 'ul' ).remove ( );
	$( '.footer-copyright' ).find ( 'style' ).remove ( );
	
	$( '.footer-copyright p:last' ).append ( link ).append ( " " ).append ( text.html ( ) );//.append ( " " ).append ( host );


	/**
	 * Выравниваем высоту колонок
	 */
        //window.setInterval ( "$( '#left-column, #right-column, #center-column' ).equalHeights ( );", 2000 );
} );