var red_line_start_state = {width:0, left:'+=50px'}; //начальное состояние красной линии
if ( $.browser.msie && +$.browser.version < 7){
	var red_line_dx = 190; //смещение по оси x красной линии
} else {
	var red_line_dx = 200; //смещение по оси x красной линии
}

$(function(){
	
	//убираем глюк с переносами
	if 	( $('#content .article .article_text br').length > 5 ){
		$('#content .article .article_text br').remove();
		$('#content .article .article_text p:last b').prepend('<br /><br />');
	}
	
	//prettyPhoto для фотографий
	$('#col_right .article .article_imgs .article_img a.img, #col_right .person .vcard .photo, a.img_banner').prettyPhoto();
	
	$('input,textarea').focus(function(){
		$(this).addClass("focus");
		if ( $(this).val() == $(this).attr("rel") ){
			$(this).val('');	

			//курсор пропадает
			if ( $.browser.msie ){
				var r = this.createTextRange();
				r.moveEnd("character",100);
				r.select();
			}
		}
	});
	
	$('input,textarea').blur(function(){
		$(this).removeClass("focus");
		if ( $(this).val() == "" ){
			$(this).val(  $(this).attr("rel") );
		}
	});

	/* бегающая красная полоса в шапке */
	//начальное состояние красной линии
	var selected_a = $('#header .editions li a.select:first');
	if ( selected_a.length ){
		red_line_start_state = {
			width:selected_a.width(),
			left:selected_a.position().left + red_line_dx
		};
		$('#menu_select_red_line').stop(false,true).css(red_line_start_state);
	}
	$('#header .editions li a').mouseenter(function(){
		$('#menu_select_red_line').stop(false,true).animate({
			width: $(this).width(),
			left: $(this).position().left + red_line_dx
		}, 'fast');
	});
	$('#header .editions').mouseleave(function(){
		$('#menu_select_red_line').stop(false,true).animate( red_line_start_state, 'fast');
	});
	
	//упрямая форма яндекса не хочет быть прозрачной
	//$('#yandexform0 .yaform__search, #yandexform0 .yaform__precise-i').css('backgroundColor',' !important');
});
