// needed to replace $.load() from jQuery because IE has problems with receiving non-xml responses
function load(query,url,loading,exec)
{
	if(loading=="wait") $(query).html("Please wait...");
	else if(loading=="image") $(query).html('<img src=\"images/loading.gif\" />');
	else if(loading=="none") { }
	else $(query).html(loading);
	
	$.get(url,{},function(xml) { var data=$(xml).find("response").text(); $(query).html(data); if(exec!="") eval(exec); },"xml");
	return $(query);
}

function openCountryDialog()
{
	$('#countrydialog').remove();
	$('#fedchoice').after('<div id="countrydialog" title="Landkeuze" style="display: none"><div id="countrydialog_form"></div></div>');
	$('#countrydialog').dialog({
		bgiframe: true,
		autoOpen: false,
		width: 640, height: 360,
		modal: true, position: ['center',100]
	});
	load("#countrydialog #countrydialog_form","ajax.php?page=ajax_user&type=choosecountryform","image","$('#conttabs').tabs({ event: 'mouseover' });");
	$('#countrydialog').dialog('open');
	
}

function openDialog(dialogdiv,attachdiv,title,loadurl)
{
	$('#'+dialogdiv).remove();
	$('#'+attachdiv).after('<div id="'+dialogdiv+'" title="'+title+'" style="display: none"><div id="'+dialogdiv+'_form"></div></div>');
	$('#'+dialogdiv).dialog({
		bgiframe: true,
		autoOpen: false,
		width: 640, height: 360,
		modal: true, position: ['center',100]
	});
	load("#"+dialogdiv+" #"+dialogdiv+"_form",loadurl);
	$('#'+dialogdiv).dialog('open');
}

function display_unreadmsg()
{
	if(window.isActive) {
		$.get("ajax.php?page=ajax_user&type=unreadmsgs",{},function(xml) {
			var data=$(xml).find("response").text();
			if($("#unreadmsg").html()!=data) {
				$("#unreadmsg").fadeOut(function() { $(this).html(data).fadeIn(); });
			}
			},"xml");
	}
	setTimeout("display_unreadmsg()",10000);
}
