$(function() {
	// Add highlight to all blocks
	$("div.block-highlight-helper").hover(function() {
		$(this).addClass("block-highlight");		
	}, function() {
		$(this).removeClass("block-highlight");
	});
});

function loadSpecialalities()
{
	var profession_id = $("#profession").val();
	var parent = $("#speciality").parent();
	parent.html("<img src=\"images/ajax.gif\" alt=\"\" /> Loading...");
	$.post(_mpc_website_ + "ajax/speciality/", {
		"profession": escape(profession_id),
		"ajax" : 1
	}, function(c) {
		parent.html(c);
		$("#speciality").focus();
		$("#speciality").change(function() {
			loadAssociationQuestion();
		});
		loadAssociationQuestion();
	});
}

function loadAssociationQuestion(check)
{
	if(!check) check = false;
	var obj = $("#speciality");
	if(obj.size() == 0)
	{
		$("td", "#association_tr").html("");
		$("#association_tr").hide();
		return;
		
	}
	var spe = obj.val();
	if(spe == "0" || spe == 0) 
	{
		$("td", "#association_tr").html("");
		$("#association_tr").hide();
		return;
	}
	
	$.post(_mpc_website_ + "ajax/speciality-association/", {
		"speciality" : spe,
		"ajax" : 1,
		"check" : check
	}, function(c) {
		if($.trim(c) != "")
		{
			$("td", "#association_tr").html(c);
			$("#association_tr").show();
			return;
		}
		else
		{
			$("td", "#association_tr").html("");
			$("#association_tr").hide();
			return;
		}
	});
}

var captchaCount = 0;

function captchaRegenerate(url)
{
	var image = $("#captchaImage");
	image.attr("src", url + "&inc=" + (captchaCount++));
}

function validEmail(email)
{
	validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
	return email.search(validRegExp) > -1
}

function showMemberInfo(member_id)
{
	var div = $("<div>");
	div.html("<img src=\"/images/ajax.gif\" /> Loading member information...");
	div.dialog({
		title : "Viewing member profile",
		modal : true,
		draggable : false,
		resizable : false,
		width : "800px",
		buttons : {
			"Close" : function() { div.dialog("close"); }
		},
		close : function() { div.remove(); }
	});
	
	$.post(_mpc_website_ + "client/member/popup-info/" + member_id + "/", {
		ajax : 1
	}, function(c) {
		div.html(c).dialog("option", "position", 'center');
	});
}
