
	
	function hideHomeBody()
	{
		if (document.getElementById('homeBodyBlock'))
		{
			document.getElementById('homeBodyBlock').style.display='none';
		}
	}

	function submitCartForm(product, quantity, code, swatch)
	{	
		document.cartForm.product.value = product;
		document.cartForm.quantity.value = quantity;
		document.cartForm.code.value = code;
		if (swatch == '')
		{
			document.cartForm.swatch.value = document.getElementById('defaultSwatch').innerHTML;
		}
		else
		{
			document.cartForm.swatch.value = swatch;	
		}
		
		document.cartForm.submit();
	}
	
	function showSubMenu(subID, menuItem)
	{
		var subMenu = document.getElementById('sub_' + subID);
		if(menuItem)
		{
			subMenu.style.left = (findLeft(menuItem) - 50) + 'px';
			subMenu.style.top = (findTop(menuItem) + menuItem.clientHeight - 22) + 'px';
			//alert(menuItem.clientHeight);
		}
		subMenu.style.visibility = 'visible';
	}

	function hideSubMenu(subID)
	{
		document.getElementById('sub_' + subID).style.visibility = 'hidden';
	}

	function hideDropdown(subID, parent1, parent2)
	{
		document.getElementById('sub_' + subID).style.visibility = 'hidden';
		if (parent1) hideSubMenu(parent1);
		if (parent2) hideSubMenu(parent2);
	}
	
	function showDropdown(subID, menuItem, parent1, parent2)
	{
		var subMenu = document.getElementById('sub_' + subID);
		if(menuItem)
		{
			subMenu.style.left = (findLeft(menuItem) + menuItem.offsetWidth) + 'px';
			subMenu.style.top = findTop(menuItem) + 'px';
		}
		if (parent1 && parent1 > 7) showSubMenu(parent1);
		if (parent2 && parent2 > 7) showSubMenu(parent2);
		subMenu.style.visibility = 'visible';
	}
	
	function findLeft(obj)
	{
		var curleft = 0;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft;
			while (obj = obj.offsetParent) curleft += obj.offsetLeft;			
		}
		return curleft;
	}
	
	function findTop(obj)
	{
		var curtop = 0;
		if (obj.offsetParent) {
			curtop = obj.offsetTop
			while (obj = obj.offsetParent) {curtop += obj.offsetTop}
		}
		return curtop;
	}
	
	var newImage, imageList, preloadCount, preloadInterval;
	var preloadCount = 0;
	imageList = new Array();
	
	function addPreloadImage(url)
	{
		imageList[imageList.length] = url;
	}
	
	function startPreloading()
	{ 
		if(imageList.length != 0)
		{
			newImage = new Image;
			newImage.src = imageList[0]
			preloadInterval = setInterval('preloadCheck()', 1000);
		}
	}
	
	function preloadCheck()
	{
		if (newImage.complete)
		{
			preloadCount += 1;
			if (preloadCount < imageList.length)
			{
				newImage.src = imageList[preloadCount];
				clearInterval(preloadInterval);
				preloadInterval = setInterval('preloadCheck()', 1000);
			}
			else
			{
				clearInterval(preloadInterval);
			}
		}
	}
	
	function imageSwap(key, url)
	{
		eval('document.' + key + '.src = \'' + url + '\'');
	}

	function mailto(recipient)
	{
		document.location.href = 'mailto:' + recipient + '@andmeuk.com?subject=Website Enquiry';
	}
	
	function goTo(url)
	{
		document.location.href = url;
	}

	function openWindow(url, width, height, sizeable)
	{
		if (sizeable) sizeable = ',resizable,scrollbars'
		else sizeable = '';
		var openWin = window.open(url,'_blank','width=' + width + ',height=' + height + ',screenX=' + ((screen.availWidth-width)/2) + ',left=' + ((screen.availWidth-width)/2) + ',screenY=' + ((screen.availHeight-height)/2) + ',top=' + ((screen.availHeight-height)/2) + sizeable);
		openWin.focus();
	}
	
	function breakout_of_frame()
	{
	  // see http://www.thesitewizard.com/archive/framebreak.shtml
	  // for an explanation of this script and how to use it on your
	  // own website
	  if (top.location != location) {
		top.location.href = document.location.href ;
	  }
	}
	
	function goToStationery() {
		var answer = confirm("You are about to be taken to our stationery website which is separate from this one. You will need to log your details again and they will be saved in the stationery area for future purchases. Press OK to continue.")
		if (answer){
			window.location = "http://hudsons.opnet.co.uk/Index.aspx?FirstPage=http://www.hudsonsofficefurniture.com/stationery/default.html";
		}
	
	}
	
	









