// 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 three arrays to create a thumbnail gallery of pictures. 


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

var num_pics = new initArray(11);
var gal_names = new initArray("<a href='http://www.modelmayhem.com/nickiw'>Nicki White</a>");
var folder_names = new initArray("nicki-white");

//  ----------------------------------------  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>')
}