window.onresize=ieResize

function ieResize()
{
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		var newwidth=document.body.clientWidth*85/100
		document.getElementById('banner').style.width=newwidth
		if(typeof(image) != 'undefined')
		{
			for (var i in image)
			{	
				var temp=image[i]
				var newwidth2=document.body.clientWidth*parseInt(temp.percentage)/100*.71
				document.getElementById(temp.imageID).style.width=newwidth2
			}
		}
		if(typeof(photo) != 'undefined')
		{
			var newwidth3=document.body.clientWidth*.12
			document.getElementById('prevPhoto').style.width=newwidth3
			document.getElementById('nextPhoto').style.width=newwidth3
			var newwidth4=document.body.clientWidth*.36
			document.getElementById('curPhoto').style.width=newwidth4
			var newwidth5=document.body.clientWidth*.095
			for (var i in photo)
			{	
				var temp='thumb'+i
				document.getElementById(temp).style.width=newwidth5
			}				
		}
		if(typeof(albumpic) != 'undefined')
		{
			var newwidth6=document.body.clientWidth*.24
			for (var i in albumpic)
			{
				var temp=albumpic[i].imageID
				document.getElementById(temp).style.width=newwidth6
			}
		}		
	}
}

function Photo(URL, caption)
{
	this.URL=URL
	this.caption=caption
}

function Imager(URL, imageID, percentage, placement)
{
	this.URL=URL
	this.imageID=imageID
	this.percentage=percentage
	this.placement=placement
}

function imageDisplay(temp)
{
	document.write('<p align=\"'+
		temp.placement+
		'\"><img src=\"'+
		temp.URL+
		'\" ')
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		document.write('style=\"width: 25px\"; ')
	}
	else
	{
		document.write('style=\"width: '+
			temp.percentage+
			'%; ')
	}

	document.write('\" id=\"'+
		temp.imageID+
		'\"></p>')
}


function photoDisplay(photo, current, totalPhotos)
{
	document.write('<center><table width=\'100%\'><tr><td width=\'20%\'>')
	var temp = current[0]-1
	if (temp==0)
	{
		temp=totalPhotos
	}
	document.write('<a href=\"javascript:prevPhoto(photo, current, totalPhotos)\">')
	var prev = new Object()	
	prev[0] = new Imager(photo[temp-1].URL, 'prevPhoto', '90', 'left')
	imageDisplay(prev[0])
	document.write('<font size=\"2\"><b><center>Previous'+
	'</b></center></font><BR>')
	document.write('</a>')

	document.write('</td><td width=\'60%\'>')

	document.write('<a href=\"javascript:nextPhoto(photo, current, totalPhotos)\">')
	var temp2 = new Object()
	var tempImg = new Image()
	tempImg.src = photo[current[0]-1].URL
	var percentage=90
//	if(tempImg.height > tempImg.width)
//	{
//		percentage=68
//	}
	temp2[0] = new Imager(photo[current[0]-1].URL, 'curPhoto', percentage, 'center')
	imageDisplay(temp2[0])
	document.write('</a>')
	document.write('<font size=\"2\"><center><p id=\'curCaption\' style=\"font-weight: bold\"><b>'+
	photo[current[0]-1].caption+
	'</b></p></center></font><BR>')
	
	document.write('</td><td>')

	var temp = current[0]+1
	if (temp>totalPhotos)
	{
		temp=1
	}
	document.write('<a href=\"javascript:nextPhoto(photo, current, totalPhotos)\">')
	var next = new Object()
	next[0] = new Imager(photo[temp-1].URL, 'nextPhoto', '90', 'right')
	imageDisplay(next[0])
	document.write('<font size=\"2\"><b><center>Next'+
	'</b></center></font>')
	document.write('</a><BR>')

	document.write('</td></tr></table></center>')
	thumnails(photo, current, totalPhotos)
	document.write('<br><center><a href=\"photos.html\">Return to Albums</a></center>')

}

