//MM_preloadImages('/global/images/promotions/product01.jpg','/global/images/promotions/product02.jpg','/global/images/promotions/product03.jpg','/global/images/promotions/product04.jpg','/global/images/promotions/product05.jpg');
//MM_preloadImages('/global/images/promotions/1_1.jpg','/global/images/promotions/1_2.jpg','/global/images/promotions/1_3.jpg','/global/images/promotions/2_1.jpg','/global/images/promotions/2_2.jpg','/global/images/promotions/2_3.jpg','/global/images/promotions/4_1.jpg','/global/images/promotions/4_2.jpg','/global/images/promotions/4_3.jpg','/global/images/promotions/5_1.jpg','/global/images/promotions/5_2.jpg','/global/images/promotions/5_3.jpg');
MM_preloadImages('/global/images/promotions/00.jpg','/global/images/promotions/01.jpg','/global/images/promotions/02.jpg','/global/images/promotions/03.jpg','/global/images/promotions/04.jpg','/global/images/promotions/05.jpg','/global/images/promotions/06.jpg');

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function rotateIndexReset()
{
        cnt = divContent.length;
        
        for (i=0; i<cnt; i++)
        {
             ri = 'imageRotateIndex' + i;
             if (document.getElementById(ri))
             {
                document.getElementById(ri).className = 'imageRotateIndex';
             }
        }
}

function rotateIndexSetCurrent(divid)
{
        if (document.getElementById(divid))
        {
            document.getElementById(divid).className = 'imageRotateIndexCurrent';
        }
}

function rotateDiv(divid, randomize)
{
    
        cnt = divContent.length;
        rotateLayer = document.getElementById(divid);
        
        rotateIndexReset();
        
        if (cnt < 2) return;
        if (randomize == true)
        {
            rand = Math.floor(Math.random()*cnt);
            
            if (rand != divRotateCurrentKey)
            {
                divRotateCurrentKey = rand;
            }
            else
            {
                rotateDiv(divid, true);
            }
            
            rotateLayer.innerHTML = divContent[rand];
            ri = 'imageRotateIndex' + rand;
            rotateIndexSetCurrent(ri);
        }
        else
        {
            if (divRotateCurrentKey == undefined)
            {
                rotateLayer.innerHTML = divContent[0];
                divRotateCurrentKey = 0;
            }
            else
            {

                if (divRotateCurrentKey<(cnt-1))
                {
                    divRotateCurrentKey++;
                }
                else
                {
                    divRotateCurrentKey = 0;
                }
                rotateLayer.innerHTML = divContent[divRotateCurrentKey];
                ri = 'imageRotateIndex' + divRotateCurrentKey;
                rotateIndexSetCurrent(ri);
            }
        }
}

function showSpecificRotateDiv(divid, key)
{
        rotateIndexReset();
        
        clearInterval(imageRotateInterval);
        rotateLayer = document.getElementById(divid);
        rotateLayer.innerHTML = divContent[key];
        
        ri = 'imageRotateIndex' + key;
        rotateIndexSetCurrent(ri);
}
