
var photoGalleryList = new Array(26);


var photoGallery_39 = new Array("2011_06_14_4","21","IMG_",".JPG","2011 Vinayagar <br>Festival Day 25 Part 4");
photoGalleryList[39] = photoGallery_39;

var photoGallery_38 = new Array("2011_06_14_3","39","IMG_",".JPG","2011 Vinayagar <br>Festival Day 25 Part 3");
photoGalleryList[38] = photoGallery_38;

var photoGallery_37 = new Array("2011_06_14_2","39","IMG_",".JPG","2011 Vinayagar <br>Festival Day 25 Part 2");
photoGalleryList[37] = photoGallery_37;

var photoGallery_36 = new Array("2011_06_14","39","IMG_",".JPG","2011 Vinayagar <br>Festival Day 25 Part 1 (Theertham Festival)");
photoGalleryList[36] = photoGallery_36;

var photoGallery_35 = new Array("2011_06_13_5","21","IMG_",".JPG","2011 Vinayagar <br>Festival Day 24 Part 5 (Ther Festival)");
photoGalleryList[35] = photoGallery_35;

var photoGallery_34 = new Array("2011_06_13_4","39","IMG_",".JPG","2011 Vinayagar <br>Festival Day 24 Part 4 (Ther Festival)");
photoGalleryList[34] = photoGallery_34;

var photoGallery_33 = new Array("2011_06_13_3","39","IMG_",".JPG","2011 Vinayagar <br>Festival Day 24 Part 3 (Ther Festival)");
photoGalleryList[33] = photoGallery_33;

var photoGallery_32 = new Array("2011_06_13_2","39","IMG_",".JPG","2011 Vinayagar <br>Festival Day 24 Part 2 (Ther Festival)");
photoGalleryList[32] = photoGallery_32;

var photoGallery_31 = new Array("2011_06_13","39","IMG_",".JPG","2011 Vinayagar <br>Festival Day 24 Part 1 (Ther Festival)");
photoGalleryList[31] = photoGallery_31;

var photoGallery_30 = new Array("2011_06_12_4","39","IMG_",".JPG","2011 Vinayagar <br>Festival Day 23 Part 4 (Sapparam Festival)");
photoGalleryList[30] = photoGallery_30;

var photoGallery_29 = new Array("2011_06_12_3","39","IMG_",".JPG","2011 Vinayagar <br>Festival Day 23 Part 3 (Sapparam Festival)");
photoGalleryList[29] = photoGallery_29;

var photoGallery_28 = new Array("2011_06_12_2","39","IMG_",".JPG","2011 Vinayagar <br>Festival Day 23 Part 2 (Sapparam Festival)");
photoGalleryList[28] = photoGallery_28;

var photoGallery_27 = new Array("2011_06_12","39","IMG_",".JPG","2011 Vinayagar <br>Festival Day 23 Part 1 (Sapparam Festival)");
photoGalleryList[27] = photoGallery_27;

var photoGallery_26 = new Array("2011_06_11_3","44","IMG_",".JPG","2011 Vinayagar <br>Festival Day 22 Part 3 (Veddai Festival)");
photoGalleryList[26] = photoGallery_26;

var photoGallery_25 = new Array("2011_06_11_2","44","IMG_",".JPG","2011 Vinayagar <br>Festival Day 22 Part 2 (Veddai Festival)");
photoGalleryList[25] = photoGallery_25;

var photoGallery_24 = new Array("2011_06_11","45","IMG_",".JPG","2011 Vinayagar <br>Festival Day 22 Part 1 (Veddai Festival)");
photoGalleryList[24] = photoGallery_24;

var photoGallery_23 = new Array("2011_06_10_3","40","IMG_",".JPG","2011 Vinayagar <br>Festival Day 21 Part 3 (Mango Festival)");
photoGalleryList[23] = photoGallery_23;

var photoGallery_22 = new Array("2011_06_10_2","41","IMG_",".JPG","2011 Vinayagar <br>Festival Day 21 Part 2 (Mango Festival)");
photoGalleryList[22] = photoGallery_22;

var photoGallery_21 = new Array("2011_06_10","42","IMG_",".JPG","2011 Vinayagar <br>Festival Day 21 Part 1 (Mango Festival)");
photoGalleryList[21] = photoGallery_21;