function nextPhoto(photo, current, totalPhotos)
{
	current[0]=current[0]+1
	if(current[0]>totalPhotos)
	{
		current[0]=1
	}
	document.getElementById('curPhoto').src=photo[current[0]-1].URL
	document.getElementById('curCaption').innerHTML = photo[current[0]-1].caption
	var temp=current[0]-1
	if (temp==0)
	{
		temp=totalPhotos
	}
	var temp2=current[0]+1
	if (temp2>totalPhotos)
	{
		temp2=1
	}
	document.getElementById('prevPhoto').src=photo[temp-1].URL
	document.getElementById('nextPhoto').src=photo[temp2-1].URL

}

function prevPhoto(photo, current, totalPhotos)
{
	current[0]=current[0]-1
	if(current[0]==0)
	{
		current[0]=totalPhotos
	}
	document['curPhoto'].src=photo[current[0]-1].URL
	document.getElementById('curCaption').innerHTML = photo[current[0]-1].caption
	var temp=current[0]-1
	if (temp==0)
	{
		temp=totalPhotos
	}
	var temp2=current[0]+1
	if (temp2>totalPhotos)
	{
		temp2=1
	}
	document.getElementById('prevPhoto').src=photo[temp-1].URL
	document.getElementById('nextPhoto').src=photo[temp2-1].URL
}

function thumnails(photo, current, totalPhotos)
{
	document.write('<table align=\'center\' width=\'100%\'><tr>')
	var i=0
	for (i in photo)
	{
		document.write('<td width=\'12%\'>')
		var temp=photo[i]
		var temp2=new Object()
		var temp3=i+''
		var temp4='thumb'+temp3
		document.write('<a href=\"javascript:thumb(photo, current, totalPhotos, '+i+')\">')
		temp2[i]=new Imager(photo[i].URL, temp4, '100', 'center')
		imageDisplay(temp2[i])
		document.write('</a></td>')
		if((i>0) && (i%8==7))
		{
			document.write('</tr><tr>')
		}
	}
	while(i%8!=7)
	{
		document.write('<td width=\'12%\'></td>')
		i++
	}
	document.write('</tr></table>')
}

function thumb(photo, current, totalPhotos, index)
{
	current[0]=index
	nextPhoto(photo, current, totalPhotos)
}

function Album(name, date, directory)
{
	this.name=name
	this.date=date
	this.directory=directory
}


function albumDisplay(album, albumpic)
{
	document.write('<table width=\"100%\" align=\'center\'><tr>')
	var j=0
	for (j in album)
	{
	}
	var i=0
	for (i in album)
	{
		document.write('<td width=\'32%\'>'+
			'<b><center><font size=\"4\"><b>'+
			album[i].name+
			'</b></font><BR><font size=\"3\"><i>'+
			album[i].date+
			'</i></font><BR>')
		var temp=albumpic[i]
		document.write('<a href=\"javascript:jumptoAlbum(album, '+i+
	 	', '+j+')\">')
		imageDisplay(temp)
		document.write('</a></td>')
		if(i>0 && i%3==0)
		{
			document.write('</tr><tr>')
		}
	}
	while(i%3!=0)
	{
		document.write('<td width=\'32%\'></td>')
		i++
	}
	document.write('</tr></table>')
}

function jumptoAlbum(album, i, j)
{	
	var temp='album.html?'+i+'?'+j
	window.location=temp
}

function getIndex(loc, i, j)
{
	var len=loc.length
	i[0]=0
	j[0]=0

	var k=0
	while (k<len)
	{
		if (loc.charAt(k)=='?')
		{
			break
		}
		k++
	}
	var l=k+1
	while(l<len)
	{
		if(loc.charAt(l)=='?')
		{
			break
		}
		l++
	}
	var m=l
	while(m<len)
	{		
		if(loc.charAt(m)=='?')
		{
			break
		}
		m++
	}
	i[0]=parseInt(loc.substring(k+1,l))
	j[0]=parseInt(loc.substring(m+1,len))
	if(isNaN(i[0]) || isNaN(j[0]) || i[0]>j[0])
	{
		i[0]=0
		j[0]=0
	}
}

