function ResizeContentContainer()
{
	return false;
	var eDiv;
	var cHeight;
	var nHeight;

	
	nHeight = ContentContainerHeight();
	eDiv = document.getElementById("contentContainer");
	
	if (eDiv != null)
	{
		cHeight = nHeight + "px";
		//alert( "sss" + eDiv.style.height );
		if (cHeight != eDiv.style.height)
		{
			eDiv.style.height =  cHeight;
		}
		
		//if (cHeight != eDiv.style.maxHeight)
			eDiv.style.maxHeight = cHeight;
		//}
	}
	
	eDiv	= document.getElementById("content");
	
	if (eDiv != null && nHeight > 20)
	{
			cHeight = (nHeight - 20) + "px";
			
			//if (cHeight != eDiv.style.minHeight)
			//{
				eDiv.style.minHeight = cHeight;
			//}
	}
}

function ContentContainerHeight()
{
	/* todo: MyLibrary
	var oLibrary = document.getElementById("Library");
	
	if (oLibrary.style.display=="none")
	{
		return pageHeight() - 275;
	}
	else
	{
		return pageHeight() - 360;
	}	
	*/
	return pageHeight() - 190;
	
}

function AddToTempShoppingCart(type, key, price, title)
{
	var cookieName;
	var cookieQuantity;
	var cartElement;
	var cartUnits;
	var button;

	if (CookiesAreEnabled())
	{
		// Get the element displaying the total value of the shopping cart.			
		cartElement = document.getElementById("cartUnits");
			
		// Get the current value of the shopping cart.
		cartUnits = cartElement.innerHTML;
		cartUnits = parseInt( cartUnits );
		
		// Create the name of the cookie
		cookieName = "hhTempShoppingCart_" + type + "_" + key
		
		// Get the current quantity.
		cookieQuantity = readCookie( cookieName );
		
		if (cookieQuantity == null)
		{
			cookieQuantity  = 0;
		}
		else
		{
			cookieQuantity = parseInt( cookieQuantity );
		}
		
		if (cookieQuantity == 0)
		{
			cookieQuantity = 1;
			cartUnits += 1;
		}
		else if (type == 1)
		{
			// Only increase the quantity for publications.
			cookieQuantity += 1;
			cartUnits += 1;
		}

		// Create a cookie with the new details. Old cookie will be overwritten if one exsists.
		createCookie(cookieName, cookieQuantity, 365);

		// Update the text for the shopping cart total			
		cartElement.innerHTML = cartUnits;

		// Get button displaying "Add to Cart" and change it.			
		button = document.getElementById("AddToCart" + key);
		button.innerHTML = "In Cart";
	}
	else if (confirm("In order to use our shopping cart browser cookies must be enabled.\n\nClick OK to view our FAQ on cookies."))
	{
		parent.location = "http://www.hordern.com/about-us/faq.aspx#Do_you_use_cookies_Can_I_still_shop_at_hordern.com_if_I_turn_off_my_cookies";
	}
}

function CookiesAreEnabled()
{
	var enabled;

	document.cookie = "testCookieEnabled";
	enabled = (document.cookie.indexOf("testCookieEnabled") > -1)
	
	return enabled;
}

function SetFocus( controlID )
{
	var ctrl;
	ctrl = document.getElementById( controlID );
	ctrl.focus()
}

function ConfirmPassword( source, arguments )
{
	var ctrlPassword;
	var ctrlConfirm;
	
	ctrlPassword	= document.getElementById("txtPassword");
	ctrlConfirm		= document.getElementById("txtConfirmPassword");
	
	arguments.IsValid	= (ctrlPassword.value == ctrlConfirm.value)
}
	
function ShowLibrary(bReload)
{
return false;
	var oLibrary = document.getElementById("Library");
	var oShowLibrary = document.getElementById("ShowLibrary");
	
	if (oLibrary.style.display=="none")
	{
		oLibrary.style.display = "";
		oShowLibrary.innerHTML = "HIDE LIBRARY";
		ResizeContentContainer();
	}
	else
	{
		oLibrary.style.display = "none";
		oShowLibrary.innerHTML = "SHOW LIBRARY";
		ResizeContentContainer();
	}
}

function OpenImagePopup(cImageURL, cWindowName, cCaption, nWidth, nHeight, nOptions)
{
    // <cCaption> for future use.
    // <nOptions> for future use.
    var cOptions;
    var cPage;
    
    if (nWidth == 0)
    {
        nWidth  = 600;
    }
    if (nHeight == 0)
    {
        nHeight = 400;
    }
    
    cPage = "/stockimages/imageautosize.asp?ImageURL=" + cImageURL + "&Caption=" + cCaption;
    cOptions = "width=" + (nWidth + 50) + ",height=" + (nHeight + 125) + ",resizable=yes,scrollbars=yes";
    window.open( cPage, cWindowName, cOptions );
    return (true);
}

