function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function colorVisualizerLinkPopup() {
	var visualizerLink = document.getElementById('color-visualizer-launcher').getElementsByTagName('a')[0];
	visualizerLink.onclick = function () {
		window.open(this.getAttribute('href'), 'popup', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=600');
		return false;
	}
}

function wireUtilityHelperText() {
	var searchTextBox = document.getElementById('search_terms');
	var zipTextBox = document.getElementById('zip-code');
	
	searchTextBox.setAttribute('value', 'Search...');
	zipTextBox.setAttribute('value', 'Enter Zip Code...');
	
	searchTextBox.onfocus = function () {
		if (this.getAttribute('value') == 'Search...') {
			this.setAttribute('value', '');
			this.style.color = '#424341';
		}
	};
	searchTextBox.onblur = function () {
		if (this.getAttribute('value') == '') {
			this.setAttribute('value', 'Search...'); 
			this.style.color = '#999999';
		}
	};
	
	zipTextBox.onfocus = function () {
		if (this.getAttribute('value') == 'Enter Zip Code...') {
			this.setAttribute('value', '');
			this.style.color = '#424341';
		}
	};
	zipTextBox.onblur = function () {
		if (this.getAttribute('value') == '') {
			this.setAttribute('value', 'Enter Zip Code...');
			this.style.color = '#999999';
		}
	};
}

addLoadEvent(colorVisualizerLinkPopup);
addLoadEvent(wireUtilityHelperText);