					function addToCart(website, merchantIdentifier, itemDescription, shortDescription, amount, weight, pageId) {

						var shoppingBasketUrl = getShoppingBasketUrl();

						shoppingBasketUrl += "?action=addToCart";
						shoppingBasketUrl += "&website=" + website;
						shoppingBasketUrl += "&merchantIdentifier=" + merchantIdentifier;
						shoppingBasketUrl += "&itemDescription=" + itemDescription;
						shoppingBasketUrl += "&shortDescription=" + shortDescription;
						shoppingBasketUrl += "&amount=" + amount;
						shoppingBasketUrl += "&weight=" + weight;
						shoppingBasketUrl += "&pageId=" + pageId;
						shoppingBasketUrl += "&r=" + Math.random();

						var ua = navigator.userAgent.toLowerCase();
						if (!window.ActiveXObject) {
							request = new XMLHttpRequest();
						} else if (ua.indexOf('msie 5') == -1) {
							request = new ActiveXObject("Msxml2.XMLHTTP");
						} else {
							request = new ActiveXObject("Microsoft.XMLHTTP");
						}
						request.open("GET", shoppingBasketUrl, false);
						request.send(null);

						//alert("Added to your basket: " + itemDescription);
					}

					function viewCart(website, merchantIdentifier) {

//						var shoppingBasketUrl = getShoppingBasketUrl();
//						shoppingBasketUrl += "?action=viewCart";
//						shoppingBasketUrl += "&website=" + website;
//						shoppingBasketUrl += "&merchantIdentifier=" + merchantIdentifier;
//						shoppingBasketUrl += "&r=" + Math.random();
						document.location.href = "basket.html";
					}

					function getShoppingBasketUrl() {
						var shoppingBasketUrl = "http://www.thecmscentrehost.com/pages/external/shoppingBasket.aspx";
						if (document.location.href.indexOf("popaddnet") > -1) {
							shoppingBasketUrl = "http://localhost/popaddnet/pages/external/shoppingBasket.aspx";
						} 
						return shoppingBasketUrl;
					}

					function addToBasket(sectionUniqueId, purchaseItemUniqueId) {
						//alert(sectionUniqueId + ', ' + purchaseItemUniqueId);
						var basket = readCookie(cookieName);
						//alert(basket);
						var foundSectionPurchase = false;
						var newBasket = "";
						if (basket != null && basket.indexOf(',') > -1) 
						{
							var basketItems = basket.split('|');
							for (var i=0; i<basketItems.length; i++) 
							{
								var basketItem = basketItems[i].split(',');
								var sectionId = basketItem[0];
								var purchaseItemId = basketItem[1];
								var quantity = basketItem[2];
								if (sectionUniqueId == sectionId && purchaseItemUniqueId == purchaseItemId) 
								{
									foundSectionPurchase = true;
									quantity = (quantity * 1) + 1;
								}
								newBasket +=  sectionId + ',' +	purchaseItemId + ',' + quantity;
								if (i < basketItems.length-1) 
								{
									newBasket += '|';
								}
							}
						}
						if (!foundSectionPurchase) 
						{
							//alert('in !foundSectionPurchase');
							if (newBasket != '') {newBasket += '|';}
							newBasket += sectionUniqueId + ',' + purchaseItemUniqueId + ',1';
						}
						//alert(newBasket);
						eraseCookie(cookieName)
						createCookie(cookieName, newBasket , 10);
					}	

					function viewBasket() 
					{
					//	alert('view basket');
						document.location.href = 'basket.html'
					}	

		var ppItemDescription;
		var ppShortDescription;
		var ppAmount;
		var ppVat;
		
		function addToPayPalCart(website, merchantIdentifier, itemDescription, shortDescription, amount, weight, pageId, vat) {

			//var answer = getAnswer("question=emailAlert;subject=add to basket: " + shortDescription);

			try {
				var message = "addToPayPalCart: " + amount + " - "  + shortDescription + " - " + itemDescription + " - " + checkForCookies();
				var ua = navigator.userAgent.toLowerCase();
				if (!window.ActiveXObject) {
					request = new XMLHttpRequest();
				} else if (ua.indexOf('msie 5') == -1) {
					request = new ActiveXObject("Msxml2.XMLHTTP");
				} else {
					request = new ActiveXObject("Microsoft.XMLHTTP");
				}
				request.open("GET", "http://www.toscadoc.co.uk/sendMessage.aspx?message=" + message, false);
				request.send(null);
			} catch (e) {}

			if (!checkForCookies()) {
				return;
			}

			ppItemDescription = itemDescription;
			ppShortDescription = shortDescription;
			ppAmount = amount;
			ppVat = vat;
			
			var frame = document.getElementById("paypalSideBarFrame");
			try {
				var innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
				if (innerDoc.location.href.indexOf("SearchAndBuyPayPalButton") > -1) {
					placeAndSubmit();
				}
			} catch (e) {
				frame.src = "SearchAndBuyPayPalButton.htm";
				waitToPlace();
			}
		}
		function checkForCookies() {
							if (cookiesOK()) {
								return true;
							}
							alert("You are not able to collect items in your basket because cookies are turned off on your machine.\n\nIf you turn on cookies you will be able to use the shopping basket.\n\nInstructions are available under the Help topic on this website.\n\nThank you.");
							return false;
		}

		function cookiesOK() {
			var result1 = false;
			createCookie('test1', 'test1', 1);
			if (readCookie('test1') == 'test1') {
				result1 = true;
			} 
			eraseCookie('test');

//			var result2 = false;
//			var x_cookieName = "xyzzy"; // unique
//			var x_domain  = ".paypal.com"; // set to whatever domain you want to test, with the standard provisos
//
//			var x_expires = new Date(); x_expires.setFullYear(x_expires.getFullYear()+1); // testing persistent cookies
//			xDeleteCookie(x_cookieName); // don't get false positive
//
//			// add path if you want to. drop expires for session cookie. drop domain for default domain test.
//			document.cookie = x_cookieName + "=test; expires=" + x_expires.toGMTString(); // + " ;domain=" + x_domain;
//
//			// now look for it.
//			var x_cookieString = document.cookie || "";
//			var x_cookies = x_cookieString.split(/\s*;\s*/);
//			var x_found = 0;
//			for (var i in x_cookies) {
//				var cookie = x_cookies[i];
//				var dough = cookie.split(/\s*=\s*/);
//				if (dough[0] == x_cookieName) { x_found = 1; break; }
//			}
//
//			// ensure it's gone
//			xDeleteCookie(x_cookieName);
//
//			// do whatever you want with x_found bool
//			if (x_found == 1) {
//				result2 = true;
//			}

			return result1;



		}

		function xDeleteCookie(x_cookieName) {
			var oldDate = new Date(1970, 1, 1);
			document.cookie = x_cookieName + "=0; expires=" + oldDate.toGMTString();
		}
		
		function viewPayPalCart() {

			if (checkForCookies()) {
				document.getElementById('paypalCart').submit();
			}
		}

		function showMoreInfo(divId, anchorDivId) {
			
			document.getElementById(divId).style.display = "";
			document.getElementById(anchorDivId).style.display = "none";
		}
		
		
		
		function waitToPlace() {
		
			try {
				var frame = document.getElementById("paypalSideBarFrame");
				try {
					var innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
					if (innerDoc.location.href.indexOf("SearchAndBuyPayPalButton") > -1) {
						placeAndSubmit();
					}
				} catch (e) {
					//window.status += "*";
					var timvar = setTimeout("waitToPlace()", 500);
				}
			} catch (e) {alert(e.message);}
		}

		function placeAndSubmit() {
				var frame = document.getElementById("paypalSideBarFrame");
				var innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
				innerDoc.getElementById("itemname").value = ppItemDescription;
				innerDoc.getElementById("itemname2").value = ppShortDescription;
				if (ppVat > 0) {ppVat = "17.5";}
				innerDoc.getElementById("tax").value = ppVat;
				innerDoc.getElementById("price").value = ppAmount.replace("£", "");
				if (!cookiesOK()) {
					innerDoc.getElementById("paypalForm").target = "paypal";
					innerDoc.getElementById("paypalForm").submit();
				} else {
					innerDoc.getElementById("paypalForm").submit();
					//alert("Added to your basket: " + ppItemDescription);
				}
		}

		function openCart2() {
				var frame = document.getElementById("paypalSideBarFrame");
				var innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
				innerDoc.getElementById("paypalCart").submit();
				var div = document.getElementById("paypalSideBarFrameDiv");
				div.style.display = "none";

		}
		
		// =============================================================================
		

					function createCookie(name,value,days)
					{
						if (days)
						{
							var date = new Date();
							date.setTime(date.getTime()+(days*24*60*60*1000));
							var expires = '; expires='+date.toGMTString();
						}
						else var expires = '';
						var docCookie = name+'='+value+expires+'; path=/';
//						var docCookie = name+'='+value+'; domain=www.thecmscentrehost.com';
						window.status = '*' + docCookie;
						document.cookie = docCookie;
					}


					function readCookie(name)
					{
						var nameEQ = name + '=';
						//window.status = '*** ' + document.cookie;
						var ca = document.cookie.split(';');
						for(var i=0;i < ca.length;i++)
						{
							var 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;
					}

					// this function gets the cookie, if it exists
					function Get_Cookie( name ) {
						alert(document.cookie);
						var start = document.cookie.indexOf( name + "=" );
						var len = start + name.length + 1;
						if ( ( !start ) &&
							( name != document.cookie.substring( 0, name.length ) ) )
						{
							return null;
						}
						if ( start == -1 ) return null;
						var end = document.cookie.indexOf( ";", len );
						if ( end == -1 ) end = document.cookie.length;
						return unescape( document.cookie.substring( len, end ) );
					}


					function eraseCookie(name)
					{
						createCookie(name,'',-1);
					}

					moz=document.getElementById&&!document.all;
					mozHeightOffset=20;

					function autoIframe(frameId) {
						document.getElementById(frameId).height=100; // required for Moz bug, value can be "", null, or integer
						document.getElementById(frameId).height=window.frames[frameId].document.body.scrollHeight+(moz?mozHeightOffset:0);
						return;
						try {
							frame = document.getElementById(frameId);
							innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
							objToResize = (frame.style) ? frame.style : frame;
							objToResize.height = innerDoc.body.scrollHeight + 40;	
						} catch (err) {
							window.status = err.message;
						}
					}
					
					// ==============================================================================
					
					function clickIE4(){
						if (event.button==2){
							alert(rightClickMessage);
							return false;
						}
					}

					function clickNS4(e){
						if (document.layers||document.getElementById&&!document.all){
							if (e.which==2||e.which==3){
								alert(rightClickMessage);
								return false;
							}
						}
					}

					function beforePrint() {
						var spans = document.getElementsByTagName("SPAN")
						for (i in spans) {
							var span = spans[i];
							if (span.className == "privateSection") {
								span.innerHTML = "";
							}
						}
					}
				 
					function disableRightClick() {
						rightClickMessage="Function Disabled.";

						if (document.layers){
							document.captureEvents(Event.MOUSEDOWN);
							document.onmousedown=clickNS4;
						}
						else if (document.all&&!document.getElementById){
							document.onmousedown=clickIE4;
						}
						 
						document.oncontextmenu=new Function("alert(rightClickMessage);return false")

						setInterval("window.clipboardData.clearData()", 200);


					}

					function hidePrivateSectionsBeforePrinting() {
						window.onbeforeprint = beforePrint;
					}
					
					// ===========================================================
					
										function getAnswer(params) {
						//alert(params);
						params = params.replace(new RegExp(/;/g), "&");
						//alert(params)

						var request;
						var ua = navigator.userAgent.toLowerCase();
						if (!window.ActiveXObject) {
							request = new XMLHttpRequest();
						} else if (ua.indexOf('msie 5') == -1) {
							request = new ActiveXObject("Msxml2.XMLHTTP");
						} else {
							request = new ActiveXObject("Microsoft.XMLHTTP");
						}

						//params  = encodeURI("a=1;b=2");
						params  = encodeURI(params);

						
						var uri = "http://www.thecmscentrehost.com/pages/external/ContentUserLoginControl.aspx";
						if (document.location.href.indexOf("localhost") > -1 || document.location.href.indexOf("C:") > -1) {
							uri = "http://localhost/popaddnet/pages/external/ContentUserLoginControl.aspx";
						}
																	 

						request.open("GET", uri + "?" + params + "&r=" + Math.random() , false);
						request.send(null);

						//alert("Status: " + request.status);

						if ( request.status == 200 )
						{
						//	len = request.getResponseHeader("Content-Length");
						//	len = request.getAllResponseHeaders().length;
						//	alert(request.status);
						//	alert(request.responseText);
						//	alert(request.responseXML);
							var txt = request.responseText.replace(/[\n\r]/g, "");
						//	alert("XXX: " + txt);
							if (txt.indexOf("***string***") > -1) {
						//		alert("A: " + txt);
								txt = txt.replace(new RegExp(/.*\*\*\*string\*\*\*/), "");
						//		alert("B: " + txt);
								txt = txt.replace(new RegExp(/\*\*\*.*/), "");
						//		alert("C: " + txt);
								return txt;
							}
							if (request.responseText.indexOf("yes") > -1) {return true;}
						} else {
						//	alert("request status != 200");
						}
						return false;
					}

					function bodyOnLoad() {

						try {
							var loginControlEmpty = document.getElementById("LoginControlEmpty");
							var loggedInDiv = document.getElementById("LoggedInDiv");
							var notLoggedInDiv = document.getElementById("NotLoggedInDiv");

							loginControlEmpty.style.display = "none";
							loggedInDiv.style.display = "none";
							notLoggedInDiv.style.display = "none";

							// show empty div.
							if (getAnswer("question=IsContentUserLoggedIn")) {
								var userName = getAnswer("question=UserName");
								document.getElementById("LoginControlUserName").innerHTML = userName;
								loggedInDiv.style.display = "";
							} else {
								notLoggedInDiv.style.display = "";
							}
						} catch (e) {}
						createCookie('test', 'test', 1);
						if (readCookie('test') == 'test') {
							//window.status = 'cookies ok';
						} else {
							//window.status = 'cookies not ok';
						}
						eraseCookie('test');
					}

					var alreadyShownSecureMessage = false;
					
					// =============================================================================
					
			function tell(txt) {
				window.status = window.status + txt
			}

			function adjustIFrameSize () {
				try {
				var iframeWindow = window;
				var x,y;
				var test1 = document.body.scrollHeight;
				var test2 = document.body.offsetHeight
				if (test1 > test2) // all but Explorer Mac
				{
					y = document.body.scrollHeight;
				}
				else	// Explorer Mac;
						//would also work in Explorer 6 Strict, Mozilla and Safari
				{
					y = document.body.offsetHeight;
				}
				if (iframeWindow.document.height) {
					var iframeElement = parent.document.getElementById(iframeWindow.name);
					if (''+iframeElement == 'undefined') {return}
					iframeElement.style.height = iframeWindow.document.height + 'px';
				}
				else if (document.all) {
					var iframeElement = parent.document.getElementById(iframeWindow.name);
					if (''+iframeElement == 'undefined') {return}
					if (iframeWindow.document.compatMode &&
						iframeWindow.document.compatMode != 'BackCompat')
						{
							iframeElement.style.height =
							y + 5 + 'px';
						}
					else {
						iframeElement.height =
						y + 5 + 'px';
					}
				}
				} catch(e) {}
			}
			
			function focusOnSearch() {
				try {
					var ib = document.getElementById("query");
					ib.focus();
					ib.value = queryString;
				} catch (e) {}
			}
			
			function checkSearchEngine() {
//				var loc = document.location.href.toLowerCase();
//				var ref = document.referrer.toLowerCase();
//				if (	loc.indexOf("searchandbuy.aspx") == -1
//						&& ref.indexOf("google") > -1 
//						&& ref.indexOf("q=") > -1) {
//					//document.location.href = "searchandbuy.aspx?query=" + ref;
//				}
			}







