$(document).ready(function(){
    var count = $(zoom_main+' img').length;

	if (ImgResize)
    $(zoom_main+' img')
        .css({
            cursor: 'pointer'
        })
        .click(function(){
        $(BigImgName).attr('src', $(this).attr('src').replace(/small/g, 'big'));
		return false;
    });
    
    $(zoom_right).click(function(){
        if (!scroll_enabled)
            return false;
    
        var pos =  0 - parseInt(
                parseInt($(zoom_main).css('left'))
                /
                wid
            ) + RightOffset;
        
        if (pos >= count)
            return false;

        scroll_enabled = false;

        $(zoom_main).animate({
            left: parseInt($(zoom_main).css('left')) - wid + 'px' 
        }, 500, function(){
            scroll_enabled = true;
        });
        
		if(animate)
        $(zoom_main+' img').eq(pos).animate({
            height: ZoomHeight + 'px',
            width:  ZoomWidth + 'px',
            top: ZoomTop+'px'
        }, 500);
        
		if(animate)
        $(zoom_main+' img').eq(pos + 1)
        .add($(zoom_main+' img').eq(pos - 1))
        .animate({
            height: ImgHeight + 'px',
            width:  ImgWidth + 'px',
            top:    ZoomTopNone+'px'
        }, 500);
    
        return false;
    });
    
    $(zoom_left).click(function(){
        if (!scroll_enabled)
            return false;

        var pos =  0 - parseInt(
                parseInt($(zoom_main).css('left'))
                /
                wid
            ) + LeftOffset;
        
        if (pos < 0)
            return false;
            
        scroll_enabled = false;

        $(zoom_main).animate({
            left: parseInt($(zoom_main).css('left')) + wid + 'px' 
        }, 500, function(){
            scroll_enabled = true;
        });
        
		if(animate)
        $(zoom_main+' img').eq(pos).animate({
            height: ZoomHeight + 'px',
            width:  ZoomWidth + 'px',
            top: ZoomTop+'px'
        }, 500);
        
		if(animate)
        $(zoom_main+' img').eq(pos + 1)
        .add($(zoom_main+' img').eq(pos - 1))
        .animate({
            height: ImgHeight + 'px',
            width:  ImgWidth + 'px',
            top:    ZoomTopNone+'px'
        }, 500);
        
        return false;
    });
});
