//
// $Id$
//
// Javascript code used throughout the website.
//
// Author: Claudio Felber (claudio.felber@perron2.ch)
// Created: 2007-05-17
//
// Copyright (c) 2007, Perron2 GmbH, All Rights Reserved.
//

window.onload = function() {
    focusControl();
}

/**
 * Sets the input focus to the first input element of the first form on the page.
 */
function focusControl() {
    if (document.forms.length > 0) {
        for (var i = 0; i < document.forms[0].elements.length; i++) {
            var elem = document.forms[0].elements[i];

            if (elem.type == 'text') {
                elem.focus();
                elem.select();
                break;
            } else if (elem.type == 'select-one' || elem.type == 'textarea' || elem.type == 'checkbox' || elem.type == 'radio' || elem.type == 'input') {
                elem.focus();
                break;
            }
        }
    }
}

function sort(column) {
	document.forms[0].sort.value = column;
	document.forms[0].submit();
}