
// ----------------
// global variables
var g_numItems=65	// 9, 14, 20, 27, 44, *65*, 77, 90
var g_batchSize = g_numItems
var g_entriesOffset=0
var g_helpOn=1
var g_aboutObj = null
var g_statusObj = null
var g_pStatusObj = null
var g_reqAlertObj = null
var g_reqAlertTimer = null
var g_totalItems = 0
var g_guestRequest
var g_bugGuestsURL = "bugGuest_XML.php"
var g_processing = false
var g_toolTips = true
// Top object to which all items are postioned, initialized onload
var g_guestbookBaseRef = document.body
var g_guestbookTop = 86

var g_ctrlRec = new Array()
	g_ctrlRec.width = 150
	g_ctrlRec.height = 200
	g_ctrlRec.left = 7
	g_ctrlRec.top = g_guestbookTop + 180
	g_ctrlRec.zindex = 10000
	g_ctrlRec.className = "controlContainer"

var g_ctrlBtnRec = new Array()
	g_ctrlBtnRec.width = 136
	g_ctrlBtnRec.height = 15
	g_ctrlBtnRec.className = "controlButtonNormal"

var g_listRec = new Array()
	g_listRec.width = 592
	g_listRec.height = 190
	g_listRec.left = 158
	g_listRec.top = g_guestbookTop - g_listRec.height
	g_listRec.slideButtonWidth = 50
	g_listRec.slideButtonHeight = 14
	g_listRec.className = "listClass"

var g_signRec = new Array()
	g_signRec.width = 187 + 2 + 5
	g_signRec.height = 203 + 2 + 5
	g_signRec.left = 608
	g_signRec.top = g_guestbookTop - g_signRec.height
	g_signRec.slideButtonWidth = 50
	g_signRec.slideButtonHeight = 14
	g_signRec.className = "signClass"

var g_topBorderRec = new Array()
	g_topBorderRec.width = 112
	g_topBorderRec.height = 6
	g_topBorderRec.left = 16
	g_topBorderRec.top = g_guestbookTop
	g_topBorderRec.zindex = 10000
	g_topBorderRec.className = "borderClass"

var g_leftBorderRec = new Array()
	g_leftBorderRec.width = 6
	g_leftBorderRec.height = 112
	g_leftBorderRec.left = 0
	g_leftBorderRec.top = g_guestbookTop + 16
	g_leftBorderRec.zindex = 10000
	g_leftBorderRec.className = "borderClass"

var g_homeRec = new Array()
	g_homeRec.width = 18
	g_homeRec.height = 18
	g_homeRec.left = 0
	g_homeRec.top = g_guestbookTop - 1
	g_homeRec.zindex = 10000
	g_homeRec.className = "borderClass"

var g_navBoxRec = new Array()
	g_navBoxRec.width = 100
	g_navBoxRec.height = 15
	g_navBoxRec.left = 0
	g_navBoxRec.top = 173
	g_navBoxRec.className = "navBoxButtonNormal"
	g_navBoxRec.classNameHover = "navBoxButtonHover"

// Initial card settings for each guestbook entry...
var g_cardRec = new Array()
	g_cardRec.left = 0
	g_cardRec.top = g_guestbookTop
	g_cardRec.width = 350 + 2 + 5
	g_cardRec.height = 130 + 2 + 5
	g_cardRec.decay = 4
	g_cardRec.slideButtonWidth = 8
	g_cardRec.slideButtonHeight = 8
	g_cardRec.dragBarHeight = 17
	g_cardRec.className = "cardClass"

	g_cardRec.c_bsz = 11
	g_cardRec.c_ox = 158    // 170 left base for out cards
	g_cardRec.c_oy = 205    // 260 top base...
	g_cardRec.c_px = 9
	g_cardRec.c_py = 8

var cnt = g_numItems-1
for(i=1; i<g_numItems; i++) {
	for(j=0; j<i+1; j++) {
		if( cnt>=0 ) {
			var x = (i-j)*g_cardRec.c_bsz
			var y = j*g_cardRec.c_bsz
			g_cardRec[cnt]          = new Array()
			g_cardRec[cnt].name     = " ..."
			g_cardRec[cnt].site     = i+" ..."
			g_cardRec[cnt].place    = i+" ..."
			g_cardRec[cnt].comments = i+" ..."
			g_cardRec[cnt].date     = i+" ..."
			g_cardRec[cnt].atHome   = true
			g_cardRec[cnt].hx       = x - g_cardRec.width + g_cardRec.left + g_cardRec.c_bsz + g_cardRec.c_px
			g_cardRec[cnt].hy       = y - g_cardRec.height + g_cardRec.top + g_cardRec.c_bsz + g_cardRec.c_py
			//g_cardRec[cnt].hz       = (g_numItems-1)-(cnt+100)
			g_cardRec[cnt].hz       = (cnt+100)
			g_cardRec[cnt].kx       = x*2.8 + g_cardRec.left + g_cardRec.c_ox  // x*2.0 spread factor
			g_cardRec[cnt].ky       = y*2.8 + g_cardRec.top + g_cardRec.c_oy   // y*1.3 spread factor
			cnt--
		}
	}
}

// ----------------
// XMLHttpRequest +

function getXMLData(url, data) {
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        g_guestRequest = new XMLHttpRequest()
        if (g_guestRequest) {
	        g_guestRequest.onreadystatechange = XMLHttpRequestHandler
	        g_guestRequest.open("POST", url, true)
	        g_guestRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
	        g_guestRequest.send(data)
		}
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        g_guestRequest = new ActiveXObject("Microsoft.XMLHTTP")
        if (g_guestRequest) {
            g_guestRequest.onreadystatechange = XMLHttpRequestHandler
	        g_guestRequest.open("POST", url, true)
	        g_guestRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
	        g_guestRequest.send(data)
        }
    }
}

function XMLHttpRequestHandler() {
	var sX = 300
	var sY = 150
	var sW = 300
    if (g_guestRequest.readyState == 0) {
		myText = "Initializing...`"
		showPStatus(myText, sX, sY, sW)
    } else if (g_guestRequest.readyState == 1) {
		myText = "Processing request...`"
		showPStatus(myText, sX, sY, sW)
    } else if (g_guestRequest.readyState == 2) {
		myText = "Acknowldeged...`"
		showPStatus(myText, sX, sY, sW)
    } else if (g_guestRequest.readyState == 3) {
		myText = "Loading entries...`"
		showPStatus(myText, sX, sY, sW)
    } else if (g_guestRequest.readyState == 4) {
        // if "OK" else alert 'em
        if (g_guestRequest.status == 200) {
			myText = "Complete!`"
			showPStatus(myText, sX, sY, sW)
			hidePStatus()
			document.getElementById("bugForm").reset()
            updateEntries()
			g_processing = false
         } else {
            alert("Cannot retrieve the XML data:\n" + g_guestRequest.statusText + "\nNote: guestbook will not load when run locally.")
			hidePStatus()
			g_processing = false
         }
	}
}

