/**
* Global JavaScript Definitions
* (Old site code also included below the main WebPage class)
*/


xhtml = new WebPage();
window.onload = new Function("xhtml.init();");


/**
* Creates a new WebPage object with methods used by all pages, can be extended to add page specific methods.
*/
function WebPage()
	{
	// Step 1. Define Properties

	this.initialized = false;
	this.debug = false;


	// Step 2. Define Public Methods

	/**
	* Sets up the initial page state and event handlers
	*/
	this.init = function()
		{
		this.initAnchors();

		// Setup drop down menus
		menu = new dropdownMenu();

		// If this the product detail page, setup a thumbnail gallery
		if (document.getElementById('detailFooterThumbnails') != null)
			{
			this.gallery = new Gallery();
			}

		// If this the product detail page, enable changing product views
		if (document.getElementById('detailBodyThumbnails') != null)
			{
			var imgs = document.getElementById('detailBodyThumbnails').getElementsByTagName('img');
			for (var x = 0; x < imgs.length; x++)
				{
				imgs[x].style.cursor = 'pointer';
				imgs[x].onclick = function()
					{
					document.getElementById('detailBodyImage').getElementsByTagName('img')[0].src = this.src.replace('small', 'large');
					}
				}
			}

		// Set class as initialized
		this.initialized = true;
		}


	/**
	* Adds standard event handlers to process in-page links and offsite links
	*/
	this.initAnchors = function()
		{
		var links = document.getElementsByTagName('a');
		for (var x = 0; x < links.length; x++)
			{
			// 1. Make offsite links and pdfs open in a new tab/window
			if (/\b(offsite|pdf)\b/.exec(links[x].className))
				{
				links[x].onclick = function()
					{
					window.open(this.href,'_blank');
					return false;
					}
				}

			// 2. Make inpage links smooth scroll
			if (/\binpage\b/.exec(links[x].className))
				{
				var url = links[x].href;
				var startPos = url.indexOf('#')+1;
				var endPos = (url.indexOf('?') != -1 ? url.indexOf('?')+1 : url.length);
				var target = url.substring(startPos, endPos);
				links[x].onclick = new Function('xhtml.smoothScroll("' + target + '");');
				links[x].href = 'javascript:javascript:void(1);';
				}

			// 3. If we're in debug mode, make empty links bright green
			if (this.debug == true && links[x].href.indexOf('#') == (links[x].href.length-1))
				{
				links[x].style.background = '#0f0';
				links[x].style.color = '#000';

				// Set the transpancy of all child nodes to 50%, so we can see the green
				for (var y = 0; y < links[x].childNodes.length; y++)
					{
					// Check if it's an element node (rather than a text node, etc)
					if (links[x].childNodes[y].nodeType == 1)
						{
						links[x].childNodes[y].style.opacity = '0.5';
						}
					}
				}

			// 4. Disable links to the current page (improves user experience)
			if (links[x].href.replace('?clearAll', '') == window.location.toString() || links[x].href.replace('?clearAll', '') == window.location.toString() + '#')
				{
				if (links[x].href.indexOf('?clearAll') != -1)
					{
					links[x].className += ' active';
					}
				links[x].style.cursor = 'default';
				links[x].style.textDecoration = 'none';
				}
			}
		}


	/**
	* Submits the specified form
	*
	* @param			formId		The id of the form to submit
	* @param			method		Override the form's default method (optional: get|post)
	*/
	this.submitForm = function(id, method)
		{
		if (method)
			{
			document.getElementById(id).method = method;
			}
		document.getElementById(id).submit();
		}


	/**
	* Scrolls the page to the specified element
	*
	* @param			elementId			The ID of the element to scroll to
	* @param			elementY			The Y position of element (optional, will be calculated if not specified)
	*/
	this.smoothScroll = function(elementId, elementY)
		{
		// If the elements vertical location hasn't been specificed, calculate it
		if (arguments.length != 2)
			{
			// Get it's offset
			obj = document.getElementById(elementId);
			obj.style.display = 'block';	// Make sure it's visible, otherwise we can't get it's location
			elementY = obj.offsetTop;

			// If its parent is relative or absolutely positioned, find it's offset and add it to the total
			while (obj.offsetParent)
				{
				obj = obj.offsetParent;
				elementY += obj.offsetTop;
				}

			// Make the scroll stop just above the target (looks nicer)
			elementY -= 15;
			if (elementY < 0)
				{
				elementY = 0;
				}

			// Check to see we're not trying to scroll off the end of the page
			var contentHeight = document.getElementById('page').offsetHeight;
			var windowHeight = (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight));
			if ( (contentHeight - windowHeight) < elementY)
				{
				elementY = (contentHeight - windowHeight);
				}
			}

		// Get the current window scroll position
		var yPos = window.scrollY ? window.scrollY : (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);

		// Calculate the pixels remaining to scroll and the scroll step size
		var distanceLeft = Math.abs(yPos - elementY);
		var stepSize = 100;
		if (distanceLeft < 400)
			{
			stepSize = 60;
			}
		if (distanceLeft < 200)
			{
			stepSize = 20;
			}
		if (distanceLeft < 50)
			{
			stepSize = 10;
			}

		// Calculate the scroll
		if (yPos < elementY)
			{
			// Scroll down
			yPos += stepSize;

			// Check if we're scrolled past the target
			if (elementY < yPos)
				{
				yPos = elementY;
				}
			}
		else if (elementY < yPos)
			{
			// Scroll Up
			yPos -= stepSize;

			// Check if we're scrolled past the target
			if (yPos < elementY)
				{
				yPos = elementY;
				}
			}

		// Check for less than zero
		if (yPos < 0)
			{
			yPos = 0;
			}
		if (elementY < 0)
			{
			elementY = 0;
			}

		// Scroll window
		window.scrollTo(0, yPos);

		// If we haven't reached the target, run the another scroll step
		if (yPos != elementY)
			{
			setTimeout("xhtml.smoothScroll('" + elementId + "', " + elementY + ");", 10);
			}
		}


	/**
	* Sets the current view in a XHTML document
	*
	* Displays and Hides elements and once complete, can optionally scroll to specified element.
	*
	* @param		toDisplay			An array of element ID's to display
	* @param		toHide				An array of element ID's to hide
	* @param		scrollTo			The element ID to scroll to once the view has been set (optional)
	*/
	this.setView = function(toDisplay, toHide, scrollTo)
		{
		// 1. Check if we've been passed an arrays or a strings for display param
		if (typeof(toDisplay) != 'array' && typeof(toDisplay) != 'object')
			{
			var toDisplay = new Array(typeof(toDisplay) != 'undefined' ? toDisplay : '');
			}

		// 2. Check if we've been passed an arrays or a strings for hide param
		if (typeof(toHide) != 'array' && typeof(toHide) != 'object')
			{
			var toHide = new Array(typeof(toHide) != 'undefined' ? toHide : '');
			}

		// 3. Display elements
		for (var x = 0; x < toDisplay.length; x++)
			{
			if (document.getElementById(toDisplay[x]))
				{
				document.getElementById(toDisplay[x]).style.display = 'block';
				}
			}

		// 4. Hide elements
		for (var x = 0; x < toHide.length; x++)
			{
			if (document.getElementById(toHide[x]))
				{
				document.getElementById(toHide[x]).style.display = 'none';
				}
			}

		// 5. Scroll to specified element, if supplied
		if (arguments.length == 3)
			{
			if (document.getElementById(scrollTo))
				{
				xhtml.smoothScroll(scrollTo);
				}
			}
		}



	// Step 3. Define Private Methods

	/**
	* Finds the parent of the element with a node type of parentTagName
	*
	* @param		element					The element object to find the parent of
	* @param		parentTagName		The type of parent element to find
	*
	* @return		The element's parent object of the specified type, or null if no parent of that type could be found
	*/
	function findParent(element, parentTagName)
		{
		if (element == null)
			{
			return null;
			}
		else
			{
			if ( element.nodeType == 1 && element.tagName.toLowerCase() == parentTagName.toLowerCase() )
				{
				return element;
				}
			else
				{
				return findParent(element.parentNode, parentTagName);
				}
			}
		}
	}



