function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; 
	for(i=0; a&&i < a.length && (x = a[i]) && x.oSrc; i++){
		if(x.name != "main" && x.name != "cap")
			x.src=x.oSrc;
	}
}

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 MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


var imgArray = new Array(
	"images/home/random/photo1.jpg",
	"images/home/random/photo2.jpg",
	"images/home/random/photo3.jpg",
	"images/home/random/photo4.jpg",
	"images/home/random/photo5.jpg",
	"images/home/random/photo6.jpg",
	"images/home/random/photo7.jpg",
	"images/home/random/photo8.jpg",
	"images/home/random/photo9.jpg",
	"images/home/random/photo10.jpg",
	"images/home/random/photo11.jpg",
	"images/home/random/photo12.jpg",
	"images/home/random/photo13.jpg",
	"images/home/random/photo14.jpg"
);

var captArray = new Array(
	"images/home/captions/photo1.gif",
	"images/home/captions/photo2.gif",
	"images/home/captions/photo3.gif",
	"images/home/captions/photo4.gif",
	"images/home/captions/photo5.gif",
	"images/home/captions/photo6.gif",
	"images/home/captions/photo7.gif",
	"images/home/captions/photo8.gif",
	"images/home/captions/photo9.gif",
	"images/home/captions/photo10.gif",
	"images/home/captions/photo11.gif",
	"images/home/captions/photo12.gif",
	"images/home/captions/photo13.gif",
	"images/home/captions/photo14.gif"
);

var orderArray = new Array();
for(i = 0; i < imgArray.length; i++){
	orderArray[i] = i;
}

var img_num = 0;
var randomArray = new Array();
// first image isnt so random
//randomArray[img_num] = orderArray.splice(0,1);
randomArray[img_num] = orderArray[0];
//since macIE doesnt support splice() remove the entry with the code below
	for(i=0; i<orderArray.length; i++) orderArray[i] = orderArray[i+1];
	orderArray.length = orderArray.length - 1;

img_num ++;

while(orderArray.length > 0){
	
	//randomArray[img_num] = orderArray.splice(Math.round(Math.random() * (orderArray.length - 1)),1);
	// since macIE doesnt support splice, the value read, then removed by copying over and popping
	var rand = Math.round(Math.random() * (orderArray.length - 1));
	randomArray[img_num] = orderArray[rand];
		for(i=rand; i<orderArray.length; i++) orderArray[i] = orderArray[i+1];
		orderArray.length = orderArray.length - 1;

	img_num ++;
}

//reset this to 0 for looping
img_num = 0;

function swap_main(){
	img_num ++;	
	if(img_num >= imgArray.length)img_num = 0;

	MM_swapImage('main','', imgArray[randomArray[img_num]],1);
	MM_swapImage('capt','', captArray[randomArray[img_num]],1);
	
	// loop tha butta'
	setTimeout('swap_main()', 7000);
}