function updateEntries() {
	var signed = "FALSE"
    var guestbook = g_guestRequest.responseXML.getElementsByTagName("GUESTBOOK")  // case sensitive!!!
	if(guestbook) {
		var success = (guestbook[0].getElementsByTagName("SUCCESS")[0].childNodes[0].nodeValue).split(":")
		if(success[0] == "FALSE") {
			alert("bugGuest::updateEntries:\n"+success[1])
			g_statusObj.hide()
		} else {
			signed = guestbook[0].getElementsByTagName("SIGNED")[0].childNodes[0].nodeValue
		}
		g_entriesOffset = guestbook[0].getElementsByTagName("PAGEOFFSET")[0].childNodes[0].nodeValue
		g_batchSize = guestbook[0].getElementsByTagName("NUMITEMS")[0].childNodes[0].nodeValue
		g_totalItems = guestbook[0].getElementsByTagName("TOTALITEMS")[0].childNodes[0].nodeValue
		//alert("Offset " + g_entriesOffset + "\nBatch size " + g_batchSize + "\nTotal items " + g_totalItems + "\n")
	}
    var entries = g_guestRequest.responseXML.getElementsByTagName("ENTRY")  // case sensitive!!!
    // loop through <entry> elements
    for (i=0; i<entries.length; i++) {
		if(i<g_numItems) {
			name = entries[i].getElementsByTagName("NAME")[0].childNodes[0].nodeValue
			site = entries[i].getElementsByTagName("SITE")[0].childNodes[0].nodeValue
			place = entries[i].getElementsByTagName("LOCATION")[0].childNodes[0].nodeValue
			comments = entries[i].getElementsByTagName("COMMENTS")[0].childNodes[0].nodeValue
			date = entries[i].getElementsByTagName("DATE")[0].childNodes[0].nodeValue
			//alert("Entry " + i + "\n" + name + "\n" + site + "\n" + place + "\n" + comments + "\n")
			g_cardRec[i].name = name
			g_cardRec[i].site = site
			g_cardRec[i].place = place
			g_cardRec[i].comments = comments
			g_cardRec[i].date = date
		}
	}
	updateList()
	updateCards()
	updateEntryLegend()
	if(signed == "TRUE") {
		bugimus.mySigner.inOut = "out"
		bugimus.mySigner.slideButton.onclick()
		hideReqAlert()
		g_cardRec[0].atHome = true
		cardToggle(0)
	}
}
// XMLHttpRequest -
// ----------------

function buildAbout() {
	g_aboutObj = document.getElementById("aboutDiv")
	g_aboutObj.show = showoDiv
	g_aboutObj.hide = hideoDiv
	g_aboutObj.hide()
	g_aboutObj.onclick = function() {
		g_aboutObj.hide()
	}
}

function buildStatus() {
	if(g_statusObj) g_guestbookBaseRef.removeChild( g_statusObj )
	g_guestbookBaseRef.appendChild( g_statusObj = document.createElement("DIV") )
	g_statusObj.style.position = "absolute"
	g_statusObj.style.zIndex = 40000
	g_statusObj.style.width = 200 + "px"
	// allow auto heighting...  g_statusObj.style.height = 15 + "px"
	g_statusObj.className = "statusClass"
	g_statusObj.appendChild( boldObj=document.createElement("B") )
		boldObj.appendChild( document.createTextNode("Status Box Success ") )
	g_statusObj.appendChild( document.createTextNode("This window contains a bold header and a short text description of status.") )
	g_statusObj.warp = warpoTo
	g_statusObj.setw = setoWidth
	g_statusObj.seth = setoHeight
	g_statusObj.show = showoDiv
	g_statusObj.hide = hideoDiv
	g_statusObj.warp(350, 200 + g_guestbookTop)
	g_statusObj.hide()
}

function showStatus(text, x, y, w) {
	if(g_toolTips) {
		g_statusObj.setw(w)
		g_statusObj.warp = warpoTo
		g_statusObj.warp(x, y + g_guestbookTop)
		var segments = text.split("`")
		g_statusObj.childNodes[0].childNodes[0].nodeValue = segments[0] + " "
		g_statusObj.childNodes[1].nodeValue = segments[1]
		g_statusObj.show()
	}
}

function hideStatus() {
	g_statusObj.hide()
	g_statusObj.warp(0, 0)
}

function buildPStatus() {
	if(g_pStatusObj) document.body.removeChild( g_pStatusObj )
	document.body.appendChild( g_pStatusObj = document.createElement("DIV") )
	g_pStatusObj.style.position = "absolute"
	g_pStatusObj.style.zIndex = 50000
	g_pStatusObj.style.width = 200 + "px"
	// allow auto heighting...  g_pStatusObj.style.height = 15 + "px"
	g_pStatusObj.className = "statusClass"
	g_pStatusObj.appendChild( boldObj=document.createElement("B") )
		boldObj.appendChild( document.createTextNode("Status Box Success ") )
	g_pStatusObj.appendChild( document.createTextNode("This window contains a bold header and a short text description of status.") )
	g_pStatusObj.warp = warpoTo
	g_pStatusObj.setw = setoWidth
	g_pStatusObj.seth = setoHeight
	g_pStatusObj.show = showoDiv
	g_pStatusObj.hide = hideoDiv
	g_pStatusObj.warp(350, 200 + g_guestbookTop)
	g_pStatusObj.hide()
}

function showPStatus(text, x, y, w) {
	g_statusObj.hide()
	g_pStatusObj.setw(w)
	g_pStatusObj.warp = warpoTo
	g_pStatusObj.warp(x, y + g_guestbookTop)
	var segments = text.split("`")
	g_pStatusObj.childNodes[0].childNodes[0].nodeValue = segments[0] + " "
	g_pStatusObj.childNodes[1].nodeValue = segments[1]
	g_pStatusObj.show()
}

function hidePStatus() {
	g_pStatusObj.hide()
}

