/* ***************************************************************************
Add event function
***************************************************************************** */
function addEvent(elm, evType, fn, useCapture) {
  // cross-browser event handling for IE5+, NS6 and Mozilla
  // By Scott Andrew
  if (elm.addEventListener) {
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent) {
    var r = elm.attachEvent('on' + evType, fn);
    //EventCache.add(elm, evType, fn);
    return r;
  } else {
    elm['on' + evType] = fn;
  }
}

function init() {
	if (!document.getElementById) return;
	var sltObj = document.getElementById('sl_states');
	if (sltObj=="") return;
	addEvent(sltObj, 'change', selectURL, false);
}


function selectURL(e) {
	var e1;
		if (window.event && window.event.srcElement) {
			e1 = window.event.srcElement;
		}
		if (e && e.target) {
			e1 = e.target;
		}
		if (!e1) return;
	location.href = e1.value;
}


/* *****************************************************************************
Simon Willison's addLoadEvent function allows you to stack up 'window.onload' events 
without them stepping on each other's toes. 
It's explained here - http://www.sitepoint.com/blog-post-view.php?id=171578
***************************************************************************** */
function addLoadEvent(func)
{
	var oldonload = window.onload;
	if(typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}
/* ************************************************************************** */


/* *****************************************************************************
// Initialize list of onload functions
/* ************************************************************************** */
addLoadEvent(function() { 
	init();
});

/* ************************************************************************** */