
' Popup Grid
' Script by Bill Scott, March, 2001
' billscott@redrivernet.com
' http://lettermanstationery.tripod.com
' IE 5.5+ only

Option Explicit


Dim Popup
Dim PopupBody
Dim PopupAll

Set Popup=window.createPopup()
Set PopupBody=Popup.document.body
Set PopupAll=PopupBody.all

' Choose image border style, or none (solid, inset, outset, double, groove, ridge, none).
PopupBody.style.borderStyle="none"

' Choose border color. If "none" is selected above, this has no effect.
PopupBody.style.borderColor="#000000"

' Choose border width. If "none" is selected above, this has no effect.
PopupBody.style.borderWidth="50px"

PopupBody.style.backgroundColor="#000000"


Dim screenx, screeny
Dim increment1, increment2
Dim padTop, padLeft
Dim backboardpaddingLeft
Dim backboardpaddingTop
Dim imageoverlapLeft
Dim imageoverlapTop

' Set your left and top padding for the image (from upper left corner of screen).
padTop=1
padLeft=1

' Set your left and top content padding for inside the backboard.
backboardpaddingLeft=10
backboardpaddingTop=10

' Set amount of image overlap on backboard.
imageoverlapLeft=10
imageoverlapTop=220

'--------------------------------------------------------------------

Sub Window_OnLoad()
	'showPopup
End Sub

Sub PopupLoaded()
With PopupAll
	screenx=window.parent.screen.width
	screeny=window.parent.screen.height

	'Insure image is no wider than half of screen width.
	if .Image1.offsetWidth>screenx/2 then .Image1.style.posWidth=screenx/2
	
	.line1.style.posTop=screeny
	.line1.style.posLeft=padLeft+.Image1.offsetWidth-imageoverlapLeft

	.line2.style.posLeft=screenx
	.line2.style.posTop=padTop+.Image1.offsetHeight-imageoverlapTop

	increment1=Int(2*((screeny-(padTop+.Image1.offsetHeight)))/40)
	increment2=Int(2*((screenx-(padLeft+.Image1.offsetWidth)))/40)

	.line3.style.posHeight=.Image1.offsetHeight+2
	.line4.style.posWidth=.Image1.offsetWidth+2
	.line5.style.posHeight=.Image1.offsetHeight+2
	.line6.style.posWidth=.Image1.offsetWidth+2

	.line3.style.posLeft=padLeft+.Image1.offsetWidth
	.line3.style.posTop=padTop-1
	.line4.style.posLeft=padLeft-1
	.line4.style.posTop=padTop-1
	.line5.style.posLeft=padLeft-1
	.line5.style.posTop=padTop-1
	.line6.style.posLeft=padLeft-1
	.line6.style.posTop=padTop+.Image1.offsetHeight

	drawline1
	drawline2
End With
End Sub

Sub drawline1()
With PopupAll
	.line1.style.posHeight=.line1.style.posHeight+increment1
	.line1.style.posTop=.line1.style.posTop-increment1
	if .line1.style.posTop<=.Image1.offsetHeight+padTop then
		.line1.style.posTop=.Image1.offsetHeight+padTop
		exit sub
	end if
	SetTimeOut"drawline1",35
End With
End Sub

Sub drawline2()
With PopupAll
	.line2.style.posWidth=.line2.style.posWidth+increment2
	.line2.style.posLeft=.line2.style.posLeft-increment2
	if .line2.style.posLeft<=.Image1.offsetWidth+padLeft then
		.line2.style.posLeft=.Image1.offsetWidth+padLeft
		SetTimeOut"showframe1",500
		exit sub
	end if
	SetTimeOut"drawline2",35
End With
End Sub

Sub showimage()
With PopupAll
	.Image1.style.posLeft=padLeft
	.Image1.style.posTop=padTop
End With
End Sub

Sub showbackboard()
With PopupAll
	.backboard.style.posWidth=screenx-(.line1.style.posLeft+.line1.style.posWidth)
	.backboard.style.posHeight=screeny-(.line2.style.posTop+.line2.style.posHeight)
	.backboard.style.posLeft=.line1.style.posLeft+.line1.style.posWidth
	.backboard.style.posTop=.line2.style.posTop+.line2.style.posHeight

	'Set backboard padding.
	.backboard.style.paddingLeft=backboardpaddingLeft
	.backboard.style.paddingTop=backboardpaddingTop

	'Reset table width.
	On Error Resume Next
	.tbl.style.posWidth=.backboard.style.posWidth-(backboardpaddingLeft*2)
	On Error GoTo 0

	.backboard.style.visibility="visible"
	.lyrics.style.posHeight=.backboard.style.posHeight/2
End With
End Sub

Sub showframe1()
With PopupAll
	.line3.style.visibility="visible"
	SetTimeOut"showframe2",500
End With
End Sub

Sub showframe2()
With PopupAll
	.line4.style.visibility="visible"
	SetTimeOut"showframe3",500
End With
End Sub

Sub showframe3()
With PopupAll
	.line5.style.visibility="visible"
	SetTimeOut"showframe4",500
End With
End Sub

Sub showframe4()
With PopupAll
	.line6.style.visibility="visible"
	SetTimeOut"showbkg",500
	SetTimeOut"showimage",500
	SetTimeOut"showbackboard",1000
End With
End Sub

Sub showbkg()
With PopupAll
	On Error Resume Next
	PopupBody.style.backgroundImage="URL(" & bkg.src & ")"
End With
End Sub

Sub showPopup()
	PopupBody.innerHTML="<div style='display:none'>" & PopupStyle.innerHTML & "</div>" & src.innerHTML
	Popup.show 0,0,window.parent.screen.width,window.parent.screen.height
	PopupLoaded
End Sub

Sub hidePopup()
	'Need this or background image will constantly show on second show popup click.
	On Error Resume Next
	PopupBody.style.backgroundImage="none"
	parent.Popup.hide
End Sub

