/* Start of configuration  */

/*  GALLERY IMAGES - Change below numberOfEditorialImages AND/OR  numberOfWeddingImages value to add more images and thumbnails 

    Assumes main image is in the directory images/weddings/main image/ and uses for example .. 4i.jpg
    Assumes thumb nail image is in the directory images/editorial/thumbs/ and uses for example .. 4t.jpg

*/

var numberOfEditorialImages = 170;
var numberOfWeddingImages = 377;


/*  change below for animated images on home page  

     animatedImages[?]="images/main image/???.jpg";
     
     Replace the ? with the order the image is to be displayed .. must be in order 
     replace the ??? with the name of the file ( assumes it lives in images/main image/ ) 

*/



function getHomePageAnimatedImages(){

  if ( !animatedImages ){     
     animatedImages =new Array();     
    
		 animatedImages[0]="images/ani/one.jpg";
		 animatedImages[1]="images/ani/two.jpg";
		 animatedImages[2]="images/ani/three.jpg";
     animatedImages[3]="images/ani/four.jpg";
		 animatedImages[4]="images/ani/five.jpg";
		 animatedImages[5]="images/ani/six.jpg";
		 animatedImages[6]="images/ani/seven.jpg";
		 animatedImages[7]="images/ani/eight.jpg";
     animatedImages[8]="images/ani/nine.jpg";     
     
	 }
	 
	 return animatedImages;

}

function getWeddingIntroPageAnimatedImages(){

  if ( !animatedImages ){     
     animatedImages =new Array();     
    
     animatedImages[0]="images/wedding/ani/one.jpg";
     animatedImages[1]="images/wedding/ani/two.jpg";
     animatedImages[2]="images/wedding/ani/three.jpg";
     animatedImages[3]="images/wedding/ani/four.jpg";
     animatedImages[4]="images/wedding/ani/five.jpg";
     animatedImages[5]="images/wedding/ani/six.jpg";
     animatedImages[6]="images/wedding/ani/seven.jpg";
     animatedImages[7]="images/wedding/ani/eight.jpg";
     animatedImages[8]="images/wedding/ani/nine.jpg";
     
     
   }
   
   return animatedImages;

}

function getEditorialIntroPageAnimatedImages(){

  if ( !animatedImages ){     
     animatedImages =new Array();     
    
     animatedImages[0]="images/editorial/ani/one.jpg";
     animatedImages[1]="images/editorial/ani/two.jpg";
     animatedImages[2]="images/editorial/ani/three.jpg";
     animatedImages[3]="images/editorial/ani/four.jpg";
     animatedImages[4]="images/editorial/ani/five.jpg";
     animatedImages[5]="images/editorial/ani/six.jpg";
     animatedImages[6]="images/editorial/ani/seven.jpg";
     animatedImages[7]="images/editorial/ani/eight.jpg";
     animatedImages[8]="images/editorial/ani/nine.jpg";
     
     
   }
   
   return animatedImages;

}


/* End of configuration  */





var animatedImages; 
var imageLink ="";
var homeAnimatedHTML ="";
var weddingsAnimatedHTML ="";
var editorialAnimatedHTML ="";




function loadWeddingPorfolioThumbnails(  ){

  loadPortfolioThumbnails('wedding', numberOfWeddingImages );
}

function loadEditorialPorfolioThumbnails(  ){

  loadPortfolioThumbnails('editorial', numberOfEditorialImages );
}


function loadPortfolioThumbnails( imageType, numberOfImages  ){
  
  var imagePostfix="i";
  var thumbnailPostfix="t";
  
  var baseDir = "images/" + imageType ;
  
  var imageDir = baseDir + "/main image/";
  var thumbDir = baseDir + "/thumbs/";
  
  var imageExtension = ".jpg";
  var thumbExtension = ".jpg";
  
  
  if (imageLink == ""){
    
		  for (var loop=0; loop < numberOfImages; loop++ ){		    
		    var imageNumber = loop+1;
		    
		    imageLink += "<a href=\"";
		    imageLink += imageDir;
		    imageLink += imageNumber;
		    imageLink += imagePostfix;
		    imageLink += imageExtension;
		       
		    imageLink += "\" rel=\"lightbox[portfolio]\" ><img  class=\"portfolioThumb\" src=\"";    
		    imageLink += thumbDir;
		    imageLink += imageNumber;
		    imageLink += thumbnailPostfix;
		    imageLink += thumbExtension;    
		    imageLink += "\"  alt=\"\" /></a>";  
		    imageLink += "\n";
		  }		 
		  
		  if (imageLink != ""){		    
		    var thumbnailArea = document.getElementById( 'portfolioThumbnails' );
		    
		    if (thumbnailArea){
		      thumbnailArea.innerHTML= "" ;
		      thumbnailArea.innerHTML= imageLink ;  
		    }		    
		  }  
 } 
}

function startGallery() {
        var myGallery = new gallery($('homePageGallery'), {
          timed: true,
          showArrows: false,
          showInfopane: false,
          showCarousel: false,
          embedLinks: true,
          delay: 4000
        });
      }



function buildAnimatedHTML( animatedImages ){         
      
      for ( loop = 0; loop < animatedImages.length; loop++ ){       
        var imagePathAndName = animatedImages[loop];
        
                
        homeAnimatedHTML += "\n<div class=\"imageElement\">";
        homeAnimatedHTML += "\n<a href=\"gallery.htm\" title=\"\" class=\"open\"></a>";
        homeAnimatedHTML += "\n<img src=\"";
        homeAnimatedHTML += imagePathAndName;
        homeAnimatedHTML += "\" class=\"full\"  alt=\"www.tjrphotography.co.uk\" ></img>";
        
        homeAnimatedHTML += "\n<img src=\"";
        homeAnimatedHTML += imagePathAndName;
        homeAnimatedHTML += "\" class=\"thumbnail\"  alt=\"www.tjrphotography.co.uk\" ></img>";          
           
        homeAnimatedHTML += "\n</div>";         
        
      }    
                
        var animatedArea = document.getElementById( 'homePageGallery' );
        
        if (animatedArea ){
          animatedArea.innerHTML= "" ;
          animatedArea.innerHTML= homeAnimatedHTML ;  
        }                  
      
      startGallery();     
}






function loadHomePageAnimatedImages(  ){

     if (homeAnimatedHTML == ""){    
        buildAnimatedHTML(getHomePageAnimatedImages());      
     } 
}

function loadWeddingPageAnimatedImages(  ){

     if (weddingsAnimatedHTML == ""){    
        buildAnimatedHTML( getWeddingIntroPageAnimatedImages() );      
     } 
}

function loadEditorialPageAnimatedImages(  ){

     if (editorialAnimatedHTML == ""){    
        buildAnimatedHTML( getEditorialIntroPageAnimatedImages());      
     } 
}


function goHome(){

location.href='index.html';

}








  