function buildRequiredAlert() {
	if(g_reqAlertObj) g_guestbookBaseRef.removeChild( g_reqAlertObj )
	g_guestbookBaseRef.appendChild( g_reqAlertObj = document.createElement("DIV") )
	g_reqAlertObj.style.position = "absolute"
	g_reqAlertObj.style.zIndex = 60000
	g_reqAlertObj.style.width = 150 + "px"
	// allow auto heighting...  g_reqAlertObj.style.height = 15 + "px"
	g_reqAlertObj.className = "reqAlertClass"
	g_reqAlertObj.appendChild( boldObj=document.createElement("B") )
		boldObj.appendChild( document.createTextNode("Required Alert Box Success ") )
	g_reqAlertObj.appendChild( document.createElement("BR") )
	g_reqAlertObj.appendChild( document.createTextNode("This window contains a short message for form validation >>") )
	g_reqAlertObj.warp = warpoTo
	g_reqAlertObj.setw = setoWidth
	g_reqAlertObj.seth = setoHeight
	g_reqAlertObj.show = showoDiv
	g_reqAlertObj.hide = hideoDiv
	g_reqAlertObj.warp(500, 100 + g_guestbookTop)
	g_reqAlertObj.hide()
}

function showReqAlert(text, x, y, w) {
	clearTimeout(g_reqAlertTimer)
	g_reqAlertObj.setw(w)
	g_reqAlertObj.warp = warpoTo
	g_reqAlertObj.warp(x, y)
	var segments = text.split("`")
	g_reqAlertObj.childNodes[0].childNodes[0].nodeValue = segments[0] + " "
	g_reqAlertObj.childNodes[2].nodeValue = segments[1]
	g_reqAlertObj.show()
}

function timeReqAlert() {
	clearTimeout(g_reqAlertTimer)
	g_reqAlertTimer = setTimeout("hideReqAlert()", 5000)
}

function hideReqAlert() {
	g_reqAlertObj.hide()
	g_reqAlertObj.warp(0, 0)
}

function buildList() {
	// Create list div
	listObj = new dragComponent(g_guestbookBaseRef, g_listRec.left, g_listRec.top, g_listRec.width, g_listRec.height)
	listObj.dragObject.id = "listId"
	//listObj.dragObject.style.border = "solid 1px red"
	bugimus.myLister = listObj

	// Initial positioning
	listObj.dragObject.warp = warpoTo
	listObj.dragObject.warp(g_listRec.left, g_listRec.top)
	bugimus.myLister.inOut = "in"
	
	// Assign chase
	attachChase(listObj.dragObject.id)
	listObj.dragObject.constrainX = true

	// Setup drag rules
	bugimus.myLister.disableDrag()
	bugimus.myLister.dragAllowed = false

	// Dragobject content
	listObj.dragObject.appendChild( infoObj = document.createElement("DIV") )
	infoObj.id = "listInfo"
	infoObj.className = g_listRec.className

	// For each guestbook entry...
	for(i=0; i<g_numItems; i++) {
		infoObj.appendChild( anchorObj=document.createElement("A") )
			anchorObj.id = "listAnchor" + i + "Id"
			anchorObj.cardNum = i
			anchorObj.href = "#"
			anchorObj.className = g_listRec.className
			nameString = (g_batchSize - i) + g_cardRec[i].name
			anchorObj.appendChild( document.createTextNode(nameString) )
			anchorObj.onmouseover = function() {
				var myText = "Guest List`Every page has "+g_numItems+" guestbook entries. These are the names of the people shown on this page. Click to see more detail on "+g_cardRec[this.cardNum].name+"'s guest card."
				showStatus(myText, 200, 245, 500)
			}
			anchorObj.onmouseout = function() {
				hideStatus()
			}
			anchorObj.onclick = function() {
				this.blur()
				cardToggle(this.cardNum)
			}
	}

	// Slide button
	listObj.dragObject.appendChild( doObj=document.createElement("DIV") )
	doObj.className = "slideButtonNormal"
	doObj.style.width = g_listRec.slideButtonWidth + "px"
	doObj.style.height = g_listRec.slideButtonHeight + "px"
	doObj.style.top = g_listRec.height - 1 + "px"
	doObj.style.left = g_listRec.width - parseInt(doObj.style.width) - 2 + "px"
	doObj.appendChild( document.createTextNode("List"))
	doObj.onmouseover = function() {
		this.style.cursor = "default"
		this.className = "slideButtonHover"
		var myText = "Show/Hide List`This button shows and hides the guest list. Try pressing it a few times to see how it moves."
		showStatus(myText, 620, 80, 125)
	}
	doObj.onmouseout = function() {
		this.className = "slideButtonNormal"
		hideStatus()
	}
	doObj.onclick = function() {
		if(bugimus.myLister.inOut == "in") {
			bugimus.myLister.inOut = "out"
			bugimus.myLister.dragObject.chase(g_listRec.left, g_listRec.top + g_listRec.height  - 1)
		} else {
			bugimus.myLister.inOut = "in"
			bugimus.myLister.dragObject.chase(g_listRec.left, g_listRec.top)
		}
	}
	bugimus.myLister.slideButton = doObj
}

function updateList() {
	for(i=0; i<g_numItems; i++) {
		var nameString = ""
		var numberOfGuest = parseInt(g_totalItems) - parseInt(g_entriesOffset) - i
		if(numberOfGuest>0) {
			if(numberOfGuest<10) nameString = "0"
			if(numberOfGuest<100) nameString = "0" + nameString
			nameString += numberOfGuest + " " + g_cardRec[i].name
		} else {
			nameString = "..."
		}
		document.getElementById("listAnchor" + i + "Id").childNodes[0].nodeValue = nameString
	}
}

function buildNavBox() {
	// Older entries button
	bugimus.myLister.dragObject.appendChild( olderObj=document.createElement("DIV") )
	olderObj.className = g_navBoxRec.className
	olderObj.style.width = g_navBoxRec.width + "px"
	olderObj.style.height = g_navBoxRec.height + "px"
	olderObj.style.top = g_navBoxRec.top + "px"
	olderObj.style.left = g_navBoxRec.left + "px"
	olderObj.appendChild( document.createTextNode("older entries"))
	olderObj.onmouseover = function() {
		g_processing ? this.style.cursor = "wait" : this.style.cursor = "default"
		this.className = g_navBoxRec.classNameHover
		var myText = "Older Entries`Click this to load an older batch of guestbook entries"
		showStatus(myText, 140, 240, 240)
	}
	olderObj.onmouseout = function() {
		this.className = g_navBoxRec.className
		hideStatus()
	}
	olderObj.onclick = function() {
		oldSet()
	}

	// Newer entries button
	bugimus.myLister.dragObject.appendChild( newerObj=document.createElement("DIV") )
	newerObj.className = g_navBoxRec.className
	newerObj.style.width = g_navBoxRec.width + "px"
	newerObj.style.height = g_navBoxRec.height + "px"
	newerObj.style.top = g_navBoxRec.top + "px"
	newerObj.style.left = g_navBoxRec.left + g_navBoxRec.width + "px"
	newerObj.appendChild( document.createTextNode("newer entries"))
	newerObj.onmouseover = function() {
		g_processing ? this.style.cursor = "wait" : this.style.cursor = "default"
		this.className = g_navBoxRec.classNameHover
		var myText = "Newer Entries`Click this to load a more recent batch of guestbook entries"
		showStatus(myText, 300, 240, 240)
	}
	newerObj.onmouseout = function() {
		this.className = g_navBoxRec.className
		hideStatus()
	}
	newerObj.onclick = function() {
		newSet()
	}

	// Entry legend
	bugimus.myLister.dragObject.appendChild( elObj=document.createElement("DIV") )
	bugimus.myLister.entryLegendObj = elObj
	elObj.className = g_navBoxRec.className
	elObj.style.border = "0px"
	elObj.style.width = g_navBoxRec.width + 50 + "px"
	elObj.style.height = g_navBoxRec.height + "px"
	elObj.style.top = g_navBoxRec.top + "px"
	elObj.style.left = g_navBoxRec.left + 2.2*g_navBoxRec.width + "px"
	elObj.appendChild( document.createTextNode("entries ...-... of ..."))
	elObj.onmouseover = function() {
		this.style.cursor = "default"
	}

}

