$(document).ready(function(){
	
	$(".userPanel").insertBefore(".NameAndText");
	
	$(".NameAndText .Text *").css("font-size", "12px");
	
	$("a[href='#mail']").attr("title","Отправить ссылку другу").attr("href","mailto:?Subject="+document.domain+"&Body="+document.location);
	
	$("a[href='#print']").attr("title","Распечатать страницу").click(function(){window.print(); return false;});
	
	$("a[href='#pluse']").attr("title","Увеличить шрифт").click(function(){
		var e = $(".NameAndText .Text");
		var size = parseInt( $(e).css("font-size"), 10) + 3;
		$("*",e).css("font-size", size+"px");
		$(e).css("font-size", size+"px");
		SetCookie("Text-font-size", size);
		return false;
	});
	
	$("a[href='#minus']").attr("title","Уменьшить шрифт").click(function(){
		var e = $(".NameAndText .Text");
		var size = parseInt( $(e).css("font-size"), 10) - 3;
		$("*",e).css("font-size", size+"px");
		$(e).css("font-size", size+"px");
		SetCookie("Text-font-size", size);
		return false;
	});
	
	var size = GetCookie("Text-font-size"); if(size!=""){ $(".NameAndText .Text, .NameAndText .Text *").css("font-size", size+"px"); }
	
	// Нижние баннеры
	$("#bannersBottom A").addClass("Banner");
	var l = $('<A href="#L" class="inline-block L Stop"></A>').click(function(){
		var a = $("#bannersBottom A.Banner");
		var i_showed = 0;
		var checked = false;
		$(a).each(function(i){
			if(this.style.display!="none" && !checked){// находим первый показываемый элемент
				i_showed = i;
				checked = true;
			}
		});
		if(i_showed>0){
			var back = i_showed - 1;
			a[ back+2 ].style.display = "none";
			a[ back ].style.display = "";
			$(this).removeClass("Stop");
			$("#bannersBottom A.R").removeClass("Stop");
		}else{
			//$(this).addClass("Stop");
			//$("#bannersBottom A.R").removeClass("Stop");
		}
		if(typeof(a[ back-1 ])!="object"){ $(this).addClass("Stop"); }
	});
	var r = $('<A href="#R" class="inline-block R"></A>').click(function(){
		var a = $("#bannersBottom A.Banner");
		var i_visible = 0;
		$(a).each(function(i){
			if(this.style.display!="none"){
				i_visible = i;// находим последний показываемый элемент
			}
		});
		var next = i_visible + 1;
		if(next!=a.length){
			a[ next-2 ].style.display = "none";
			a[ next ].style.display = "";
			$("#bannersBottom A.L").removeClass("Stop");
		}else{
			//$(this).addClass("Stop");
			
		}
		if(typeof(a[ next+1 ])!="object"){ $(this).addClass("Stop");  }
	});
	$("<td></td>").prepend(l).insertBefore("#bannersBottom TD");
	$("<td></td>").append(r).insertAfter("#bannersBottom TD:eq(1)");
	
	
	
	
	
	// jsListing
	var l = $('<td class="L"  valign="bottom"></td>').click(function(){
		var a = $("#jsListing .News");
		var i_showed = 0;
		var checked = false;
		$(a).each(function(i){
			if(this.style.display!="none" && !checked){// находим первый показываемый элемент
				i_showed = i;
				checked = true;
			}
		});
		if(i_showed>0){
			var back = i_showed - 1;
			a[ back+4 ].style.display = "none";
			a[ back ].style.display = "";
			$(this).removeClass("Stop");
			$("#jsListing .R").removeClass("Stop");
		}
		if(typeof(a[ back-1 ])!="object"){ $(this).addClass("Stop"); }
	});
	var r = $('<td class="R" valign="bottom"></td>').click(function(){
		var a = $("#jsListing .News");
		var i_visible = 0;
		$(a).each(function(i){
			if(this.style.display!="none"){
				i_visible = i;// находим последний показываемый элемент
			}
		});
		var next = i_visible + 1;
		if(next!=a.length){
			a[ next-4 ].style.display = "none";
			a[ next ].style.display = "";
			$("#jsListing .L").removeClass("Stop");
		}
		if(typeof(a[ next+1 ])!="object"){ $(this).addClass("Stop");  }
	});
	//-$("#jsListing TD").prepend(l).append(r);
	$(r).insertAfter("#jsListing TD");
	$(l).insertBefore("#jsListing TD:first");
	
	
	
	
	
	// jsListing2
	var l = $('<td class="L"  valign="bottom"></td>').click(function(){
		var a = $("#jsListing2 .News");
		var i_showed = 0;
		var checked = false;
		$(a).each(function(i){
			if(this.style.display!="none" && !checked){// находим первый показываемый элемент
				i_showed = i;
				checked = true;
			}
		});
		if(i_showed>0){
			var back = i_showed - 1;
			a[ back+4 ].style.display = "none";
			a[ back ].style.display = "";
			$(this).removeClass("Stop");
			$("#jsListing2 .R").removeClass("Stop");
		}
		if(typeof(a[ back-1 ])!="object"){ $(this).addClass("Stop"); }
	});
	var r = $('<td class="R" valign="bottom"></td>').click(function(){
		var a = $("#jsListing2 .News");
		var i_visible = 0;
		$(a).each(function(i){
			if(this.style.display!="none"){
				i_visible = i;// находим последний показываемый элемент
			}
		});
		var next = i_visible + 1;
		if(next!=a.length){
			a[ next-4 ].style.display = "none";
			a[ next ].style.display = "";
			$("#jsListing2 .L").removeClass("Stop");
		}
		if(typeof(a[ next+1 ])!="object"){ $(this).addClass("Stop");  }
	});
	$(r).insertAfter("#jsListing2 TD");
	$(l).insertBefore("#jsListing2 TD:first");
	
	
	// jsListing3
	var l = $('<td class="L"  valign="bottom"></td>').click(function(){
		var a = $("#jsListing3 .News");
		var i_showed = 0;
		var checked = false;
		$(a).each(function(i){
			if(this.style.display!="none" && !checked){// находим первый показываемый элемент
				i_showed = i;
				checked = true;
			}
		});
		if(i_showed>0){
			var back = i_showed - 1;
			a[ back+4 ].style.display = "none";
			a[ back ].style.display = "";
			$(this).removeClass("Stop");
			$("#jsListing3 .R").removeClass("Stop");
		}
		if(typeof(a[ back-1 ])!="object"){ $(this).addClass("Stop"); }
	});
	var r = $('<td class="R" valign="bottom"></td>').click(function(){
		var a = $("#jsListing3 .News");
		var i_visible = 0;
		$(a).each(function(i){
			if(this.style.display!="none"){
				i_visible = i;// находим последний показываемый элемент
			}
		});
		var next = i_visible + 1;
		if(next!=a.length){
			a[ next-4 ].style.display = "none";
			a[ next ].style.display = "";
			$("#jsListing3 .L").removeClass("Stop");
		}
		if(typeof(a[ next+1 ])!="object"){ $(this).addClass("Stop");  }
	});
	$(r).insertAfter("#jsListing3 TD");
	$(l).insertBefore("#jsListing3 TD:first");
	
	
	
	// пролистывание длинной новости
	var longHTML = longTime = innerWidth = null;
	$(".MoreLinks DIV DIV A").mouseover(function(){
		
		
		var inner = $(this).parent();
		var outer = $(inner).parent()[0].clientWidth//offsetWidth;
		
		//var innerKids = $(inner).children();
		/*
		
		
		var widthE = function(e){
			return ( e.offsetWidth + e.style.paddingLeft + e.style.paddingRight + e.style.borderLeftWidth + e.style.borderRightWidth );
		};
		
		var inner = $(this).parent();
		var outer = $(inner).parent()[0].offsetWidth;
		
		var innerWidthStart = $(inner)[0].offsetWidth;
		*/
		longHTML = $(this).text();
		
		var a = this;
		var t = longHTML;
		// a.offsetLeft + a.offsetWidth > inner
		longTime = setInterval(function(){
			if(t){
				//1. var innerWidth = $(a).parent()[0].offsetWidth + 19;
				//2. var inner = $(a).parent()[0].offsetWidth;
				//var kids = $(inner).children();
				//var innerWidth = paddingLR(kids[0]) + paddingLR(kids[1]);
				//console.log(allPaddingsLR(kids[0])+" + "+allPaddingsLR(kids[1])+" = "+ innerWidth+" > "+outer);
				//console.log( a.offsetLeft+" + "+a.offsetWidth+" > "+inner);
				// 1. if(innerWidth > outer){//inner > outer //( (a.offsetLeft + a.offsetWidth) > inner)
				
				
				
				var w = a.offsetWidth + a.offsetLeft + 9;//widthE(kids[0]) + widthE(kids[1]);
				//if($.browser.msie){ w += 9; }
				//console.log(w+" = "+ a.offsetWidth+" + "+a.offsetLeft+" > "+outer);
				if(w >= outer){
					t = t.substr(1);
					$(a).html( t );
				}else{
					//$(inner).css("width", innerWidthStart+"px");
				}
			}
		},100);
	}).mouseout(function(){
		clearInterval(longTime);
		//var c = $(this).clone();
		//$( c ).insertAfter(this);
		//$(this).remove();
		$(this).text(longHTML);
		//$(this).html(longHTML);
		//$(this).css("width","auto");
		//$(this).parent().css("width",innerWidth+"px");
		//$(this).parent().width(innerWidth);
	});
});

