function initQuickGallery() {

        var transitionTime = 10000;
        var imageSwitchTimer;
        var imageSwitchInterval = 26000;
	  var movingTime=5000;
	  var timess;
	  
        
        function createImage(){
                jQuery('<img src="" />').attr({src:imageList[currentImage].path, id:currentImage+"-pic"}).css("display","none").appendTo('#home-gallery').bind('load', function(){
                        jQuery(this).fadeIn(movingTime, function(){
				     piltWidth=jQuery('#home-gallery img').width();
				     piltHeight=jQuery('#home-gallery img').height();
				     var vaheWidth=piltWidth-width;
				     var vaheHeight=piltHeight-height;
				     //console.log(vaheWidth);
                             times=4; 
				     while(times>0){
					     if(times==1 && vaheHeight>0)$('#'+currentImage+'-pic').animate({top: '+='+vaheHeight+'px'}, movingTime);
					     else if(times==3 && vaheHeight>0)$('#'+currentImage+'-pic').animate({top: '-='+vaheHeight+'px'}, movingTime);
					     else if(times==2 && vaheWidth>0)$('#'+currentImage+'-pic').animate({left: '+='+vaheWidth+'px'}, movingTime);
					     else if(times==4 && vaheWidth>0)$('#'+currentImage+'-pic').animate({left: '-='+vaheWidth+'px'}, movingTime);
					     var imagesCount = jQuery('').length;
					     if (imagesCount > 1) {
							   for (key = 0; key < imagesCount - 1; key++) {
								  jQuery('#home-gallery img:eq('+key+')').remove();
							   }
					     }
					     times--;
					}
                        });
                });
        }
        var width = jQuery('#home-gallery').width();
	  var picWidth;
	  var height=jQuery('#home-gallery').height();
	  var picHeight;
        
	  function initImageRotator(){
		if (imageSwitchTimer) {
			clearInterval(imageSwitchTimer);
		}
		imageSwitchTimer = setInterval(function(){
			removeImage();
			currentImage++;
			if (currentImage == lastImage) 
				currentImage = 0;
			createImage();
		//$(pic[i]).animate({top: '0'}, 1000);
		//jQuery('#show-next').trigger('click');
		}, imageSwitchInterval);
        }

	  function removeImage(){
	    jQuery('#'+currentImage+'-pic').fadeOut(movingTime, function(){
		   jQuery(this).remove();
	    });
	    //jQuery('#'+currentImage+'-pic').remove();
	  }

        if (imageList != null && imageList.length > 0) {;
                var currentImage = 0;
                var lastImage = imageList.length - 1;

                // create first image
                createImage();

                //jQuery('.navigation-bar').fadeIn(fadeInTime);

                
                // init imagerotator
                initImageRotator();

        }
} 
