function getTransaction(transid) {
	return parent.frames[transid].transaction;
}

function sync(transid, who, atOnce, regexpr) {
	if (regexpr!=null && !regexpr.test(who.value)) {
		alert('illegal input');
		return;
	}
	if(who.type=='file') {
		getTransaction(transid).setMultiPart();
		who.parentNode.insertBefore(who.cloneNode(false), who);
		getTransaction(transid).appendNode(who.id, who);
	}
	else
		addAction(transid, who.id, who.value);
	if (atOnce)
		syncNow(transid);
}

function addAction(transid, id, value) {
	getTransaction(transid).addAction(id, value);
}

function syncNow(transid) {
	getTransaction(transid).commit();
}

function checkEnter(who, event, url) {
	if (event.keyCode==13) {
		if (who.onchange!=null) {
			who.onchange();
			who.onchange = null;
		}
		window.setTimeout('window.location.href="'+url+'"', 20);
	}
}

function syncOptions(transid, who, atOnce) {
	var s = '';
	for (var i=0; i<who.length; i++) {
		if(who.options[i].selected == true) {
			if(s.length>0)
				s+= ',';
			s += i;
		}
	}
	addAction(transid, who.id, s);
	if (atOnce)
		syncNow(transid);
}

function ajaxPost(who) {
	var req = new XMLHttpRequest();
	var res = null;
	var param = encodeURI(who.id+'='+who.value);
	req.open('POST', 'index.xml');
	req.send(param);
}