nt=new Array()
/////////////////nt[nt.length] = "progid:DXImageTransform.Microsoft.Barn(orientation='horizontal' motion='out')";
/////////////////nt[nt.length] = "progid:DXImageTransform.Microsoft.blinds(bands=3, direction=right)";
/////////////////nt[nt.length] = "progid:DXImageTransform.Microsoft.Checkerboard(Direction='right')";
//////////////////////////////////nt[nt.length] = "progid:DXImageTransform.Microsoft.fade(duration=1,overlap=0.0)";
/////////////////nt[nt.length] = "progid:DXImageTransform.Microsoft.Inset()";
/////////////////nt[nt.length] = "progid:DXImageTransform.Microsoft.Iris(irisStyle='cross', motion='in')";
/////////////////nt[nt.length] = "progid:DXImageTransform.Microsoft.Iris(irisStyle='circle', motion='out')";
/////////////////nt[nt.length] = "progid:DXImageTransform.Microsoft.Iris(irisStyle='diamond', motion='in')";
/////////////////nt[nt.length] = "progid:DXImageTransform.Microsoft.Iris(irisStyle='plus', motion='out')";
/////////////////nt[nt.length] = "progid:DXImageTransform.Microsoft.Iris(irisStyle='star', motion='in')";
/////////////////nt[nt.length] = "progid:DXImageTransform.Microsoft.Iris(irisStyle='square', motion='out')";
/////////////////nt[nt.length] = "progid:DXImageTransform.Microsoft.Pixelate()";
/////////////////nt[nt.length] = "progid:DXImageTransform.Microsoft.RadialWipe(wipeStyle='clock') ";
/////////////////nt[nt.length] = "progid:DXImageTransform.Microsoft.RandomBars(motion='horizontal')";
/////////////////nt[nt.length] = "progid:DXImageTransform.Microsoft.Slide(bands=3, slidestyle='hide')";
/////////////////nt[nt.length] = "progid:DXImageTransform.Microsoft.Stretch(stretchStyle='pull')";
nt[nt.length] = "progid:DXImageTransform.Microsoft.Strips(Duration=1, Motion='rightdown')"
/////////////////nt[nt.length] = "progid:DXImageTransform.Microsoft.RandomDissolve()";
/////////////////nt[nt.length] = "progid:DXImageTransform.Microsoft.Spiral()";
nt[nt.length] = "progid:DXImageTransform.Microsoft.Wheel(duration=3)";
/////////////////nt[nt.length] = "progid:DXImageTransform.Microsoft.Wipe(GradientSize=1.0, wipeStyle=0, motion='forward')";
/////////////////nt[nt.length] = "progid:DXImageTransform.Microsoft.zigzag(GridSizeX=5, GridSizeY=5)";

pause=4 // seconds
gridNumX=6 // horizontal grid number, 10 max
gridNumY=6 // vertical grid number, 10 max
effectsOn=1 // 0 = off 1 = on
runNum=3 // when to run your function

// preloader
aIndex=0
var preloaded=new Array()
function initPixelImages(){
preloaded[aIndex]=new Image()
preloaded[aIndex].onload=checkLoading
preloaded[aIndex].src=pic[aIndex]
}

function checkLoading(){
aIndex++
if(aIndex!=pic.length){
setTimeout("initPixelImages()",100)
}
else{
//createGrid() // function to run
}

if(aIndex==runNum){
createGrid() // function to run
}

}
// end preloader

function createGrid(){
if(gridNumX<=0){gridNumX=1}
if(gridNumY<=0){gridNumY=1}
if(gridNumX>10){gridNumX=10}
if(gridNumY>10){gridNumY=10}
thePixelator=document.getElementById("pixelator_display")

totalWidth=thePixelator.offsetWidth
totalHeight=thePixelator.offsetHeight

if(totalWidth%gridNumX!=0){ // check to ensure totalWidth divides by gridNumX equally
totalWidth++
thePixelator.style.width=totalWidth+"px"  // if not then increase by one
createGrid()
return
}

if(totalHeight%gridNumY!=0){ // check to ensure totalHeight divides by gridNumY equally
totalHeight++
thePixelator.style.height=totalHeight+"px" 
createGrid()
return
}

gridWidth=totalWidth/gridNumX
gridHeight=totalHeight/gridNumY

totalX=gridNumX*gridNumY

gridPosX=0
gridPosY=0

gridX=[]
gridY=[]

for(var i=0;i<gridNumX;i++){
gridX[i]= -gridPosX
gridPosX+=gridWidth
}

for(var i=0;i<gridNumY;i++){ // when x and y are equal moz renders y as 50% so this second array is created to offset position y by 1 pixel
gridY[i]= -gridPosY+1
gridPosY+=gridHeight
}

num=0

for(var y=0;y<gridNumY;y++){ // create the grid within the display area

for(var x=0;x<gridNumX;x++){
newDiv=document.createElement("DIV")
newDiv.setAttribute("id","cell"+num)
newDiv.style.fontSize="8px"
newDiv.style.width=gridWidth+"px"
newDiv.style.height=gridHeight+"px"
newDiv.style.cssFloat="left"
newDiv.style.styleFloat="left"
newDiv.style.backgroundPosition=gridX[x]+'px '+gridY[y]+"px"
newDiv.style.filter
thePixelator.appendChild(newDiv)
num++
}

}

thePixelator.style.width=totalWidth+"px" 
thePixelator.style.height=totalHeight+"px" 

document.getElementById("pixelator_container").style.width=totalWidth+"px"
document.getElementById("pixelator_container").style.heigt=totalHeight+"px"

initPixelator()
}

function initPixelator(){
list=new Array()
maxNum=totalX
for(var n=0;n<maxNum;n++){
list[n]=n
}
applyEffect()
}

tran=0
count=0

function applyEffect(){
rdmNum=Math.floor(Math.random()*maxNum)
chosenNum=list.splice(rdmNum,1)
maxNum--

if(tran==nt.length){tran=0}

currentElement=document.getElementById("cell"+chosenNum)

if(currentElement.filters&&effectsOn==1){
currentElement.style.filter=nt[tran]
currentElement.filters[0].apply()
}

currentElement.style.backgroundImage="url("+pic[count]+")"

if(currentElement.filters&&effectsOn==1){
currentElement.filters[0].play(0.5)
}

t=setTimeout("applyEffect()",50)

if(maxNum==0){
clearTimeout(t)
setTimeout("nextImage()",(pause*1000)/2)
tran++
}
}

function nextImage(){
maxNum=totalX
count++
if(count>pic.length-1){count=0}
setTimeout("initPixelator()",(pause*1000)/2)
}
