
function returnSubmitsForm(evt,buttonName)
{
	var keyCode = evt.which ? evt.which :evt.keyCode ? evt.keyCode : evt.charCode;
	if (keyCode == 13) 
	{
		document.getElementById(buttonName).click();
        return false;
	}
	return true;
}

// ***** [TW]18/11/2003 17:17:28 - Add or remove product to compare function *****
var divComparingMaxClientIDs = "";

function AddRemoveCompare(prod)
{
	if (eval("comp"+prod)=="false")
	{
		eval("comp"+prod+"=\"true\";");
		numberComparing += 1;
	}
	else
	{
		eval("comp"+prod+"=\"false\";");
		numberComparing -=1;
	}
	if (numberComparing > maxCompare)
	{
		//alert("Too many");
		eval("comp"+prod+"=\"false\";");
		numberComparing -= 1;
	}
	else
	{
		//***** [TW]18/11/2003 17:40:12 - Date is added to avoid caching when products removed and then added again *****
		document.getElementById(prod).src="/compare/_addremovecompare.aspx?cc="+prod+"&dt="+new Date();
	}
	if (numberComparing == maxCompare)
	{
		divs = divComparingMaxClientIDs.split(",");
		for (i=0;i<divs.length-1;i++)
		{
			document.getElementById(divs[i]).innerHTML = comparingMaxMessage;
		}
	}
	else
	{
		divs = divComparingMaxClientIDs.split(",");
		for (i=0;i<divs.length-1;i++)
		{
			document.getElementById(divs[i]).innerHTML = '';
		}
	}
}

//Show hide div jscript
<!-- 
function showOrHide(theObject){

	var explorer;
	var netscape4;
	var netscape6;
	var theDOM, theSuffix, hiddenKeyword, dhtml;

	if (document.all) {
	explorer = true;
	}
	else if (document.layers) {
	netscape4 = true;
	} else {
	netscape6 = true;
	}

	if(explorer){
	theDOM = 'document.all';
	theSuffix = '.style';
	hiddenKeyword = 'none';
	dhtml = true;
	}

	if(netscape4){
	theDOM = 'document';
	theSuffix = '';
	hiddenKeyword = 'none';
	dhtml = false;
	}

	if (netscape6) {
	theDOM = "document.getElementsByTagName('*')";
	theSuffix = ".style";
	hiddenKeyword = "none";
	dhtml = true;
	}

   if(dhtml){
             var theObjectReference = eval(theDOM + '.' + theObject + theSuffix);
             if(theObjectReference.display == hiddenKeyword){
                  theObjectReference.display = 'block';
             } else {
                  theObjectReference.display = hiddenKeyword;
             }
        }
}
// -->


// ***** [TW]12/02/2004 13:48:32 - Update Essential Accessories Qty When Checkbox clicked *****
function UpdateRelatedQty(theCheckbox)
{
	assQtyBox = theCheckbox.replace("CHK","ASSQTY");
	if (document.getElementById(theCheckbox).checked)
	{
		document.getElementById(assQtyBox).value = "1";
	}
	else
	{
		document.getElementById(assQtyBox).value = "0";
	}
}

// ***** [TW]12/02/2004 14:18:27 - Update Essential Accessories Checkbox when quantity is changed *****
function UpdateRelatedChk(theQtyBox)
{
	assChkBox = theQtyBox.replace("ASSQTY","CHK");
	if (document.getElementById(theQtyBox).value == "0" || document.getElementById(theQtyBox).value == "")
	{
		document.getElementById(assChkBox).checked = false;
	}
	else
	{
		document.getElementById(assChkBox).checked = true;
	}
}

// ***** [TW]12/02/2004 14:30:44 - If the qty box is left blank, change it back to 0 *****
function UnBlank(theQtyBox,setTo)
{
	if (setTo == undefined){ setTo = 0; }
	if ((document.getElementById(theQtyBox).value == "") || (setTo > 0 && document.getElementById(theQtyBox).value == "0"))
	{
		document.getElementById(theQtyBox).value = setTo;
	}
}

// ***** [TW]12/02/2004 14:37:35 - Check the keypress is a digit, otherwise disallow it *****
function CheckKeyPress(evt)
{
	var keyCode = event.which ? event.which :event.keyCode ? event.keyCode : event.charCode;
	if ((keyCode >= 48 && keyCode <= 57) || (keyCode >= 96 && keyCode <= 105) || keyCode == 46 || keyCode == 8)
	{
		return true;
	}
	else
	{
		return false;
	}
}

  function numericOnly(txtBox)  {

    var msg=txtBox.value;
    var chr;

    for ( i=0; i < msg.length; i++ )  {
      chr=msg.substring(i,i+1);
      if ( chr<"0" || chr>"9" )  {
    msg=msg.substring(0,i);
    txtBox.value=msg;
      }
    }
  }

