/* =============================================================================
$Id: comon.js 6176 2007-04-30 10:37:29Z howardb $
$Date: 2007-04-30 11:37:29 +0100 (Mon, 30 Apr 2007) $
$Revision: 6176 $
$Author: howardb $
Copyright (c) 2005 Conchango Ltd. All rights reserved.
Web Application Version: [BUILD_16.07.32_3_071015]
Release Date: [15-October-2007]
============================================================================= */
function $(el)
{
	return document.getElementById(el);
}

/*
 * Append function to window.onload
 */
window.addLoadEvent = function(func)
{
	var oldonload = window.onload;

	if (typeof window.onload != 'function')
		window.onload = func;
	else
		window.onload = function()
		{
			oldonload();
			func();
		}
}


/*
 * Load CSS to support JS
 */
window.loadCss = function(cssFile)
{
	var agt=navigator.userAgent.toLowerCase();

	if (!((-1 != agt.indexOf("msie")) && (-1 != agt.indexOf("mac")))) //Don't bother with IE:Mac.
		document.writeln('<link rel="stylesheet" type="text/css" href="'+cssFile+'" media="screen" />');
}


var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("msie 5.0")!=-1)
{
	//kill background anchor images in IE 5.0 as it doesn't render them correctly
	var strOut = '<style>\n'
	strOut += ' a {background-image:none !important}\n'
	strOut += '</style>\n'
	document.writeln(strOut);


	//IE5 doesn't support the array push method, so we have to write our own version.
	Array.prototype.push = function(item)
	{
		this[this.length] = item;
	}

}

// allow limited number of characters in text field
function textLimit(field, maxlen) {
if (field.value.length > maxlen) 
field.value = field.value.substring(0, maxlen);
}

// clear default characters from textfield
function clearForm(thefield) {
	if (thefield.defaultValue==thefield.value)
	thefield.value = ""
	}

// VBV Frame bust out script - header.jsp, header-checkout-shop.jsp
function frameBust() {
    var parentTitle = parent.document.title;
    // breaking out of selenium test suite, now checking title for selenium		
	if ( parentTitle.search("Selenium") == -1 && parent.location != self.location ) {
		parent.location = self.location;
	}
}