// Globals
var military_slideshow = 0;
var wedding_slideshow = 0;
var portrait_slideshow = 0;
var count = 0;
var sname = '';
var numPortrait = 22;
var numWedding = 24;
var numMilitary = 9;

var doneWedding = 0;
var donePortrait = 0;
var doneMilitary = 0;

function preloadThumbnails()
{
	var image = new Image();
	for (i=0; i<numMilitary; i++)
	{
		image.src = 'photos/military/thumbs/thumb_' + i + '.jpg';
	}
	for (i=0; i<numWedding; i++)
	{
		image.src = 'photos/wedding/thumbs/thumb_' + i + '.jpg';
	}
	for (i=0; i<numPortrait; i++)
	{
		image.src = 'photos/portrait/thumbs/thumb_' + i + '.jpg';
	}
}

function preloadImages()
{
	var image = new Image();
	for (i=0; i<numMilitary; i++)
	{
		image.src = 'photos/military/large/large_' + i + '.jpg';
	}
	for (i=0; i<numWedding; i++)
	{
		image.src = 'photos/wedding/large/large_' + i + '.jpg';
	}
	for (i=0; i<numPortrait; i++)
	{
		image.src = 'photos/portrait/large/large_' + i + '.jpg';
	}
}

function buildSlideShow(category, numImages)
{
	if (count > 0)
	{
		document.body.removeChild($(sname));
	}
	sname = 'slideshow' + count;
	count = count + 1;

	var list = document.createElement('ul');
	list.setAttribute('id',sname);

	for (i=0;i<numImages;i++)
	{
		var item = document.createElement('li');
		var h3 = document.createElement('h3');
		//h3.innerHTML = 'Click image to enlarge';
		var span = document.createElement('span');
		span.innerHTML = 'photos/' + category + '/large/large_' + i + '.jpg';
		var p = document.createElement('p');
		var a = document.createElement('a');
		a.innerHTML = '<img src="photos/' + category + '/thumbs/thumb_' + i + '.jpg" />';
		a.onClick = '#';
		item.appendChild(h3);
		item.appendChild(span);
		item.appendChild(p);
		item.appendChild(a);
		list.appendChild(item);
	}
	list.style.display = 'none';

	document.body.appendChild(list);
}

function clearSlideshow()
{
	var children = $('image'), child;
	while (child = children.firstChild)
	{
		children.removeChild(child);
	}
	
	children = $('slider'), child;
	while (child = children.firstChild)
	{
		children.removeChild(child);
	}
	$('slider').style.left = 0;
}

function show_wedding_portfolio()
{
	show_wedding();
	if (!doneWedding)
	{
		// No idea why this is needed but Firefox often draws the thumbs 
		// wrong the first time
		setTimeout('show_wedding()', 100);
		doneWedding = 1;
	}
}

function show_wedding()
{
	hideAll();
	clearSlideshow();
	buildSlideShow('weddings', numWedding);

	$('wrapper').style.display='block';
	wedding_slideshow=new TINY.slideshow("wedding_slideshow");

	wedding_slideshow.auto=false;
	wedding_slideshow.speed=5;
	//wedding_slideshow.link="linkhover";
	//wedding_slideshow.info="information";
	wedding_slideshow.info=0;
	wedding_slideshow.thumbs="slider";
	wedding_slideshow.left="slideleft";
	wedding_slideshow.right="slideright";
	wedding_slideshow.scrollSpeed=4;
	wedding_slideshow.spacing=5;
	wedding_slideshow.active="#fff";
	wedding_slideshow.init(sname,"image","imgprev","imgnext","imglink");
}

function show_military_portfolio()
{
	show_military();
	if (!doneMilitary)
	{
		// No idea why this is needed but Firefox often draws the thumbs 
		// wrong the first time
		setTimeout('show_military()', 100);
		doneMilitary = 1;
	}
}

function show_military()
{
	hideAll();
	clearSlideshow();
	buildSlideShow('military', numMilitary);

	$('wrapper').style.display='block';
	military_slideshow=new TINY.slideshow("military_slideshow");

	military_slideshow.auto=false;
	military_slideshow.speed=5;
	//military_slideshow.link="linkhover";
	//military_slideshow.info="information";
	military_slideshow.info=0;
	military_slideshow.thumbs="slider";
	military_slideshow.left="slideleft";
	military_slideshow.right="slideright";
	military_slideshow.scrollSpeed=4;
	military_slideshow.spacing=5;
	military_slideshow.active="#fff";
	military_slideshow.init(sname,"image","imgprev","imgnext","imglink");
}

function show_portrait_portfolio()
{
	show_portrait();
	if (!donePortrait)
	{
		// No idea why this is needed but Firefox often draws the thumbs 
		// wrong the first time
		setTimeout('show_portrait()', 100);
		donePortrait = 1;
	}
}

function show_portrait()
{
	hideAll();
	clearSlideshow();
	buildSlideShow('portrait', numPortrait);
	
	$('wrapper').style.display='block';
	portrait_slideshow=new TINY.slideshow("portrait_slideshow");

	portrait_slideshow.auto=false;
	portrait_slideshow.speed=5;
	//portrait_slideshow.link="linkhover";
	//portrait_slideshow.info="information";
	portrait_slideshow.info=0;
	portrait_slideshow.thumbs="slider";
	portrait_slideshow.left="slideleft";
	portrait_slideshow.right="slideright";
	portrait_slideshow.scrollSpeed=4;
	portrait_slideshow.spacing=5;
	portrait_slideshow.active="#fff";
	portrait_slideshow.init(sname,"image","imgprev","imgnext","imglink");
}

function hideAll()
{
	$('wrapper').style.display = 'none';
	$('about_us_div').style.display = 'none';
	$('contact_div').style.display = 'none';
	$('wedding_prices_div').style.display = 'none';
	$('military_prices_div').style.display = 'none';
	$('portrait_prices_div').style.display = 'none';
}

function show_contact()
{
	// Hide everyone
	hideAll();

	// Make contact page visible	
	$('contact_div').style.display = 'block';
}

function show_about_us()
{
	// Hide everyone
	hideAll();

	// Make contact page visible	
	$('about_us_div').style.display = 'block';
}

function show_wedding_prices()
{
	// Hide everyone
	hideAll();

	// Make contact page visible	
	$('wedding_prices_div').style.display = 'block';
}

function show_military_prices()
{
	// Hide everyone
	hideAll();

	// Make contact page visible	
	$('military_prices_div').style.display = 'block';
}

function show_portrait_prices()
{
	// Hide everyone
	hideAll();

	// Make contact page visible	
	$('portrait_prices_div').style.display = 'block';
}

function goto_store()
{
	//window.location = 'http://localhost/catalog';
	window.location = 'http://www.geocities.com/tara_allegra/index.html';
}