function updateEntryLegend() {
	var to = g_totalItems - g_entriesOffset
	var from = to - g_batchSize + 1
	var newString = "entries " + from + "-" + to + " of " + g_totalItems
	bugimus.myLister.entryLegendObj.childNodes[0].nodeValue = newString
}

function buildCard(cardnum) {
	// Create card
	i = cardnum
	dObj = new dragComponent(g_guestbookBaseRef, 0, 0, g_cardRec.width, g_cardRec.dragBarHeight)
	dObj.dragObject.id = "card"+i+"Id"
	g_cardRec[i].hz = dObj.dragObject.getz()

	// Attach positioning methods
	dObj.dragObject.warp = warpoTo
	dObj.dragObject.warp(g_cardRec[i].hx, g_cardRec[i].hy)
	dObj.dragObject.setz(g_cardRec[i].hz)
	attachChase(dObj.dragObject.id)
	dObj.dragObject.decay=g_cardRec.decay

	// Visible card container
	dObj.dragObject.appendChild( lookObj = document.createElement("DIV") )
	lookObj.className = g_cardRec.className
	lookObj.parentObject = dObj.dragObject
	lookObj.onclick = function() {
		this.parentObject.elevate()
	}

	// Drag'n'drop bar
	lookObj.appendChild( dragBarObj = document.createElement("DIV") )
	lookObj.appendChild( document.createElement("BR") )
	lookObj.appendChild( document.createTextNode("Initial content...") )
	dragBarObj.className = "cardButtonNormal"
	dragBarObj.style.borderTopWidth = "1px"
	dragBarObj.style.borderRightWidth = "1px"
	dragBarObj.style.borderBottomWidth = "2px"
	dragBarObj.style.borderLeftWidth = "2px"
	dragBarObj.style.width = g_cardRec.width - 3 + "px"
	dragBarObj.style.height = g_cardRec.dragBarHeight - 2 + "px"
	dragBarObj.style.top = "0px"
	dragBarObj.style.left = "0px"
	dragBarObj.onmouseover = function() {
		this.style.cursor = "move"
	}
	dragBarObj.appendChild( boldObj=document.createElement("B") )
		boldObj.appendChild( titleNode=document.createTextNode("\u00a0"+g_cardRec[i].name+" "+i) )
	dObj.dragObject.titleNode = titleNode

	// Load initial content	
	tempObj = document.createElement("DIV")
	tempObj.appendChild( boldObj=document.createElement("B") )
		boldObj.appendChild( document.createTextNode("initial content... "+i) )
	loadCard(dObj.dragObject, tempObj, g_cardRec.height)

	// Lower right button
	dObj.dragObject.appendChild( tuckObj=document.createElement("DIV") )
	tuckObj.className = "cardButtonNormal"
	tuckObj.style.width = g_cardRec.slideButtonWidth + "px"
	tuckObj.style.height = g_cardRec.slideButtonHeight + "px"
	tuckObj.style.top = g_cardRec.height - parseInt(tuckObj.style.height) - 4 + "px"
	tuckObj.style.left = g_cardRec.width - parseInt(tuckObj.style.width) - 4 + "px"
	tuckObj.onmouseover = function() {
		this.style.cursor = "default"
		this.className = "cardButtonHover"
		var myText = "Guest Cards`These are all the name cards tucked away nicely in the corner. You can click on these buttons to bring them out to read. Click them again when you're done to tuck them back into place. Try dragging them around the page too!"
		showStatus(myText, 90, 90, 200)
	}
	tuckObj.onmouseout = function() {
		this.className = "cardButtonNormal"
		hideStatus()
	}
	tuckObj.cardNum = i
	tuckObj.onclick = function() {
		cardToggle(this.cardNum)
	}

	// Lower left date bar
	dObj.dragObject.appendChild( dateObj=document.createElement("DIV") )
	dateObj.style.position = "absolute"
	dateObj.style.fontSize = "8px"
	dateObj.style.width = g_cardRec.width - 100 + "px"
	dateObj.style.height = g_cardRec.slideButtonHeight + 3 + "px"
	dateObj.style.top = g_cardRec.height - parseInt(dateObj.style.height) - 2 + "px"
	dateObj.style.left = 5 + "px"
	dateObj.appendChild( italicObj=document.createElement("I") )
		italicObj.appendChild( dateNode=document.createTextNode(g_cardRec[i].date) )
	dObj.dragObject.dateNode = dateNode

	// progress bar
	var sX = 300
	var sY = 180
	var sW = 300
	myText = "Building page...` percent complete " + parseInt(100*i/g_numItems) + "%"
	showStatus(myText, sX, sY, sW)
}

function loadCard(cardObj, tempObj, contentHeight) { 
	if(contentHeight > g_cardRec.height-30) {
		cardObj.childNodes[0].removeChild( cardObj.childNodes[0].childNodes[2] )
		bsbObj = new bugScrollBar(	cardObj.childNodes[0]	// append to this object
									,350								// scrollBar base width
									,100								// scrollBar base height 
									,"gfx/bugGuest_up.gif"			// up button normal image
									,"gfx/bugGuest_up.gif"			// up button hover image
									,"gfx/bugGuest_up.gif"			// up button down image
									,"gfx/bugGuest_down.gif"			// down button normal image
									,"gfx/bugGuest_down.gif"			// down button hover image
									,"gfx/bugGuest_down.gif"			// down button down image
									,"gfx/bugGuest_base.gif"			// drag base image
									,"gfx/bugGuest_drag.gif"			// drag button normal image
									,"gfx/bugGuest_drag.gif"			// drag button hover image
									,"gfx/bugGuest_drag.gif"			// drag button down image
									,10									// all button image widths
									,10									// up & down image heights
									,10									// top padding
									,10								// bottom padding
									,20									// drag button image height
									,10									// gap between content and scrollbar
		)
		clonedRef = tempObj.cloneNode(true)
		bsbObj.setClonedHTML( clonedRef )
	} else {
		// These lines attempt to prevent horizontal overflow on the cards...
		// someone typed in a very long word with no spaces into the comments section
		// 7/1/2005
		tempObj.style.overflow = "hidden"
		tempObj.style.width = g_cardRec.width - 7 + "px"
		// end
		cardObj.childNodes[0].removeChild( cardObj.childNodes[0].childNodes[2] )
		clonedRef = tempObj.cloneNode(true)
		cardObj.childNodes[0].appendChild( clonedRef )
	}
}

