
	var iLastSelectedImage = null;
	var count_pict = arr_pict_url.length;
	
	if(count_in_str > count_pict)
	{
	    count_in_str = count_pict;
	}
	var end_pict = count_pict - 1;
	var start = 0;
	var end = count_in_str-1;
	var step = 0;
	
	function show_picture()
	{
	    //alert(step);
	    str='';
	    start += step;
	    end += step;
	    var iCounter = 0
    
    	sClickEvents = '';
	    if ( start > 0 ) {
	    	//$$('img_left').src = aButtons['left']['on'].src;
	    	$$('img_left_on').style.display = 'block';
	    	$$('img_left_off').style.display = 'none';
	    }
	    if ( end < end_pict ) {
	    	//$$('img_right').src = aButtons['right']['on'].src;
	    	$$('img_right_on').style.display = 'block';
	    	$$('img_right_off').style.display = 'none';
	    }
		
	    for(i=start;i<=end;i++)
	    {
	    	
	        if(end >= end_pict)
	        {
	        	//$$('img_right').src = aButtons['right']['off'].src;
	        	$$('img_right_off').style.display = 'block';
	        	$$('img_right_on').style.display = 'none';
	        }

	        if(start==0)
	        {
	        	$$('img_left_off').style.display = 'block';
	        	$$('img_left_on').style.display = 'none';
	        }
	        
    		if ( typeof arr_pict_url[i] == 'undefined' ) break;
    		$$( 'photoImage' + iCounter ).src = arr_pict_url[i];
    		$$( 'photoImage' + iCounter ).title = arr_pict_alt[i];
    		$$( 'photoImage' + iCounter ).alt = arr_pict_alt[i];
    		var sTitle = ( arr_pict_alt[i].length >= 0 && arr_pict_alt[i].length < 20 ? arr_pict_alt[i] : ( arr_pict_alt[i].substr( 0,20 ) ) + '...' );
    		$$( 'imageTitle' + iCounter ).innerHTML = sTitle;
    		
    		sClickEvents += "$$( 'photoImage" + iCounter + "').onclick = function(){showBigImg( " + i + ", " + iCounter + " )};";
			

	        iCounter++;
	    }
	    eval( sClickEvents );
	    
	
	}
	function move_picture(go)
	{
	    //alert(go);
	    //alert('st='+start+',end='+end);
	    
	    if((go > 0 && end < end_pict) || (go < 0 && start > 0))
	    {
	        step = go;
	        show_picture();
	        if ( $$( 'photoImage' + iLastSelectedImage ) != null ) {
	        	$$( 'photoImage' + iLastSelectedImage ).className = 'gallery photo pointer';
	        }
//	        alert( iLastSelectedImage )
//	        alert( iLastSelectedImage + '_' + (iLastSelectedImage-go) )
	        if ( $$( 'photoImage' + (iLastSelectedImage-go) ) != null ) {
	        	$$( 'photoImage' + ( iLastSelectedImage-go ) ).className = 'gallery photo selected';
	        }
	        iLastSelectedImage = iLastSelectedImage-go;
	        
	        timerId= setTimeout('move_picture('+go+')', period);
	    }
	    else
	    {
	        step = 0;
	        clearTimeout(timerId);
	    }
	
	}
	function stopTimer()
	{
	    clearTimeout(timerId);
	}
	
	function showBigImg( iNumber, iFixedImageNum ){
		$$( 'bigImage' ).src = arr_pict_big_url[iNumber];
		if ( iLastSelectedImage != null && $$( 'photoImage' + iLastSelectedImage ) ) {
			$$( 'photoImage' + iLastSelectedImage ).className = 'gallery photo pointer';
		}
		
		$$( 'photoImage' + iFixedImageNum ).className = 'gallery photo selected';
		iLastSelectedImage = iFixedImageNum;
		$$( 'titleBigImage' ).innerHTML = arr_pict_alt[iNumber];
		widthCalculate( iNumber );
	}
	
	function widthCalculate( iNumber ){
		var h = arr_pict_height[iNumber];
		var w = arr_pict_width[iNumber];
		var height = IMAGE_HEIGHT;
		var width = (height/h)*w;
		if ( width > IMAGE_MAX_WIDTH ){
			width 	= IMAGE_MAX_WIDTH;
			height 	= (width/w)*h;
			$$( 'bigImage' ).style.width = IMAGE_MAX_WIDTH + 'px';
			$$( 'bigImage' ).style.height = height + 'px';
			$$( 'bigImage' ).style.marginBottom = ( IMAGE_HEIGHT - height ) + 'px';
		} else {
			$$( 'bigImage' ).style.width = '';
			$$( 'bigImage' ).style.height = IMAGE_HEIGHT + 'px';
			$$( 'bigImage' ).style.marginBottom = '';
		}
	}
