var HT = {};

function setStylesheet () {
	selectCSS = document.createElement('link');
	selectCSS.setAttribute('type','text/css');
	selectCSS.setAttribute('rel','stylesheet');
	selectCSS.setAttribute('media','screen');
	selectCSS.setAttribute('href','/static/css/js.css');
	document.getElementsByTagName('head')[0].appendChild(selectCSS);
}
function createContextFunction(context, method, method2) {
	return (function(x){
		method = (method == "post") ? method2 : method;
		eval("context."+method+"(x)");
		return false;
	});
}
function initSearchField() {
	var i = YAHOO.util.Dom.get('search-top');
	if (i) {
		i.orgVal = i.value;
		YAHOO.util.Event.addListener(i, 'focus', function() {if (this.value == this.orgVal) this.value = ''});
		YAHOO.util.Event.addListener(i, 'blur', function() {if (this.value == '') this.value = this.orgVal});
	}
	var g = YAHOO.util.Dom.get('search-glossary');
	if (g) {
		g.orgVal = g.value;
		YAHOO.util.Event.addListener(g, 'focus', function() {if (this.value == this.orgVal) this.value = ''});
		YAHOO.util.Event.addListener(g, 'blur', function() {if (this.value == '') this.value = this.orgVal});
	}
}

function initSearchFieldCustomer() {
	var i = YAHOO.util.Dom.get('search-customer');
	if (!i) return;
	
	i.orgVal = i.value;
	YAHOO.util.Event.addListener(i, 'focus', function() {if (this.value == this.orgVal) this.value = ''});
	YAHOO.util.Event.addListener(i, 'blur', function() {if (this.value == '') this.value = this.orgVal});
}

function initSearchFieldLayover() {
	var i = YAHOO.util.Dom.get('search-layover');
	if (!i) return;
	
	i.orgVal = i.value;
	YAHOO.util.Event.addListener(i, 'focus', function() {if (this.value == this.orgVal) this.value = ''});
	YAHOO.util.Event.addListener(i, 'blur', function() {if (this.value == '') this.value = this.orgVal});
}

function initSearchFieldResults() {
	var i = YAHOO.util.Dom.get('search-results');
	if (!i) return;
	
	i.orgVal = i.value;
	YAHOO.util.Event.addListener(i, 'focus', function() {if (this.value == this.orgVal) this.value = ''});
	YAHOO.util.Event.addListener(i, 'blur', function() {if (this.value == '') this.value = this.orgVal});
}

function initSearchFieldResults2() {
	var i = YAHOO.util.Dom.get('search-results2');
	if (!i) return;
	
	i.orgVal = i.value;
	YAHOO.util.Event.addListener(i, 'focus', function() {if (this.value == this.orgVal) this.value = ''});
	YAHOO.util.Event.addListener(i, 'blur', function() {if (this.value == '') this.value = this.orgVal});
}


function initSearchFieldGlossary() {
	var i = YAHOO.util.Dom.get('search-glossary');
	if (!i) return;
	
	i.orgVal = i.value;
	YAHOO.util.Event.addListener(i, 'focus', function() {if (this.value == this.orgVal) this.value = ''});
	YAHOO.util.Event.addListener(i, 'blur', function() {if (this.value == '') this.value = this.orgVal});
}

HT.getQuerystring = function(key, default_){
	if (default_==null) default_="";
	key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
	var qs = regex.exec(window.location.href);
	if(qs == null)
		return default_;
	else
		return qs[1];
}