function toggleObject(obj) {
	if (isHidden(obj)) {
		showObject(obj);
	} else {
		hideObject(obj);
	}
}

function showObject(obj) {
	if (obj.style != undefined) {
		obj.style.display = 'block';
		//obj.style.display = 'inline';
		obj.style.visibility = 'visible';
	}
	if (obj.visibility != undefined) {
		obj.visibility = 'visible';
	}
}

function hideObject(obj) {
	if (obj.style != undefined) {
		obj.style.display = 'none';
		obj.style.visibility = 'hidden';
	}
	if (obj.visibility != undefined) {
		obj.visibility = 'hidden';
	}
}

function alertMe() {
    //alert('hallo');
}

function isVisible(obj) {
	return ((obj.style.display == 'block') | (obj.visibility == 'visible'));
}

function isHidden(obj) {
	return ((obj.style.display == 'none') | (obj.visibility == 'hidden'));
}

function optionSelected(opt, value) {
   for (var i=0; i < opt.length; i++) {
      if (opt.options[i].value == value) {
          opt.options[i].selected=true;
      }
     }
}

function sortOptionsByName(opt) {
    var test;
    var verdi;
    if (opt == null) return;
    var tmpArray = new Array();
    for (var i=0; i<opt.length; i++) {
        tmpArray.push(new Option(opt.options[i].text, opt.options[i].value));
    }
    tmpArray.sort(optionsComparator);
    clearOptionList(opt);

    for (var i=0; i<tmpArray.length; i++) opt[i] = new Option(tmpArray[i].text, tmpArray[i].value);
}

function optionsComparator(a, b) {
     if (a.text.toLowerCase() < b.text.toLowerCase()) return(-1);
     if (a.text.toLowerCase() > b.text.toLowerCase()) return(1);
     return 0;
}
