window.onload = function () {	
	if (document.getElementById('ao_hd_info_top')) {
		document.getElementById('srch').value = 'search';
		document.getElementById('srch').onfocus=function() {
			if (document.getElementById('srch').value == "search") {
				document.getElementById('srch').value = '';
			}
		}
		document.getElementById('srch').onblur=function() {
			if (document.getElementById('srch').value == "") {
				document.getElementById('srch').value = 'search';
			}
		}
	}
	if (document.getElementById('selectCatagory')) {
		var c=document.getElementById('selectCatagory');
		c.onchange=function() {
			document.browse_by_cat.submit();
		}
	}
	if (document.getElementById('selectManufacturer')) {
		var m=document.getElementById('selectManufacturer');
		m.onchange=function() {
			document.browse_by_man.submit();
		}
	}
	if (document.getElementById('product_result')) {
		checkCartQuan();
		if (document.getElementById('theChoice')) {
			var c=document.getElementById('theChoice');
			c.onchange=function() {
				checkCartQuan();
			}
		}
	}
	if (document.getElementById('prods_rt')) {
		var a = document.getElementById('content_txt').getElementsByTagName("a");
		for (var i=0; i < a.length; i++) { 
			if (a[i].id) {
				document.getElementById(a[i].id).onclick=function() {					
					this.setAttribute('href','#');
					var d=this.id.substr(1,(this.id.length-1));
					if (this.id.substr(0,1) == "m") {
						//alert('clicked manufacturer '+d);
						document.getElementById('srch').value = 'Manufacturer Id '+d;
					} else  {
						//alert('clicked category '+d);
						document.getElementById('srch').value = 'Category Id '+d;
					}
					document.getElementById('search_frm').submit();					
					return false;
				}			
			}
		}
	}
	if (document.getElementById('cart')) {
		document.getElementById('cart').style.display = 'block';
		
	}
}
function checkCartQuan() {
	if (document.getElementById('theChoice')) {
		var sel=document.getElementById('theChoice');
		var b=sel.options[sel.selectedIndex].value.split("-");		
	} else {
		var b=document.productForm.theCart.value.split("-");
	}
	var ii = document.getElementById('the_price');
	if (b[1]=="T") {
		var h='<input type="submit" value="Add to Shopping Cart">';
		ii.innerHTML = "Price: "+b[2];
	} else if (b[1]=="Q") {
		var h='&nbsp;';
		ii.innerHTML = "Price: contact for quote";
	} else {
		var h='<div id="ao_thumbs_warning">This item is currently out of stock.</div>';
		ii.innerHTML = "&nbsp;";
	}
	var i = document.getElementById('toCart');
	i.innerHTML = h;
}
