	function hide() {
		var myCookie = getCookie('region');
		if (myCookie != null) {
			var cook = trim(myCookie);
			if (cook != 'USA') {
				//load the xml document
				loadXMLContent(myCookie);
				//hide buttons
				getShoppingCartButtons("AddToCartButton");
				//hide quantity text
				var aElm=document.body.getElementsByTagName('small');
				for(var i=0; i<aElm.length; i++) {
					aElm[i].style.display = "none";
    				}        
				//hide quantity input
				var aElm=document.body.getElementsByTagName('input');
				for(var i=0; i<aElm.length; i++) {
    					if(aElm[i].size == 3) {
						aElm[i].style.display = "none";
					}
    				} 
				//swap out prices with xml data	
				setTimeout('swapPrice()', 100);
			}
		} else {
			//if no cookie, enforce region choice 
			window.open('/changeRegion.html','linkname','fullscreen=yes,scrollbars=no,toolbar=no, menubar=no, resizable=no');
		}
	}

	//IE detection
	function isIEx() {
  		return navigator.appName.indexOf("Microsoft") != -1;
	}

	function swapPrice() {
		var aElm=document.body.getElementsByTagName('table');
		var myPrice = '';
		for(var i=0; i<aElm.length; i++) {
    			if(aElm[i].className == "productTable" || aElm[i].className == "productMain") {
				//make sure we are within the node
				//basically a foreach in the DOM
				//BEGIN PRODUCT
				var productId = "N/A";
				var variantId = "N/A";
				var aBElm=aElm[i].getElementsByTagName('tr');
				for(var j=0; j<aBElm.length; j++) {
					var aFElm=aBElm[j].getElementsByTagName('input');
					//alert("aFElm.length=" + aFElm.length);
					for(var k=0; k<aFElm.length; k++) {
						//alert("k=" + k + "; " + "aFElm[k].name=" + aFElm[k].name);
						if (aFElm[k].name == 'ProductID') {
							productId = aFElm[k].value;
							//alert("setting productId to |" + productId + "|");
						} 
						if (aFElm[k].name == 'VariantID') {
							variantId = aFElm[k].value;
							//alert("setting variantId to |" + variantId + "|");
						} 
					}
					//skip over the empty elements
					if (productId != "undefined") {
						//alert("Good!  Found that productId does have a value. productId=" + productId);
						//remove price from node 
						var aGElm=aBElm[j].getElementsByTagName('dd');
						for(var h=0; h < aGElm.length; h++) {
							if (aGElm[h].className == 'price' || aGElm[h].className == 'MSRP') {
								//replace with xml data
								//aGElm[h].innerText = productId + ' - ' + variantId;
								myPrice =  getRegionPrice(productId, variantId);
								if (myPrice == undefined) {
									aGElm[h].innerHTML =  "";
								} else {
									aGElm[h].innerHTML =  "MSRP: " + myPrice;
								}
							}
						}
					}
				}
				//END PRODUCT
			}
    		}
			myPrice =  getRegionPrice(productId, variantId);
			if (myPrice == undefined) {
			getPriceForSwap('MSRP', '');
			} else {
				getPriceForSwap('MSRP', myPrice);
			}
	}

	function hideButton(element) {
		var style = element.style;
        	//style.filter = "alpha(opacity=50)";
		style.display = "none";
	}

	function getShoppingCartButtons(findClass) {
		var aElm=document.body.getElementsByTagName('*');
		for(var i=0; i<aElm.length; i++) {
    			if(aElm[i].className==findClass) {
    				//do something
				hideButton(aElm[i]);
        		}
    		}        
	}

	function getPriceForSwap(findClass, price) {
		var aElm=document.body.getElementsByTagName('*');
		for(var i=0; i<aElm.length; i++) {
    			if(aElm[i].className==findClass) {
    				//do something
					if(price == "") {
						aElm[i].innerHTML = price;
					} else {
					aElm[i].innerHTML = "MSRP: " + price;
					}
        		}
    		}        
	}
	
	function loadXMLContent(countryName) {
		var url = ("/regions/regions.xml");

		if (window.XMLHttpRequest)
		{
			request = new XMLHttpRequest();
		}
		else if (window.ActiveXObject)
		{
			try
			{
				request = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e1)
			{
				try
				{
					request = new ActiveXObject("Microsoft.XMLHTTP");
				} 
				catch (e2)
				{
					//fail
				}
			}
		}

		request.open("GET",url,true);
		request.onreadystatechange = function()
		{
			if (request.readyState == 4)
			{
				xmlDoc = request.responseXML;
				//processing xml...
				var elCount = xmlDoc.getElementsByTagName("region").length;
				var elms = xmlDoc.getElementsByTagName("region");
				var country = "";
				var countryElm = "";
				for (var i = 0; i < elCount; i++) {
					if (isIEx()) {
						country = elms[i].getElementsByTagName("name")[0].text;
					} else {
						country = elms[i].getElementsByTagName("name")[0].textContent;
					}
					countryElm = elms[i];
					if (country == countryName) {
						prices = new Array();
						var elk = elms[i].getElementsByTagName("product");
						for (var j = 0; j < elk.length; j++) {
							//create the price object as a three element array
							var product = new Array();
							if (isIEx()) {
								var prodId = elms[i].getElementsByTagName("productId")[j].text;
								var variantId = elms[i].getElementsByTagName("variantId")[j].text;
								var price = elms[i].getElementsByTagName("price")[j].text;
							} else {
								var prodId = elms[i].getElementsByTagName("productId")[j].textContent;
								var variantId = elms[i].getElementsByTagName("variantId")[j].textContent;
								var price = elms[i].getElementsByTagName("price")[j].textContent;
							}
							product[0] = prodId;
							product[1] = variantId;
							product[2] = price;
							//add the product array to the master prices array
							prices[prices.length] = product;
						}
					} 
				}
			}
		}
		request.send(null);
	}

	function trim (str) {
		var	str = str.replace(/^\s\s*/, ''),
			ws = /\s/,
			i = str.length;
		while (ws.test(str.charAt(--i)));
		return str.slice(0, i + 1);
	}	

	function getRegionPrice(productId, variantId) {
		//step through the price array and see if there is a match
		// if not, display a N/A
		try {
		for (var i = 0; i < prices.length; i++) {
			var yourId = trim(prices[i][0]);
			var myId = trim(productId);
			var price = trim(prices[i][2]);
			if (yourId == myId) {
				//right here
				if ('undefined' != price)  {
					return price;
				} else {
					return '';
				}
			}
		}
		} catch (e) {
			return '';
		}
	}

function getCookie( check_name ) {
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; 
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}	

