function user_pm_popup(new_window)
{
	if ($("#phpbbprivmsg").length == 0)
	{
		$("body").append('<div id="phpbbprivmsg" style="display: none;"></div>');
	}
	if ($("#phpbbprivmsg").dialog('isOpen'))
	{
		return;	
	}
	$("#phpbbprivmsg").html("<p><center><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span>Tiene almenos un nuevo mensaje privado en su bandeja de entrada.<br /><br />&iquest;Desea ver su bandeja de entrada ahora mismo?</center></p>");
	$("#phpbbprivmsg").dialog(
		{
			bgiframe: false,
			title: "Nuevo(s) mensaje(s) privado(s)",
			modal: true,
			resizable: false,
			draggable: true,
			show: 'fold',
			hide: 'fold',
			closeOnEscape: true,
			buttons:
			{
				'No': function(){$(this).dialog('close');},
				"Si": function(){
					if (new_window == true)
					{
						window.open(phpbb_root_path + 'ucp.php?i=pm&folder=inbox');
					}
					else
					{
						document.location = phpbb_root_path + 'ucp.php?i=pm&folder=inbox';
					}
				}						
			},
			width: '450px',
			//height: '255px',
			position: 'center',
			stack: true,
			close: function() { $(this).dialog("destroy"); }
		}
	);
}
	
function loginbox()
{
	$("#loginform #redirect").val(window.location.href);
	$("#loginbox").dialog({
		autopen: true,
		bgiframe: false,
		title: 'Identificarse',
		modal: true,
		resizable: false,
		draggable: true,
		show: 'fold',
		hide: 'fold',
		closeOnEscape: true,
		buttons:
		{
			'Cancelar': function(){$(this).dialog('close');},
			"Identificarse": function(){$("#loginform").submit();}						
		},
		width: '350px',
		//height: '255px',
		position: 'center',
		stack: true,
		close: function() { $(this).dialog("destroy"); }
	});
}
	
if (s_new_pm == '1')
{
	$(function(){ user_pm_popup(); });
}

function quicksearch()
{
	var offset = $("#quicksearch_link").offset();
	$("#quicksearchbox").css({top: offset.top + 20, left: offset.left - $("#quicksearch_link").width()});
	$("#quicksearchbox").toggle("fold", "slow");
}

function toggle_spoiler(spoiler_link)
{
	var spoiler = $(spoiler_link).parent().parent().parent();
	$(spoiler).children(".spoilercontent").toggle("blind", "fast");
	if(typeof resize_images == 'function')
	{
		resize_images();
	} 
}

function more_smilies(url)
{
	if ($("#phpbbsmilies").length == 0)
	{
		$("body").append('<div id="phpbbsmilies" style="display: none;" empty="true"><center><br/><img src="' + t_imageset_path + '/ajax_loaderb.gif" border="0" title="Cargando..." alt="Cargando..." /><br/><br />Cargando...</center></div>');
	}	
	$("#phpbbsmilies").dialog({
				bgiframe: false,
				title: (l_smilies) ? l_smilies : '',
				modal: false,
				resizable: false,
				draggable: true,
				show: 'fold',
				hide: 'fold',
				closeOnEscape: true,
				buttons:
				{
					'Cerrar': function(){$(this).dialog('close');}				
				},
				width: 200,
				height: 'auto',
				position: 'center',
				stack: true,
				open: function()
				{
					if ($("#phpbbsmilies").attr("empty") == "true")
					{
						$.ajax({
							url: url,
							dataType: 'html',
							success: function(result)
							{
								$("#phpbbsmilies").html(result);
								$("#phpbbsmilies").attr("empty", "false")
							}
						});
					}
				},
				close: function() { $(this).dialog("destroy"); }				  
			});
}

function toggle_whoisonline()
{
	switch ($("#whoisonline").css("display"))
	{
		case 'none':
			//Mostramos
			$("#whoisonline_content").toggle('blind', 'slow');
		break;
		default:
			$("#whoisonline_content").toggle('blind', 'slow');
		break;
	}
}

//Popup if IE 6 or lower

$(function(){
	var browser = jQuery.browser;
	var version = jQuery.browser.version;

	if (browser = 'msie')
	{
		if (version <= 6.0)
		{
			var msg = 'Actualmente estas utilizando Internet Explorer 6, este navegador no respeta los estandares web y es totalmente inseguro a la hora de navegar por internet. \r';
			msg += 'HaloSpain.com no es compatible con este navegador por lo que te recomendamos que instales uno de la siguiente lista: \n \n';
			msg += '\t * Internet Explorer 7 (O superior) \n';
			msg += '\t * Mozilla Firefox 3.5 (O superior) \n';
			msg += '\t * Google Chorme 2.0 (O superior) \n';
			msg += '\t * Safari 4 (O superior)';
			alert(msg);	
		}
	}
});

/**
* Mark/unmark checklist
* id = ID of parent container, name = name prefix, state = state [true/false]
*/
function marklist(id, name, state)
{
	var parent = document.getElementById(id);
	if (!parent)
	{
		eval('parent = document.' + id);
	}

	if (!parent)
	{
		return;
	}

	var rb = parent.getElementsByTagName('input');
	
	for (var r = 0; r < rb.length; r++)
	{
		if (rb[r].name.substr(0, name.length) == name)
		{
			rb[r].checked = state;
		}
	}
}