		// Global variable
		thisPage = '<? echo $selfPageFilename; ?>';

		function hiliteTab(thisColumnID,mouseAction) {
			var cellColor = null;

			if (mouseAction=="over") { cellColor = '#AAAABB'; }
			else if (mouseAction=="out") { cellColor = '#DDDDEE'; }

			if (! document.getElementById(thisColumnID)) { return; }

			document.getElementById(thisColumnID).style.backgroundColor = cellColor;
		}
		function clickTab(thisLink) {
			document.location.href=thisLink;
		}
		function preLoader() {
			doSearch();

//			if (! document.getElementById("matched_string")) { return; }
//			document.location.href="#matched_string";
		}
		function optSearch(fn,save_field) {
			var f = document.forms[fn];

			if (save_field!='search') { f.search.value = ''; }
			if (save_field!='keyword') { f.keyword.value = ''; }
			if (save_field!='manf') { f.manf.options[0].selected = true; }
//			if (save_field!='manf') { f.manf.value = ''; }

			if (save_field=='manf' && f.manf.options[0].selected!=true) { f.submit(); }
		}
		function goRadio(fn,rName,rValue) {
			if (! fn) { fn = 0; }
			var f = document.forms[fn];
			var e;

			for (var i=0; i<f.elements.length; i++) {
				e = f.elements[i];
				if (e.type!='radio' || e.name!=rName) { continue; }
				if (e.value==rValue) {
					e.checked=true;
					break;
				}
			}
			createNewAddress();
		}
		function goTerms() {
			document.location.href='bill_terms.php';
		}
		SEARCH_SET = false;
		function doSearch(do_this) {
			var f = document.forms[0];
			// when "! do_this" it's being called from preLoader(),
			// and if the web visitor has pre-emptively clicked into
			// this field before the page finishes loading we shouldn't
			// continue with the loading procedure on this function.
			if (! do_this && SEARCH_SET==true) { return; }

			if (do_this=='focus' && f.search.value=='Equipment Search') {
				f.search.value = '';
				document.getElementById('search_field').style.color = 'black';
			} else if ((do_this=='blur' || ! do_this) && (f.search.value=='' || f.search.value=='Equipment Search')) {
				f.search.value = 'Equipment Search';
				document.getElementById('search_field').style.color = 'gray';
			}
			SEARCH_SET = true;
		}
		function activitySelect(do_this) {
			if (! do_this) { do_this = ''; }

			var allActivities = document.getElementById('allActivities').getElementsByTagName('p');
			var activityName = '';
			// used to determine if someone is clicking an activity prior
			// to this function loading; if so, don't load the default, stay
			// where the user is clicking.
			var activitySet = false;

			for (var i=0; i<allActivities.length; i++) {
				if (! allActivities[i].id) { continue; }
				if (! document.getElementById(allActivities[i].id)) { continue; }
				activityName = allActivities[i].id.replace('activity','');
				if (allActivities[i].id==do_this) {
					document.getElementById(allActivities[i].id).className='selectedTag';
					document.getElementById('column'+activityName).className='showColumn';
				} else {
					if (! do_this && document.getElementById('column'+activityName).className=='showColumn') {
						activitySet = allActivities[i].id; // set when determined that an activity is already clicked
						return;
					}

					document.getElementById(allActivities[i].id).className='unselectedTag';
					document.getElementById('column'+activityName).className='hideColumn';
				}
			}

			if (! do_this && activitySet==false) {
				activitySelect('activityBuy');
			}
		}
		function trim(str) {
			return str.replace(/^\s*|\s*$/g,'');
		}
		function pictureViewer(itemNum,picW,picH) {
			if (! itemNum) { return; }

			if (! picW) { picW = 550; }
			if (! picH) { picH = 500; }

			var imgRatio = picW/picH;
			if (picW<300) {
				picW = 300;
				picH = picW/imgRatio;
			}

			picW = parseInt(picW+20);
			picH = parseInt(picH+20);

			var uOptions = "toolbar=0,scrollbars=1,location=0,status=0,menubar=0,resizable=0,";
			var uSize = "width="+picW+",height="+picH+",left=200,top=150";

			var uGoTo = '/pictureView.php?itemNum='+itemNum;

			cWindow = window.open(uGoTo,'pictureView',uOptions+uSize);
		}
		function orderHelp() {
			var uOptions = "toolbar=0,scrollbars=1,location=0,status=0,menubar=0,resizable=0,";
			var uSize = "width=400,height=500,left=200,top=150";

			var uGoTo = 'help.php';

			cWindow = window.open(uGoTo,'orderHelp',uOptions+uSize);
		}
		function createNewAddress() {
			var r = document.forms['shipping'].shiptoid;
			var v = false;

			if (! r.length) {
				if (r.checked===true) { v = r.value; }
			} else {
				for (var i=0; i<r.length; i++) {
					if (r[i].checked!==true) { continue; }
					v = r[i].value;
				}
			}
			if (v===false || v>0) {
				document.getElementById('new_shipping_address').style.display = 'none';
				document.getElementById('new_shipping_address').style.visibility = 'hidden';
				return;
			}

			document.getElementById('new_shipping_address').style.display = 'block';
			document.getElementById('new_shipping_address').style.visibility = 'visible';
		}
