// JavaScript Document
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 3000;

// Duration of crossfade (seconds)
var crossFadeDuration = 3;
var t;
var j = 0;
var p = Pic.length;
var maxheight = 300;

var preLoad = new Array();
for (i = 0; i < p; i++){
   preLoad[i] = new Image();
   preLoad[i].src = Pic[i];
}
function nextImage(){
	j=j+1;
	if (j>(p-1)){j=0;}
	ImageSwap(j);
}
function prevImage(){
	j=j-1;
	if(j<0){ j=(p-1);}
	ImageSwap(j);
}
function ImageSwap(k){
	clearTimeout(t);
	j = k;
   if (document.all){
	  document.images.MainImage.style.filter="blendTrans(duration=2)";
	  document.images.MainImage.style.filter="blendTrans(duration=crossFadeDuration)";
	  document.images.MainImage.filters.blendTrans.Apply();      
   }
   document.images.MainImage.src = preLoad[j].src;
   
   if(preLoad[j].height > maxheight){
	   document.images.MainImage.style.height = maxheight + "px";
//	   document.images.MainImage.removeAttribute("height");

   } else {
	   document.images.MainImage.style.height = preLoad[j].height + "px";
   }
   
   if (document.all){
	  document.images.MainImage.filters.blendTrans.Play();
   }
}
function stopSlideShow(){
	j=j-1;
	if(j<0){ j=(p-1);}
	clearTimeout(t);
	document.getElementById('run_stop_button').innerHTML = '<a href="javascript:runSlideShow();" title="Play"><img border="0" src="/listings_gsmls/run_play.jpg"></a>';
}
function runSlideShow(){
	document.getElementById('run_stop_button').innerHTML = '<a href="javascript:stopSlideShow();" title="Stop"><img border="0" src="/listings_gsmls/stop_play.jpg"></a>';
   if (document.all){
	  document.images.MainImage.style.filter="blendTrans(duration=2)";
	  document.images.MainImage.style.filter="blendTrans(duration=crossFadeDuration)";
	  document.images.MainImage.filters.blendTrans.Apply();
   }
   document.images.MainImage.src = preLoad[j].src;
   if(preLoad[j].height > maxheight){
	   document.images.MainImage.style.height = maxheight + "px";
   } else {
	   document.images.MainImage.style.height = preLoad[j].height + "px";
   }

   if (document.all){
	  document.images.MainImage.filters.blendTrans.Play();
   }
   j = j + 1;
   if (j > (p-1)){ 
		j=0;
	}
   t = setTimeout('runSlideShow()', slideShowSpeed);
}