var photoGallery_20 = new Array("2011_06_09","30","IMG_",".JPG","2011 Vinayagar <br>Festival Day 20");
photoGalleryList[20] = photoGallery_20;

var photoGallery_19 = new Array("2011_06_08","27","IMG_",".JPG","2011 Vinayagar <br>Festival Day 19");
photoGalleryList[19] = photoGallery_19;

var photoGallery_18 = new Array("2011_06_07","39","IMG_",".JPG","2011 Vinayagar <br>Festival Day 18");
photoGalleryList[18] = photoGallery_18;

var photoGallery_17 = new Array("2011_06_06_2","47","IMG_",".JPG","2011 Vinayagar <br>Festival Day 17 Part 2");
photoGalleryList[17] = photoGallery_17;

var photoGallery_16 = new Array("2011_06_06","47","IMG_",".JPG","2011 Vinayagar <br>Festival Day 17 Part 1");
photoGalleryList[16] = photoGallery_16;

var photoGallery_15 = new Array("2011_06_05","43","IMG_",".JPG","2011 Vinayagar <br>Festival Day 16");
photoGalleryList[15] = photoGallery_15;

var photoGallery_14 = new Array("2011_06_04","29","IMG_",".JPG","2011 Vinayagar <br>Festival Day 15");
photoGalleryList[14] = photoGallery_14;

var photoGallery_13 = new Array("2011_06_03","37","IMG_",".JPG","2011 Vinayagar <br>Festival Day 14");
photoGalleryList[13] = photoGallery_13;

var photoGallery_12 = new Array("2011_06_02","14","IMG_",".JPG","2011 Vinayagar <br>Festival Day 13");
photoGalleryList[12] = photoGallery_12;

var photoGallery_11 = new Array("2011_06_01","14","IMG_",".JPG","2011 Vinayagar <br>Festival Day 12");
photoGalleryList[11] = photoGallery_11;

var photoGallery_10 = new Array("2011_05_31","6","IMG_",".JPG","2011 Vinayagar <br>Festival Day 11");
photoGalleryList[10] = photoGallery_10;

var photoGallery_9 = new Array("2011_05_30","34","IMG_",".JPG","2011 Vinayagar <br>Festival Day 10");
photoGalleryList[9] = photoGallery_9;

var photoGallery_8 = new Array("2011_05_29","21","IMG_",".JPG","2011 Vinayagar <br>Festival Day 9");
photoGalleryList[8] = photoGallery_8;

var photoGallery_7 = new Array("2011_05_28","59","IMG_",".JPG","2011 Vinayagar <br>Festival Day 8");
photoGalleryList[7] = photoGallery_7;

var photoGallery_6 = new Array("2011_05_27","30","IMG_",".JPG","2011 Vinayagar <br>Festival Day 7");
photoGalleryList[6] = photoGallery_6;

var photoGallery_5 = new Array("2011_05_26","37","IMG_",".JPG","2011 Vinayagar <br>Festival Day 6");
photoGalleryList[5] = photoGallery_5;

var photoGallery_4 = new Array("2011_05_25","14","IMG_",".JPG","2011 Vinayagar <br>Festival Day 5");
photoGalleryList[4] = photoGallery_4;

var photoGallery_3 = new Array("2011_05_23","45","IMG_",".JPG","2011 Vinayagar <br>Festival Day 3");
photoGalleryList[3] = photoGallery_3;

var photoGallery_2 = new Array("2011_05_22","6","IMG_",".JPG","2011 Vinayagar <br>Festival Day 2");
photoGalleryList[2] = photoGallery_2;

var photoGallery_1 = new Array("2011_05_21_2","36","IMG_",".JPG","2011 Vinayagar <br>Festival Day 1 Part 2");
photoGalleryList[1] = photoGallery_1;

var photoGallery_0 = new Array("2011_05_21","36","IMG_",".JPG","2011 Vinayagar <br>Festival Day 1 Part 1");
photoGalleryList[0] = photoGallery_0;




var MAX_IMAGE_ON_GALLERY_PAGE = 12;
var MAX_IMAGE_ON_MAIN_PAGE = 4;
var currentPhotoGalleryListIndex = -1;
var previousPhotoGalleryListIndex = ( photoGalleryList.length - 1);
var currentPhotoGalleryIndex = -1;

