function ApeerImage(curent_img, old_img, op, last_inx){
    op+=10;
    curent_img.style.opacity = op/100;
    curent_img.style.filter = 'alpha(opacity='+op+')';
    if(op == 100){
        if(old_img){
            try{
                old_img.removeNode(true);
            }
            catch(e){
                if (old_img.parentNode)
                    old_img.parentNode.removeChild(old_img);
            }                        
        } 
        if(rgpics.length == last_inx+1)
            last_inx = 0;
        else
            last_inx++;
        window.setTimeout(
            function(){
                InitPicture(rgpics[last_inx])
            },
            10000);
    }
    else
        window.setTimeout(
            function(){
                ApeerImage(curent_img, old_img, op, last_inx)
            },
            10);
}
            
function InitPicture (pic){
    var target = document.getElementById('rgroupshow');
    var n_img = document.createElement('IMG');
    var old_img = target.firstChild;
    n_img.src = pic.src;
    n_img.width = rgwidth;
    n_img.height = rgheight;
    n_img.hspace = 0;
    n_img.style.position = 'absolute';
    n_img.style.opacity = 0.01;
    n_img.style.filter = 'alpha(opacity=1)';
    target.appendChild(n_img,target.firstChild);
    ApeerImage(n_img,old_img,0,rgpics.indexOf(pic));
}

addEvent(
    window,
    'load',
    function(){
        InitPicture(rgpics[0]);
    },
    false);
           
//window.onload = function()
//{   InitPicture(rgpics[0]);
//}

