// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
// - - - - - - ( event listener ) - - - - - - - -
// by Scott Andrew - http://scottandrew.com
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function addEvent(obj, evType, fn)
	{
	if (obj.addEventListener)
		{
		obj.addEventListener(evType, fn, false); 
		return true;
		}
	else if (obj.attachEvent)
		{
		var r = obj.attachEvent('on'+evType, fn);
		return r;
		}
	else
		{
		return false;
		}
	}

function fill(field, name, id)
{
	tf = document.getElementById(field);
	tfid = document.getElementById(field + 'id');
	tf.value = name;
	tfid.value = id;
	
}

function fill2(field, evt)
{
    evt = (evt) ? evt : ((window.event) ? window.event : null);
    var item, content, div;
    if (evt) {
        var select = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
        if (select && select.options.length > 1) {
			tf = document.getElementById(field + 'text');
			tfid = document.getElementById(field + 'id');
			testurl = document.getElementById('test');
			selind = select.selectedIndex;
			tf.value = select.options[selind].text;
			tfid.value = select.options[selind].value;        
//			resulturl = resulturl + tf.value + '/' + tfid.value + '/';
//	        alert(select.options[selind].value + ' ' + select.options[selind].text);
        }
    }
    if(field=='from')
    {
    	sel = document.getElementById('topics');
    	sel.name = 'to';
    	
    	fromtext = tf.value;
    	fromid = tfid.value;
    	clearTopicList();
    	
		var searchInput = document.getElementById(searchInputId);
		searchInput.value = searchInputMessage1;   
		searchInput.focus(); 	
    }
    else if(field=='to')
    {
//		df = document.getElementById('locations');
//		df.submit();
    	totext = tf.value;
    	toid = tfid.value;
    	
		resulturl = resulturl + fromtext + '/naar/' + totext + '/' + fromid + '/' + toid
		document.location.href = resulturl;
    }
}

// run all the onload scripts
function runScripts()
	{
	runLSPrep();
	}

var fromid		= 0;
var toid		= 0;
var fromtext	= '';
var totext	= '';

window.onload = runScripts;