function updateCards() {
	// Attach a temp container for card data height calculations
	g_guestbookBaseRef.appendChild( heightCalcObj = document.createElement("DIV") )
	heightCalcObj.style.border = "solid black 1px"
	heightCalcObj.style.position = "absolute"
	heightCalcObj.style.display = "block"
	heightCalcObj.style.visibility = "hidden"
	heightCalcObj.style.width = g_cardRec.width + "px"
	heightCalcObj.style.top = "250px"
	heightCalcObj.style.left = "225px"
	// For each guestbook entry...
	for(i=0; i<g_numItems; i++) {

		heightCalcObj.appendChild( newInfoObj = document.createElement("DIV") )
		
		newInfoObj.appendChild( boldObj=document.createElement("B") )
			boldObj.appendChild( document.createTextNode("Name: ") )
		newInfoObj.appendChild( document.createTextNode(g_cardRec[i].name) )
		newInfoObj.appendChild( document.createElement("BR") )
	
		newInfoObj.appendChild( boldObj=document.createElement("B") )
			boldObj.appendChild( document.createTextNode("Site: ") )
		newInfoObj.appendChild( document.createTextNode(g_cardRec[i].site) )
		newInfoObj.appendChild( document.createElement("BR") )
	
		newInfoObj.appendChild( boldObj=document.createElement("B") )
			boldObj.appendChild( document.createTextNode("Location: ") )
		newInfoObj.appendChild( document.createTextNode(g_cardRec[i].place) )
		newInfoObj.appendChild( document.createElement("BR") )
	
		newInfoObj.appendChild( boldObj=document.createElement("B") )
			boldObj.appendChild( document.createTextNode("Comments: ") )
		newInfoObj.appendChild( document.createTextNode(g_cardRec[i].comments) )
		newInfoObj.appendChild( document.createElement("BR") )

		cardObj = document.getElementById("card" + i + "Id")
		var contentHeight = heightCalcObj.offsetHeight
		heightCalcObj.removeChild( newInfoObj )
		loadCard(cardObj, newInfoObj, contentHeight)

		var nameString = ""
		var numberOfGuest = parseInt(g_totalItems) - parseInt(g_entriesOffset) - i
		if(numberOfGuest>0) {
			if(numberOfGuest<10) nameString = "0"
			if(numberOfGuest<100) nameString = "0" + nameString
			nameString += "\u00a0" + numberOfGuest + " - " + g_cardRec[i].name
		} else {
			nameString = "..."
		}
		cardObj.titleNode.nodeValue = nameString
		cardObj.dateNode.nodeValue = g_cardRec[i].date
	} // for all cards
}

function buildAllCards() {
	var i=0
	var interval=80
	for(i=0; i<g_numItems; i++) {
		setTimeout("buildCard("+i+")", interval*i)
	}
	setTimeout("bugimus.myLister.slideButton.onclick()", interval*i++)	
	setTimeout("hideStatus()", interval*i++)	

	var loc = unescape(window.location)
	if( loc.substring(0,4) == "http" ) {
		var sendData = "pgsize="+g_numItems+"&offset="+g_entriesOffset
		setTimeout("getXMLData(g_bugGuestsURL, \""+sendData+"\")", interval*i++)	
	}
}

function cardToggle(cardNum) {
	myCardObj = document.getElementById("card"+cardNum+"Id")
	myCardObj.setz(g_cardRec[cardNum].hz)
	if(g_cardRec[cardNum].atHome) {
		myCardObj.elevate()
		myCardObj.chase(g_cardRec[cardNum].kx, g_cardRec[cardNum].ky)
		g_cardRec[cardNum].atHome = false
	} else {
		myCardObj.chase(g_cardRec[cardNum].hx, g_cardRec[cardNum].hy)
		g_cardRec[cardNum].atHome = true
	}
}

function cardsOut() {

	bugimus.myLister.inOut = "out"
	bugimus.myLister.slideButton.onclick()
	var colCount=0
	var rowCount=0
	var minWidth = 900
	var kx = new Array()
	var ky = new Array()

	if(bugimus.BSNwinWidth > minWidth) {
		minWidth = bugimus.BSNwinWidth
	}

	for(i=0; i<g_numItems; i++) {

		kx[i] = colCount*(g_cardRec.width*0.4) + g_cardRec.left + g_cardRec.c_ox
		ky[i] = rowCount*(g_cardRec.dragBarHeight-3) + g_cardRec.top + 15
		colCount++
		rowCount++

		if (bugimus.myLister.inOut == "out") {
			ky[i] += g_cardRec.c_oy
		}
		if( kx[i]+(1.5*g_cardRec.width) > minWidth ) {
			colCount=0
		}

		document.getElementById("card"+i+"Id").setz(g_cardRec[i].hz)
		g_cardRec[i].atHome = false
	}
	for(i=0; i<g_numItems; i++) {
		r = g_numItems-1-i
		setTimeout("document.getElementById(\"card"+r+"Id\").chase("+kx[r]+","+ky[r]+")", 200*i)
	}
}

function cardsIn() {
	for(i=0; i<g_numItems; i++) {
		r = g_numItems-1-i
		document.getElementById("card"+i+"Id").setz(g_cardRec[i].hz)
		setTimeout("document.getElementById(\"card"+r+"Id\").chase("+g_cardRec[r].hx+","+g_cardRec[r].hy+")", 200*i)
		g_cardRec[i].atHome = true
	}
}

