// ilaniowear2.js

navRoot = new navNode("root", null) ;
curNav = null ;
defNav = null ;
isGoodBrowser = false ;

var gEvent ;
var mouseOffsetX = -1 ;
var mouseOffsetY = -1 ;
var navDrawerOpen = 1 ;
var navDrawerOpening = 0 ;

function debug(msg)
{
	window.console.log(msg) ;
}

function navNode(name, obj)
{
	this.name = name ;
	this.obj = obj ;
	this.parent = null ;
	this.children = new Array(0) ;
	this.level = 0 ;
	this.subMenuState = "none" ;
	this.index = 0 ;
	this.x = this.y = this.r = 0 ;
}

function addNavChild(childNode, parentNode)
{
	childNode.parent = parentNode ;
	childNode.level = parentNode.level + 1 ;
	childNode.index = parentNode.children.length ;
	parentNode.children[parentNode.children.length] = childNode ;
	parentNode.subMenuState = (parentNode.level == 0) ? "visible" : "hidden" ;

	coords = getNodeCoords(childNode) ;
	childNode.x = coords[0] ;
	childNode.y = coords[1] ;
	childNode.r = coords[2] ;
}

function addAreasToNavTree(parentNode, imgID)
{
	elts = document.getElementsByTagName("AREA") ;
	for (var i = 0 ; i < elts.length ; ++i)
	{
		obj = elts[i] ;
		objImgID = obj.parentNode.name.replace(/_map/, '') ;
		if (objImgID == imgID)
		{
			obj.imgID = objImgID ;
			pairs = obj.alt.split(';') ;
			for (j = 0 ; j < pairs.length ; ++j)
			{
				nvPair = pairs[j].split('=') ;
				eval('obj.' + nvPair[0] + ' = nvPair[1] ;') ;
			}
			isGoodBrowser = true ;
			child = new navNode(obj.name, obj) ;
			addNavChild(child, parentNode) ;
		}
	}
}

function setDefNav(nodeName)
{
	if (!isGoodBrowser)
		return ;
	defNav = getNavNodeByName(navRoot, nodeName) ;
	navOver(null) ;
}

