function new_XMLHttpRequest() {
	if (window.ActiveXObject) 
		return new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest) 
		return new XMLHttpRequest();
	else return false;
}

function getElementTextNS(prefix, local, parentElem, index) {
    var result = "";
    if (prefix && window.ActiveXObject) {
        // IE/Windows way of handling namespaces
        result = parentElem.getElementsByTagName(prefix + ":" + local)[index];
    } else {
        // the namespace versions of this method 
        // (getElementsByTagNameNS()) operate
        // differently in Safari and Mozilla, but both
        // return value with just local name, provided 
        // there aren't conflicts with non-namespace element
        // names
        result = parentElem.getElementsByTagName(local)[index];
    }
    if (result) {
        // get text, accounting for possible
        // whitespace (carriage return) text nodes 
        if (result.childNodes.length > 1) {
            return result.childNodes[1].nodeValue;
        } else {
            return result.firstChild.nodeValue;    		
        }
    } else {
        return "n/a";
    }
}

function openWindow (location, height, width) {
	newwindow = window.open(location, 'foto', 'scrollbars=yes, resizable=yes, height=' + height + ',width=' + width);
	if(window.focus) newwindow.focus;
	return false;
}

function deleteSelf(obj)
{
	obj.parentNode.removeChild(obj);
}

	function asyncSubmit(form, func) {
			var str = '';
			for (var i = 0; i < form.elements.length; i++)
			{
				str += form.elements[i].name + '=' + form.elements[i].value + '&'; 	
			}
			var req = new_XMLHttpRequest();
			req.onreadystatechange = function () {
				if(req.readyState == 4 && req.status == 200) {
					func(req);
				} 
			} 
			req.open("POST", form.action, true);
			req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
			req.send(str);
		}
	
		function makeCallback(func,obj) {
			return function(req) {
				func(obj, req);
			}
		}

	function cloneObject(obj) {
			var nobj = obj.cloneNode(true);
			obj.parentNode.appendChild(nobj);
		}
		function resetLast(form, index) 
		{
			if(window.event) index++;
			form.elements[form.elements.length - index].value = '';
		}