function buildSigner() {
	// Create submit div
	signObj = new dragComponent(g_guestbookBaseRef, g_signRec.left, g_signRec.top, g_signRec.width, g_signRec.height)
	signObj.dragObject.id = "signId"
	//signObj.dragObject.style.border = "solid 1px red"
	bugimus.mySigner = signObj

	// Initial positioning
	signObj.dragObject.warp = warpoTo
	signObj.dragObject.warp(g_signRec.left, g_signRec.top)
	bugimus.mySigner.inOut = "in"
	
	// Assign chase
	attachChase(signObj.dragObject.id)
	signObj.dragObject.constrainX = true

	// Setup drag rules
	bugimus.mySigner.disableDrag()
	bugimus.mySigner.dragAllowed = false
	signObj.dragObject.onmouseover = function() {
		if(bugimus.mySigner.dragAllowed) bugimus.mySigner.enableDrag()
	}
	signObj.dragObject.onmouseout = function() {
		timeReqAlert()
	}

	// Dragobject content
	signObj.dragObject.appendChild( infoObj = document.createElement("DIV") )
	infoObj.className = g_signRec.className

	// Form, name...
	infoObj.appendChild( formObj = document.createElement("FORM") )
		formObj.id = "bugForm"
		formObj.method = "post"
		formObj.action = "testSubmit.html"

	// name...
	//formObj.appendChild( document.createElement("BR") )
	formObj.appendChild( boldObj=document.createElement("B") )
		boldObj.appendChild( document.createTextNode("Name:") )
	formObj.appendChild( document.createElement("BR") )
	formObj.appendChild( input1Obj = document.createElement("INPUT") )
		input1Obj.id = "bugFormName"
		input1Obj.onmousedown = function() { bugimus.mySigner.disableDrag() }
		input1Obj.onmouseout = function() { if(bugimus.mySigner.dragAllowed) bugimus.mySigner.enableDrag() }

	// site...
	formObj.appendChild( document.createElement("BR") )
	formObj.appendChild( boldObj=document.createElement("B") )
		boldObj.appendChild( document.createTextNode("Site: ") )
	formObj.appendChild( document.createElement("BR") )
	formObj.appendChild( input2Obj = document.createElement("INPUT") )
		input2Obj.id = "bugFormSite"
		input2Obj.onmousedown = function() { bugimus.mySigner.disableDrag() }
		input2Obj.onmouseout = function() { if(bugimus.mySigner.dragAllowed) bugimus.mySigner.enableDrag() }

	// place...
	formObj.appendChild( document.createElement("BR") )
	formObj.appendChild( boldObj=document.createElement("B") )
		boldObj.appendChild( document.createTextNode("Location: ") )
	formObj.appendChild( document.createElement("BR") )
	formObj.appendChild( input3Obj = document.createElement("INPUT") )
		input3Obj.id = "bugFormPlace"
		input3Obj.onmousedown = function() { bugimus.mySigner.disableDrag() }
		input3Obj.onmouseout = function() { if(bugimus.mySigner.dragAllowed) bugimus.mySigner.enableDrag() }

	// comments...
	formObj.appendChild( document.createElement("BR") )
	formObj.appendChild( boldObj=document.createElement("B") )
		boldObj.appendChild( document.createTextNode("Comments:") )
	formObj.appendChild( document.createElement("BR") )
	formObj.appendChild( input4Obj = document.createElement("TEXTAREA") )
	formObj.appendChild( document.createElement("BR") )
		input4Obj.id = "bugFormComments"
		input4Obj.onmousedown = function() { bugimus.mySigner.disableDrag() }
		input4Obj.onmouseout = function() { if(bugimus.mySigner.dragAllowed) bugimus.mySigner.enableDrag() }

	// submit button...
	formObj.appendChild( input5Obj = document.createElement("DIV") )
	input5Obj.className = g_navBoxRec.className
	input5Obj.style.width = g_signRec.width - 30 + "px"
	input5Obj.style.height = g_navBoxRec.height + "px"
	input5Obj.style.top = g_signRec.height - parseInt(input5Obj.style.height) - 13 + "px"
	input5Obj.style.left = 15 + "px"
	input5Obj.style.fontWeight = "bold"
	input5Obj.appendChild( document.createTextNode("Sign Guestbook"))
	input5Obj.onmouseover = function() {
		this.style.cursor = "default"
		this.className = g_navBoxRec.classNameHover
	}
	input5Obj.onmouseout = function() {
		this.className = g_navBoxRec.className
		if(bugimus.mySigner.dragAllowed) bugimus.mySigner.enableDrag() 
	}
	input5Obj.onmousedown = function() { 
		bugimus.mySigner.disableDrag() 
	}
	input5Obj.onclick = function() {
		signIt()
	}

	// Slide button
	infoObj.appendChild( doObj=document.createElement("DIV") )
	doObj.className = "slideButtonNormal"
	doObj.style.width = g_signRec.slideButtonWidth + "px"
	doObj.style.height = g_signRec.slideButtonHeight + "px"
	doObj.style.top = g_signRec.height - 1 + "px"
	doObj.style.left = g_signRec.width - parseInt(doObj.style.width) - 2 + "px"
	doObj.appendChild( document.createTextNode("Sign"))
	doObj.onmouseover = function() {
		this.style.cursor = "default"
		this.className = "slideButtonHover"
		var myText = "Sign Guestbook`Click on this button to show and hide this form. Please fill in the fields and let me know you dropped by to say hello. And, please, no spam ok?"
		showStatus(myText, 665, 45, 150)
	}
	doObj.onmouseout = function() {
		this.className = "slideButtonNormal"
		hideStatus()
	}
	doObj.onclick = function() {
		if(bugimus.mySigner.inOut == "in") {
			if(bugimus.myLister.inOut == "out") {
				bugimus.myLister.slideButton.onclick()
			}

			bugimus.mySigner.inOut = "out"
			bugimus.mySigner.dragObject.chase(g_signRec.left, g_signRec.top + g_signRec.height)
		} else {
			bugimus.mySigner.inOut = "in"
			bugimus.mySigner.dragObject.chase(g_signRec.left, g_signRec.top)
		}
	}
	bugimus.mySigner.slideButton = doObj
}

function buildBorders() {
	// Create top border
	g_guestbookBaseRef.appendChild( topBorderObj = document.createElement("DIV") )
	topBorderObj.style.zIndex = g_topBorderRec.zindex
	topBorderObj.style.width = g_topBorderRec.width + "px"
	topBorderObj.style.height = g_topBorderRec.height + "px"
	topBorderObj.className = g_topBorderRec.className
	topBorderObj.warp = warpoTo
	topBorderObj.warp(g_topBorderRec.left, g_topBorderRec.top)

	// Create left border
	g_guestbookBaseRef.appendChild( leftBorderObj = document.createElement("DIV") )
	leftBorderObj.style.zIndex = g_leftBorderRec.zindex
	leftBorderObj.style.width = g_leftBorderRec.width + "px"
	leftBorderObj.style.height = g_leftBorderRec.height + "px"
	leftBorderObj.className = g_leftBorderRec.className
	leftBorderObj.warp = warpoTo
	leftBorderObj.warp(g_leftBorderRec.left, g_leftBorderRec.top)

	// Create home button
	g_guestbookBaseRef.appendChild( homeObj = document.createElement("DIV") )
	homeObj.style.zIndex = g_homeRec.zindex
	homeObj.style.width = g_homeRec.width + "px"
	homeObj.style.height = g_homeRec.height + "px"
	homeObj.className = g_homeRec.className
	homeObj.warp = warpoTo
	homeObj.warp(g_homeRec.left, g_homeRec.top)
}

