//	index.js - Functions used only by index.html
//
//	Copyright (C) 2006-2009 Charles A Upsdell, All Rights Reserved; www.upsdell.com

function myOnLoadGallery ( )
{
	myGalleriaSetMenu();
	oState.repairStates();
	setInitialGallery();
	myInsertGalleryNameAndControls();
	myInsertCaption3();
	myInsertFirstPhoto();
	myInsertThumbnails( 'ins_thumbnails', sGallery, nThumbnailColumns, nThumbnailRows );
	myAnalytics();
}

function myBuy ( )
{
	if ( oState.gallery && oState.photo && Photo[getPhotoIndex(oState.gallery,oState.photo)].for_sale )
		oState.gotoPage( 'buy.html', null, null, oState.gallery, oState.photo );
}

function myInsertFirstPhoto ( )
{
	var o_photowidth = getObject( 'ins_photowidth' );
	if ( o_photowidth )
		o_photowidth.innerHTML = '<img src="' + sPhotoFolder + 'spc_photowidth.png">';
	var i = Photo.length;
	var sInitialGallery = sGallery = oState.gallery;
	var sInitialPhoto = oState.photo;
	if ( (sInitialPhoto == null) || (getPhotoIndex(sInitialGallery,sInitialPhoto) == -1) )
		sInitialPhoto = Photo[Gallery[getGalleryIndex(oState.gallery)].photo[0]].name;
	myGalleriaInsertPhoto( Photo[getPhotoIndex(oState.gallery,sInitialPhoto)].name );
	myGalleriaInsertPhotoControls( 'ins_photo_controls' );
	var obj_preamble = getObject( 'ins_preamble' );
	if ( obj_preamble == null )
		return;
	i = getGalleryIndex( sInitialGallery );
	obj_preamble.innerHTML = ( (Gallery[i].preamble == '') ? ('This is gallery ' + Gallery[i].name + ':' ) : (Gallery[i].preamble) );
}

function setInitialGallery ( )
{
	var sCurrentGallery = oState.gallery;
	if ( sCurrentGallery == null )
		sCurrentGallery = sFirstGallery;
	setArgGallery( sCurrentGallery );
}