var MAIN_PAGE_IMAGE_NAME = "mainPageImage";
var GALLERY_PAGE_IMAGE_NAME = "galleryPageImage";

function setEventPhotoGalleryPage(inIndex){
	currentPhotoGalleryIndex = inIndex;
	currentPhotoGalleryListIndex = -1;
	var photoGalleryVar1 = photoGalleryList[currentPhotoGalleryIndex];
	previousPhotoGalleryListIndex = parseInt(photoGalleryVar1[1], 10) - 1;
	setNextPageImageForPhotoGalleryPage();
}


function setNextPageImageForPhotoGalleryPage(){
	resetImageOnPhotoGalleryPage();
	if(currentPhotoGalleryIndex == -1){
		setImageForPhotoGalleryPage();
	}
	else{
		setEventImageForPhotoGalleryPage();
	}
}

function setPreviousPageImageForPhotoGalleryPage(){
	resetImageOnPhotoGalleryPage();
	if(currentPhotoGalleryIndex == -1){
		setPreviousImageForPhotoGalleryPage();
	}
	else{
		setEventPreviousImageForPhotoGalleryPage();
	}
}



function setEventImageForPhotoGalleryPage(){
	var photoGalleryVar1 = photoGalleryList[currentPhotoGalleryIndex];
	var numberOfPhotos = parseInt(photoGalleryVar1[1], 10);
	document.getElementById("eventGalleryText").innerHTML =  photoGalleryVar1[4];
	var currentPhotoIndex = currentPhotoGalleryListIndex;
	var needNextButton = false;
	var needPrevButton = false;
	
	if(currentPhotoGalleryListIndex == -1){
		currentPhotoIndex = ( numberOfPhotos - 1);
	}
	previousPhotoGalleryListIndex = currentPhotoIndex + MAX_IMAGE_ON_GALLERY_PAGE;

	for(var p = 0; ( p < MAX_IMAGE_ON_GALLERY_PAGE && currentPhotoIndex >= 0); p++){
		if(currentPhotoIndex >= 0 ){
			document.getElementById((GALLERY_PAGE_IMAGE_NAME + p)).src = getImageThumbnailsPath(photoGalleryVar1,currentPhotoIndex);
			document.getElementById((GALLERY_PAGE_IMAGE_NAME +"Text" +p)).innerHTML = "";
			document.getElementById((GALLERY_PAGE_IMAGE_NAME +"Href" +p)).href = "javaScript:setSingleImage('"+getImagePath(photoGalleryVar1,currentPhotoIndex) +"')";
			currentPhotoIndex = currentPhotoIndex - 1;
		}
	}
	
	document.getElementById("displayPreviousButtonOnly").style.display = 'none';
	document.getElementById("displayBothButton").style.display = 'none';
	document.getElementById("displayNextButtonOnly").style.display = 'none';
	
	currentPhotoGalleryListIndex = currentPhotoIndex;

	if(previousPhotoGalleryListIndex <= ( numberOfPhotos - 1)){
		needPrevButton = true;
	}
	if(currentPhotoIndex >= 0 ){
		needNextButton = true;
	}
	if(needPrevButton && needNextButton){
		document.getElementById("displayBothButton").style.display = 'block';
	}	
	else if(needPrevButton){
		document.getElementById("displayPreviousButtonOnly").style.display = 'block';
	}	
	else if(needNextButton){
		document.getElementById("displayNextButtonOnly").style.display = 'block';
	}
}


