function defaultSelect(select, default_value) {

    for (var i = 0; i < select.options.length; i++) {

        if (select.options[i].value == default_value) {

            select.selectedIndex = i;

            return;
        }
    }
}

function uniPop(href, winname, width, height, x, y, toolbar, scrollbars, resizable, status) {
    if (href == "") href = '/support';
    if (winname == 'spellChecker') href += escape(document.eventForm.notes.value);
    if ((width < 100) || (width == null)) var width = '515';
    if ((height < 100) || (height == null)) var height = '475';
    if (toolbar == null) var toolbar = 'yes';
    if (scrollbars == null) var scrollbars = 'yes';
    if (resizable == null) var resizable = 'yes';
    if (status == null) var status = 'yes';
    var theParam = "width=" + width +
                   ",height=" + height +
                   ",toolbar=" + toolbar +
                   ",scrollbars=" + scrollbars +
                   ",resizable=" + resizable +
                   ",status=" + status +
                   ",screenX=" + x + ",screenY=" + y + ",top=" + y + ",left=" + x;
    var thePopup = window.open(href, winname, theParam);
}


function confirmURL(text, url) {
    if (confirm(text)) {
        location.href = (url);
    }
}


function deleteOnFocus(field, default_value) {

    if (field.value == default_value) {

        field.value = '';
    }

}

function textCounter(field, countfield, maxlimit) {

    if (field.value.length > maxlimit) // if too long...trim it!
        field.value = field.value.substring(0, maxlimit);
    // otherwise, update 'characters left' counter
    else
        countfield.value = maxlimit - field.value.length;
}

function setInterval(check_value) {

    for (var i = 0; i < document.date_form.elements.length; i++) {

        var e = document.date_form.elements[i];

        if (e.name == "interval_type" && e.value == check_value) {

            e.checked = true;
        }
    }
}


/**
 * This function creates an xml http object for backend
 * calls to the server. Attempts to create this object on all
 * browsers, if unsucessful, it pops up an alert to the user detailing
 * the errors.
 *
 * @return xmlhttp
 */
function getHTTPObject()
{
    var xmlhttp;

    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
            xmlhttp = false;
        }
    }

    if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
    {
        try {
            xmlhttp = new XMLHttpRequest();
        } catch (e) {
            alert("Your browser lacks some key features used by this page." +
                  "Some functionality might not work properly.Pleas contact your webmaster.");
        }
    }
    return xmlhttp;
}