function buildControls() {
	// Create control container
	g_guestbookBaseRef.appendChild( controlObj = document.createElement("DIV") )
	controlObj.className = g_ctrlRec.className
	controlObj.style.zIndex = g_ctrlRec.zindex
	//controlObj.style.width = g_ctrlRec.width + "px"
	//controlObj.style.height = g_ctrlRec.height + "px"
	controlObj.appendChild( boldObj=document.createElement("B"))
		boldObj.appendChild( document.createTextNode("bugGuest Control"))
		boldObj.appendChild( document.createElement("BR"))
		boldObj.appendChild( document.createElement("BR"))
	controlObj.warp = warpoTo
	controlObj.warp(g_ctrlRec.left, g_ctrlRec.top)

	// Create "sign guestbook" button
	controlObj.appendChild( signItObj = document.createElement("DIV") )
	signItObj.className = g_ctrlBtnRec.className
	signItObj.style.width = g_ctrlBtnRec.width + "px"
	signItObj.style.height = g_ctrlBtnRec.height + "px"
	signItObj.appendChild( document.createTextNode("Sign Guestbook"))
	signItObj.onmouseover = function() {
		this.style.cursor = "default"
		this.className = "controlButtonHover"
	}
	signItObj.onmouseout = function() {
		this.className = "controlButtonNormal"
	}
	signItObj.onclick = function() {
		bugimus.mySigner.inOut = "in"
		bugimus.mySigner.slideButton.onclick()
		bugimus.mySigner.dragObject.elevate()
		document.getElementById("bugFormName").focus()
	}

	// Create "cards in" button
	controlObj.appendChild( cardsInObj = document.createElement("DIV") )
	cardsInObj.className = g_ctrlBtnRec.className
	cardsInObj.style.width = g_ctrlBtnRec.width + "px"
	cardsInObj.style.height = g_ctrlBtnRec.height + "px"
	cardsInObj.appendChild( document.createTextNode("All Cards IN <-"))
	cardsInObj.onmouseover = function() {
		this.style.cursor = "default"
		this.className = "controlButtonHover"
	}
	cardsInObj.onmouseout = function() {
		this.className = "controlButtonNormal"
	}
	cardsInObj.onclick = function() {
		cardsIn()
	}

	// Create "cards out" button
	controlObj.appendChild( cardsOutObj = document.createElement("DIV") )
	cardsOutObj.className = g_ctrlBtnRec.className
	cardsOutObj.style.width = g_ctrlBtnRec.width + "px"
	cardsOutObj.style.height = g_ctrlBtnRec.height + "px"
	cardsOutObj.appendChild( document.createTextNode("All Cards OUT ->"))
	cardsOutObj.onmouseover = function() {
		this.style.cursor = "default"
		this.className = "controlButtonHover"
	}
	cardsOutObj.onmouseout = function() {
		this.className = "controlButtonNormal"
	}
	cardsOutObj.onclick = function() {
		cardsOut()
	}

	// Create default style 0 button
	controlObj.appendChild( style0Obj = document.createElement("DIV") )
	style0Obj.className = g_ctrlBtnRec.className
	style0Obj.style.width = g_ctrlBtnRec.width + "px"
	style0Obj.style.height = g_ctrlBtnRec.height + "px"
	style0Obj.appendChild( document.createTextNode("Style \"Olympic Peaks\""))
	style0Obj.onmouseover = function() {
		this.style.cursor = "default"
		this.className = "controlButtonHover"
	}
	style0Obj.onmouseout = function() {
		this.className = "controlButtonNormal"
	}
	style0Obj.onclick = function() {
		BSU_setActiveStyleSheet("peak")
	}

	// Create style 1 button
	controlObj.appendChild( style1Obj = document.createElement("DIV") )
	style1Obj.className = g_ctrlBtnRec.className
	style1Obj.style.width = g_ctrlBtnRec.width + "px"
	style1Obj.style.height = g_ctrlBtnRec.height + "px"
	style1Obj.appendChild( document.createTextNode("Style \"Ozone Asylum\""))
	style1Obj.onmouseover = function() {
		this.style.cursor = "default"
		this.className = "controlButtonHover"
	}
	style1Obj.onmouseout = function() {
		this.className = "controlButtonNormal"
	}
	style1Obj.onclick = function() {
		BSU_setActiveStyleSheet("asylum")
	}

	// Create style 2 button
	controlObj.appendChild( style2Obj = document.createElement("DIV") )
	style2Obj.className = g_ctrlBtnRec.className
	style2Obj.style.width = g_ctrlBtnRec.width + "px"
	style2Obj.style.height = g_ctrlBtnRec.height + "px"
	style2Obj.appendChild( document.createTextNode("Style \"Home 2004\""))
	style2Obj.onmouseover = function() {
		this.style.cursor = "default"
		this.className = "controlButtonHover"
	}
	style2Obj.onmouseout = function() {
		this.className = "controlButtonNormal"
	}
	style2Obj.onclick = function() {
		BSU_setActiveStyleSheet("home2004")
	}

	// Create style 3 button
	controlObj.appendChild( style3Obj = document.createElement("DIV") )
	style3Obj.className = g_ctrlBtnRec.className
	style3Obj.style.width = g_ctrlBtnRec.width + "px"
	style3Obj.style.height = g_ctrlBtnRec.height + "px"
	style3Obj.appendChild( document.createTextNode("Style \"Utah 2008\""))
	style3Obj.onmouseover = function() {
		this.style.cursor = "default"
		this.className = "controlButtonHover"
	}
	style3Obj.onmouseout = function() {
		this.className = "controlButtonNormal"
	}
	style3Obj.onclick = function() {
		BSU_setActiveStyleSheet("utah2008")
	}

	// Create style 4 button
	/*
	controlObj.appendChild( style4Obj = document.createElement("DIV") )
	style4Obj.className = g_ctrlBtnRec.className
	style4Obj.style.width = g_ctrlBtnRec.width + "px"
	style4Obj.style.height = g_ctrlBtnRec.height + "px"
	style4Obj.appendChild( document.createTextNode("Blue Style"))
	style4Obj.onmouseover = function() {
		this.style.cursor = "default"
		this.className = "controlButtonHover"
	}
	style4Obj.onmouseout = function() {
		this.className = "controlButtonNormal"
	}
	style4Obj.onclick = function() {
		BSU_setActiveStyleSheet("blueGuest")
	}
	*/

	// Create tooltip toggle button
	controlObj.appendChild( tipToggleObj = document.createElement("DIV") )
	tipToggleObj.className = g_ctrlBtnRec.className
	tipToggleObj.style.width = g_ctrlBtnRec.width + "px"
	tipToggleObj.style.height = g_ctrlBtnRec.height + "px"
	tipToggleObj.appendChild( document.createTextNode("Disable Tooltips"))
	tipToggleObj.onmouseover = function() {
		g_processing ? this.style.cursor = "wait" : this.style.cursor = "default"
		this.className = "controlButtonHover"
	}
	tipToggleObj.onmouseout = function() {
		this.className = "controlButtonNormal"
	}
	tipToggleObj.onclick = function() {
		if(g_toolTips) {
			g_toolTips=false
			this.childNodes[0].nodeValue = "Enable Tooltips"
		} else  {
			g_toolTips=true
			this.childNodes[0].nodeValue = "Disable Tooltips"
		}
	}

	// Create about button
	controlObj.appendChild( aboutObj = document.createElement("DIV") )
	aboutObj.className = g_ctrlBtnRec.className
	aboutObj.style.width = g_ctrlBtnRec.width + "px"
	aboutObj.style.height = g_ctrlBtnRec.height + "px"
	aboutObj.appendChild( document.createTextNode("About"))
	aboutObj.onmouseover = function() {
		g_processing ? this.style.cursor = "wait" : this.style.cursor = "default"
		this.className = "controlButtonHover"
	}
	aboutObj.onmouseout = function() {
		this.className = "controlButtonNormal"
	}
	aboutObj.onclick = function() {
		g_aboutObj.show()
	}
}