// ############################################################################


/**
* Down Drop Menu Class
* (old code from 2006 release of site)
*/
function dropdownMenu() {
	this.menuTimeout = null;
	this.headings = new Array('globalHeaderJewelry','globalHeaderAbout', 'globalHeaderSupport', 'globalHeaderLinks');
	this.menus = new Array('globalHeaderJewelryMenu','globalHeaderAboutMenu', 'globalHeaderSupportMenu', 'globalHeaderLinksMenu');

	// Add event handlers to headings
	for (var x=0; x<this.headings.length; x++)
		{
		document.getElementById(this.headings[x]).onmouseover = function()
			{
			try
				{
				clearTimeout(menu.menuTimeout);
				menu.show(this.id + 'Menu');
				}
			catch (err)
				{
				}
			}
		document.getElementById(this.headings[x]).onmouseout = function()
			{
			try
				{
				clearTimeout(menu.menuTimeout);
				menu.menuTimeout = setTimeout("menu.hide();", 800);
				}
			catch (err)
				{
				}
			}
		}

	// Add show/hide event handlers to menus
	for (var x = 0; x < this.menus.length; x++)
		{
		var anchors = document.getElementById(this.menus[x]).getElementsByTagName('a');
		for (var y=0; y<anchors.length; y++)
			{
			anchors[y].onmouseover = function()
				{
				try
					{
					clearTimeout(menu.menuTimeout);
					}
				catch (err)
					{
					}
				}
			anchors[y].onmouseout = function()
				{
				try
					{
					clearTimeout(menu.menuTimeout);
					menu.menuTimeout = setTimeout("menu.hide();", 800);
					}
				catch (err)
					{
					}
				}
			}
		}

	// Class member functions
	this.hide = function()
		{
		clearTimeout(menu.menuTimeout);
		for (var x = 0; x < this.menus.length; x++)
			{
			document.getElementById(this.menus[x]).style.visibility = 'hidden';
			}
		}

	this.show = function(id)
		{
		menu.hide();
		document.getElementById(id).style.visibility = 'visible';
		}
	}



