// JavaScript Document
/*
Gallery Creator 
Author: Hahns Robinson 
Company: Hahns Across Your Body Corsets
Website: http://hahnsacrossyourbodycorsets.com
Created: 1-24-08 2:41AM
This script uses the value of two arrays to create a thumbnail gallery of pictures. 


*/
//Change these values to reflect galleries and number of pictures. 

var num_pics = new initArray(3,2,2,3,3,3,3,3,2,4,2,2,3,8,2,3,3);
var gal_names = new initArray("Alaina's Designs -- Pink/Black Corset","Alaina's Designs -- Pink and Green Corset w/ Tutu","Andi's Red and Black Corset", "Black Cherry Corset", "Black Faux Leather Corset", "Black Pink PVC Corset", "Blue Black PVC Corset","Blue Fairy Frost", "Blue Gold Corset", "Burgandy Fairy Frost Corset", "Chocolate/Baby Blue Corset","Cowboy Corset", "Jade and Cream Corset","Maria -- Purple Leather Corset w/ Spoon Busk",  "Pink With Yellow Floral Corset", "Purple Paisley Corset", "Red/Black Rose Corset");
var folder_names = new initArray("pink-black-alainas-corset","alaina-pink-green", "andi-red-black-corset", "black-cherry-corset", "black-faux-leather-corset", "black-pink-pvc", "blue-black-pvc-corset","blue-fairy-frost", "blue-gold-corset", "burgandy-fairy-frost", "chocolate-baby-blue-corset","cowboy-corset", "jade","maria-purple-leather", "pink-yellow-corset", "purple-paisley-corset", "red-black-rose-corset");

//  ----------------------------------------  DO NOT EDIT BELOW THIS POINT!!!  -----------------------------------------

var num_gals = 0;
var gallery = new Array(); 

//function calls

check_length();
fill_galleries();
create_galleries();


// ----------------------------------------  Functions ------------------------------------------------------------------

//Compares the defining arrays for similar length.  
function check_length() {
	if (num_pics.length == gal_names.length) {
		num_gals = num_pics.length; 
	} 
	else 
		if (num_pics.length < gal_names.length) {
			var dif = gal_names.length - num_pics.length;
			num_gals = num_pics.length + dif;}
			else {
				var dif = num_pics.length - gal_names.length;
				num_gals = gal_names.length + dif;
			}
}

function fill_galleries() {
	
	for (i=0; i < num_gals; i++) {
var j = i + 1;
		gallery[j] = new Object();
		gallery[j].base = "../images/site/" + folder_names[j] + "/";
		gallery[j].tn_base = "../images/site/" + folder_names[j] + "/thumbs/";
		gallery[j].photos = new Array();
		gallery[j].photo_lnk = new Array();
		gallery[j].thumbs = new Array();
			for (n = 0; n < num_pics[j]; n++) { var m = n + 1;
				gallery[j].photos[m] = gallery[j].base + folder_names[j] + "-" + m + ".jpg";
				gallery[j].thumbs[m] = gallery[j].tn_base + folder_names[j] + "-" + m + "_tn.jpg";
				gallery[j].photo_lnk[m] = '<a href="../php/photo.php?picURL=' + gallery[j].photos[m] + '"><img src="' + gallery[j].thumbs[m] + '"/></a>';
			}
		gallery[j].tn_list ="";
			for (n = 0; n < num_pics[j]; n++) { var m = n + 1;
				gallery[j].tn_list = gallery[j].tn_list + "&nbsp;&nbsp;&nbsp;" + gallery[j].photo_lnk[m];
			}		
		gallery[j].name = gal_names[j];
	} 
}

function initArray() {
	this.length = initArray.arguments.length;
	for (var i = 0; i < this.length; i++)
	this[i+1] = initArray.arguments[i];
	}
	
	
function create_galleries() {
	
	document.write('<div align="center">');
		for (i = 0; i < gallery.length ; i++) { j = i + 1;
			if (gallery[j]) {
				document.write("<br/>"); 
				document.write(gallery[j].tn_list + '<br/>');
				document.write(gallery[j].name + "<br/>");}//end if
		}//end loop
	document.write('</div>')
}