﻿// ==============================================================================
// ==============================================================================
//									SLIDE SHOW
// ==============================================================================
// ==============================================================================

// =======================================
// set the slide show variables
// =======================================

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 4000

// Duration of crossfade (milliseconds)
var crossFadeDuration = 3000

// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below

Pic[0] = 'images/Gallery/Pendari_Gallery_r1_c1_f2.jpg'
Pic[1] = 'images/Gallery/Pendari_Gallery_r1_c3_f2.jpg'
Pic[2] = 'images/Gallery/Pendari_Gallery_r1_c5_f2.jpg'
Pic[3] = 'images/Gallery/Pendari_Gallery_r3_c1_f2.jpg'
Pic[4] = 'images/Gallery/Pendari_Gallery_r3_c3_f2.jpg'
Pic[5] = 'images/Gallery/Pendari_Gallery_r3_c5_f2.jpg'
Pic[6] = 'images/Gallery/Pendari_Gallery_r5_c1_f2.jpg'
Pic[7] = 'images/Gallery/Pendari_Gallery_r5_c3_f2.jpg'
Pic[8] = 'images/Gallery/Pendari_Gallery_r5_c5_f2.jpg'
Pic[9] = 'images/Gallery/Pendari_Gallery_r1_c1_f3.jpg'
Pic[10] = 'images/Gallery/Pendari_Gallery_r1_c3_f3.jpg'
Pic[11] = 'images/Gallery/Pendari_Gallery_r1_c5_f3.jpg'
Pic[12] = 'images/Gallery/Pendari_Gallery_r3_c1_f3.jpg'
Pic[13] = 'images/Gallery/Pendari_Gallery_r3_c3_f3.jpg'
Pic[14] = 'images/Gallery/Pendari_Gallery_r3_c5_f3.jpg'
Pic[15] = 'images/Gallery/Pendari_Gallery_r5_c1_f3.jpg'
Pic[16] = 'images/Gallery/Pendari_Gallery_r5_c3_f3.jpg'
Pic[17] = 'images/Gallery/Pendari_Gallery_r5_c5_f3.jpg'
Pic[18] = 'images/Gallery/Pendari_Gallery_r1_c1_f4.jpg'
Pic[19] = 'images/Gallery/Pendari_Gallery_r1_c3_f4.jpg'
Pic[20] = 'images/Gallery/Pendari_Gallery_r1_c5_f4.jpg'
Pic[21] = 'images/Gallery/Pendari_Gallery_r3_c1_f4.jpg'
Pic[22] = 'images/Gallery/Pendari_Gallery_r3_c3_f4.jpg'
Pic[23] = 'images/Gallery/Pendari_Gallery_r3_c5_f4.jpg'
Pic[24] = 'images/Gallery/Pendari_Gallery_r5_c1_f4.jpg'
Pic[25] = 'images/Gallery/Pendari_Gallery_r5_c3_f4.jpg'
Pic[26] = 'images/Gallery/Pendari_Gallery_r5_c5_f4.jpg'


// =======================================
// do not edit anything below this line
// =======================================

var t;
var j = 9;
var p = Pic.length;
var imgIndex = 1;

var preLoad = new Array();
for (i = 0; i < p; i++){
   preLoad[i] = new Image();
   preLoad[i].src = Pic[i];
}

function runSlideShow(){
  
   imgIndex = imgIndex + 1;
   if (imgIndex > 3) imgIndex=1;
  

   		switch  (imgIndex) {
   			case 1:
				blendimage('blenddiv1','blendimage1', preLoad[j].src,crossFadeDuration);
				blendimage('blenddiv3','blendimage3', preLoad[j + 2].src,crossFadeDuration);
				blendimage('blenddiv5','blendimage5', preLoad[j + 4].src,crossFadeDuration);
				break; 
				
			case 2:
				blendimage('blenddiv4','blendimage4', preLoad[j + 3].src,crossFadeDuration);
				blendimage('blenddiv6','blendimage6', preLoad[j + 5].src,crossFadeDuration);
				blendimage('blenddiv8','blendimage8', preLoad[j + 7].src,crossFadeDuration);
				break;
				
   			case 3: 
				blendimage('blenddiv2','blendimage2', preLoad[j + 1].src,crossFadeDuration);
				blendimage('blenddiv7','blendimage7', preLoad[j + 6].src,crossFadeDuration);
				blendimage('blenddiv9','blendimage9', preLoad[j + 8].src,crossFadeDuration);
				break;

		}
   

   
   j = j + 3;
   if (j > (p-9)) j=0;
   
   t = setTimeout('runSlideShow()', slideShowSpeed)
  
}


function blendimage(divid, imageid, imagefile, millisec) { 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
     
    //set the current image as background 
     document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
     changeOpac(0, imageid);
	 //document.getElementById(imageid).width=0;
	 document.getElementById(imageid).src = imagefile;
	 //document.getElementById(imageid).style.opacity=0; 
	 
//	alert("hello");
    for(i = 70; i <= 100; i=i+2) { 
		//if (i==20) alert("i=0");
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed)); 
        timer++; 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 	
    var object = document.getElementById(id).style; 
	if (opacity==0) 
		object.visibility='hidden'
	else
	    object.visibility='visible';
    object.filter = "alpha(opacity=" + opacity + ")";     
    object.opacity = (opacity / 100); 
    //object.MozOpacity = (opacity / 100); 
    //object.KhtmlOpacity = (opacity / 100); 
} 

// ==============================================================================
// ==============================================================================
//								END OF SLIDE SHOW
// ==============================================================================
// ==============================================================================

 

