function addOptionToSelect(selectID, text, value) {
    var select  = document.getElementById(selectID);
    var option  = document.createElement("option");
    option.text = text;
    option.value= value;

    try{
        //standards compliant; doesnt work in IE
        select.add(option, null);
    }catch(ex){
        //IE only
        select.add(option);
    }
}

function setSelectedIndex(selectID, value){
    var select = document.getElementById(selectID);

    for (var intI = 0; intI < select.options.length; intI++) {
        if (select.options[intI].value == value) {
            select.options[intI].selected = true;
        }
    }
}

function getSelectOptionValue(selectID) {
    return document.getElementById(selectID).options[document.getElementById(selectID).selectedIndex].value;
}

function clearSelect(selectID) {
    document.getElementById(selectID).options.length = 0;
}

function setHrefTargetBlank(object){
    object.target = '_blank';
}

function $(name){
    object = document.getElementById(name);

    if (object !== null){
        return object;
    }else{
        return false;
    }
}

function confirmChoice(text, link){
    if (window.confirm(text) === true){
        location.href=link;
    }

    return false;
}

function readKey(event){
    var key = null;
    if (window.event){
        key = window.event.keyCode; //IE support
    }else{
        key = event.which; //Firefox support
    }

    alert(key);
    //example: key=13 ==> enter
}

function trim(stringToTrim) {
    return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function scrollScreen(offsetW, offsetH) {
    scroll(offsetW, offsetH);
}

//Source: http://www.netlobo.com/url_query_string_javascript.html
function getURLParam(name) {
    name        = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS  = "[\\?&]"+name+"=([^&#]*)";
    var regex   = new RegExp( regexS );
    var results = regex.exec( window.location.href );

    if( results == null ) {
        return "";
    }

    return results[1];
}