// JavaScript Document
var wstl1 = '<p><a class="set" href="index.html?set=';
var wstl2 = '&picture=';
var wstl3 = '">';
var wstl4 = '</a></p>';

var wp1 = '<img src="';
var wp2 = '" alt="';
var wp3 = '">';

var wm1 = '<embed autostart="true" src="';
var wm2 = '"></embed>';

var Previous = "&laquo; Previous";
var Next = "Next &raquo;";

var pn1 = '<a class="" href="index.html?';
var pn2 = '">';
var pn3 = '</a>';

function writeSetTitleLinks(){
	for(setLoop=1;setLoop<=numSets;setLoop++){
		var wstlLink = new String()
		//alert(setLoop);
		//alert(SetTitles[setLoop]);
		wstlLink = wstl1 + setLoop + wstl2 + 1 + wstl3 + SetTitles[setLoop] + wstl4;
		document.write(wstlLink);
	};//end for setLoop
};//end function writeSetTitleLinks

function writeCurrentSetTitle(){
	var wcstString = new String()
	wcstString = SetTitles[getItemValue('set')];
	//alert(wcstString);
	document.write(wcstString);
};//end function writeCurrentSetTitle

function writeCurrentPictureTitle(){
	var wcptString = new String()
	var set = getItemValue('set');
	var pic = getItemValue('picture');

	//alert(set);
	//alert(pic);

	wcptString = PictureTitles[set][pic];
	document.write(wcptString);
};//end function writeCurrentPictureTitle

function writePicture(){
	var wpString = new String()
	var set = getItemValue('set');
	var pic = getItemValue('picture');

	if ( PictureType[set][pic] == PicTypeMovie )
		{
			wpString = wm1 + PictureURL[set][pic] + wm2;
		}
	  else
		{
			wpString = wp1 + PictureURL[set][pic] + wp2 + PictureDescription[set][pic] + wp3;
		};//end if movie

	document.write(wpString);
};//end function writePicture

function writePictureDescription(){
	var wpdString = new String()
	var set = getItemValue('set');
	var pic = getItemValue('picture');

	wpdString = PictureDescription[set][pic] ;
	document.write(wpdString);
};//end function writePictureDescription

function LastInSet(set,picture){
	var nextPic = picture -1 + 2;
	//alert(nextPic);
	//alert(PictureTitles[set][nextPic]);
	if(PictureTitles[set][nextPic]==undefined)
		{
		return true
		}
	  else
		{
		return false
		};//end if
};//end of function LastInSet

function LastSet(set){
	var nextSet = set - 1 + 2;
	//alert(nextSet);
	//alert(PictureTitles[nextSet][1]);
	//if(PictureTitles[nextSet][1]==undefined)
	if (nextSet > numSets)
		{
		return true
		}
	  else
		{
		return false
		};//end if
};//end of function LastSet

function writeNextLink(){
	var set = getItemValue('set');
	var pic = getItemValue('picture');
	var Last = new Boolean()

	var linkString = new String()

	var newSet;
	var newPic;

	Last = LastInSet(set,pic);

	if ( Last == true )
	    	{
		Last = LastSet(set);
		if ( Last == true )
			{
			newSet = 1;
			newPic = 1;
			}
		  else
			{
			newSet = set - 1 + 2;
			newPic = 1;
			};//end of if Last (last set check)
		}
	  else
		{
		newSet = set;
		newPic = pic - 1 + 2;
		};//end of if Last (in set check)

	linkString = pn1 + "set=" + newSet + "&picture=" + newPic + pn2 + Next + pn3;

	document.write (linkString);
};//end of function writeNextLink

function FirstInSet(set,picture){
	var prevPic = picture -1;
	//alert(prevPic);
	//alert(PictureTitles[set][prevPic]);
	if(PictureTitles[set][prevPic]==undefined)
		{
		return true
		}
	  else
		{
		return false
		};//end if
};//end of function FirstInSet

function FirstSet(set){
	var prevSet = set - 1;
	//alert(prevSet);
	//alert(PictureTitles[prevSet][1]);
	//if(PictureTitles[prevSet][1]==undefined)
	if (prevSet < 1)
		{
		return true
		}
	  else
		{
		return false
		};//end if
};//end of function FirstSet

function writePreviousLink(){
	var set = getItemValue('set');
	var pic = getItemValue('picture');
	var First = new Boolean()

	var linkString = new String()

	var newSet;
	var newPic;

	First = FirstInSet(set,pic);

	if ( First == true )
	    	{
		First = FirstSet(set);
		if ( First == true )
			{
			newSet = numSets;
			newPic = PictureTitles[newSet].length - 1;
			}
		  else
			{
			newSet = set - 1;
			newPic = PictureTitles[newSet].length - 1;
			};//end of if First (first set check)
		}
	  else
		{
		newSet = set;
		newPic = pic - 1;
		};//end of if First (in set check)

	linkString = pn1 + "set=" + newSet + "&picture=" + newPic + pn2 + Previous + pn3;

	document.write (linkString);
};//end of function writePreviousLink

function CheckForPresenseOfSetAndPictureQueryString(){
	var set = getItemValue('set');
	var pic = getItemValue('picture');

	var NoQueryString = new Boolean(false)

	if(set==null){NoQueryString = true};
	if(pic==null){NoQueryString = true};

	if (NoQueryString==true){location.href="index.html?set=1&picture=1";};
};//end of function CheckForPresenseOfSetAndPictureQueryString
