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])
            },
            6000);
    }
    else
        window.setTimeout(
            function(){
                ApeerImage(curent_img, old_img, op, last_inx)
            },
            10);
}

function ShowItem(divs,op, idx)
{
	if(idx==0)
	{
		HideItem(divs[divs.length-1]);	
	}
	else
	{
		 HideItem(divs[idx-1]);	
	}
	divs[idx].style.display='block';	
	op+=10;
    divs[idx].style.opacity = op/100;
    divs[idx].style.filter = 'alpha(opacity='+op+')';
	
    if(op >= 100){
		idx++;
		if(divs.length==idx)
			idx=0;

        window.setTimeout(
            function(){
                ShowItem(divs,0,idx)
            },
            6000);
    }
    else
        window.setTimeout(
            function(){
                 ShowItem(divs,op, idx)
            },
            50);	
}


function HideItem(div)
{
	div.style.display='none';
	div.style.opacity = 0.01;
	div.style.filter = 'alpha(opacity=1)';
}

            
function InitPicture (pic){
    var target = document.getElementById('rgroupshow');
	var divs=[];	
	var len=target.children.length;
	for(var i=0;i<len;i++)
	{
		if(target.children[i].tagName=='DIV')
		{			
			target.children[i].style['z-index'] = i;
			divs.push(target.children[i]);			
		}
	}
	if(divs.length==0)return;	
	ShowItem(divs,0,0);
}

addEvent(
    window,
    'load',
    function(){
        InitPicture(0);
    },
    false);
           
//window.onload = function()
//{   InitPicture(rgpics[0]);
//}