/**
* Product Detail Page Gallery Class
* (old code from 2006 release of site)
*/
function Gallery()		// CLASS
	{
	this.pageSize = 720;
	this.images = 4;
	this.currentPage = 1;
	this.pages = 1;

	gallery = this;

	this.init = function()
		{
		// Add rollover event handlers
		var anchors = document.getElementById('detailFooterThumbnailsImages').getElementsByTagName('a');
		for (var x = 0; x < anchors.length; x++)
			{
			var img = anchors[x].getElementsByTagName('img')[0];
			img.onmouseover = function()
				{
				resizeImg(this, 194.8052);
				}
			img.onmouseout = function()
				{
				resizeImg(this, 100);
				}
			}

		// Get the number of images
		this.images = document.getElementById('detailFooterThumbnailsImages').getElementsByTagName('a').length;
		this.pages = Math.ceil( this.images / 4 );

		// Setup the scrolling options
		if (document.getElementById('detailFooterThumbnailsImages').className != '')
			{
			this.currentPage = parseInt(document.getElementById('detailFooterThumbnailsImages').className);
			}

		// Update buttons
		document.getElementById('detailFooterPrev').href = 'javascript:gallery.prev();';
		document.getElementById('detailFooterNext').href = 'javascript:gallery.next();';
		this.updateButtons();
		}

	this.prev = function()
		{
		if (this.currentPage == 1)
			{
			return;
			}

		this.currentPage--;
		document.getElementById('detailFooterThumbnailsImages').style.left = '-' + ((this.currentPage - 1) * this.pageSize) + 'px';

		// update buttons
		this.updateButtons();
		}

	this.next = function()
		{
		if (this.currentPage == this.pages)
			{
			return;
			}

		this.currentPage++;
		document.getElementById('detailFooterThumbnailsImages').style.left = '-' + ((this.currentPage - 1) * this.pageSize) + 'px';

		// update buttons
		this.updateButtons();
		}

	this.updateButtons = function()
		{
		if (this.currentPage == 1)
			{
			document.getElementById('detailFooterPrev').className = 'prev disabled';
			}
		else
			{
			document.getElementById('detailFooterPrev').className = 'prev';
			}

		if (this.currentPage == this.pages)
			{
			document.getElementById('detailFooterNext').className = 'next disabled';
			}
		else
			{
			document.getElementById('detailFooterNext').className = 'next';
			}
		}

	this.change = function(elementId, filename)
		{
		try
			{
			document.getElementById(elementId).src = 'images/' + filename;
			}
		catch (err)
			{
			// element doesn't exist, so ignore
			}
		}

	this.init();
	}



