var currContainer=0;
var maxContainer=1
var currSlide=0;
var maxSlide=0;
var ss;
function slideShow(show){
	clearTimeout(ss);
	currSlide=0;
	initGallery(show);
	
	//store number of slides
	maxSlide=galleryArr.length-1;
	
	//show first slide
/*$('#slide'+currContainer).attr('src',galleryArr[currSlide]);
	$('#slideshow'+currContainer).attr('z-index',2).fadeIn(1000,function(){});

	//increment counters
	currSlide+=1;if(currSlide>maxSlide){currSlide=0;}
	currContainer+=1;if(currContainer>maxContainer){currContainer=0;}

	//call slide changer
	ss=setTimeout('runSlideShow();',5000); */
	
	runSlideShow();
}
function runSlideShow(){
	var sl=currContainer;

	//set source of new image
	$('#slide'+sl).attr('src',galleryArr[currSlide]);

	//find next slide number
	currSlide+=1;if(currSlide>maxSlide){currSlide=0;}
	//find next container number
	currContainer+=1;if(currContainer>maxContainer){currContainer=0;}

	$('#slideshow'+currContainer).attr('z-index',1);
	$('#slideshow'+sl).attr('z-index',2).fadeIn(1000,function(){$('#slideshow'+currContainer).fadeOut(1000)});

	ss=setTimeout('runSlideShow();',5000);
}


var galleryArr=new Array()

function initGallery(show){
	//clear prev slide show
	galleryArr=new Array();

	//set images for current slide show
	if(show=='home'){
           //HOME
		galleryArr[0]=["images/gallery/front.jpg"]
		galleryArr[1]=["images/gallery/front3.jpg"]
                galleryArr[2]=["images/gallery/cakes/cake3.jpg"]
                galleryArr[3]=["images/gallery/cakes/cake5.jpg"]
                galleryArr[4]=["images/gallery/catering/catering2.jpg"]
                galleryArr[5]=["images/gallery/art/art1.jpg"]
                galleryArr[6]=["images/gallery/cupboard/cupboard2.jpg"]
                galleryArr[7]=["images/gallery/1.jpg"]
	} else if(show=='es'){
          //STAFF
		galleryArr[0]=["images/gallery/menu/menu2.jpg"]
		galleryArr[1]=["images/gallery/menu/menu3.jpg"]
		galleryArr[2]=["images/gallery/menu/menu4.jpg"]
		galleryArr[2]=["images/gallery/menu/menu1.jpg"]

	} else if(show=='company'){
          // BURNCH
		galleryArr[0]=["images/gallery/company/company1.jpg"]
		galleryArr[1]=["images/gallery/company/company2.jpg"]

	} else if(show=='dr'){
          // PATISSERIE
		galleryArr[0]=["images/gallery/1.jpg"]
		galleryArr[1]=["images/gallery/company/company1.jpg"]
		galleryArr[2]=["images/gallery/cakes/cake1.jpg"]
		galleryArr[3]=["images/gallery/menu/menu2.jpg"]
	} else if(show=='location'){
          // LOCATION
		galleryArr[0]=["images/gallery/gmap.jpg"]

	} else if(show=='location1'){
		galleryArr[0]=["images/gallery/exterior3.jpg"]
		galleryArr[1]=["images/gallery/nbi4.jpg"]
		galleryArr[2]=["images/gallery/nbi3.jpg"] 
	} else if(show=='ph'){
          // GALLERY
           	galleryArr[0]=["uploadpictures/IMG_0521.jpg"]
		galleryArr[1]=["images/gallery/cakes/cake1.jpg"]
		galleryArr[2]=["uploadpictures/IMG_0283.jpg"]
		galleryArr[3]=["uploadpictures/IMG_0288.jpg"]
		galleryArr[4]=["uploadpictures/IMG_0442.jpg"]
		galleryArr[5]=["uploadpictures/IMG_0463.jpg"]
		galleryArr[6]=["uploadpictures/IMG_0509.jpg"]
		galleryArr[7]=["uploadpictures/IMG_0521.jpg"]
		galleryArr[8]=["uploadpictures/IMG_0578.jpg"]
		galleryArr[9]=["uploadpictures/IMG_0517.jpg"]

	}
       else if(show=='cakes'){
          // MENU
          	galleryArr[0]=["images/gallery/cakes/cake3.jpg"]
		galleryArr[1]=["images/gallery/cakes/cake1.jpg"]

         	galleryArr[2]=["images/gallery/cakes/cake4.jpg"]
	}
       else if(show=='catering'){
          // MENU
		galleryArr[0]=["images/gallery/catering/catering2.jpg"]

	}
	
       else if(show=='contact'){
          // MENU
	galleryArr[0]=["images/gallery/contactus.jpg"]
	}
       else if(show=='art'){
          // MENU
		galleryArr[0]=["images/gallery/art/art1.jpg"]
                galleryArr[1]=["images/gallery/front2.jpg"]

        }
         else if(show=='newmenu5'){
          // MENU
		galleryArr[0]=["images/gallery/cofee.jpg"]
	}
        else if(show=='np'){
          // NEWS AND PRESS
			galleryArr[0]=["images/gallery/press.jpg"]
	}
}
