	function InvokeAction(Element, A)
	{
		if (Element.form)
		{
			document.forms[Element.form.name].action += A;
			document.forms[Element.form.name].submit();
		}
		else
		{
			document.forms[Element].action += A;
			document.forms[Element].submit();
		}
	}

	var Opened
	function ToggleMenu(ItemId)
	{
		if (document.getElementById('SubMenu' + ItemId))
		{
			if (Opened)
			{
				document.getElementById('SubMenu' + Opened).style.display = 'none';
			}

			var IsOpen = 'block' == document.getElementById('SubMenu' + ItemId).style.display;
			document.getElementById('SubMenu' + ItemId).style.display = IsOpen ? 'none' : 'block';
			Opened = ItemId;
		}
	}

	function EnableAll(list)
	{
		for(i = 0 ; i < list.length; i++)
		{
			list[i].disabled = false;
		}
	}
	
	function EditProfile()
	{
		location.href = 'EditProfile.asp';
	}

	function LogOff()
	{
		location.href = 'LogOff.asp';
	}

	function SetPassword()
	{
		location.href = 'SetPassword.asp';
	}

	function ViewProfile()
	{
		location.href = 'ViewProfile.asp';
	}

	function ViewDocument(LocationId, DocumentId)
	{
		location.href = 'ViewLocatie.asp?LocationId='+LocationId + '&DocumentId=' + DocumentId;
	}

	function JoinSubCompetition()
	{
		location.href = 'JoinSubCompetition.asp';
	}

	function JoinCompetition()
	{
		location.href = 'JoinCompetition.asp';
	}
	
	function JoinThisSubCompetition(SubCompetitionId)
	{
		location.href = 'JoinSubCompetition.asp?SubCompetitionId=' + SubCompetitionId;
	}

	function JoinThisCompetition(CompetitionId)
	{
		location.href = 'JoinCompetition.asp?Action=Save&CompetitionId=' + CompetitionId;
	}

	function LeaveSubCompetition(SubCompetitionId)
	{
		if(confirm('Wilt u zich afmelden bij deze subcompetitie?'))
		{
			location.href = 'LeaveSubCompetition.asp?SubCompetitionId=' + SubCompetitionId;
		}
	}

	function NewSubCompetition()
	{
		location.href = 'NewSubCompetition.asp';
	}

	function DeleteSubCompetitionParticipant(SubCompetitionId, ParticipantId)
	{
		if(confirm('Wilt u deze persoon verwijderen uit uw subcompetitie?'))
		{
			location.href = 'ViewSubCompetition.asp?SubCompetitionId=' + SubCompetitionId + '&ParticipantId=' + ParticipantId + '&Action=Delete';
		}
	}
	function RefuseSubCompetitionParticipant(SubCompetitionId, ParticipantId)
	{
		if(confirm('Wilt u deze persoon weigeren uit uw subcompetitie?'))
		{
			location.href = 'ViewSubCompetition.asp?SubCompetitionId=' + SubCompetitionId + '&ParticipantId=' + ParticipantId + '&Action=Refuse';
		}
	}
	function EditPrediction(ParticipantId, PdFId, RankingType, Ranking)
	{
		location.href = 'EditPrediction.asp?ParticipantId=' + ParticipantId + '&PdFId=' + PdFId + '&RankingType=' + RankingType + '&Ranking=' + Ranking + '&Action=Load';
	}

	function ViewPredictions()
	{
		location.href = 'MyPredictions.asp';
	}
	function EditStagePrediction(ParticipantId, StageId, Ranking)
	{
		location.href = 'EditStagePrediction.asp?ParticipantId=' + ParticipantId + '&StageId=' + StageId + '&Ranking=' + Ranking + '&Action=Load';
	}
	function EditQuestionPrediction(ParticipantId, QuestionId)
	{
		location.href = 'EditQuestionPrediction.asp?ParticipantId=' + ParticipantId + '&QuestionId=' + QuestionId + '&Action=Load';
	}

	function autoComplete (field, select, property, forcematch) {
	var found = false;
	for (var i = 0; i < select.options.length; i++) {
	if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
		found=true; break;
		}
	}
	if (found) { select.selectedIndex = i; }
	else { select.selectedIndex = -1; }
	if (field.createTextRange) {
		if (forcematch && !found) {
			field.value=field.value.substring(0,field.value.length-1);
			return;
			}
		var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
		if (cursorKeys.indexOf(event.keyCode+";") == -1) {
			var r1 = field.createTextRange();
			var oldValue = r1.text;
			var newValue = found ? select.options[i][property] : oldValue;
			if (newValue != field.value) {
				field.value = newValue;
				var rNew = field.createTextRange();
				rNew.moveStart('character', oldValue.length) ;
				rNew.select();
				}
			}
		}
	}