function setEventPreviousImageForPhotoGalleryPage(){
	var photoGalleryVar1 = photoGalleryList[currentPhotoGalleryIndex];
	var numberOfPhotos = parseInt(photoGalleryVar1[1], 10);
	document.getElementById("eventGalleryText").innerHTML =  photoGalleryVar1[4];
	var currentPhotoIndex = previousPhotoGalleryListIndex;
	previousPhotoGalleryListIndex = previousPhotoGalleryListIndex + MAX_IMAGE_ON_GALLERY_PAGE;
	var needNextButton = true;
	var needPrevButton = false;
	for(var p = 0; ( p < MAX_IMAGE_ON_GALLERY_PAGE && currentPhotoIndex >= 0); p++){
		if(currentPhotoIndex >= 0 ){
			document.getElementById((GALLERY_PAGE_IMAGE_NAME + p)).src = getImageThumbnailsPath(photoGalleryVar1,currentPhotoIndex);
			document.getElementById((GALLERY_PAGE_IMAGE_NAME +"Text" +p)).innerHTML = "";
			document.getElementById((GALLERY_PAGE_IMAGE_NAME +"Href" +p)).href = "javaScript:setSingleImage('"+getImagePath(photoGalleryVar1,currentPhotoIndex) +"')";
			currentPhotoIndex = currentPhotoIndex - 1;
		}
	}
	
	document.getElementById("displayPreviousButtonOnly").style.display = 'none';
	document.getElementById("displayBothButton").style.display = 'none';
	document.getElementById("displayNextButtonOnly").style.display = 'none';
	
	currentPhotoGalleryListIndex = currentPhotoIndex;
	
	if(previousPhotoGalleryListIndex <=( numberOfPhotos - 1)){
		needPrevButton = true;
	}
	if(needPrevButton && needNextButton){
		document.getElementById("displayBothButton").style.display = 'block';
	}	
	else if(needPrevButton){
		document.getElementById("displayPreviousButtonOnly").style.display = 'block';
	}	
	else if(needNextButton){
		document.getElementById("displayNextButtonOnly").style.display = 'block';
	}
}



function setPreviousImageForPhotoGalleryPage(){
	var photoGalleryListSize = previousPhotoGalleryListIndex;
	previousPhotoGalleryListIndex = previousPhotoGalleryListIndex + MAX_IMAGE_ON_GALLERY_PAGE;
	var needNextButton = true;
	var needPrevButton = false;
	for(var p = 0; ( p < MAX_IMAGE_ON_GALLERY_PAGE && photoGalleryListSize >= 0); p++){
		if(photoGalleryListSize >= 0 ){
			var photoGalleryVar1 = photoGalleryList[photoGalleryListSize];
			var maxImage = parseInt(photoGalleryVar1[1], 10);
			var randNum = getRandomNumber(maxImage);
			document.getElementById((GALLERY_PAGE_IMAGE_NAME + p)).src = getImageThumbnailsPath(photoGalleryVar1,randNum);
			document.getElementById((GALLERY_PAGE_IMAGE_NAME +"Text" +p)).innerHTML = photoGalleryVar1[4];
			document.getElementById((GALLERY_PAGE_IMAGE_NAME +"Href" +p)).href = "javaScript:setEventPhotoGalleryPage("+ photoGalleryListSize +")";
			photoGalleryListSize = photoGalleryListSize - 1;

		}
	}
	
	document.getElementById("displayPreviousButtonOnly").style.display = 'none';
	document.getElementById("displayBothButton").style.display = 'none';
	document.getElementById("displayNextButtonOnly").style.display = 'none';
	
	currentPhotoGalleryListIndex = photoGalleryListSize;
	
	if(previousPhotoGalleryListIndex <=( photoGalleryList.length - 1)){
		needPrevButton = true;
	}
	if(needPrevButton && needNextButton){
		document.getElementById("displayBothButton").style.display = 'block';
	}	
	else if(needPrevButton){
		document.getElementById("displayPreviousButtonOnly").style.display = 'block';
	}	
	else if(needNextButton){
		document.getElementById("displayNextButtonOnly").style.display = 'block';
	}
}

function setImageForPhotoGalleryPage(){
	var photoGalleryListSize = currentPhotoGalleryListIndex;
	var needNextButton = false;
	var needPrevButton = false;
	
	if(currentPhotoGalleryListIndex == -1){
		photoGalleryListSize = ( photoGalleryList.length - 1);
	}
	previousPhotoGalleryListIndex = photoGalleryListSize + MAX_IMAGE_ON_GALLERY_PAGE;

	for(var p = 0; ( p < MAX_IMAGE_ON_GALLERY_PAGE && photoGalleryListSize >= 0); p++){
		if(photoGalleryListSize >= 0 ){
			var photoGalleryVar1 = photoGalleryList[photoGalleryListSize];
			var maxImage = parseInt(photoGalleryVar1[1], 10);
			var randNum = getRandomNumber(maxImage);
			document.getElementById((GALLERY_PAGE_IMAGE_NAME + p)).src = getImageThumbnailsPath(photoGalleryVar1,randNum);
			document.getElementById((GALLERY_PAGE_IMAGE_NAME +"Text" +p)).innerHTML = photoGalleryVar1[4];
			document.getElementById((GALLERY_PAGE_IMAGE_NAME +"Href" +p)).href = getSlideShowPath(photoGalleryVar1);
			photoGalleryListSize = photoGalleryListSize - 1;
		}
	}
	
	document.getElementById("displayPreviousButtonOnly").style.display = 'none';
	document.getElementById("displayBothButton").style.display = 'none';
	document.getElementById("displayNextButtonOnly").style.display = 'none';
	
	currentPhotoGalleryListIndex = photoGalleryListSize;

	if(previousPhotoGalleryListIndex <= ( photoGalleryList.length - 1)){
		needPrevButton = true;
	}
	if(photoGalleryListSize >= 0 ){
		needNextButton = true;
	}
	if(needPrevButton && needNextButton){
		document.getElementById("displayBothButton").style.display = 'block';
	}	
	else if(needPrevButton){
		document.getElementById("displayPreviousButtonOnly").style.display = 'block';
	}	
	else if(needNextButton){
		document.getElementById("displayNextButtonOnly").style.display = 'block';
	}
}