function newSet() {
	var newOffset = parseInt(g_entriesOffset) - g_numItems
	if(!g_processing && newOffset >= 0 ) {
		g_processing = true
		g_entriesOffset = newOffset
		var sendData = "pgsize="+g_numItems+"&offset="+g_entriesOffset
		getXMLData(g_bugGuestsURL, sendData)
	}
}

function oldSet() {
	if(!g_processing && g_numItems==g_batchSize ) {
		g_processing = true
		g_entriesOffset = g_numItems + parseInt(g_entriesOffset)
		var sendData = "pgsize="+g_numItems+"&offset="+g_entriesOffset
		getXMLData(g_bugGuestsURL, sendData)
	}
}

function signIt() {
	var fName = document.getElementById("bugFormName")
	//	var fEmail = document.getElementById("bugFormEmail")
	var fSite = document.getElementById("bugFormSite")
	var fPlace = document.getElementById("bugFormPlace")
	var fComments = document.getElementById("bugFormComments")

	if( fName.value == "" ) {
		myAlert = "Name required!` got a name? >>"
		showReqAlert(myAlert, g_signRec.left-109, g_signRec.top+g_signRec.height+fName.offsetTop-5, 100)
		fName.focus()
	} else if( fSite.value == "" ) {
		myAlert = "Site required!` just put \"none\" if need be >>"
		showReqAlert(myAlert, g_signRec.left-189, g_signRec.top+g_signRec.height+fSite.offsetTop-5, 180)
		fSite.value = "none"
		fSite.focus()
	} else if( fPlace.value == "" ) {
		myAlert = "Location required!` where are you from? >>"
		showReqAlert(myAlert, g_signRec.left-159, g_signRec.top+g_signRec.height+fPlace.offsetTop-5, 150)
		fPlace.focus()
	} else if( fComments.value == "" ) {
		myAlert = "Comments required!` got something to say? >>"
		showReqAlert(myAlert, g_signRec.left-159, g_signRec.top+g_signRec.height+fComments.offsetTop-5, 150)
		fComments.focus()
	} else {
		g_processing = true
		g_entriesOffset = 0
		var sendData = ""
			sendData += "name="+document.getElementById("bugFormName").value
			sendData += "&email="  //+document.getElementById("bugFormEmail").value
			sendData += "&webpage="+document.getElementById("bugFormSite").value
			sendData += "&location="+document.getElementById("bugFormPlace").value
			sendData += "&comments="+document.getElementById("bugFormComments").value
			sendData +=	"&pgsize="+g_numItems+"&offset="+g_entriesOffset
		//alert( sendData )
		getXMLData(g_bugGuestsURL, sendData)
	}
}

function attachChase(refId) {
	refObj = document.getElementById(refId)
	refObj.constrainX = false
	refObj.constrainY = false
	refObj.timer = null
	refObj.speed = 10
	refObj.active = false
	refObj.decay = 5
	refObj.getx = getoX
	refObj.gety = getoY
	refObj.setx = setoX
	refObj.sety = setoY
	refObj.chase = function ( x, y ) {
		if(this.active)clearTimeout(this.timer)
		dx=x-this.getx()
		dy=this.gety()-y
		distance=Math.round(Math.sqrt(dx*dx+dy*dy))
		if(dx==0) angle=Math.PI*((dy>0)?.5:1.5)
		else angle=Math.atan(dy/dx)+(Math.PI*((dx<0)?1:(dy<0)?2:0))
		xstep=(dx>1)?Math.ceil(distance*Math.cos(angle)/this.decay):Math.floor(distance*Math.cos(angle)/this.decay)
		ystep=(dy<1)?Math.ceil(-distance*Math.sin(angle)/this.decay):Math.floor(-distance*Math.sin(angle)/this.decay)
		if(!this.constrainX) {
			this.setx(this.getx()+xstep)
		}
		if(!this.constrainY) {
			this.sety(this.gety()+ystep)
		}
		if( distance>1 ) {
			this.active=true
			this.timer=setTimeout("document.getElementById(\""+this.id+"\").chase("+x+","+y+")", this.speed)
		} else {
			clearTimeout(this.timer)
			this.warp(x,y)
			this.active=false
		}
	}
}

function maintainHeight() {
	// Keep height of working area sized to browser
	var newHeight = bugimus.BSNwinHeight 
					- document.getElementById("guestbookDiv").offsetTop
					- 20
					+ "px"
	document.getElementById("guestbookDiv").style.height = newHeight
}
//setInterval("maintainHeight()", 3000)

function initialize() {
	buildStatus()
	buildPStatus()
	buildBorders()
	buildList()
	buildSigner()
	buildRequiredAlert()
	buildControls()
	buildAbout()
	buildNavBox()
	buildAllCards()
}
onload=initialize


