function doWebboardPost(pForm,live) {
	pForm.live.value = live ? 1 : 0;
	var req = new GForm(pForm);
	req.inintLoading('wait', true );
	req.submit(function(xhr){
		var datas = req.toJSON( xhr.responseText );
		if ( datas[0].error != '' ) {
			alert( datas[0].error );
			if ( datas[0].input != '' )
			{
				new GHighlight( datas[0].input ).play();
				document.getElementById( datas[0].input ).focus();
			};
		} else {
			var req2 = new GAjax();
			req2.inintLoading( 'wait' , true );
			req2.send( web_url + 'getcontent.php' , 'module=webboard/main&page=1' , function(xhr){
				var data = xhr.responseText;
				var el = $E( 'content' );
				el.innerHTML = data;
				loader.inint( el );
				Object.evalScript( data );
				alert( datas[0].alert );
			});
		};
	});
	pForm.submit();
};

function doWebboardReply(pForm) {
	var req = new GForm(pForm);
	req.inintLoading('wait', true );
	req.submit(function(xhr){
		var datas = req.toJSON( xhr.responseText );
		if ( datas[0].error != '' ) {
			alert( datas[0].error );
			if ( datas[0].input != '' )
			{
				new GHighlight( datas[0].input ).play();
				document.getElementById( datas[0].input ).focus();
			};
		} else {
			var req2 = new GAjax();
			req2.inintLoading( 'wait' , true );
			req2.send( web_url + 'getcontent.php' , 'module=webboard/view&visited=1&wbid=' + datas[0].id , function(xhr){
				var data = xhr.responseText;
				var el = $E( 'content' );
				el.innerHTML = data;
				loader.inint( el );
				Object.evalScript( data );
				alert( datas[0].alert );
			});
		};

	});
	return true;
}

function doWebboardAction( obj ) {
	var query = obj.id;
	var ds = query.split( '-' );
	if ( ds[0] == 'delete' && ds[1] == 'q' && !confirm( 'คุณต้องการลบคำถามนี้และคำตอบของคำถามนี้ทั้งหมด ?' ) ) {
		return;
	} else if ( ds[0] == 'delete' && ds[1] == 'r' && !confirm( 'คุณต้องการลบคำตอบนี้ ?' ) ) {
		return;
	} else if ( ds[0] == 'category' && ds[1] == 'q' ) {
		query += '&value=' + obj.value;
	};
	var req = new GAjax();
	req.inintLoading( 'wait' , true );
	req.send( web_url + '/webboard/action.php' , 'data=' + query , function(xhr) {
		if ( xhr.responseText != '' ) {
			alert(xhr.responseText);
		} else if ( ds[0] == 'delete' && ds[1] == 'q'  ) {
			$G( 'WL_' + ds[2] ).remove();
		} else if ( ds[0] == 'delete' && ds[1] == 'r'  ) {
			$G( 'WR_' + ds[2] ).remove();
		};
	});
};

function setSmile(what) {
	var detail = $E('detail');
 	detail.value = detail.value + what;
  	detail.focus();
};

function setColor(color) {
	setSmile('[color=' + color + '][/color]');
};