var natth = 0;
function atth_add(f){
	$('atth_msg').innerHTML = '';
	var atth = document.getElementById('atth');
	ath_div = document.createElement('div');
	ath_div.innerHTML = '<div class="attachment">'+f['name']+' ('+Math.ceil(f['size']/1000)+'kb) <span onclick="atth_remove('+natth+');" class="toggle_1">remove</span></div>';
	if (f['prev']=='thumbnail'){
		ath_thm = document.createElement('div');
		thm_img = document.createElement('img');
		thm_img.src = '/message/attach/?attid='+f['code']+'&disp=thm';
		thm_img.className = 'thumbnail';
		ath_thm.appendChild(thm_img);
		ath_div.appendChild(ath_thm);
	}
	var ath_id = document.createElement('input');
	ath_id.type = 'hidden';
	ath_id.value = f['code'];
	ath_id.name = 'ath_'+natth;
	ath_div.appendChild(ath_id);
	atth.appendChild(ath_div);
}

function atth_remove(n){
	var atth = document.getElementById('atth');
	var ath_div = atth.getElementsByTagName('div')[n];
	atth.removeChild(ath_div);
	$('uframe').style.display = 'block';
}

function atth_error(s){
	$('uframe').style.display = 'block';
	$('atth_msg').innerHTML = '<div class="error">'+s+'</div>';
}

function atth_uploading(){
	$('uframe').style.display = 'none';
	$('atth_msg').innerHTML = '<img src="/images/loading.gif" alt=""/> Uploading file, please wait...';
}