﻿function init() {
	frmSearch_attachEvent();
	establishActiveContainer();
	attachSecNavEvents();
}

function frmSearch_attachEvent() {
	var oSearchEl = false;
	if(oSearchEl = document.getElementById('txtSearchTerm')) {
		oSearchEl.onfocus = function() {
			if(this.value == this.defaultValue) {
				this.value = '';
			}
		}
		oSearchEl.onblur = function() {
			if(this.value == '') {
				this.value = this.defaultValue;
			}
		}
	}
}

function establishActiveContainer() {
	if(!document.getElementById('secondary-nav')) return false;
	var cSecNav = document.getElementById('secondary-nav').getElementsByTagName('A');
	for(var i=0; i<cSecNav.length; i++) {
		if(cSecNav[i].className.indexOf('active') !=-1) {
			cSecNav[i].parentNode.className = 'active';	
		}
		if (cSecNav[i].parentNode.id != "search")
			cSecNav[i].parentNode.style.width = (cSecNav[i].offsetWidth) + "px";
	}
}

function attachSecNavEvents() {
	if(!document.getElementById('secondary-nav')) return false;
	var cSecNav = document.getElementById('secondary-nav').getElementsByTagName('A');
	for(var i=0; i<cSecNav.length; i++) {
		if(cSecNav[i].className.indexOf('active') == -1) {
			cSecNav[i].onmouseover = function() { snMouseOver(this) }
			cSecNav[i].onmouseout = function() { snMouseOut(this) }
		}
	}
}

function snMouseOver(el) {
	el.className += ' active';
	el.parentNode.className += ' active';
}

function snMouseOut(el) {
	var className = ''
	className = el.className.replace(/active/g, '');
	el.className = className;
	
	className = el.parentNode.className.replace(/active/g, '');
	el.parentNode.className = className;
}


function searchsite(){
		var searchfield = document.getElementById("txtSearchTerm");
	if(searchfield.value=="Search the site")
		return;
	window.location="http://www.google.com/custom?q=&sa=Google+Search&cof=S%3Ahttp%3A%2F%2Fwww.xrfsupplies.com%3BAH%3Aleft%3BLH%3A51%3BL%3Ahttp%3A%2F%2Fwww.xrfsupplies.com%2Fimages%2Flogo_xrfsupplies_googlesearch.gif%3BLW%3A711%3BAWFID%3Ab0fb91857b23eaf3%3B&domains=www.xrfsupplies.com&sitesearch=www.xrfsupplies.com&q="+searchfield.value;
}

window.onload = init;






















