/*
var a = $(".Latest .MoreLinks DIV A")[0]
var t = 
$(a).html( t.substr(1) );



<div class="outer">
	<div class="inner">
		<span class="html"></span>
	</div>
</div>

var html = $(".html");
var html2 = $(html)

var inner = $(".inner");
var html = $(inner).html();
for(var i=0; i<5; i++){
	html += html;
}
var html2 = html;




var w = e.offsetWidth;// реальная ширина горизонтального блока
var w_max = $(e).parent()[0].offsetWidth;// ширина области в которой проказывается горизонтальный блок

setInterval(function(){
	var w_inner = w + e.style.left;// ширина показываемой части (т.к. e.style.left всегда с минусом, то + означает -)
	if( w_inner < w_max){// если оставшаяся к показу ширина блока меньше ширины области в которой он показывается
		$( copy ).appendTo( e );// добавляем вторую часть
	}
	if(){
		
	}
},1500)




http://74.125.77.132/search?q=cache:o0PSBd5UBeAJ:www.nr2.ru/+http://www.nr2.ru/&cd=1&hl=ru&ct=clnk&gl=ru&client=firefox

var marqueespeed1=1;
var copyspeed1=marqueespeed1;
var marqueespeed2=1;
var copyspeed2=marqueespeed2;

function myScroll1()
{
	if (parseInt(cross_marquee1.style.left)>actualwidth1)
		cross_marquee1.style.left=parseInt(cross_marquee1.style.left)-copyspeed1+"px";
	else
		cross_marquee1.style.left=parseInt(marqueewidth)+"px";
}

function myScroll2()
{
	if (parseInt(cross_marquee2.style.left)>actualwidth2)
		cross_marquee2.style.left=parseInt(cross_marquee2.style.left)-copyspeed2+"px";
	else
		cross_marquee2.style.left=parseInt(marqueewidth)+"px";
}

function myScrollInit()
{
	cross_marquee1=document.getElementById("marqd1");
	cross_marquee1.style.left="0px";
	actualwidth1=-cross_marquee1.offsetWidth;

	cross_marquee2=document.getElementById("marqd2");
	cross_marquee2.style.left="0px";
	actualwidth2=-cross_marquee2.offsetWidth;

	marqueewidth = 861;

	setTimeout('setInterval("myScroll1()",15)', 1000);
	setTimeout('setInterval("myScroll2()",30)', 1500);
}

myScrollInit();


*/