function setImageForMainPage(){
	var photoGalleryListSize = ( photoGalleryList.length - 1);
	for(var k = 0; k <= MAX_IMAGE_ON_MAIN_PAGE; k++){
		var photoGalleryVar1 = photoGalleryList[photoGalleryListSize];
		var maxImage = parseInt(photoGalleryVar1[1], 10);
		var randNum = getRandomNumber(maxImage);
		if(photoGalleryListSize < 0 ){
			photoGalleryListSize = ( photoGalleryList.length - 1);
		}
		document.getElementById((MAIN_PAGE_IMAGE_NAME + k)).src = getImageThumbnailsPath(photoGalleryVar1,randNum);
		document.getElementById((MAIN_PAGE_IMAGE_NAME +"Href" + k)).href = getSlideShowPath(photoGalleryVar1);
		photoGalleryListSize = photoGalleryListSize - 1;
	}
 }


function resetImageOnPhotoGalleryPage(){
	for(var p = 0; p < 12; p++){
		document.getElementById((GALLERY_PAGE_IMAGE_NAME + p)).src = "photos/blankImage.jpg";
		document.getElementById((GALLERY_PAGE_IMAGE_NAME +"Text" +p)).innerHTML = " ";
		document.getElementById((GALLERY_PAGE_IMAGE_NAME +"Href" +p)).href = "javaScript:loadBlankPhotoAction('"+ (GALLERY_PAGE_IMAGE_NAME + p) +"')";
	}
	
	document.getElementById("eventGalleryText").innerHTML = " ";
	document.getElementById("displayPreviousButtonOnly").style.display = 'none';
	document.getElementById("displayBothButton").style.display = 'none';
	document.getElementById("displayNextButtonOnly").style.display = 'none';
}

function loadBlankPhotoAction(inFieldName){
	document.getElementById(inFieldName).src = "photos/blankImage.jpg";
}

function getImageThumbnailsPath(inPhotoGalleryArray, inImageNumber){
	var imageLocation = "photos/photoGallery/"+ inPhotoGalleryArray[0];
	imageLocation = imageLocation + "/thumbnails/" + inPhotoGalleryArray[2] + inImageNumber + inPhotoGalleryArray[3];
	return imageLocation;
}

function getImagePath(inPhotoGalleryArray, inImageNumber){
	var imageLocation = "photos/photoGallery/"+ inPhotoGalleryArray[0];
	imageLocation = imageLocation + "/" + inPhotoGalleryArray[2] + inImageNumber + inPhotoGalleryArray[3];
	return imageLocation;
}

function getSlideShowPath(inPhotoGalleryArray){
	var imageLocation = "photos/photoGallery/"+ inPhotoGalleryArray[0] +"/slideShow.html";
	return imageLocation;
}

function setBackToPhotoGalleryPage(){
	document.getElementById("showPhotoGalleryPage").style.display = 'block';
	document.getElementById("showPhotoImagePage").style.display = 'none';
}
function setSingleImage(inImagePath){
	var winParms = "status,resizable,top=50px,left=50px,height=550px,width=550px,scrollbars";
	openNewWindow(inImagePath, "photoWindow",winParms);
}
function getRandomNumber(inMaxNumber)
{
	return Math.floor(Math.random()* inMaxNumber);
}
