// JavaScript Document
$(function(){
	$('#dialog').dialog({
		autoOpen: false,
		width: 400,
		modal : true
	});			
});

function send_reply(msg_id){
	var o = $('#dialog');
	o.load('compose_message.php', 'msg_id=' + msg_id);
	o.dialog('option', 'buttons', {});
	o.dialog('option', 'title', 'Compose Message');
	$('#ccontent').text('Loading, please wait...');
	o.dialog('open');
}

function send_comment_onmember(mem_id){
	var o = $('#dialog');
	o.load('comment_onmember.php', 'id=' + mem_id);
	o.dialog('option', 'buttons', {});
	o.dialog('option', 'title', 'Post comment');
	$('#ccontent').text('Loading, please wait...');
	o.dialog('open');
}

function select_winner_novoting(id, ai, fr, on, br){
	var o = $('#dialog');
	//alert('id=' + id + '&ai=' + ai + '&fr=' + fr + '&on=' + on + '&br=' + br);
	o.load('select_winner.php', 'id=' + id + '&ai=' + ai + '&fr=' + fr + '&on=' + on + '&br=' + br);
	o.dialog('option', 'buttons', {});
	o.dialog('option', 'title', 'Select Winner');
	$('#ccontent').text('Loading, please wait...');
	o.dialog('open');
}

function send_message(to, is_bracket){
	var o = $('#dialog');
	o.load('compose_message.php', 'id=' + to + (is_bracket?'&i_type=bracket':''));
	o.dialog('option', 'buttons', {});
	o.dialog('option', 'title', 'Compose Message');
	$('#ccontent').text('Loading, please wait...');
	o.dialog('open');
}
function flag_content(id, type){
	var o = $('#dialog');
	o.load('flag_content.php', 'id=' + id + '&type=' + type);
	o.dialog('option', 'buttons', {});
	o.dialog('option', 'title', 'Flag this ' + type);
	$('#ccontent').text('Loading, please wait...');
	o.dialog('open');
}
function update_pi(type){
	var o = $('#dialog');
	o.load('update_profile.php', 'type=' + type);
	o.dialog('option', 'buttons', {});
	o.dialog('option', 'title', 'Change ' + type);
//	$('#ccontent').text('Loading, please wait...');
	o.dialog('open');
}
function show_votes(fr, ai){
	var o = $('#dialog');
	//alert('id=' + id + '&ai=' + ai + '&fr=' + fr + '&on=' + on + '&br=' + br);
	o.load('votes.php', 'id=' + fr + '&ai=' + ai);
	o.dialog('option', 'buttons', {});
	o.dialog('option', 'title', 'Submit Vote');
	$('#ccontent').text('Loading, please wait...');
	o.dialog('open');
	o.bind('dialogclose', function(event) {
		if(document.getElementById('round_end_msg')) location.reload();
	});
}