$(function() {
	
	$(".LESSMOREX").truncate(200, {
		trail: [
		     " (...) <div id='lmore'><a onclick='$(this).ResizeMe();' href='#' class='truncate_show floatRight wiecej3'></a></div>",
		     "<div id='lmore'><a onclick='$(this).ResizeMeShrink();' href='#' class='truncate_hide floatRight mniej' style='position: relative; left: 6px;'></a></div>"
		]
	});
	
	$(".LESSMORE").truncate( 650, {
        trail: [
            " (...) <div class='floatRight wiecejBg vcenterTable' style='top:0px;margin-top:25px;'><a href='#' class='truncate_show hcenter vcenterCell wiecej2'></a></div>",
            "<div class='floatRight wiecejBg vcenterTable' style='top:0px;margin-top:25px;margin-bottom:10px;'><a href='#' class='truncate_hide hcenter vcenterCell mniej2'></a></div>"
        ],
        callback: function() {$(this).jScrollUpdate();}
    });

	
	$.fn.ResizeMe = function()
	{
		var oldH = $(".LESSMOREX").height() - $(".mainLeadTop").height() - $(".mainLeadBot").height() + 45;
		setTimeout(function () {
			var newH = $(".LESSMOREX").height() - $(".mainLeadTop").height() - $(".mainLeadBot").height() + 55;
				if(newH<0){ newH=9; }
					$("#resizeme").css({"height":newH});
					$("#TPan").css({"margin-bottom":"30px"});
					var dif=newH-oldH-50;
					$("#FOOTER").css("top",dif);
			}, 500
		);
	}

	$.fn.ResizeMeShrink = function()
	{
		var oldH = $(".LESSMOREX").height() - $(".mainLeadTop").height() - $(".mainLeadBot").height() + 45;
		setTimeout(function () {
			var newH = $(".LESSMOREX").height() - $(".mainLeadTop").height() - $(".mainLeadBot").height() + 45;
				if(newH<0){
					newH=9;
						if ($.browser.name == 'msie') {
							newH=14;
						}	
				}
					$("#resizeme").css({"height":newH});
					$("#TPan").css({"margin-bottom":"0px"});
					var dif=newH-oldH + 400;
					
					if ($.browser.name == 'msie') {
						dif +=100;
					}
					
					$("#FOOTER").css("top",dif);

			}, 500
		);
	}

	
	
	$.fn.jScrollUpdate = function()
	{	
		$('#JanuzCont').jScrollPaneRefresh();
		
		$('a.mniej2').css("display","block");
		
		
		//if ($.browser.name + '-' + $.browser.versionNumber != 'msie-6') {
			
			
			//$('#JanuzCont').jScrollPaneRemove();
			//$('#JanuzCont').jScrollPane({showArrows:true, scrollbarWidth:10, scrollbarMargin:5, dragMaxHeight:10 });
			
			
			//$('#TPan').css('visibility','visible');
 			//$('#ScroolJanusz').css('visibility','visible');
		/*}else{
			var CurTop = $('#JanuzCont').data('jScrollPanePosition');
			//$('#JanuzCont').jScrollPaneRemove();
			$('#JanuzCont').jScrollPane({showArrows:true, scrollbarWidth:10, scrollbarMargin:5, dragMaxHeight:10 });
			$('#JanuzCont').jScrollPaneRemove();
			$('#JanuzCont').jScrollPane({showArrows:true, scrollbarWidth:10, scrollbarMargin:5, dragMaxHeight:10 });
			
			if (CurTop>0) {
				$('#JanuzCont').scrollTo(CurTop);
			}

			//$('#TPan').css('visibility','visible');
 			//$('#ScroolJanusz').css('visibility','visible');
			
		}*/
	};
	
	$.fn.jScrollUpdate();

});


