		$(function() {
			$("div#scrollingText").smoothDivScroll({autoScroll: "always", autoScrollDirection: "endlessloopright", autoScrollStep: 2, autoScrollInterval: 80 });


			$("div.scrollableArea").bind("mouseover", function(){
				$("div#scrollingText").smoothDivScroll("stopAutoScroll");
			});

			$("div.scrollableArea").bind("mouseout", function(){
				$("div#scrollingText").smoothDivScroll("startAutoScroll");
			});

			$("#prev_prev1").bind("click", function(){
				$("div#scrollingText").smoothDivScroll("stopAutoScroll");scroll('left');
                //$("div#scrollingText").smoothDivScroll({autoScrollStep: 5, scrollStep:100, autoScrollInterval: 15,autoScrollDirection:"endlessloopright"});$(".btn-prev").toggle();$('#next_next1').show();$('#next_next2').hide();
			});

			$("#prev_prev2").bind("click", function(){
				$("div#scrollingText").smoothDivScroll("stopAutoScroll");

                //$("div#scrollingText").smoothDivScroll({autoScrollStep: 1, autoScrollInterval: 20,autoScrollDirection:"endlessloopright"});$(".btn-prev").toggle();
			});

			$("#next_next1").bind("click", function(){
			     $("div#scrollingText").smoothDivScroll("stopAutoScroll");scroll('right');
				 //$("div#scrollingText").smoothDivScroll({autoScrollStep: 5, scrollStep:100, autoScrollInterval: 15,autoScrollDirection:"endlessloopleft"});$(".btn-next").toggle();$('#prev_prev1').show();$('#prev_prev2').hide();
			});

			$("#next_next2").bind("click", function(){
				$("div#scrollingText").smoothDivScroll({autoScrollStep: 1, autoScrollInterval: 20,autoScrollDirection:"endlessloopleft"});$(".btn-next").toggle();
			});
            $("#li_next1").bind("click", function(){
				$("div#scrollingText").smoothDivScroll("moveToElement", "number", 2);
			});
            $("#li_next2").bind("click", function(){
				$("div#scrollingText").smoothDivScroll("moveToElement", "number", 3);
			});
            $("#li_next3").bind("click", function(){
				$("div#scrollingText").smoothDivScroll("moveToElement", "number", 4);
			});
            $("#li_next4").bind("click", function(){
				$("div#scrollingText").smoothDivScroll("moveToElement", "number", 5);
			});
            $("#li_next5").bind("click", function(){
				$("div#scrollingText").smoothDivScroll("moveToElement", "number", 6);
			});
            $("#li_next6").bind("click", function(){
				$("div#scrollingText").smoothDivScroll("moveToElement", "number", 7);
			});

		});
function scroll(line){
/*    function nospace(str) {var VRegExp=new RegExp(/^[ ]+/g); var VResult=str.replace(VRegExp,''); return VResult}
    var arr=[]; var i=0;
    $(".scrollableArea > .photo").each(function(){
        var on=$(this).attr('name')+'';
        var w = '<div class="photo" name="'+on+'" onclick="'+on+'" style="cursor: pointer; float: left;">'+$(this).html()+'</div>';
        arr[i] = w; i++;delete on;
    });  */
    if (line=='left'){
            var item_width = $('.scrollableArea div').width() + 10;

            var scrollArea = parseInt($('.scrollableArea').css('left')) ;

            var left_indent = parseInt($('.scrollableArea').css('left')) - item_width;

            $('.scrollableArea:not(:animated)').animate({'left' : '-=224'},500,function(){

                $('.scrollableArea div:last').after($('.scrollableArea div:first'));

                $('.scrollableArea').css({'left' : '0px'});
            });

        //var j=arr.length; var first=arr[0]; delete arr[0]; var b = arr.slice(1,j); b[j-1]=first;
        //var j=b.length; var first=b[0]; delete b[0]; var arr = b.slice(1,j); arr[j-1]=first;
        //var j=arr.length; var first=arr[0]; delete arr[0]; var b = arr.slice(1,j); b[j-1]=first;
    }
    if (line=='right'){
            var item_width = $('.scrollableArea div').width() + 10;

            var scrollArea = parseInt($('.scrollableArea').css('left')) ;

            var left_indent = parseInt($('.scrollableArea').css('left')) + item_width;

            $('.scrollableArea').animate({'left' : '+=224'},500,function(){

            $('.scrollableArea div:first').before($('.scrollableArea div:last'));

            $('.scrollableArea').css({'left' :'0px'});
            });

        //var b=[]; var k=arr.length-1; b[0]=arr[k]; delete arr[k]; for(var j=1;j<arr.length;j++){b[j] = arr[j-1];}
        //var arr=[]; var k=b.length-1; arr[0]=b[k]; delete b[k]; for(var j=1;j<b.length;j++){arr[j] = b[j-1];}
        //var b=[]; var k=arr.length-1; b[0]=arr[k]; delete arr[k]; for(var j=1;j<arr.length;j++){b[j] = arr[j-1];}
    }
    if (line!=='left' && line!=='right') return false;
    //var new_div=''; new_div = b.join('\r\n');
    //$(".scrollableArea > .photo").remove();
    //$(".scrollableArea").append(new_div);
    clearTimeout(window.t);
    t = setTimeout(function(){
        if (line=='left'){$("div#scrollingText").smoothDivScroll({autoScrollStep: 1, autoScrollInterval: 80,autoScrollDirection:"endlessloopright"});$("div#scrollingText").smoothDivScroll("startAutoScroll");}
        if (line=='right'){$("div#scrollingText").smoothDivScroll({autoScrollStep: 1, autoScrollInterval: 80,autoScrollDirection:"endlessloopleft"});$("div#scrollingText").smoothDivScroll("startAutoScroll");}
    },3000);
}
function layout_show(id,album,path){
	$('.popup-table').show();
	$('.popup').html('Загрузка...').load(path+'?show_id='+id+'&album='+album).show();
	return false;
}
function layout_close(){
	$('.popup-table').hide();
	$('.popup').hide();
	return false;
}
function changeWmode(){
	$(document).ready(function(){
		$('object').each(function(objects){
			wmode = false;
			if($(this).attr('id')=='')$(this).attr('id','random'+Math.random());
			$('#'+ this.id + ' > param').each(function(params){
					if($(this).attr('name')=='wmode'){
						if($(this).attr('value')=='transparent' || $(this).attr('value')=='opaque'){wmode = true;} else {
							$(this).remove();
						}
					}
			});
			if(wmode === false){
				$('#'+ this.id).html($('#'+ this.id).html()+'<param name=wmode value=transparent>');
			}
		})
		$('embed').attr('wmode','transparent');
    var embedTag;
    $("embed").each(function(i) {
        embedTag = $(this).attr("outerHTML");
        if ((embedTag != null) && (embedTag.length > 0)) {
            embedTag = embedTag.replace(/embed /gi, "embed wmode=\"transparent\" ");
            $(this).attr("outerHTML", embedTag);
        }
        // This "else" was added
        else {
            $(this).wrap("<div></div>");
        }
    });
	})
}
changeWmode();