/**
* Misc Functions
* (old code from 2006 release of site)
*/
function detailImage(x)
	{
	var total = parseInt(document.getElementById('detailBodyImage').className);
	var image = document.getElementById('detailBodyImage').getElementsByTagName('img')[0];
	// Update image
	image.src = image.src.replace(/\d{2}\.jpg$/, (''+(x < 10 ? '0' : '') + x + '.jpg'));
	}

function detailImagePrev()
	{
	var total = parseInt(document.getElementById('detailBodyImage').className);
	var image = document.getElementById('detailBodyImage').getElementsByTagName('img')[0];
	var current = document.getElementById('detailBodyImage').getElementsByTagName('img')[0].src.match(/(\d{2})\.jpg$/);
	x = parseInt(current[1]);
	if (--x < 1)
		{
		x = total;
		}
	// Update image
	image.src = image.src.replace(/\d{2}\.jpg$/, (''+(x < 10 ? '0' : '') + x + '.jpg'));
	}

function detailImageNext()
	{
	var total = parseInt(document.getElementById('detailBodyImage').className);
	var image = document.getElementById('detailBodyImage').getElementsByTagName('img')[0];
	var current = document.getElementById('detailBodyImage').getElementsByTagName('img')[0].src.match(/(\d{2})\.jpg$/);
	x = parseInt(current[1] * 1);
	if (total < ++x)
		{
		x = 1;
		}
	// Update image
	image.src = image.src.replace(/\d{2}\.jpg$/, (''+(x < 10 ? '0' : '') + x + '.jpg'));
	}

function popup(filename, width, height)
	{
	url = window.location.toString().substring(0,window.location.toString().lastIndexOf('/')+1) + filename;

	if (!width)
		{
		var width = 800;
		}

	if (!height)
		{
		var height = 550;
		}

	var left = (screen.width ? (screen.width/2)-(width/2) : 40);
	var top = (screen.height ? (screen.height/2)-(height/2) : 40);
	if (left < 0)
		{
		left = 0;
		}
	if (top < 0)
		{
		top = 0;
		}
	window.open(url, 'royalorderpopup', 'toolbar=no,location=no,directories=no,status=yes,scrollbars=no,resizable=yes,copyhistory=no,top='+top+',left='+left+',width='+width+',height='+height);
	return false;
	}


/* =================================================================================== */

pressPage = 1;
pressTotalPages = 12;

function pressPrev()
	{
	// Change page
	pressPage--;
	if (pressPage < 1)
		{
		pressPage = 1;
		}

	// Update nav
	document.getElementById('pressPrev').className = '';
	document.getElementById('pressNext').className = '';
	if (pressPage == 1)
		{
		document.getElementById('pressPrev').className = 'hidden';
		}
	
	// Update content
	for (var x = 1; x <= pressTotalPages; x++)
		{
		document.getElementById('pressItems' + x).className = 'hidden';
		}
	document.getElementById('pressItems' + pressPage).className = '';
	}


function pressNext()
	{
	// Change page
	pressPage++;
	if (pressTotalPages < pressPage)
		{
		pressPage = pressTotalPages;
		}

	// Update nav
	document.getElementById('pressPrev').className = '';
	document.getElementById('pressNext').className = '';
	if (pressPage == pressTotalPages)
		{
		document.getElementById('pressNext').className = 'hidden';
		}
	
	// Update content
	for (var x = 1; x <= pressTotalPages; x++)
		{
		document.getElementById('pressItems' + x).className = 'hidden';
		}
	document.getElementById('pressItems' + pressPage).className = '';
	}


