//V2.0 2004-11-26 MP
// (c) 2004-2006 Ovitech
function fillLocations() {
	setValue('locationtext');
	clearList('locationselect', false);
	listUpdate('locationselect', ovitechlocationID, ovitechlocation, false, false);
}

function locationReset(defaulttext) {
	fillLocations();
	var locationText = getObject('locationtext');
	locationText.style.color='#666666';
	locationText.value = defaulttext;
	submitEmptyLocation();
	selectFirst('locationselect');
	submitLocation();
	submitLocationForm();
}

function locationTextFocus(defaulText) {
	if (getValue('locationtext') == defaulText) {
		var locationText = getObject('locationtext');
		locationText.value = '';
		locationText.style.color='#000000';
	}
//	var buttonToon = getObject('locationok');
//	buttonToon.style.visibility = "visible";
}

function selectFirst(field) {
	field = getObject(field);
	for (var i = 1 ; i < field.length ; i++) {
		field.options[i].selected = false;
	}
	field.options[0].selected = true;
}

function submitEmptyLocation() {
	var empty = getValue('empty');
	if (empty == 0) {
		setValue('location');
		submitLocationForm();
		setValue('empty', '1');
	}
}

function submitLocation(locationselect) {
	var location = getObject('location');
	location.value = locationselect;
	submitLocationForm();
	setValue('empty', '0');
}

function submitLocationForm() {
	var form = getObject('locationsubmit');
	form.submit();
}

function submitLocationOne() {
	list = getObject('locationselect');
	if (list.length == 1) submitLocation();
	else submitEmptyLocation();
}

function subSetLocation(begin, caseSensitive) {
	var arrText = Array();
	var arrVal = Array();
	var locationpart = getValue('locationtext');
	var locationArray   = ovitechlocation;
	var locationArrayID = ovitechlocationID;
	var indexArray = subSetArray(locationpart, locationArray, begin);
	for (var i = 0 ; i < indexArray.length ; i++) {
		arrText[i] = locationArray[indexArray[i]];
		arrVal[i] = locationArrayID[indexArray[i]];
	}
	clearList('locationselect', false);
	listUpdate('locationselect', arrVal, arrText, false, false);

}