function checkAll(field) {
    if (field.length) {
        for (i = 0; i < field.length; i++) {
            if (field[i].checked) {
                field[i].checked = false;
            } else {
                field[i].checked = true ;
            }
        }
    } else {
        if (field.checked) 
            field.checked = false;
        else
            field.checked = true;
    }
}

function fcheckAll(field) {
    for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}

function uncheckAll(field) {
    for (i = 0; i < field.length; i++)
	field[i].checked = false ;
}

function handleHttpResponse(http, fieldToFill) {
    if (http.readyState == 4) {
	document.getElementById(fieldToFill).innerHTML = http.responseText;
    }
}

function getTracking(trackValue, key, fieldToFill) {
    var http = new HTTPRequest();
    if (http) {
	http.open('GET', '/perl/track.pl?num=' + escape(trackValue) + '&key=' + escape(key), true);
	http.onreadystatechange = function (){ handleHttpResponse(http, fieldToFill)};
	http.send(null);
    }
}

HTTPRequest = function () {

    var xmlhttp=null;
    try {
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (_e) {
	try {
	    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
	    } catch (_E) {  }
    }
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
	try {
	    xmlhttp = new XMLHttpRequest();
	} catch (e) {
	    xmlhttp = false;
	}
    }
    return xmlhttp;
}