function EnlargeImage( imageName, images )
{
    var nImage;
    var cImage;
    var cImages;
    var cAttributes;
    
    nImage = GetCurrentImage( imageName, images );
    cImages = images.split(",");
    cImage = cImages[nImage];
    //alert(cImage);
    cAttributes = cImage.split(":");
    
    if (cAttributes.length == 1)
    {
        alert( "Sorry, this image can not be enlarged." );
    }
    else
    {
        OpenImagePopup( cAttributes[1], "ImagePopup", "", parseInt( cAttributes[2] ), parseInt( cAttributes[3] ), 0 );        
    }
}

function SwapImage(imageName, image)
{
    var attributes;
    attributes = image.split(":");
	document.images[imageName].src = attributes[0];
}

function NextImage( imageName, images )
{
    var nCurrentImage;
    var cNextImage;
    var cImages;
    var cAtrributes;
    
    nCurrentImage = GetCurrentImage( imageName, images );
    
    if (nCurrentImage == -1)
    {
        alert( "Could not find next image." );
    }
    else
    {
        cNextImage = GetNextImage( images, nCurrentImage );
        cAttributes = cNextImage.split(":");
	    document.images[imageName].src = cAttributes[0];
	    document.images[imageName].width = cAttributes[1];
	    document.images[imageName].height = cAttributes[2];
    }
}

function NextLargeImage( imageName, images )
{
    var nCurrentImage;
    var cNextImage;
    var cImages;
    var cAtrributes;
    
    nCurrentImage = GetCurrentImage( imageName, images );
    
    if (nCurrentImage == -1)
    {
        alert( "Could not find next image." );
    }
    else
    {
        cNextImage = GetNextImage( images, nCurrentImage );
        cAttributes = cNextImage.split(":");
	    document.images[imageName].src = cAttributes[0];
	    document.images[imageName].width = cAttributes[1];
	    document.images[imageName].height = cAttributes[2];
    }
}

function GetNextImage( images, nCurrentImage )
{
    var cImages;
    var nImage;
    
    cImages = images.split(",");
    nImage = nCurrentImage + 1;
    if (nImage == cImages.length)
    {
        nImage = 0
    }

    return cImages[nImage];
}

function GetCurrentImage( imageName, images )
{
	if(document.images)
	{
	    var cCurrent;
	    var cNext;
	    var cImage;
	    var cImages;
	    var cAttributes;
	    var nImage;
	    
	    cCurrent = document.images[imageName].src;
	    
	    cImages = images.split(",");

	    for(nImage = 0; nImage < cImages.length; nImage++)
	    {
	        cAttributes = cImages[nImage].split(":");

	        if (cCurrent.indexOf(cAttributes[0]) > -1)
            {
	            break;	            
	        }
	    }

	    if (nImage < cImages.length)
	    {
            return nImage;	    
	    }
	    else
	    {
	        return -1;
	    }
	}
}

function ReSize(iWidth, iHeight)
{
	window.resizeTo(iWidth, iHeight);
	location.reload(true);
}
	
/*	sfHover() is called by IE during the loading of the page. 

	sfHover() finds all the <li> elements inside the "nav" <div> and attaches a function
	for mouseover and mouseout.
	
	Firefox does not need the call, the stylesheet is enough for firefox.
*/
function sfHover()
{	
	//jsLogger.trace("sfHover: start");
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");	

	for (var i=0; i<sfEls.length; i++)
	{		
		sfEls[i].onmouseover = sfHoverMouseOver;
		sfEls[i].onmouseout = sfHoverMouseOut;
		//sfEls[i].onmouseout={ function() javascript:sfHoverMouseOut(); }
		
	}
	//jsLogger.trace("sfHover: end");
}

function sfHoverMouseOver()
{
	//jsLogger.trace("sfHoverMouseOver: " + GetHRef(this.innerHTML));
	this.className+=" sfhover";
}

function sfHoverMouseOut()
{
	//jsLogger.trace("sfHoverMouseOut: " + GetHRef(this.innerHTML));
	this.className=this.className.replace(new RegExp(" sfhover\\b"), ""); 
}

// Get the first href in <text>. 
function GetHRef(text)
{
	var nStart;
	var nEnd;
	
	nStart = text.indexOf('href="', 0);
	nEnd = text.indexOf('"', nStart + 6);
	
	if (nEnd > nStart)
	{
		return text.substr(nStart + 6, nEnd - nStart - 6);
	}
	else
	{
		return (text.substr(0, 100).replace("<","&lt;"));
	}
}


// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well
// http://javascript.about.com/library/blscreen2.htm
function pageWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;} 
function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} 
function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;} 
function posTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;} 
function posRight() {return posLeft()+pageWidth();} 
function posBottom() {return posTop()+pageHeight();}
                    
                    
/* Original source from http://www.quirksmode.org/js/cookies.html
********************************************************************************************************/
function createCookie(name,value,days)
{
	var expires;
	var date;
	
	if (days > 0) 
	{
		date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	}
	else
	{
		expires = "";
	}
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	var c;
	var i;
	
	for (i=0; i < ca.length; i++)
	{
		c = ca[i];
		while (c.charAt(0)==' ')
		{
			c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0)
			{
				return c.substring(nameEQ.length,c.length);
			}
		}
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}

function eClick( text )
{
	parent.location = "&#109;&#097;&#105;&#108;&#116;&#111;&#058;" + eNumbersToText(text);
}

function eNumbersToText( numbers )
{
	var character;
	var characters;
	var text;

	text = "";	
	characters = numbers.length;

	for (character = 0; character < characters; character = character + 3)
	{
		text += String.fromCharCode(numbers.substr(character,3));
	}
	
	return text;
}

// Convert <numberString> to a number.
function GetNumber( numberString )
{
	// Remove $ and , symbols.
	var cleanNumber	= numberString.replace( /\$|\,/g, "" );
	var number = Number( cleanNumber );
	
	return number;
}

// Round <number> to <decimals> places.
function Round( number, decimals)
{
  return Math.round( number * Math.pow( 10, decimals ) ) / Math.pow( 10, decimals )
}

// Format a number with $ sign, commas and specified number of decimals.
function FormatCurrency( number, decimals )
{
	//debug("FormatCurrency", "entered");
	var formatted = FormatNumber(number, decimals);

	if (formatted.substr(0,1) == "-")
	{
		formatted = "-$" + formatted.substr( 1, formatted.length-1 );
	}
	else
	{
		formatted = "$" + formatted;
	}
	return formatted;
}	

function FormatNumber(number, decimals)
{
	//debug("FormatNumber", "entered");
	var numberString;
	var decimalIndex;
	var whole;
	var decimalString;
	var formatted;
	var characters;
	var comma;
	var isMinus;
					
	if (number.NaN)
	{
		// Not a valid number so return that.
		formatted	= number;
	}
	else
	{
		numberString	= number.toString();
					
		// Find . in numberString
		decimalIndex	= numberString.indexOf( "." );
					
		if (decimalIndex == -1)
		{
			// No decimal points so we will add one now
			numberString	= numberString + "."
		}
					
		// Find . in numberString
		decimalIndex	= numberString.indexOf( "." );

		// Split the number into its whole number and decimals.
		whole	= numberString.substr( 0, decimalIndex );
		decimalString	= numberString.substring( decimalIndex + 1, numberString.length );

		// Find out is the number is minus, if so remove the minus sign.						
		if (Number( whole ) < 0)
		{
			isMinus	= true;
			whole	= whole.substring( 1, whole.length );
		}
		else
		{
			isMinus	= false;
		}
						
		// Make decimal at least <decimals> long
		while (decimalString.length < decimals)
		{
			decimalString	+= "0";
		}
						
		// Make sure decimals are only <decimals> long.
		decimalString	= decimalString.substr( 0, decimals );
						
		formatted	= "";
		characters		= (whole.length - 1);
		comma	= 0;

		// Work for the last digit in whole to the first digit adding each
		// digit to start of formatted. When comma is 3 insert a comma.
		for (characters; characters >= 0; characters--)
		{
			comma++;
							
			if (comma == 3)
			{
				formatted	= "," + whole.substr( characters, 1 ) + formatted;
				comma	= 0;
			}
			else
			{
				formatted	= whole.substr( characters, 1 ) + formatted;
			}
		}

		// Remove any leading ,.
		if (formatted.substr(0,1) == ",")
		{ 
			formatted	= formatted.substr( 1, formatted.length-1 );
		}
						
		// Add the parts back together + the $ symbol.
		formatted	= formatted + "." + decimalString;
						
		// Add the minus sign if required.
		if (isMinus)
		{
			formatted	= "-" + formatted;
		}
	}
					
	return formatted;
} 

function IsPasteKey(field)
{
	// debug("ddd", "ddd");
	// debug("IsPasteKey.ctrlKey", event.ctrlKey);
	// debug("IsPasteKey.keyCode", event.keyCode);
	
	
	if (event.ctrlKey && event.keyCode == 45) // Ctrl + Ins
	{
		return true;
	}
	else if (event.shiftKey && event.keyCode == 45) // Ctrl + Ins
	{
		return true;
	}
	else if (event.ctrlKey && event.keyCode == 86) // Ctrl + V (or v)
	{
		return true;
	}
	else
	{
		return false;
	}
}