			function update()
            {
                if(curr_x != prev_x)
                {
                    prev_x = curr_x;
                    flag = true;
                }

                if (flag)
                    {
                         movediv();
                         flag = false;
                    }
    

            }
			
			function cloud_alone(){
				$('#cloud_alone').css('left', screen.width+parseInt($('#cloud_alone').css('width')));
				$('#cloud_alone').animate({left: -parseInt($('#cloud_alone').css('width'))*2}, 100000, 'linear', function(){cloud_alone();});
				}
			
			function two_clouds(){
				$('#two_clouds').css('left', screen.width+parseInt($('#two_clouds').css('width')));
				$('#two_clouds').animate({left: -parseInt($('#two_clouds').css('width'))*2}, 100000, 'linear', function(){two_clouds();});
				}
			
			function left_clouds(){
				$('#left_clouds').css('left', screen.width+parseInt($('#left_clouds').css('width')));
				$('#left_clouds').animate({left: -parseInt($('#left_clouds').css('width'))*2}, 150000, 'linear', function(){left_clouds();});
				}
				
			function right_clouds(){
				$('#right_clouds').css('left', screen.width+parseInt($('#right_clouds').css('width')));
				$('#right_clouds').animate({left: -parseInt($('#right_clouds').css('width'))*2}, 150000, 'linear', function(){right_clouds();});
				}
			
			function clouds(){
					$('#cloud_alone').animate(
											  {left: -parseInt($('#cloud_alone').css('width'))*2},
											  40000, 'linear', function(){cloud_alone();});
					$('#two_clouds').animate(
											  {left: -parseInt($('#two_clouds').css('width'))*2},
											  70000, 'linear', function(){two_clouds()});
					$('#left_clouds').animate(
											  {left: -parseInt($('#left_clouds').css('width'))*2},
											  100000, 'linear', function(){left_clouds()});
					$('#right_clouds').animate(
											  {left: -parseInt($('#right_clouds').css('width'))*2},
											  200000, 'linear', function(){right_clouds()});
					}
			
            function movediv(){
                //var center = screen.width/2;
				var center = window.outerWidth;
                                
				$('#main_bg').stop();
                                $('#main_bg').animate({left: -prev_x/2-525}, 200, 'linear');
				$('#cloud_outer').stop();
				$('#cloud_outer').animate({left: -prev_x/2+320}, 200, 'linear');
				$('#bg_house').stop();
				$('#bg_house').animate({left: -prev_x/4-680}, 200, 'linear');
				$('#road').stop();
				$('#road').animate({left: 60-prev_x/10}, 200, 'linear');
				$('#left_side_house').stop();
				$('#left_side_house').animate({right: prev_x/6+710}, 200, 'linear');
				$('#right_side_house').stop();
				$('#right_side_house').animate({left: -prev_x/6+928}, 200, 'linear');
				$('#two_house').stop();
				$('#two_house').animate({left: -prev_x/6-735}, 200, 'linear');
				$('#sun').stop();
				$('#sun').animate({left: -270-prev_x/3}, 200, 'linear');
				$('#main_house_outer').stop();
				$('#main_house_outer').animate({left: 80-prev_x/8}, 200, 'linear');
				$('#lamp').stop();
				$('#lamp').animate({left: prev_x/6-595}, 200, 'linear');
            }
			
			var lim_c = 0;
			var prev = '';

                        function truck_first(){
				var center_page = document.documentElement.scrollWidth/2 + 20;
                                var rights = - parseInt($('#truck').css('width')) - 100;
				$('#truck').css('right', rights);
                                $('#truck').show();
				$('#truck').animate({right: center_page}, 6000, 'linear', function(){
                                    $('#front_truck_wheel').hide();
                                    $('#back_truck_wheel').hide();
                                    setTimeout(function(){truck_second();}, 10000);
                                });
			}

                        function truck_second(){
                                $('#front_truck_wheel').show();
                                $('#back_truck_wheel').show();
                                var car_right = document.documentElement.scrollWidth+100;
				$('#truck').animate({right: car_right}, 6000, 'linear', function(){
                                    setTimeout(function(){truck_first()}, 20000);
                                });
                                
			}

			function mazda(){
				var car_left = document.documentElement.scrollWidth + parseInt($('#mazda6').css('width'));
				$('#mazda6').css('left', -parseInt($('#mazda6').css('width')));
				$('#mazda6').animate({left: car_left}, 3000, 'linear');
				prev = 'mazda';
			}
			
			function mazda_blue(){
				var car_right = document.documentElement.scrollWidth + parseInt($('#mazda6_blue').css('width'));
				$('#mazda6_blue').css('right', -parseInt($('#mazda6_blue').css('width')));
				$('#mazda6_blue').animate({right: car_right}, 4000, 'linear');
				prev = 'mazda_blue';
			}
			
			function audi(){
				var car_left = document.documentElement.scrollWidth + parseInt($('#audi').css('width'));
				$('#audi').css('left', -parseInt($('#audi').css('width')));
				$('#audi').animate({left: car_left}, 5000, 'linear');
				prev = 'audi';
			}
			
			function land(){
				var car_left = document.documentElement.scrollWidth + parseInt($('#land').css('width'));
				$('#land').css('left', -parseInt($('#land').css('width')));
				$('#land').animate({left: car_left}, 6000, 'linear');
				prev = 'land';
			}
			
			function limusine(){
				var car_right = document.documentElement.scrollWidth + parseInt($('#limusine').css('width'));
				$('#limusine').css('right', -parseInt($('#limusine').css('width')));
				$('#limusine').animate({right: car_right}, 7000, 'linear');
				lim_c = 0;
			}
			
				
			function cars(){
				var c = rand();
				if(c < 2){
					if(prev == 'mazda') cars();
					else mazda();
				}
				else if(c >= 2 && c < 4){
					if(lim_c < 5) cars();
					else limusine();
				}
				else if(c >= 4 && c < 6){
					if(prev == 'land') cars();
					else land();
				}
				else if(c >= 6 && c < 8){
					if(prev == 'mazda_blue') cars();
					else mazda_blue();
				}
				else{
					if(prev == 'audi') cars();
					else audi();
				}
			}
			
			function rand(){
				return Math.round(Math.random()*10);
				}

                        function fnc(){
                           $("a.images").fancybox();
                        }

            $('document').ready(function(){
                
                $("a.images").fancybox();
                if(is_main == '1'){
					setInterval(function(){update();}, 50);
                                        
                                        var img_gaz = document.createElement('img');
                                        img_gaz.onload = function () {
                                            setTimeout(function(){truck_first();}, 10000);
                                        };
                                        $(img_gaz).attr('src', '/images/gazel.png');
                                        
                                        var img = document.createElement('img');
                                        img.onload = function () {
                                            var img2 = document.createElement('img');
                                            img2.onload = function () {
                                                var img3 = document.createElement('img');
                                                img3.onload = function () {
                                                    var img4 = document.createElement('img');
                                                    img4.onload = function () {
                                                        var img5 = document.createElement('img');
                                                        img5.onload = function () {
                                                             setInterval(function(){lim_c++; cars();}, 8000);
                                                        };
                                                        $(img5).attr('src', '/images/limusine.png');
                                                    };
                                                    $(img4).attr('src', '/images/land.png');
                                                };
                                                $(img3).attr('src', '/images/audi.png');
                                            };
                                            $(img2).attr('src', '/images/mazda6_blue.png');
                                        };
                                        $(img).attr('src', '/images/mazda6.png');

                                        var img_city = document.createElement('img');
                                        $(img_city).attr('src', '/images/city_hover.png');
                                        
					
		}
                else{
                    clouds();
                }
                
                
                                
            });