function pressPopup(filename)
	{
	var pressPopupSizes = { 1: { width: 446 }, 10: { width: 448 }, 11: { width: 463 }, 12: { width: 524 }, 13: { width: 1862 }, 14: { width: 493 }, 15: { width: 496 }, 16: { width: 445 }, 17: { width: 493 }, 18: { width: 465 }, 19: { width: 475 }, 2: { width: 932 }, 20: { width: 1405 }, 21: { width: 557 }, 22: { width: 475 }, 23: { width: 439 }, 24: { width: 1894 }, 25: { width: 475 }, 26: { width: 868 }, 27: { width: 466 }, 28: { width: 497 }, 29: { width: 999 }, 3: { width: 703 }, 30: { width: 475 }, 31: { width: 514 }, 32: { width: 932 }, 33: { width: 475 }, 34: { width: 498 }, 35: { width: 467 }, 36: { width: 467 }, 37: { width: 475 }, 38: { width: 475 }, 39: { width: 467 }, 4: { width: 489 }, 40: { width: 982 }, 41: { width: 912 }, 42: { width: 499 }, 43: { width: 932 }, 45: { width: 467 }, 46: { width: 1421 }, 47: { width: 467 }, 48: { width: 467 }, 49: { width: 499 }, 5: { width: 917 }, 50: { width: 475 }, 51: { width: 475 }, 52: { width: 406 }, 53: { width: 491 }, 54: { width: 475 }, 55: { width: 462 }, 56: { width: 868 }, 57: { width: 1814 }, 58: { width: 979 }, 59: { width: 948 }, 6: { width: 926 }, 60: { width: 475 }, 61: { width: 475 }, 62: { width: 936 }, 63: { width: 467 }, 64: { width: 475 }, 65: { width: 475 }, 66: { width: 475 }, 67: { width: 475 }, 68: { width: 977 }, 69: { width: 497 }, 7: { width: 455 }, 70: { width: 497 }, 71: { width: 932 }, 72: { width: 475 }, 73: { width: 475 }, 74: { width: 467 }, 75: { width: 525 }, 76: { width: 467 }, 77: { width: 467 }, 78: { width: 514 }, 79: { width: 475 }, 8: { width: 464 }, 80: { width: 475 }, 81: { width: 2840 }, 82: { width: 3730 }, 83: { width: 932 }, 84: { width: 475 }, 85: { width: 467 }, 86: { width: 932 }, 87: { width: 467 }, 88: { width: 932 }, 89: { width: 475 }, 9: { width: 436 }, 90: { width: 475 }, 91: { width: 475 }, 92: { width: 475 }, 94: { width: 475 }, 95: { width: 932 }, 96: { width: 473 }, 97: { width: 497 }, 98: { width: 2918 } };

	url = window.location.toString().substring(0,window.location.toString().lastIndexOf('/')+1) + 'press/' + filename;

	try
		{
		var imageSetNumber = parseInt(filename.replace(/[^0-9]+/g, ''));
		var width = pressPopupSizes[imageSetNumber].width;		
		}
	catch (err)
		{
		var width = screen.width;
		}

	var height = 640;
	if (screen.width < width)
		{
		var width = screen.width;
		}

	var left = Math.floor((screen.width - width) / 2);
	var top = 32;
	if (typeof(pressPopupWindow) != 'undefined')
		{
		try
			{
			pressPopupWindow.close();
			}
		catch (err)
			{
			}
		}
	pressPopupWindow = window.open(url, 'royalorderpress', 'toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,top='+top+',left='+left+',width='+width+',height='+height);
	return false;
	}


/* =================================================================================== */

/**
The JavaScript functions below will gradually enlarge or shrink an image
on the current page. I use this for mouseover effects, but there might be
some other interesting applications of it as well.

You can use these scripts in any way you'd like, just don't pretend like
you wrote them yourself.

version 1.0
March 17, 2005
Julian Robichaux, http://www.nsftools.com
*/

/**** adjust these two parameters to control how fast or slow
 **** the images grow/shrink ****/
// how many milliseconds we should wait between resizing events
var resizeDelay = 1;
// how many pixels we should grow or shrink by each time we resize
var resizeIncrement = 5;

// this will hold information about the images we're dealing with
var imgCache = new Object();


/**
The getCacheTag function just creates a (hopefully) unique identifier for
each <img> that we resize.
*/
function getCacheTag (imgElement) {
	return imgElement.src + "~" + imgElement.offsetLeft + "~" + imgElement.offsetTop + "~" + Math.floor(Math.random()*100);
}


/**
We're using this as a class to hold information about the <img> elements
that we're manipulating.
*/
function cachedImg (imgElement, increment) {
	this.img = imgElement;
	this.cacheTag = getCacheTag(imgElement);
	this.originalSrc = imgElement.src;
	
	var h = imgElement.height;
	var w = imgElement.width;
	this.originalHeight = h;
	this.originalWidth = w;
	
	increment = (!increment) ? resizeIncrement : increment;
	this.heightIncrement = Math.ceil(Math.min(1, (h / w)) * increment);
	this.widthIncrement = Math.ceil(Math.min(1, (w / h)) * increment);
}