function initNavTree()
{
	checkBrowser() ;

	addAreasToNavTree(navRoot, "navball") ;
	addAreasToNavTree(getNavNodeByName(navRoot, "uppers"), "sub_uppers") ;
	addAreasToNavTree(getNavNodeByName(navRoot, "lowers"), "sub_lowers") ;
	addAreasToNavTree(getNavNodeByName(navRoot, "words"), "sub_words") ;
	addAreasToNavTree(getNavNodeByName(navRoot, "goodies"), "sub_goodies") ;
	addAreasToNavTree(getNavNodeByName(navRoot, "middles"), "sub_middles") ;
	addAreasToNavTree(getNavNodeByName(navRoot, "etc"), "sub_etc") ;
	//dumpTree(navRoot) ;

	cartDiv = document.getElementById("cart_icon") ;
	if (cartDiv && (document.location.href.search(/\/cart\//) < 0))
	{
		cartDiv.style.visibility = "visible" ;
		cartRollover = new Image() ;				// preload cart rollover
		cartRollover.src = 'i/cart_black.jpg' ;

		copyDiv = document.getElementById("copyright") ;
		copyDiv.style.visibility = "visible" ;		// show copyright notice if this isn't a cart page
	}

	return (isGoodBrowser) ;
}

function dumpTree(p)
{
	debug(p.level + ": " + p.name) ;
	for (var i = 0 ; i < p.children.length ; ++i)
		dumpTree(p.children[i]) ;
}

function getNavNodeByName(parentNode, name)
{
	for (var i = 0 ; i < parentNode.children.length ; ++i)
	{
		p = parentNode.children[i] ;
		if (p.name == name)
			return (p) ;
		if (p.children)
			if (null != (p = getNavNodeByName(p, name)))
				return (p) ;
	}
	return (null) ;
}

function navOver(node)
{
	if (!node)
		node = defNav ;
	if (node == curNav)
		return ;

	if (node && curNav && (node.name == "all"))
		return ;
	curNav = node ;

	// set UI appropriately
	setIndicator(curNav) ;
	if (curNav && (curNav.level > 1))
		setIndicator(curNav.parent) ;
	else
		document.green_ball.style.visibility = "hidden" ;

	// show any sub-menus
	setSubMenuState() ;

	// set the text displayed for this item
	setNavText() ;
}

function getMouseNavNode(node)
{
	if ((node.children.length > 0) && (node.subMenuState != 'hidden'))
	{
		// if mouse is in the first node (the entire circle for this level), then we're definitely not in a sub-menu,
		// so just check the siblings in this level but don't descend the tree

		if (mouseIsInNode(node.children[0]))
		{
			for (var i = 1 ; i < node.children.length ; ++i)
				if (mouseIsInNode(node.children[i]))
					return (node.children[i]) ;
			return (node.children[0]) ;
		}

		for (var i = 1 ; i < node.children.length ; ++i)
			if (null != (p = getMouseNavNode(node.children[i])))
				return (p) ;
	}

	if ((node.level > 0) && mouseIsInNode(node))
		return (node) ;
	return (null) ;
}

function mouseIsInNode(node)
{
	if (mouseOffsetX < 0)
	{
		theDiv = document.getElementById("main_nav_div") ;
		mouseOffsetX = parseInt(theDiv.style.left) ;
		mouseOffsetY = parseInt(theDiv.style.top) ;
		
		if (null != (theDiv = document.getElementById("nav_drawer_div")))
		{
			mouseOffsetX += parseInt(theDiv.style.left) ;
			mouseOffsetY += parseInt(theDiv.style.top) ;
		}
	}

	if (isMSIE)
	{
		dx = gEvent.offsetX - node.x ;
		dy = gEvent.offsetY - node.y ;
	}
	else
	{
		dx = gEvent.clientX - mouseOffsetX - node.x + ((document.all) ? document.body.scrollLeft : window.pageXOffset) ;
		dy = gEvent.clientY - mouseOffsetY - node.y + ((document.all) ? document.body.scrollTop : window.pageYOffset) ;
	}

	return (((dx * dx + dy * dy) <= (node.r * node.r)) ? true : false) ;
}

function navMouse(evt)
{
	if (!isGoodBrowser)
		return ;
	gEvent = evt ;
	navOver(getMouseNavNode(navRoot)) ;
}

function getNodeCoords(node)
{
	parentImg = eval('document.' + node.obj.imgID) ;
	xOffset = parseInt(parentImg.style.left) ;
	yOffset = parseInt(parentImg.style.top) ;
	coordArray = node.obj.coords.split(',') ;
	coordArray[0] = parseInt(coordArray[0]) + xOffset ;
	coordArray[1] = parseInt(coordArray[1]) + yOffset ;

	return (coordArray) ;
}

function setNodeBkgImg(node, useAltImg)
{
	bkgImg = eval('document.' + node.obj.imgID) ;
	bkgImg.src = node.parent.children[useAltImg ? 1 : 0].obj.nodeImg ;
}

function setIndicator(node)
{
	if (!node)
	{
		document.orange_ball.style.visibility = "hidden" ;
		document.green_ball.style.visibility = "hidden" ;
		setNodeBkgImg(navRoot.children[0], false) ;
		return ;
	}

	setNodeBkgImg(node, node.index == 1) ;

	indicator = (node.level == 1) ? document.orange_ball : document.green_ball ;

	if (node.index < 2)		// nodes 0 and 1 are the total area and "home" area, respectively
		indicator.style.visibility = "hidden" ;
	else
	{
		indicator.style.top = (node.y - node.r + 1) + "px" ;
		indicator.style.left = (node.x - node.r + 2) + "px" ;
		indicator.style.visibility = 'visible' ;
	}
}

function setSubMenuState()
{
	// first set all sub-menus off
	setSubMenus(navRoot, "clearAll") ;

	// then set correct ones to "on"
	for (p = curNav ; p && (p.level > 0) ; p = p.parent)
		if (p.subMenuState == "hidden")
			p.subMenuState = "visible" ;

	if (curNav && (curNav.subMenuState == "visible"))
		//setNodeBkgImg(curNav.children[0], false) ;			// style 1: submenu name is selected only when mouse is on "home" node
		setNodeBkgImg(curNav.children[0], true) ;			// style 2: submenu name is selected for "home" node or parent node

	// then draw the whole tree
	setSubMenus(navRoot, "drawIt") ;
}

function setSubMenus(node, mode)
{
	if (node.subMenuState == "none")
		return ;

	if (node.level > 0)
	{
		if (mode == "clearAll") 
			node.subMenuState = "hidden" ;
		else
		{
			img = eval('document.' + node.children[0].obj.imgID) ;
			img.style.visibility = node.subMenuState ;
		}
	}

	for (var i = 0 ; i < node.children.length ; ++i)
		setSubMenus(node.children[i], mode) ;
}

function setNavText()
{
	var node = curNav ;

	// we don't need any text for the "home" item or any items with a sub-menu
	if (node && ((node.index < 2) || (node.subMenuState == "visible")))
		node = null ;

	theDiv = document.getElementById("nav_text") ;
	theDiv.style.visibility = "hidden" ;
	theDiv.style.minWidth = 0 ;
	setInnerHTML(theDiv, node ? node.name : "") ;

	if (node)
	{
		p = node.parent.children[0] ;			// enclosing region
		theDiv.style.minWidth = (theDiv.offsetWidth + 10) + "px" ;
		theDiv.style.left = (p.x - theDiv.offsetWidth / 2) + "px" ;
		theDiv.style.top = (p.y + 65) + "px" ;
		theDiv.style.visibility = "visible" ;
	}
}

function delObjChildren(obj)
{
	while (obj.childNodes.length > 0)
		obj.removeChild(obj.childNodes[0]) ;
}

function setInnerHTML(obj, str)
{
	var theText = document.createTextNode(str) ;
	delObjChildren(obj) ;
	obj.appendChild(theText) ;
}

function navClick()
{
	if (curNav)
	{
		var dest = curNav.obj.href ;
		if (dest.length && (-1 == dest.search(/no_link/)))
			self.location = makeURL(curNav.obj.href, false) ;
	}
}

function navTextEvent(evt)
{
	if ((!isGoodBrowser) || (!defNav) || (defNav.level < 2))
		return ;

	theDiv = document.getElementById("nav_text") ;
	if (theDiv.style.visibility == 'hidden')
		return ;

	theDiv.style.cursor = 'pointer' ;

	gEvent = evt ;
	if (gEvent.type == 'click')
	{
		navClick() ;
		return ;
	}
	theDiv.style.textDecoration = (gEvent.type == 'mouseover') ? 'underline' : 'none' ;
}

function openCloseNavDrawer(evt)
{
	var navDrawerDiv = document.getElementById("nav_drawer_div") ;
	var	mouseX ;

	if (navDrawerOpening)
		return ;

	gEvent = evt ;
	mouseX = gEvent.clientX + ((document.all) ? document.body.scrollLeft : window.pageXOffset) ;
	if (mouseX > 150)
		mouseX -= parseInt(navDrawerDiv.style.left.replace(/px/, '')) ;

	if (((mouseX > 285) ? 0 : 1) != navDrawerOpen)
	{
		navDrawerOpen = 1 - navDrawerOpen ;
		animateNavDrawer() ;
	}
}

function animateNavDrawer()
{
	var navDrawerDiv = document.getElementById("nav_drawer_div") ;
	var x = parseInt(navDrawerDiv.style.left.replace(/px/, '')) ;

	navDrawerOpening = 1 ;

	if (navDrawerOpen)
	{
		if (x == 0)
		{
			navDrawerOpening = 0 ;
			return ;
		}
		x += 40 ;
		if (x > 0)
			x = 0 ;
	}
	else
	{
		if (x == -260)
		{
			navDrawerOpening = 0 ;
			return ;
		}
		x -= 40  ;
		if (x < -260)
			x = -260 ;
	}
		
	navDrawerDiv.style.left = x + 'px' ;
	setTimeout('animateNavDrawer()', 30) ;
}



//////////////////////////////////////
//                                  //
//   image-enlargement functions    //
//                                  //
//////////////////////////////////////

var enlargeWin = null ;
var preloadList = new Array() ;
var	imgCache = new Array() ;
var lastAnimateTimeoutID = -1 ;
var	nextImgSrc = '' ;
var	pageLoaded = false ;

function prepareEnlarge(obj, index)
{
	preloadList[index] = obj.src.replace(/_small/, '_full') ;
}

function showHideLoadingGif(showIt)
{
	document.getElementById('loading_img').style.visibility = showIt ? 'visible' : 'hidden' ;
}

function displayLoadingGif()
{
	return ;		// decided not to use this functionality, at least for the initial image

	showHideLoadingGif(!pageLoaded) ;
	if (!pageLoaded)
		setTimeout("displayLoadingGif()", 200) ;
}

function finishPreloads()
{
	// this fn gets called when initial page load is complete
	pageLoaded = true ;

	// ...so hide the "loading" gif, in case it got shown
	showHideLoadingGif(false) ;

	for (var i = 0 ; i < preloadList.length ; ++i)
	{
		imgCache[i] = new Image() ;
		imgCache[i].src = preloadList[i] ;
	}
}

function getImgIndexFromSrc(src)
{
	for (var i = 0 ; i < preloadList.length ; ++i)
		if (preloadList[i] == src)
			return (i)
	return (-1) ;
}

function enlarge(obj)
{
	var newImgSrc = obj.src.replace(/_small/, '_full') ;
	var oldImgSrc = document.getElementById('main_img').src ;
	var	dir ;
	var oldIndex ;

	if ((oldImgSrc == newImgSrc) || (!pageLoaded))
		return ;

	oldIndex = getImgIndexFromSrc(oldImgSrc) ;
	if (typeof (imageSwitchHook) == 'function')
		imageSwitchHook("pre", oldIndex) ;

	if (0 <= lastAnimateTimeoutID)
	{
		clearTimeout(lastAnimateTimeoutID) ;
		showHideLoadingGif(false) ;
	}

	dir = (oldIndex < getImgIndexFromSrc(newImgSrc)) ? -1 : 1 ;
	nextImgSrc = newImgSrc ;
	animateImgSwitch(0, dir) ;
}

function animateImgSwitch(pctDone, dir)
{
	var	img1 = document.getElementById('main_img') ;
	var	img2 = document.getElementById('main_img_2') ;
	var	newImgSrc = nextImgSrc ;
	var	cacheImg ;
	var x, width, height ;

	if (-1 == (x = getImgIndexFromSrc(newImgSrc)))
		return ;
	cacheImg = imgCache[x] ;

	if (pctDone == 0)
	{
		// make sure it's loaded
		if (!cacheImg.complete)
			newImgSrc = '/navball/blank.gif' ;

		if (isNaN(height = parseInt(getImgSize(newImgSrc).split(' ')[1])))
			height = 1016 ;	

		if (dir < 0)
		{
			img2.src = newImgSrc ;
			img2.height = height ;
		}
		else
		{
			img2.src = img1.src ;
			img2.height = img1.height ;
			img1.style.left = '-' + img1.width + 'px' ;
			img1.src = newImgSrc ;
			img1.height = height ;
			img2.style.left = '0px' ;
			img2.clip = 'rect(0px, ' + img1.width + 'px, 1100px, 0px)' ;
		}
	}

	pctDone += 10 ;
	if (pctDone == 100)
	{
		if (dir < 0)
		{
			img1.src = img2.src ;
			img1.height = img2.height ;
		}
		img2.src = '' ;
		img2.style.clip = 'rect(0px, 0px, 1100px, 0px)' ;
		img1.style.left = '0px' ;

		// if image hadn't been loaded when we started animating...
		if (img1.src = '/navball/blank.gif')
		{
			if (cacheImg.complete)			// ...but it is now, use the image
				img1.src = nextImgSrc ;
			else							// ...still not ready, so use the "loading" animated gif until it's ready
			{
				showHideLoadingGif(true) ;
				lastAnimateTimeoutID = setTimeout('waitForLoad()', 200) ;
			}
		}

		if (typeof (imageSwitchHook) == 'function')
			imageSwitchHook("post", x) ;

		return ;
	}

	x = (width = parseInt(img1.width)) * ((dir < 0) ? pctDone : 100 - pctDone) / 100 ;
	img1.style.left = '-' + x + 'px' ;
	img2.style.left = width - x + 'px' ;
	img2.style.clip = 'rect(0px, ' + x + 'px, 1100px, 0px)' ;

	lastAnimateTimeoutID = setTimeout('animateImgSwitch(' + pctDone + ', ' + dir + ')', 30) ;
}

function waitForLoad()
{
	var	x, cacheImg ;

	if (-1 == (x = getImgIndexFromSrc(nextImgSrc)))
		return ;
	cacheImg = imgCache[x] ;
	if (cacheImg.complete)
	{
		showHideLoadingGif(false) ;
		document.getElementById('main_img').src = nextImgSrc ;
	}
	else
		lastAnimateTimeoutID = setTimeout('waitForLoad()', 200) ;
}


/////////////////////////////////////
//                                 //
//     browser-compatibility       //
//                                 //
/////////////////////////////////////

var isMSIE = false ;
var isSafari = false ;

function mySetCookie(name, value, maxAge)
{
	var expDate = new Date() ;

	if (!maxAge)
		maxAge = 1000 * 60 * 60 * 24 * 7 ;		// default: expires 1 week from now
	expDate.setTime(expDate.getTime() + maxAge) ;

	document.cookie = name + "=" + escape(value) + "; expires=" + expDate.toGMTString() + "; path=/" ;
}

function checkBrowser()
{
    var agt = navigator.userAgent.toLowerCase() ;
    var appVer = navigator.appVersion.toLowerCase() ;
	var browserList = new Array("opera", "firefox", "safari") ;

	isSafari = (appVer.indexOf('safari') >= 0) ;

	if (document.cookie.indexOf('didBrowserCheck') >= 0)
	{
		isMSIE = (document.cookie.indexOf('is_msie') >= 0) ;
		return ;
	}

	// check for msie
    if (appVer.indexOf('msie') >= 0)
	{
		// make sure it's not another browser reporting msie compatibility
		for (var i = 0 ; i < browserList.length ; ++i)
			if (agt.indexOf(browserList[i]) >= 0)
				break ;
		if (i == browserList.length)
		{
			isMSIE = true ;
			if (agt.indexOf("mac") >= 0)		// msie for mac --> not allowed
			{
				self.location = '/cgi/noscript.sh' ;
				return ;
			}
		}
	}
	
	// make sure cookies are working
	document.cookie = 'cookieTest=true;path=/' ;
	if (document.cookie.indexOf('cookieTest') < 0)
	{
		self.location = '/cgi/cookies.sh' + ((self != top) ? '?inFrame' : '') ;
		return ;
	}

	// record that we passed the test, and whether this was msie
	mySetCookie("didBrowserCheck", isMSIE ? "is_msie" : "isnt_msie", 10 * 60) ;		// check again in 10 mins

	// save referer if we haven't already
	saveReferer() ;
}

function saveReferer()
{
	if (document.cookie.indexOf('origRef') < 0)
	{
		var s = document.referrer ;
		var d = new Date() ;
		var utcSec = Math.round(d.getTime() / 1000) + d.getTimezoneOffset() * 60 ;

		document.cookie = "origRef=" + ((s == '') ? 'none' : escape(utcSec + "|" + s)) + "; expires=Thu, 31-Dec-2020 00:00:00 GMT; path=/" ;
	}
}

function writeIlanio(textColor)
{
	if (textColor == null)
		textColor = "000" ;

	//document.write('<span style="font-family: \'Arial Black\',Arial,sans-serif; font-size: 140px; line-height: 0.75; color: #000;">') ;
	document.write('<span style="font-family: Arial ,sans-serif; font-weight: bold;  font-size: 140px; line-height: 0.75; color: #' + textColor + ';">') ;
	if (isMSIE)
		document.write('<span style="letter-spacing: -.6em">ILANIO</span>') ;
	else
		document.write('<span style="letter-spacing: -.075em">I<span style="letter-spacing: -.2em">L</span>ANIO</span>') ;
		//document.write('<span style="letter-spacing: -.075em">I<span style="letter-spacing: -.2em">L</span>ANIO</span>') ;
	document.write('</span>') ;
	document.close() ;
}




/////////////////////////////////////
//                                 //
//      xmlhttp req stuff          //
//                                 //
/////////////////////////////////////

var gXMLReq ;
var gXMLReqFailed = false ;

function loadXMLDoc(url, method, data, handler)
{
	gXMLReq = false;

	if (window.XMLHttpRequest)			// branch for native XMLHttpRequest object
	{
		try
		{
			gXMLReq = new XMLHttpRequest() ;
		}
		catch(e)
		{
			gXMLReq = false ;
		}
	}
	else if (window.ActiveXObject)		// branch for IE/Windows ActiveX version
	{
		try
		{
			gXMLReq = new ActiveXObject("Msxml2.XMLHTTP") ;
		}
		catch(e)
		{
			try
			{
				gXMLReq = new ActiveXObject("Microsoft.XMLHTTP") ;
			}
			catch(e)
			{
				gXMLReq = false ;
			}
		}
	}

	if (gXMLReq)
	{
		if (handler)
			gXMLReq.onreadystatechange = handler ;
		gXMLReq.open(method, url, true) ;
		if (method.toUpperCase() == 'POST')
			gXMLReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded') ;
		gXMLReq.send(data) ;
	}
}

function aSampleXMLReqHandler()
{
	if (gXMLReq.readyState == 4)			// only if gXMLReq shows "loaded"
	{
		if (gXMLReq.status == 200)
			alert(gXMLReq.responseText) ;
		else
		{
			gXMLReqFailed = true ;				// xml req failed; try again as normal post
			// do something
		}
	}
}

function formToString(theForm)
{
	var s = '' ;
	var elt ;
	
	for (var i = 0 ; i < theForm.elements.length ; ++i)
	{
		elt = theForm.elements[i];
		if ((elt.type == 'text') || (elt.type == 'hidden') || (elt.type == 'select-one') || (elt.type == 'textarea'))
			s += ((i > 0) ? '&' : '') + elt.name + '=' + escape(elt.value) ;
	}
	return (s) ;
}

function doXMLReq(target, method, data, handler)
{
	gXMLReq = false ;
	if (method == "GET")
		target += '?' + data, data = '' ;
	if (!gXMLReqFailed)
		loadXMLDoc(target, method, data, handler) ;
	return (gXMLReq) ;
}



////////////////////////
//                    //
// stuff for laying   //
// out pages          //
//                    //
////////////////////////

var arrangeDragTgt = null ;
var arrangeX, arrangeY ;

function arrangeEvt(event)
{
	if (event.type == 'mousedown')
	{
		arrangeDragTgt = event.target ;
		arrangeDragTgt.style.position = 'relative' ;

		if (!arrangeDragTgt.style.left)
			arrangeDragTgt.style.left = '0px' ;
			
		if (!arrangeDragTgt.style.top)
			arrangeDragTgt.style.top = '0px' ;

		arrangeX = event.clientX ;
		arrangeY = event.clientY ;
	}
	else if (event.type == 'mouseup')
	{
		x = parseInt(arrangeDragTgt.style.left.replace(/px/, '')) ;
		y = parseInt(arrangeDragTgt.style.top.replace(/px/, '')) ;
		alert("new pos: left " + x + ", top " + y) ;
		arrangeDragTgt = null ;
	}
	else if (event.type == 'mousemove')
	{
		if (arrangeDragTgt == null)
			return ;
		dx = event.clientX - arrangeX ;
		dy = event.clientY - arrangeY ;
		arrangeX = event.clientX ;
		arrangeY = event.clientY ;
		if (dx)
			arrangeDragTgt.style.left = (parseInt(arrangeDragTgt.style.left.replace(/px/, '')) + dx) + 'px' ;
		if (dy)
			arrangeDragTgt.style.top = (parseInt(arrangeDragTgt.style.top.replace(/px/, '')) + dy) + 'px' ;
	}
}


/////////////////////////////////////
//                                 //
//         misc other stuff        //
//                                 //
/////////////////////////////////////


function dispEmail(user, domain, isLink)
{
	var s = "" ;

	if (isLink)
		s += "<a href='mailto:" + user + "@" + domain + "'>" ;
	s += user + "@" + domain ;
	if (isLink)
		s += "</a>" ;

	document.write(s) ;
	document.close() ;
}		

function makeURL(path, secure)
{
	var newURL = path + '' ;
	newURL = newURL.replace(/^https?:\/\/[^\/]*\//, '') ;
	newURL = newURL.replace(/^\//, '') ;

	if (secure)
		return ('https://' + self.location.hostname + '/' + newURL) ;
	else
		return ('http://' + self.location.hostname + '/' + newURL) ;
}

function hiliteLink(obj, turnOn)
{
	var tgtLink ;
	var spans = document.getElementsByTagName("SPAN") ; 

	for ( ; obj ; obj = obj.parentNode)
		if (obj.href && (-1 < obj.href.search(/.html$/)))
		{
			tgtLink = obj.href ;
			break ;
		}
	if (!tgtLink)
		return ;

	for (var i = 0 ; i < spans.length ; ++i)
	{
		if ((-1 < spans[i].className.search(/^garmentName/)) && (spans[i].parentNode.href == tgtLink))
		{
			spans[i].style.textDecoration = turnOn ? "underline" : "" ;
			break ;
		}
	}
}

function getEltPos(tgtElt, withinDiv)
{
	var	x = 0 ;
	var y = 0 ;

	while (true)
	{
		y += tgtElt.offsetTop, x += tgtElt.offsetLeft ;
		tgtElt = tgtElt.offsetParent ;
		if ((!tgtElt) || (withinDiv && (tgtElt.tagName == 'DIV')))
			break ;
	}
	return (x + ',' + y) ;
}

function myScrollOffset()
{
	var x,y;

	if (self.pageYOffset) 															// all except Explorer
		x = self.pageXOffset, y = self.pageYOffset ;
	else if (document.documentElement && document.documentElement.scrollTop)		// Explorer 6 Strict
		x = document.documentElement.scrollLeft, y = document.documentElement.scrollTop ;
	else if (document.body)															// all other Explorers
		x = document.body.scrollLeft, y = document.body.scrollTop ;

	return (x + ',' + y) ;
}

function myInnerWidth()
{
	var x,y;

	if (self.innerHeight)															// all except Explorer
		x = self.innerWidth, y = self.innerHeight ;
	else if (document.documentElement && document.documentElement.clientHeight)		// Explorer 6 Strict Mode
		x = document.documentElement.clientWidth, y = document.documentElement.clientHeight ;
	else if (document.body)															// other Explorers
		x = document.body.clientWidth, y = document.body.clientHeight ;

	return (x + ',' + y) ;
}

function getScrollRect()
{
	var top, left, bottom, right ;

	windSize = myInnerWidth().split(',') ;
	windScroll = myScrollOffset().split(',') ;

	left = parseInt(windScroll[0]) ;
	top = parseInt(windScroll[1]) ;
	right = left + parseInt(windSize[0]) ;
	bottom = top + parseInt(windSize[1]) ;

	return (left + ',' + top + ',' + right + ',' + bottom) ;
}

