
' Script by and many thanks to Bill Scott May 2000
' billscott@redrivernet.com

Option Explicit
Dim screenx, screeny
Dim gw, gh, gcount
Dim gpl, gpt, gpr, gpb, gpxstart, gpystart, gxycount, ginc, gxyinc
Dim xpercent, ypercent, xtemp, ytemp
Dim origw, origh, origl, origt
Dim origb
Dim boxwidth, boxheight
Dim proportion, Image1width, Image1height
Dim boxProportion

' Set box proportion for your image. (WIDTH/HEIGHT)
' For horizontal images (landscape), .66 is usually okay.
' For vertical images (portrait), 1.5 is usually okay.
' For a square image, use 1.0

boxProportion=.99

Sub Window_OnLoad()
	screenx=document.body.clientWidth
	screeny=document.body.clientHeight
	box.style.posWidth=deskpad.style.posWidth
	box.style.posHeight=box.style.posWidth*boxProportion
	box.style.posLeft=(screenx-box.style.posWidth)/2
	boxwidth=box.style.posWidth
	boxheight=box.style.posHeight
	deskpad.style.posLeft=box.style.posLeft
	deskpad.style.posTop=box.style.posTop+box.style.posHeight
	' Calculate new image width and height.
	' First subtract out the border widths of graphic box.
	Image1height=boxheight-16    '2xleft and right border.
	Image1width=boxwidth-16     '2xtop and bottom border.
	proportion=Image1height/Image1width
	
	' Figure new width and height for Image1.
	if proportion*Image1width>=Image1height then
		Image1.style.posHeight=proportion*Image1width
		Image1.style.posWidth=Image1width
	else
		Image1.style.posHeight=Image1height
		Image1.style.posWidth=Image1height/proportion
	end if
	' This script expands a graphic image (image id=Image1) from a zero point to any specified size. Emanation point is centered on the image.
	' Set desired X,Y graphic size compared to original**********
	xpercent=92
	ypercent=92
	origw=Image1.style.posWidth
	origh=Image1.style.posHeight
	origl=Image1.style.posLeft
	origt=Image1.style.posTop
	
	' X,Y position setup**********
	' Get final X and Y coordinates for image.
	gpl=Image1.style.posLeft
	gpt=Image1.style.posTop

	' Calculate actual and relative X,Y center of image.
	gpr=gpl+Image1.style.posWidth
	gpb=gpt+Image1.style.posHeight
	xpercent=xpercent*.01
	ypercent=ypercent*.01
	xtemp=CInt(xpercent*Image1.style.posWidth)
	ytemp=CInt(ypercent*Image1.style.posHeight)
	gpr=gpl+xtemp
	gpb=gpt+ytemp
	gpxstart=(gpr-gpl)/2
	gpystart=(gpb-gpt)/2
	Image1.style.posLeft=CInt(gpxstart)+gpl
	Image1.style.posTop=CInt(gpystart)+gpt

	' Set position factor.
	gxycount=.99

	' Expand setup**********
	' Get image width and height.
	gw=xtemp
	gh=ytemp

	' Set expansion factor.
	gcount=.04
	ginc=gcount

	' Reduce image size to zero, then display.
	Image1.style.posWidth=0
	Image1.style.posHeight=0
	Image1.style.visibility="visible"

	deskpad.style.visibility="visible"

	SetTimeOut"expandImage1",3700
End Sub

Sub expandImage1()
	Image1.style.posLeft=CInt(gxycount*gpxstart)+gpl
	Image1.style.posTop=CInt(gxycount*gpystart)+gpt
	gxycount=gxycount-ginc

	Image1.style.posWidth=CInt(gcount*gw)
	Image1.style.posHeight=CInt(gcount*gh)
	if gcount<1.0 then
		gcount=gcount+ginc
		SetTimeOut"expandImage1",20
	end if		
End Sub