//Speechbubble Categories Functions 

function showSpeechBubble(subID, menuItem, moreInfoOrImageTop, moreInfoOrImageLeft)
	{
		var subMenu = document.getElementById('sub_' + subID);
		
		if(menuItem)
		{
			subMenu.style.left = (findLeft(menuItem) - moreInfoOrImageLeft) + 'px';
			subMenu.style.top = (findTop(menuItem) + menuItem.clientHeight + moreInfoOrImageTop) + 'px';
		}
		subMenu.style.display = '';
	}
	
	
function hideSpeechBubble(subID, menuItem)
	{
		var subMenu = document.getElementById('sub_' + subID);
		subMenu.style.display = 'none';
	}
	


	
	
	
//Speechbubble Products Functions 

function showSpeechBubbleProd(subID, menuItem, moreInfoOrImageTop, moreInfoOrImageLeft)
	{
		var subMenu = document.getElementById('prod_' + subID);
		
		if(menuItem)
		{
			subMenu.style.left = (findLeft(menuItem) - moreInfoOrImageLeft) + 'px';
			subMenu.style.top = (findTop(menuItem) + menuItem.clientHeight + moreInfoOrImageTop) + 'px';
		}
		subMenu.style.display = '';
	}
	
	
function hideSpeechBubbleProd(subID, menuItem)
	{
		var subMenu = document.getElementById('prod_' + subID);
		subMenu.style.display = 'none';
	}	
	
	
	
function showSpeechBubbly(subID)
	{
		var subMenu = document.getElementById('sub_' + subID);
		
		subMenu.style.display = '';
	}
	
function hideSpeechBubbly(subID)
	{
		var subMenu = document.getElementById('sub_' + subID);
		
		subMenu.style.display = 'none';
	}


function showSpeechBubblyProd(subID)
	{
		var subMenu = document.getElementById('prod_' + subID);
		
		subMenu.style.display = '';
	}
	
function hideSpeechBubblyProd(subID)
	{
		var subMenu = document.getElementById('prod_' + subID);
		
		subMenu.style.display = 'none';
	}
	
	
	
function plusOrMinusQuantity(isThisPlusOrMinusButton)
{
	if(isThisPlusOrMinusButton == 'minus')
	{
		if (document.cartForm.allQuantity.value != 1) 
		{
		document.cartForm.allQuantity.value = document.cartForm.allQuantity.value - 1;
		}
	}
	
	
	if(isThisPlusOrMinusButton == 'plus')
	{
	document.cartForm.allQuantity.value = parseInt(document.cartForm.allQuantity.value) + 1;
	}
	
}


var obj = '';
var obj2 ='';
	function closerelevantbox(objpassed, obj2passed)
	{
	obj = document.getElementById(objpassed);
	obj2 = document.getElementById(obj2passed);
	}
	document.onclick=check; 
	function check(e){ 
	if (obj != '')
	{
	var target = (e && e.target) || (event && event.srcElement); 
	checkParent(target)?obj.style.display='none':null; 
	
	target==obj2?obj.style.display='block':null;
	}

	} 
	function checkParent(t){ 
	while(t.parentNode){ 
	if(t==document.getElementById(obj)){ 
	return false 
	} 
	t=t.parentNode 
	} 
	return true 
	}
	
	
	
//Displays the Outer container of the dropdown menus and passes three parameters for the following:
//positionmenu: position of the menu using margin left
//bkcolor: Backgroundcolour of the menu
//categorydisplay: displays the relevant links for the relevant sector passed through.
var storemenu

