/*  SOME NOTES 
glo_curimg is the current image global variable
*/

var thisDim = 0;	// start at 1, because zero is the init image
var intDoodley; 	// var for the clearint
var crossFadeDuration = 5;	// fade duration
var imageDispDuration = 6000; // display duration
//slideImg[slideImg.length-1].onLoad = beginTrans();

function dynSlide() {
	dynNext();
	intDoodley = window.setInterval(dynNext,imageDispDuration);
}

function killSlide() {
	window.clearInterval(intDoodley);
}

function dynNext() {
	if(glo_curimg == mediaid.length-1) {
		dynLoad(0);
	} else {
		dynLoad(glo_curimg+1);
	}
}

function dynPrev() {
	if(glo_curimg == 0) {
		dynLoad(mediaid.length-1);
	} else {
		dynLoad(glo_curimg-1);
	}
}

function dynLoad(i) {
	window.status = 'Loading Image...';
	lgImg=new Image();
    lgImg.onload=doTrans; 
	lgImg.src=lg[i];
	document.getElementById("largeimg").src = lg[i];
	document.getElementById("imgtitle").innerHTML = mtitle[i];
	document.getElementById("copyright").innerHTML = cpy[i];
	document.getElementById("imgcaption").innerHTML = mcap[i];
	glo_curimg = i;
	if (hasSalesItems[i] == 1)  {
		document.getElementById("imgpurchase").style.display = 'block';
	} else {
		document.getElementById("imgpurchase").style.display = 'none';	
	}
}

	
function popPurchase() {
	document.location = './index.htm?purchase='+mediaid[glo_curimg];	
}

function doTrans() {
	if (document.all && (navigator.userAgent.indexOf('MSIE 5') == -1 && navigator.userAgent.indexOf('Macintosh') == -1)){  
		document.images.largeimg.style.filter="blendTrans(duration=2)";	
		document.images.largeimg.filters.blendTrans(duration=crossFadeDuration).Apply();
   		document.images.largeimg.filters.blendTrans.Play();
   		document.images.largeimg.src=lgImg.src;  
		window.status='';   
   	} else {
		 
		 // the following will correct an image transition sizing issue on the mac

		 document.images.largeimg.src=lgImg.src;
		 window.status=''; 
		 if(window.location.search.indexOf('debug') > -1) {
			alert(document.images.largeimg.width + ' ' + lgImg.width); 
		 }		 
		 if(navigator.userAgent.indexOf('Macintosh') > -1 && document.images.largeimg.width != lgImg.width && lgImg.width > 0) {
			 document.images.largeimg.width = lgImg.width;
		 }
		   
	}
	window.status ='';
	document.getElementById("largeimg").src = lg[glo_curimg];
	document.getElementById("imgtitle").innerHTML = mtitle[glo_curimg];
	document.getElementById("copyright").innerHTML = cpy[glo_curimg];
	document.getElementById("imgcaption").innerHTML = mcap[glo_curimg];
	
	if (hasSalesItems[glo_curimg] == 1)  {
		document.getElementById("imgpurchase").style.display = 'block';
	} else {
		document.getElementById("imgpurchase").style.display = 'none';	
	}
	//window.scrollTo(0,0);
}


