var _hall_canSubmit = true;

function _hall_refresh_pic() {
	box = $('imgbox');
	t = $('picid');
	t.value = parseInt(t.value) ? Math.abs(parseInt(t.value)) : '';
	if(!t.value) {
		box.innerHTML = "<img id='theimg' src='image/nopic.gif' />";
		return;
	}
	ajaxget('hall.php?ajax=getpic&picid='+t.value, box.id, box.id, '正在获取图片');
}
function _hall_refresh_apic() {
	box = $('imgbox');
	t = $('albumid');
	t.value = parseInt(t.value) ? Math.abs(parseInt(t.value)) : '';
	if(!t.value) {
		box.innerHTML = "<img id='theimg' src='image/nopic.gif' />";
		return;
	}
	ajaxget('hall.php?ajax=getapic&albumid='+t.value, box.id, box.id, '正在获取图片');
}

function _hall_checksubmit(formid) {
	switch(formid) {
		case 'add2hall_form':
		if(!$('picid').value || $('imgbox').innerHTML=='图片不存在') {
			alert('请输入图片picid');
			return false;
		}
		if(!$('hallid').value) {
			alert('请选择展厅');
			return false;
		}
		break;
		case 'donate_form':
		$('num').value = abs(parseInt($('num').value));
		$('num').value = isNaN($('num').value) ? '' : $('num').value;
		if(!$('num').value) {
			alert('请输入声望数量');
			return false;
		}
		break;
		case 'addalbum_form':
		if(!$('albumid').value || $('imgbox').innerHTML=='相册不存在') {
			alert('请输入相册albumid');
			return false;
		}
		if(!$('hallid').value) {
			alert('请选择展厅');
			return false;
		}
		break;
	}
	return _hall_canSubmit;
}

function _hall_exchange() {
	r = $('result');
	no = $('num');
	isSave = $('ex_cm_radio').checked;
	
	no.value = Math.abs(parseInt(no.value));
	if(isNaN(no.value)) no.value = '';
	
	if(no.value) {
		_hall_canSubmit = true;
		if(isSave) {
			newC = _hall_credit - parseInt(no.value);
			newM = _hall_money + no.value * _hall_ex_cm;
			if(newC < 0) {
				result.innerHTML = '声望不足，无法兑换';
				_hall_canSubmit = false;
			} else result.innerHTML = '兑换后您的声望='+newC+'; 金币='+newM;
		} else {
			newC = _hall_credit + parseInt(no.value);
			newM = _hall_money - no.value * _hall_ex_mc;
			if(newM < 0) {
				result.innerHTML = '金币不足，无法兑换';
				_hall_canSubmit = false;
			} else result.innerHTML = '兑换后您的声望='+newC+'; 金币='+newM;
		}
	} else {
		result.innerHTML = '请输入声望数量';
	}
}