var t
var j = 0
var p = Pic.length

var preLoad = new Array();

for (i = 0; i < p; i++) {
	   preLoad[i] = new Image();
      	   preLoad[i].src = Pic[i];
}

if (window.addEventListener)
        window.addEventListener('load', initFade, false);
else if (window.attachEvent)
         window.attachEvent('onload', initFade);

function resize(img) {
	   if (img.width < img.height) {
                 img.width = img.width * (180 / img.height);
                 img.height = 180;
	   } else {
	   	img.height = img.height * (180 / img.width);
		img.width = 180;
	   }
}

function initFade() {
	runSlideShow();
}

function runSlideShow(){
       	var imageobj = document.images.SlideShow;
	if (document.all){
		if (imageobj != null) {
        	     	document.images.SlideShow.style.filter="blendTrans(duration=" + crossFadeDuration + ")";
		        document.images.SlideShow.filters.blendTrans.Apply();
		}
      	 }
	if (imageobj != null) {
		resize(preLoad[j]);
		imageobj.width = preLoad[j].width;
		imageobj.height = preLoad[j].height;
		imageobj.src = preLoad[j].src;
			
		document.getElementById('SlideShowLink').href = preLoad[j].src;
		try {
			document.getElementById('description').innerHTML = Desc[j];
		} catch (e) {}
		document.getElementById('SlideShowLink').title = Desc[j];
	}
	
	 
    	 if (document.all){
		if (imageobj != null) {
	         	document.images.SlideShow.filters.blendTrans.Play();
		}
     	 }
	
	j = j + 1;
	if (j > (p-1)) j=0;
	t = setTimeout('runSlideShow()', slideShowSpeed); 
}