/**
This is the function that should be called in the onMouseOver and onMouseOut
events of an <img> element. For example:

<img src='onesmaller.gif' onMouseOver='resizeImg(this, 150, "onebigger.gif")' onMouseOut='resizeImg(this)'>

The only required parameter is the first one (imgElement), which is a
reference to the <img> element itself. If you're calling from onMousexxx, 
you can just use "this" as the value.

The second parameter specifies how much larger or smaller we should resize
the image to, as a percentage of the original size. In the example above,
we want to resize it to be 150% larger. If this parameter is omitted, we'll
assume you want to resize the image to its original size (100%).

The third parameter can specify another image that should be used as the
image is being resized (it's common for "rollover images" to be similar but
slightly different or more colorful than the base images). If this parameter
is omitted, we'll just resize the existing image.
*/
function resizeImg (imgElement, percentChange, newImageURL) {
	// convert the percentage (like 150) to an percentage value we can use
	// for calculations (like 1.5)
	var pct = (percentChange) ? percentChange / 100 : 1;
	
	// if we've already resized this image, it will have a "cacheTag" attribute
	// that should uniquely identify it. If the attribute is missing, create a
	// cacheTag and add the attribute
	var cacheTag = imgElement.getAttribute("cacheTag");
	if (!cacheTag) {
		cacheTag = getCacheTag(imgElement);
		imgElement.setAttribute("cacheTag", cacheTag);
	}
	
	// look for this image in our image cache. If it's not there, create it.
	// If it is there, update the percentage value.
	var cacheVal = imgCache[cacheTag];
	if (!cacheVal) {
		imgCache[cacheTag] = new Array(new cachedImg(imgElement), pct);
	} else {
		cacheVal[1] = pct;
	}
	
	// if we're supposed to be using a rollover image, use it
	if (newImageURL)
		imgElement.src = newImageURL;
	
	// start the resizing loop. It will continue to call itself over and over
	// until the image has been resized to the proper value.
	resizeImgLoop(cacheTag);
	return true;
}


/**
This is the function that actually does all the resizing. It calls itself
repeatedly with setTimeout until the image is the right size.
*/
function resizeImgLoop (cacheTag) {
	// get information about the image element from the image cache
	var cacheVal = imgCache[cacheTag];
	if (!cacheVal)
		return false;
	
	var cachedImageObj = cacheVal[0];
	var imgElement = cachedImageObj.img;
	var pct = cacheVal[1];
	var plusMinus = (pct > 1) ? 1 : -1;
	var hinc = plusMinus * cachedImageObj.heightIncrement;
	var vinc = plusMinus * cachedImageObj.widthIncrement;
	var startHeight = cachedImageObj.originalHeight;
	var startWidth = cachedImageObj.originalWidth;
	
	var currentHeight = imgElement.height;
	var currentWidth = imgElement.width;
	var endHeight = Math.round(startHeight * pct);
	var endWidth = Math.round(startWidth * pct);
	
	// if the image is already the right size, we can exit
	if ( (currentHeight == endHeight) || (currentWidth == endWidth) )
		return true;
	
	// increase or decrease the height and width, making sure we don't get
	// larger or smaller than the final size we're supposed to be
	var newHeight = currentHeight + hinc;
	var newWidth = currentWidth + vinc;
	if (pct > 1) {
		if ((newHeight >= endHeight) || (newWidth >= endWidth)) {
			newHeight = endHeight;
			newWidth = endWidth;
		}
	} else {
		if ((newHeight <= endHeight) || (newWidth <= endWidth)) {
			newHeight = endHeight;
			newWidth = endWidth;
		}
	}
	
	// set the image element to the new height and width
	imgElement.height = newHeight;
	imgElement.width = newWidth;
	
	// if we've returned to the original image size, we can restore the
	// original image as well (because we may have been using a rollover
	// image in the original call to resizeImg)
	if ((newHeight == cachedImageObj.originalHeight) || (newWidth == cachedImageObj.originalwidth)) {
		imgElement.src = cachedImageObj.originalSrc;
	}
	
	// shrink or grow again in a few milliseconds
	setTimeout("resizeImgLoop('" + cacheTag + "')", resizeDelay);
}