function displaymenu(positionmenu, bkcolor,categorydisplay)
	{
	document.getElementById('dropdownMenu').style.marginLeft = positionmenu; 
	document.getElementById('dropdownMenu').style.backgroundColor= bkcolor;
	document.getElementById('dropdownMenu').style.display = '';
	document.getElementById(categorydisplay).style.display = '';
	
	storemenu = categorydisplay
	}
	
//This function hides the outer container with the sector menu 

function hidemenu()
	{
	document.getElementById('dropdownMenu').style.display = 'none';
	document.getElementById(storemenu).style.display = 'none';
	}

//If the menu is visible the following function will 
//allow the user to hover over the content within the menu itself
	
function hoverMenuIfVisible()
	{
	document.getElementById('dropdownMenu').style.display = '';
	document.getElementById(storemenu).style.display = '';
	}
	
//If the menu is visible the following function will 
//hide the menu when the user has hovered off the menu

function hideMenuIfVisible()
	{
	document.getElementById('dropdownMenu').style.display = 'none';
	document.getElementById(storemenu).style.display = 'none';	
	}
	


//Displays the contact dropdown list on the right hand side of the page 
function showDDContactForm(topCoordinate, menuName, conflictingmenuitem)
	{
	document.getElementById(menuName).style.display = '';
	

	
	
	
	document.getElementById(menuName).style.top = topCoordinate;
	document.getElementById(menuName).style.right = '33px';
	document.getElementById(conflictingmenuitem).style.display = 'none';
	}

//Hides the contact dropdown list on the right hand side of the page 
function hideDDContactForm(menuName)
	{
	document.getElementById(menuName).style.display = 'none';
	}
	
//Populates a dropdownbox's input field for the callback form

function populateinputfield(itemselected)
	{
	document.callbackForm.nature.value = itemselected;	
	document.getElementById('subjectdropdownmenu').style.display = 'none';
	}
	
//Populates a dropdownbox's input field for the callback form

function populateinputfield2(itemselected)
	{
	document.callbackForm.time.value = itemselected;	
	document.getElementById('timedropdownmenu').style.display = 'none';
	}

	
	
	

//Swatch Panel


function highlightswatch(swatchtoChange)

{
	document.getElementById(swatchtoChange).style.backgroundImage = "url('/images/Swatches/red.gif')";
	
}
	

function unhighlightswatch(swatchtoChange)

{
document.getElementById(swatchtoChange).style.backgroundImage = "url('/images/Swatches/noImage.gif')";
}
	
	
function displayDropDown()
{
	
	document.getElementById('dropDownContainer').style.display ='';
	
	}


function selectOption(sizeId, sizeName, refNumb)
{
	document.cartForm.itemSizeSelected.value = sizeName;
	document.cartForm.itemSize.value = sizeId;
	document.getElementById('dropDownContainer').style.display ='none';
	//document.getElementById('refNumber2').innerHTML ='<h5>' + 'Ref:' + refNumb + '</h5>';
	document.cartForm.refNumberStore.value = refNumb;
	
}



//Function for Search bar dropdowns

function showRelevantDropdown(nameofDropdown, closeConflictingDropdown)
{
	document.getElementById(nameofDropdown).style.display ='';
	document.getElementById(closeConflictingDropdown).style.display ='none';
	}
	
	

		
	
function selectProductsDropdownOption(nameofDropdown, valueofSelectProduct, nameofSelectProduct)
{
	document.searchForm.productsRange.value = valueofSelectProduct;
	document.searchForm.showSelectProduct.value = nameofSelectProduct;
	document.getElementById(nameofDropdown).style.display ='none';
	}
	
	
function selectPricesDropdownOption(nameofDropdown, valueofSelectPrice, nameofSelectPrice)
{
	document.searchForm.priceRange.value = valueofSelectPrice;
	document.searchForm.showSelectedPrice.value = nameofSelectPrice;
	document.getElementById(nameofDropdown).style.display ='none';
	}
	








	