// ***** [TW]28/04/2004 12:56:19 - Check to see if the font size is too small.  If it is, use a different css class for the body *****
function Size()
{
	spanWidth = document.getElementById("headerTelephoneNumber").offsetWidth;
	if (spanWidth < 130){
		document.body.className="bodyBigger";
	}
	if (spanWidth < 100){
		document.body.className="bodyBiggest";
	}
}

/****** PERSISTING EXPANDABLE/COLLAPSIBLE ELEMENTS ********/
var enablepersist="on" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="no" //Collapse previously open content when opening present? (yes/no)

if (document.getElementById){
	document.write('<style type="text/css">')
	document.write('.switchcontent{display:none;}')
	document.write('</style>')
}

function getElementbyClass(classname)
{
	ccollect=new Array()
	var inc=0
	var alltags=document.all? document.all : document.getElementsByTagName("*")
	for (i=0; i<alltags.length; i++)
	{
		if (alltags[i].className==classname)
		{
			ccollect[inc++]=alltags[i];
		}
	}
}

function get_cookie(Name)
{ 
	var search = Name + "=";
	var returnvalue = "";
	if (document.cookie.length > 0)
	{
		offset = document.cookie.indexOf(search);
		if (offset != -1)
		{ 
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1)
			{
				end = document.cookie.length;
			}
			returnvalue=unescape(document.cookie.substring(offset, end));
		}
	}
	return returnvalue;
}

function getselectedItem()
{
	if (get_cookie("ShowBits") != "")
	{
		selectedItem=get_cookie("ShowBits");
		return selectedItem;
	}
	else
	{
		return "";
	}
}

function revivecontent()
{
	selectedItem=getselectedItem();
	selectedComponents=selectedItem.split("|");
	for (i=0; i<selectedComponents.length-1; i++)
	{
		// We could do with making sure that the element still exists (i.e. are we still on the same page), otherwise the first page after a line listing will have a javascript error if filter box was showing
		if (document.getElementById(selectedComponents[i]))
		{
			document.getElementById(selectedComponents[i]).style.display="block";
		}
	}
}

function Expand(cid)
{
	if (typeof ccollect!="undefined")
	{
		document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none";
	}
}

function do_onload()
{
	getElementbyClass("switchcontent");
	if (enablepersist=="on" && typeof ccollect!="undefined")
	{
		revivecontent();
	}
}

function saveswitchstate()
{
	var inc=0, selectedItem="";
	while (ccollect[inc])
	{
		if (ccollect[inc].style.display=="block")
		{
			selectedItem+=ccollect[inc].id+"|";
		}
		inc++;
	}
	document.cookie="ShowBits" + "=" + selectedItem + ";path=/";
}

if (window.addEventListener)
{
	window.addEventListener("load", do_onload, false);
}
else if (window.attachEvent)
{
	window.attachEvent("onload", do_onload);
}
else if (document.getElementById)
{
	window.onload=do_onload;
}

if (enablepersist=="on" && document.getElementById)
{
	window.onunload=saveswitchstate;
}

/****************************/

function OpenWindow(url,windowname,width,height)
{
	var newWindow = window.open(url,windowname,'width=' + (width+5) + ',height=' + (height+5) + ',menubar,statusbar');
	newWindow.focus();	
}

function OpenResizableWindow(url,windowname,width,height)
{
	var newWindow = window.open(url,windowname,'width=' + (width+5) + ',height=' + (height+5) + 'left,top,menubar,statusbar,scrollbars');
	newWindow.focus();	
}

function miniHelp(url,windowname,width,height)
{
	var newWindow = window.open(url,windowname,'width=' + (width+5) + ',height=' + (height+5) + ',menubar,statusbar,resizable,scrollbars');
	newWindow.focus();	
}

var oldColour = 0;
function colourObjIn(obj){
    oldColour=obj.style.backgroundColor;
    obj.style.backgroundColor = '#fffde6';
}
function colourObjOut(obj){
    obj.style.backgroundColor = oldColour;
}

// TW 01/07/05 - Search Suggest, a groovy function

var ty = false;
var q=null;
var w=null;
var mS=null;
var oInput=null;
var cW="";
var lS="";
var lI = "";
var cI="";
var mXR = null;
var sC = 0;
var kR = new Array(21);
var kW = new Array(21);
var SiteURL = "";
var SearchedKeywords = "";

function ab(sK)
{
    SearchedKeywords = sK;
	q = document;
	w=window;
	mS = q.getElementById("divSearchSuggestMessage");
	oInput = q.getElementById("Search1_txtSearch");
	if (w.XMLHttpRequest) 
	{
		mXR = new XMLHttpRequest();
	}
	else if (w.ActiveXObject) 
	{
		mXR = new ActiveXObject("Microsoft.XMLHTTP");
	}
	g();
}

function dink() 
{
	g();
	if (ty)return;
	cW = oInput.value;
	if (cW.length < 2){
		mS.style.display = "";
		return;
	}
	if (cW==SearchedKeywords)return;
	if (lS==cW)return;

	mS.style.display = "block";
	
	var textBoxLeft = oInput.offsetLeft;
	textBoxLeft += oInput.offsetParent.offsetLeft;
	textBoxLeft += oInput.offsetParent.offsetParent.offsetLeft;
	textBoxLeft += 5;
	mS.style.left = textBoxLeft + "px";
	
	var textBoxTop = oInput.offsetTop;
	textBoxTop += oInput.offsetParent.offsetTop;
	textBoxTop += oInput.offsetParent.offsetParent.offsetTop;
	textBoxTop += oInput.offsetParent.offsetParent.offsetParent.offsetTop;
	textBoxTop += oInput.offsetHeight;
	textBoxTop += 95;
	mS.style.top = textBoxTop + "px";
	
	//mS.innerHTML = "Working...";
	lS = cW;
	//mS.innerHTML = "Searching for " + cW;
	dH(SiteURL + '/searchsuggest/searchsuggest.aspx?k='+cW);
}

function g()
{
	 setTimeout("dink()", 250);
}

function dH(url) 
{
	if (w.XMLHttpRequest) 
	{
		mXR = new XMLHttpRequest();
		if (mXR)
		{
			mXR.onreadystatechange = pRC;
			mXR.open("GET", url, true);
			mXR.send(null);
		}
	}
	else if (w.ActiveXObject) 
	{
		mXR = new ActiveXObject("Microsoft.XMLHTTP");
		if (mXR) 
		{
			mXR.onreadystatechange = pRC;
			mXR.open("GET", url, true);
			mXR.send();
		}
	}
}

function pRC() 
{
	if (mXR.readyState == 4) 
	{
		if (mXR.status == 200)
		{
			//mS.innerHTML = "<span style=\"float:left\">Other Customers Recently Purchased...</span><span style=\"float:right\"><img src=\"/images/common/close.gif\" width=\"14\" height=\"14\" alt=\"Click To Close\" onclick=\"CloseSearchSuggest()\" style=\"cursor:pointer\"></span>";
			mS.innerHTML = "<span style=\"float:left\">Zu Ihrer Suche passende Topseller...</span><span style=\"float:right\"><img src=\"/images/common/close.gif\" width=\"14\" height=\"14\" alt=\"Zum Schlie&#223;en hier klicken\" onclick=\"CloseSearchSuggest()\" style=\"cursor:pointer\"></span>";
			if (mXR.responseText.length > 0){
				mS.innerHTML += mXR.responseText;
			}
			else
			{
				mS.style.display = "";
			}
		}
		else 
		{
			mS.innerHTML ="Aktuell k&#246;nnen leider keine Daten angezeigt werden:\n" + mXR.statusText;
		}
	}
}
function doneTyping()
{
	 ty=false;
}

function Typing()
{
	ty=true;
	//mS.innerHTML = "Waiting until you've finished typing...";
	setTimeout("doneTyping()", 1);
	if (w.event)
	{
		if (event.keyCode == 13) 
		{
			event.cancelBubble = true;
			event.returnValue = false;
		}
	}
}

function CloseSearchSuggest()
{
	mS.style.display = "";
}

function popUp(URL) {
    id = "newWindow";
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=450,height=450');");
}

function popupCaptcha(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=450,height=300');");
}

function OpenImageGallery(url,windowname,width,height)
{
	var newWindow = window.open(url,windowname,'width=' + (width+5) + ',height=' + (height+5) + ',menubar=0,statusbar=0,resizable=0,scrollbars=1');
	newWindow.focus();	
}
//[sp] call multiple time window.onload event 03-03-2008
//"The way this works is relatively simple: if window.onload has not already been assigned a function, the function passed to addLoadEvent is
// simply assigned to window.onload. If window.onload has already been set, a brand new function is created which
// first calls the original onload handler, then calls the new handler afterwards."

function addLoadEvent(func) {   
   var oldonload = window.onload;   
   
   if (typeof window.onload != 'function')
    {   
     window.onload = func;   
    } 
   else
    {   
     window.onload = function()
     {   
   
       if (oldonload) 
       {      
        oldonload();   
       }   
       func();   
     }   
   }   
 }  