String.prototype.startsWith = function(str){
    return (this.indexOf(str) === 0);
}
﻿
function postviewmemberform2(memberid, clubid, listingtype) {
    document.viewMember.memberid.value = memberid;
    document.viewMember.clubid.value = clubid;
    document.viewMember.listingtype.value = listingtype;
    document.viewMember.submit();
}

function postviewmemberform (memberid) {
     document.viewMember.memberid.value = memberid;
     document.viewMember.submit();
}

function posteditmemberform (memberid) {
     document.editMember.memberid.value = memberid;
     document.editMember.submit();
     //alert ("You typed: " + memberid);
}
function postdeletememberform (memberid) {
     document.deleteMember.memberid.value = memberid;
     document.deleteMember.submit();
     //alert ("You typed: " + memberid);
}
function postupdatememberform (id) {
  document.updateMember.memberid.value = id;
  if (checkThatStringContainsSomething(document.forms.updateMember.firstname.value)== false)
	 alert("Du måste skriva in ett förnamn för medlemmen.");
  else if (checkThatStringContainsSomething(document.forms.updateMember.lastname.value)== false)
	 alert("Du måste skriva in ett efternamn för medlemmen.");
  else if (checkThatStringContainsSomething(document.forms.updateMember.street.value)== false)
	 alert("Du måste skriva in en gatuadress för medlemmen.");
  else if (checkThatStringContainsSomething(document.forms.updateMember.city.value)== false)
	 alert("Du måste skriva in en postadress för medlemmen.");
  else if (checkThatStringContainsSomething(document.forms.updateMember.firstname.value)== false)
	 alert("Du måste skriva in ett födelsedatum för medlemmen.");
  else if(checkThatStringContainsDate(document.forms.updateMember.birthday.value)==false)
      alert("Födelsedatumet måste sättas och innehålla ett datum på formatet: ÅÅÅÅ-MM-DD, ex: 1975-03-23");
  else if ((typeof document.forms.updateMember.regdate != 'undefined') && checkThatStringContainsDate(document.forms.updateMember.regdate.value)==false)
      alert("Betalningsdatum måste sättas och innehålla ett datum på formatet: ÅÅÅÅ-MM-DD, ex: 2007-09-23");
  else if ((typeof document.forms.updateMember.regdate != 'undefined') && ((checkThatStringContainsSomething(document.forms.updateMember.fee.value) == false) || (checkThatStringIsOnlyInts(document.forms.updateMember.fee.value)==false)))
      alert("Summa måste sätta till det belopp som betalts i medlemsavgift, dvs ett heltal.");
  else if (checkZipcode(removeSpace(document.forms.updateMember.zipcode))==false)
      alert("Postnummer fältet får endast innehålla siffror, ex: 58334");
  else if (document.forms.updateMember.birthday.value == "1970-01-01")
	alertbadbirthday();
  else
      document.updateMember.submit();
}

function postupdatepersonform (id) {
  document.updateMember.memberid.value = id;
  if (checkThatStringContainsSomething(document.forms.updateMember.firstname.value)== false)
	 alert("Du måste skriva in ett förnamn för medlemmen.");
  else if (checkThatStringContainsSomething(document.forms.updateMember.lastname.value)== false)
	 alert("Du måste skriva in ett efternamn för medlemmen.");
  else if (checkThatStringContainsSomething(document.forms.updateMember.firstname.value)== false)
	 alert("Du måste skriva in ett födelsedatum för medlemmen.");
  else if(checkThatStringContainsDate(document.forms.updateMember.birthday.value)==false)
      alert("Födelsedatumet måste sättas och innehålla ett datum på formatet: ÅÅÅÅ-MM-DD, ex: 1975-03-23");
  else
      document.updateMember.submit();
}


function postviewdistrictform (districtid) {
     document.viewDistrict.districtid.value = districtid;
     document.viewDistrict.submit();
}

function postviewdistrictform (districtid, listingid) {
     document.viewDistrict.districtid.value = districtid;
      document.viewDistrict.listingtype.value = listingid;
     document.viewDistrict.submit();
}


function posteditdistrictform (districtid) {
     document.editDistrict.districtid.value = districtid;
     document.editDistrict.submit();
}
function postdeletedistrictform (districtid) {
     document.deleteDistrict.districtid.value = districtid;
     document.deleteDistrict.submit();
}
function postupdatedistrictform (districtid) {
     document.updateDistrict.districtid.value = districtid;
     if(checkThatStringContainsDate(document.forms.updateDistrict.startseason.value)==false)
	 alert("Verksamhetsår startdatum måste sättas och innehålla ett datum på formatet: ÅÅÅÅ-MM-DD, ex: 2008-01-01");     
     else if(checkThatStringContainsDate(document.forms.updateDistrict.endseason.value)==false)
	 alert("Verksamhetsår slutdatum måste sättas och innehålla ett datum på formatet: ÅÅÅÅ-MM-DD, ex: 2008-12-31");
     else if((checkThatStringContainsSomething(document.forms.updateDistrict.started.value)== true) && (checkThatStringContainsDate(document.forms.updateDistrict.started.value)==false))
    	alert("Startdatum för distriktet skall innehålla ett datum på formatet: ÅÅÅÅ-MM-DD, ex: 1918-09-01");
     else if (checkThatStringContainsSomething(document.forms.updateDistrict.name.value)== false)
	 alert("Du måste skriva in ett namn på distriktsförbundet.");
     else
	 document.updateDistrict.submit();
}


function postviewclubform (clubid) {
     document.viewClub.clubid.value = clubid;
     document.viewClub.submit();
}
function postviewclubform (clubid, listingid) {
     document.viewClub.clubid.value = clubid;
     document.viewClub.listingtype.value = listingid;
     document.viewClub.submit();
}
function posteditclubform (clubid) {
     document.editClub.clubid.value = clubid;
     document.editClub.submit();
}
function postdeleteclubform (clubid) {
     document.deleteClub.clubid.value = clubid;
     document.deleteClub.submit();
}
function postupdateclubform (clubid) {
    document.updateClub.clubid.value = clubid;
    if(checkThatStringContainsDate(document.forms.updateClub.startseason.value)==false)
	alert("Verksamhetsår startdatum måste sättas och innehålla ett datum på formatet: ÅÅÅÅ-MM-DD, ex: 2008-01-01");     

    else if(checkThatStringContainsDate(document.forms.updateClub.endseason.value)==false)
	alert("Verksamhetsår slutdatum måste sättas och innehålla ett datum på formatet: ÅÅÅÅ-MM-DD, ex: 2008-12-31");

    else if((checkThatStringContainsSomething(document.forms.updateClub.started.value)== true) && (checkThatStringContainsDate(document.forms.updateClub.started.value)==false))
    	alert("Startdatum för klubben skall innehålla ett datum på formatet: ÅÅÅÅ-MM-DD, ex: 1918-09-01");

    else if (checkZipcode(removeSpace(document.forms.updateClub.zipcode))==false)
	alert("Postnummer fältet får endast innehålla siffror, ex: 58334");

    else if (checkThatStringContainsSomething(document.forms.updateClub.name.value)== false)
	alert("Du måste skriva in ett namn på klubben.");
    
    else 
	document.updateClub.submit();
}



function postviewfederationform (federationid) {
     document.viewFederation.federationid.value = federationid;
     document.viewFederation.submit();
}

function postviewfederationform (federationid, listingid) {
     document.viewFederation.federationid.value = federationid;
     document.viewFederation.listingtype.value = listingid;
     document.viewFederation.submit();
}

function posteditfederationform (federationid) {
     document.editFederation.federationid.value = federationid;
     document.editFederation.submit();
}

function postdeletefederationform (federationid) {
     document.deleteFederation.federationid.value = federationid;
     document.deleteFederation.submit();
}

function postupdatefederationform (federationid) {
    document.updateFederation.federationid.value = federationid;
    if(checkThatStringContainsDate(document.forms.updateFederation.startseason.value)==false)
	alert("Verksamhetsår startdatum måste sättas och innehålla ett datum på formatet: ÅÅÅÅ-MM-DD, ex: 2008-01-01");     
    else if(checkThatStringContainsDate(document.forms.updateFederation.endseason.value)==false)
	alert("Verksamhetsår slutdatum måste sättas och innehålla ett datum på formatet: ÅÅÅÅ-MM-DD, ex: 2008-12-31");
    else if (checkZipcode(removeSpace(document.forms.updateFederation.zipcode))==false)
	alert("Postnummer fältet får endast innehålla siffror, ex: 58334");
    else if (checkThatStringContainsSomething(document.forms.updateFederation.name.value)== false)
	alert("Du måste skriva in ett namn på riksförbundet.");
    
    else 
	document.updateFederation.submit();
}

function postaddfederationform (federationid) {
     document.addFederation.submit();
}

function postadddistrictform (federationid) {
     document.addDistrict.submit();
}

function postaddclubform (districtid) {
     document.addClub.submit();
}

function postaddmemberform (clubid) {
     document.addMember.clubid.value = clubid;
     document.addMember.submit();
}

function postaddpersonform (clubid) {
     document.addPerson.clubid.value = clubid;
     document.addPerson.submit();
}

function postfindmemberform(memberid) {
  document.findMember.submit();
}


function clubsortorder(order) {
  document.viewClub.sortorder.value = order;
  document.viewClub.submit();
}


function posteditfsform(ordermemberid) {
  document.editTfs.submit();
}



function postimportmemberform(order) {
  document.importMember.submit();
}

function postexportform(order) {
  document.exportMember.submit();
}

function posteditregform(memberid, clubid, date, regstartdate, regenddate) {
    document.updateReg.regmemberid.value = memberid;
    document.updateReg.regclubid.value = clubid;
    document.updateReg.regdate.value = date;
    document.updateReg.regyearstart.value = regstartdate;
    document.updateReg.regyearend.value = regenddate;
    document.updateReg.submit();
}


function postupdatememberroleform3(functionid) {
    document.updateMemberRole3.functionid.value = functionid;
    document.updateMemberRole3.submit();
}

function postupdatememberroleform2(functid, orgtype, level, orgid, startdat) {
    document.updateMemberRole.functionid.value = functid;
    document.updateMemberRole.typeoforg.value = orgtype;
    document.updateMemberRole.level.value = level;
    document.updateMemberRole.orgid.value = orgid;
    document.updateMemberRole.startdate.value = startdat;
    document.updateMemberRole.submit();
}

function postupdatememberroleform(functionidd) {
    document.updateMemberRole.functionid.value = functionidd;
    document.updateMemberRole.submit();
}



function postupdateregform(memberid) {
    document.updateReg.regmemberid.value = memberid;
    if (checkThatStringContainsDate(document.forms.updateReg.regdate.value)==false)
	alert("Betalningsdatum måste sättas och innehålla ett datum på formatet: ÅÅÅÅ-MM-DD, ex: 2007-09-23");
    else if ((typeof document.forms.updateReg.regdate != 'undefined') && ((checkThatStringContainsSomething(document.forms.updateReg.fee.value) == false) || (checkThatStringIsOnlyInts(document.forms.updateReg.fee.value)==false)))
	alert("Summa måste sätta till det belopp som betalts i medlemsavgift, dvs ett heltal.");
    else 
	document.updateReg.submit();
}

function posteditrolesform(memberid) {
    document.editMemberRole.memberid.value = memberid;
    document.editMemberRole.submit();
}


function postsearchclubform(zip) {
    document.showNearestClub.submit();
}

function postnewpasswordform(memberid, clubid) {
    document.PasswordMember.memberid.value = memberid;
    document.PasswordMember.clubid.value = clubid;
    input_box=confirm("Vill du skicka ut ett nytt lösenord per epost till för denna medlem?");
    if (input_box==true) { 
      document.PasswordMember.submit();
    }  
}

function alertbadbirthday() {
    input_box=confirm("Är du säker på att födelsedatumet är 1970-01-01? ");
    if (input_box==true) { 
      document.updateMember.submit();
    }  
}

function posttransfermemberform(memberid, clubid) {
    document.transferMember.memberid.value = memberid;
    document.transferMember.clubid.value = clubid;
    document.transferMember.submit();
}

function postupdatemembertransferform(memberid, oldclubid, newclubid, sentindate, answer) {
    document.updateMemberTransfer.memberid.value = memberid;
    document.updateMemberTransfer.oldclub.value = oldclubid;
    document.updateMemberTransfer.newclub.value = newclubid;
    document.updateMemberTransfer.reqdate.value = sentindate;
    document.updateMemberTransfer.answer.value = answer;
    document.updateMemberTransfer.submit();
}

function postupdatememberseriestransferform(memberid, oldclubid, newclubid, sentindate, answer) {
    document.updateMemberSeriesTransfer.memberid.value = memberid;
    document.updateMemberSeriesTransfer.oldclub.value = oldclubid;
    document.updateMemberSeriesTransfer.newclub.value = newclubid;
    document.updateMemberSeriesTransfer.reqdate.value = sentindate;
    document.updateMemberSeriesTransfer.answer.value = answer;
    document.updateMemberSeriesTransfer.submit();
}

function postviewmembertransferform() {
    document.viewMemberTransferList.submit();
}


function postviewseriestransferform() {
    document.viewMemberSeriesTransferList.submit();
}

function poststartratememberform() {
    document.StartRateMember.submit();
}


function postviewclublaskratingform(clubid, ratingdate) {
    document.ViewClubLASKRating.clubid.value = clubid;
    document.ViewClubLASKRating.ratingdate.value = ratingdate;
    document.ViewClubLASKRating.submit();
}

function postviewclublaskratingform(clubid) {
    document.ViewClubLASKRating.clubid.value = clubid;
    document.ViewClubLASKRating.submit();
}

function postviewdistrictratingform(districtid) {
    document.ViewDistrictLASKRating.districtid.value = districtid;
    document.ViewDistrictLASKRating.submit();
}

function posteditclubratingform(clubid) {
    document.EditClubLASKRating.clubid.value = clubid;
    document.EditClubLASKRating.ratingdate.value = document.ViewClubLASKRating.ratingdate.value;
    document.EditClubLASKRating.submit();
}

function postupdateclubratingform(clubid) {
    document.UpdateClubLASKRating.clubid.value = clubid;
    document.UpdateClubLASKRating.submit();
}
function postshowfederationratingform(federationid) {
    document.ShowFederationRating.federationid.value = federationid;
    document.ShowFederationRating.submit();
}
function postshowfederationratingform(startI, endI) {
    document.ShowFederationRating.startIndex.value = startI;
    document.ShowFederationRating.endIndex.value = endI;
    document.ShowFederationRating.submit();
}
function postviewfederationratingform(federationid) {
    document.ViewFederationRating.federationid.value = federationid;
    document.ViewFederationRating.submit();
}
function postviewfederationratingform(startI, endI) {
    document.ViewFederationRating.startIndex.value = startI;
    document.ViewFederationRating.endIndex.value = endI;
    document.ViewFederationRating.submit();
}
function postshowclubratingform(clubid) {
    document.ShowClubRating.clubid.value = clubid;
    document.ShowClubRating.submit();
}
function postshowdistrictratingform(districtid) {
    document.ShowDistrictRating.districtid.value = districtid;
    document.ShowDistrictRating.submit();
}
function postviewclubregform(clubid) {
    document.ViewClubRegistration.clubid.value = clubid;
    document.ViewClubRegistration.submit();
}

function postshowclubregform(clubid) {
    document.ShowClubRegistration.clubid.value = clubid;
    document.ShowClubRegistration.submit();
}

function posteditclubregistrationform(clubid) {
    document.EditClubRegistration.clubid.value = clubid;
    document.EditClubRegistration.submit();
}
function postupdateclubregistrationform(clubid) {
    document.UpdateClubRegistration.clubid.value = clubid;
    document.UpdateClubRegistration.submit();
}

function postviewmailinglistform() {
    document.viewMailingList.submit();
}

function posteditmemberpaymentform2(memberid, clubid, paymentid) {
    document.editMemberPayment.memberid.value = memberid;
    document.editMemberPayment.clubid.value = clubid;
    document.editMemberPayment.paymentid.value = paymentid;
    document.editMemberPayment.submit();
}

function postdeletememberpaymentform(paymentid) {
    document.deleteMemberPayment.paymentid.value = paymentid;
    document.deleteMemberPayment.submit();
}

function posteditmemberpaymentform(paymentid) {
    document.editMemberPayment.paymentid.value = paymentid;
    document.editMemberPayment.submit();
}


function postupdatememberpaymentform(paymentid) {
    document.updateMemberPayment.paymentid.value = paymentid;
    document.updateMemberPayment.submit();
}

function postexportclubform(clubid) {
    document.exportClub.clubid.value = clubid;
    document.exportClub.submit();
}

function postexportdistrictform(districtid) {
    document.exportDistrict.districtid.value = districtid;
    document.exportDistrict.submit();
}

function postaddexistingmemberform(clubid) {
    document.addExistingMember.clubid.value = clubid;
    document.addExistingMember.submit();
}

function postmergememberform() {
   document.mergeMember.submit();
}


function posteditmemdatesform(year, clubid) {
    document.editMemDates.regyear.value = year;
    document.editMemDates.clubid.value = clubid;
    document.editMemDates.submit();
}


function postupdatememdatesform(clubid) {
    document.updateMemDates.clubid.value = clubid;
    document.updateMemDates.submit();
}


function postexportratingform(clubid, rankingdate) {
    document.ExportLASKRating.ratingdate.value = rankingdate;
    document.ExportLASKRating.clubid.value = clubid;
    if (document.ExportLASKRating.orgtype.value == "federation") {
	document.ExportLASKRating.membergenre.value = document.ViewFederationRating.membergenre.value;
	document.ExportLASKRating.ratingdate.value = document.ViewFederationRating.ratingdate.value;
    }
    document.ExportLASKRating.submit();
}

function postexportratingform2(clubid) {
    document.ExportLASKRating.ratingdate.value = document.ViewClubLASKRating.ratingdate.value;
    document.ExportLASKRating.clubid.value = clubid;
    document.ExportLASKRating.submit();
}


function postimportratingform(clubid, rankingdate) {
    document.ImportLASKRating.ratingdate.value = rankingdate;
    document.ImportLASKRating.clubid.value = clubid;
    document.ImportLASKRating.submit();
}

function postimportratingform2(clubid) {
    document.ImportLASKRating.ratingdate.value = document.ViewClubLASKRating.ratingdate.value;
    document.ImportLASKRating.clubid.value = clubid;
    document.ImportLASKRating.submit();
}

function posteditclubyearregform(clubid) {
    document.editClubYearRegs.clubid.value = clubid;
    document.editClubYearRegs.submit();
}

function posteditclubyearregformvb(editfunction, clubid, relregyear) {
    document.editClubYearRegs.editfunction.value = editfunction;
    document.editClubYearRegs.clubid.value = clubid;
    document.editClubYearRegs.regyear.value = relregyear;
    document.editClubYearRegs.vb.value = document.getElementById("vb"+relregyear).value;
    document.editClubYearRegs.submit();
}

function posteditclubyearregformclub(editfunction, clubid, relregyear) {
    document.editClubYearRegs.editfunction.value = editfunction;
    document.editClubYearRegs.clubid.value = clubid;
    document.editClubYearRegs.regyear.value = relregyear;
    document.editClubYearRegs.submit();
}

function posteditclubyearregformfed(editfunction, clubid, relregyear) {
    document.editClubYearRegs.editfunction.value = editfunction;
    document.editClubYearRegs.clubid.value = clubid;
    document.editClubYearRegs.regyear.value = relregyear;
    document.editClubYearRegs.submit();
}

function postpaperform(editfunction) {
    document.editPaper.editfunction.value = editfunction;
    document.editPaper.submit();
}


function postpaperform2(editfunction, deldate) {
    document.editPaper.editfunction.value = editfunction;
    document.editPaper.deliverydate.value = deldate;
    document.editPaper.submit();
}


function postdeleteregform(memberid, clubid, date, regstartdate, regenddate) {
    document.DeleteMembership.memberid.value = memberid;
    document.DeleteMembership.clubid.value = clubid;
    document.DeleteMembership.regdate.value = date;
    document.DeleteMembership.regyearstart.value = regstartdate;
    document.DeleteMembership.regyearend.value = regenddate;
    document.DeleteMembership.submit();
}

function postviewfedstatisticsform(viewfunction) {
    document.viewFedStatistics.listingtype.value = viewfunction;
    document.viewFedStatistics.submit();
}

function postshowplayerratingform(memberid) {
    document.ShowMemberRating.memberid.value = memberid;
    document.ShowMemberRating.submit();
}

function postedittournamentform (tournamentid) {
    document.editTournament.tournamentid.value = tournamentid; 	
    document.editTournament.submit();
}

function postdeletetournamentform (tournamentid) {
    document.deleteTournament.tournamentid.value = tournamentid; 
    input_box=confirm("Är du säker på att du vill ta bort turneringen? Tar du bort den försvinner alla klasser/grupp och resultat i turneringen!");
    if (input_box==true) {
    	document.deleteTournament.submit();	
    }
}

function postupdatetournamentform(tournamentid) {
    document.updateTournament.tournamentid.value = tournamentid;
    document.updateTournament.submit();
} 

function postviewtournament(tournamentid) {
    document.viewTournament.tournamentid.value = tournamentid;
    document.viewTournament.submit();
} 

function postviewtournamentclass(tournamentclassid) {
    document.viewTournamentClass.tournamentclassid.value = tournamentclassid;
    document.viewTournamentClass.submit();
} 


function postedittournamentclassform (tournamentid, tournamentclassid) {
    document.editTournamentClass.tournamentid.value = tournamentid; 	
    document.editTournamentClass.tournamentclassid.value = tournamentclassid; 	
    document.editTournamentClass.submit();
}

function postupdatetournamentclassform(tournamentclassid) {
    document.updateTournamentClass.tournamentclassid.value = tournamentclassid;
    document.updateTournamentClass.submit();
} 

function postviewtournamentclassgroup(tournamentclassgroupid) {
    document.viewTournamentClassGroup.id.value = tournamentclassgroupid;
    document.viewTournamentClassGroup.submit();
} 


function postedittournamentclassgroupform (tournamentclassid, tournamentclassgroupid) {
    document.editTournamentClassGroup.tournamentclassid.value = tournamentclassid; 	
    document.editTournamentClassGroup.id.value = tournamentclassgroupid; 	
    document.editTournamentClassGroup.submit();
}

function postupdatetournamentclassgroupform(tournamentclassgroupid) {
    document.updateTournamentClassGroup.id.value = tournamentclassgroupid;
    document.updateTournamentClassGroup.submit();
} 

function postdeletetournamentclassgroupform(tournamentclassgroupid) {
    document.deleteTournamentClassGroup.id.value = tournamentclassgroupid;
    input_box=confirm("Är du säker på att du vill ta bort gruppen? Tar du bort den försvinner alla resultat i gruppen!");
    if (input_box==true) { 
    	document.deleteTournamentClassGroup.submit();
    }
} 

function postviewtournamentpartform(tournamentclassgroupid, partid) {
    document.viewTournamentPart.tournamentpartid.value = partid;
    document.viewTournamentPart.submit();
} 

function postdeletetournamentpartform() {
    input_box=confirm("Är du säker på att du vill ta bort deltagaren? Tar du bort den försvinner alla resultat i deltagaren gjort!");
    if (input_box==true) {
       document.deleteTournamentPart.submit();
    }
} 



function postedittournamentpartform (tournamentclassgroupid, partid, teamnumber) {
    document.editTournamentPart.tournamentclassgroupid.value = tournamentclassgroupid; 	
    document.editTournamentPart.tournamentpartid.value = partid;
    document.editTournamentPart.teamnumber.value = teamnumber;
    document.editTournamentPart.submit();
}

function postshowtournamentteamresultform (partid, teamnumber) {
    document.showTournamentTeamResult.partid.value = partid;
    document.showTournamentTeamResult.teamnumber.value = teamnumber;
    document.showTournamentTeamResult.submit();
}

function postshowindtournamentresultform (groupid, partid) {
    document.showIndTournamentResult.partid.value = partid;
    document.showIndTournamentResult.id.value = groupid;
    document.showIndTournamentResult.submit();
}

function postupdatetournamentpartform(addmore) {
    document.updateTournamentPart.updatemore.value = addmore; 	
    document.updateTournamentPart.submit();
} 

function postedittournamentpairingform(gameid) {
    document.editTournamentClassGroupPairing.id.value = gameid;
    document.editTournamentClassGroupPairing.submit();
} 

function postupdatepairingsform(repair) {
    document.updateTournamentPairing.repair.value = repair;
    document.updateTournamentPairing.submit();
} 

function postedittournamentroundresultform(id) {
    document.editTournamentRoundResult.id.value = id;
    document.editTournamentRoundResult.submit();
} 

function postupdatetournamentroundresultform() {
    document.updateTournamentRoundResult.submit();
} 

function postshowtournamentroundresultform(id) {
    document.ShowTournamentRoundResult.id.value = id;
    document.ShowTournamentRoundResult.submit();
}

function postedittournamentadminform(tournamentid, memberid, level) {
    document.editTournamentAdmin.tournamentid.value = tournamentid;
    document.editTournamentAdmin.memberid.value = memberid;
    document.editTournamentAdmin.type.value = level;
    document.editTournamentAdmin.submit();
}

function postexporttournamentcontendersnform(functionnumber) {
    document.exportTournament.functionnumber.value = functionnumber;
    document.exportTournament.submit();
}


function postaddtournamentadminform() {
    document.editTournamentAdmin.memberid.value = document.addTournamentAdmin.id.value;
    document.editTournamentAdmin.type.value = 1;
    document.editTournamentAdmin.submit();
}

function postdeletetournamentclassform(tournamentclassid) {
    document.deleteTournamentClass.id.value = tournamentclassid;
    input_box=confirm("Är du säker på att du vill ta bort klassen? Tar du bort den försvinner alla grupper med alla resultat!");
    if (input_box==true) {
    	document.deleteTournamentClass.submit();
    }
} 

function postviewmemberclassform(id) {
    document.viewMemberClass.memberid.value = id;
    document.viewMemberClass.submit();
}

function posteditmemberclassform(memberid, groupid) {
    document.editMemberClass.memberid.value = memberid;
    document.editMemberClass.groupid.value = groupid;
    document.editMemberClass.submit();
}

function postupdatememberclassform(memberid) {
    document.updateMemberClass.memberid.value = memberid;
    document.updateMemberClass.submit();
}

function postdeletememberclassform(memberid, groupid) {
    document.deleteMemberClass.memberid.value = memberid;
    document.deleteMemberClass.groupid.value = groupid;
    input_box=confirm("Är du säker på att du vill ta bort klasstillhörigheten?");
    if (input_box==true) {
    	document.deleteMemberClass.submit();
    }
}

function postsmregistrationformform() {
    document.smRegistrationForm.partid.value = document.smRegistrationForm.inputmemberid.value;
    document.smRegistrationForm.submit();
}

function postsmregistrationformform() {
    document.smRegistrationForm.partid.value = document.smRegistrationForm.inputmemberid.value;
    document.smRegistrationForm.submit();
}

function postfindplayerform(id) {
   document.findPlayer.submit();
}

function postsmregistrationformform2(id) {
    document.smRegistrationForm.partid.value = id;
    document.smRegistrationForm.submit();
}

function postsmregistrationformform3() {
	document.smRegistrationForm.groupid.value = document.smRegistrationForm.inputgroupid.value;
    document.smRegistrationForm.submit();
}

function postschack4anaddclass() {
	document.schack4anclassregistration.submit();
}

function postlistschack4anplayerform(func) {
	document.schack4anclassregistration.functionid.value = func;
	document.schack4anclassregistration.submit();
}

function postaddschack4anplayerform(func) {
	document.schack4anclassregistration.functionid.value = func;
	document.schack4anclassregistration.submit();
}

function posteditschack4anplayerform(func) {
	document.schack4anclassregistration.functionid.value = "3";
	document.schack4anclassregistration.id.value = func;
	document.schack4anclassregistration.submit();
}

function posteditedschack4anplayerform(func) {
	document.schack4anclassregistration.functionid.value = "3";
	document.schack4anclassregistration.id.value = func;
	document.schack4anclassregistration.submit();
}

function postviewdistrictschack4anform(districtid) {
    document.ViewDistrictSchack4an.districtid.value = districtid;
    document.ViewDistrictSchack4an.submit();
}

function postimporttournamentresultform(tid) {
    document.importTournamentResult.tournamentid.value = tid;
    document.importTournamentResult.submit();
}

function postviewschack4anclassform(classid) {
    document.ViewSchack4anClassForm.id.value = classid;
    document.ViewSchack4anClassForm.submit();
}

function posteditdistrictschack4anplayerform(playerid) {
    document.EditDistrictSchack4anPlayerForm.id.value = playerid;
    document.EditDistrictSchack4anPlayerForm.submit();
}

function postexportschack4anform() {
    document.ExportSchack4anForm.submit();
}

function postuploadtournamentpgnform(tid) {
    document.uploadPGN.tournamentid.value = tid;
    document.uploadPGN.submit();
}





function updateSelectedPlayers(selectname, selectindex,selectedplayer, nrofboards) {
    var i = 0;
    var selindex = selectindex;
    while ((selindex<nrofboards) && document.getElementById(selectname+selindex) != null) {
	if (selectname=="whitememberid" && (selectindex % 2 == 1) && (selindex % 2 == 1))
		document.getElementById("blackmemberid"+selindex).selectedIndex = selectedplayer+i+1;
	else if(selectname=="blackmemberid" && (selectindex % 2 == 1) && (selindex % 2 == 1))
		document.getElementById("whitememberid"+selindex).selectedIndex = selectedplayer+i+1;
	else if (selectname=="whitememberid" && (selectindex % 2 == 0) && (selindex % 2 == 0))
		document.getElementById("blackmemberid"+selindex).selectedIndex = selectedplayer+i+1;
	else if(selectname=="blackmemberid" && (selectindex % 2 == 0) && (selindex % 2 == 0))
		document.getElementById("whitememberid"+selindex).selectedIndex = selectedplayer+i+1;
	else 
		document.getElementById(selectname+selindex).selectedIndex = selectedplayer+i+1;
	i++;
	selindex = selectindex+i;
    }
}

function editclubratingformnameclean2(blaha) {
	for(var i=0; i<document.UpdateClubLASKRating.elements.length; i++) {
		if (document.UpdateClubLASKRating.elements[i].name.startsWith('rating')) {
			document.UpdateClubLASKRating.elements[i].value = '';
		}
	}
}

function updateTeamScore(nrofboards) {
    var i = 0;
    var whitescore = 0;
    var blackscore = 0; 
    var editedResults = 0;
    var result = 0;
    while (i<nrofboards) {
	result = document.getElementById("result"+i).value;
	if (result == 1 || result == 2 ) {
		whitescore += 2;
		editedResults++;
	}
	else if (result == -1 || result == -2 ) {
		blackscore += 2;
		editedResults++;
	}
	else if (result == 0) {
		whitescore += 1;
		blackscore += 1;
		editedResults++;
	}
	else if (result == 100) {
		whitescore += 2;
		blackscore += 2;
		editedResults++;
	}
	i++;
    }
    document.getElementById("homeresult").selectedIndex = whitescore;
    document.getElementById("awayresult").selectedIndex = blackscore;
    if (editedResults == nrofboards)
	    document.getElementById("finalized").selectedIndex = 1;
    else
	    document.getElementById("finalized").selectedIndex = 0;
}

function postexportfidetournamentform(classgroupid) {
    document.exportFIDETournamentClassGroup.id.value = classgroupid;
    document.exportFIDETournamentClassGroup.submit();
} 

// Checking form fields code.

function checkDate(field) {
    if (checkThatStringContainsSomething(field.value) == false)
	return true;
    if (checkThatStringContainsDate(field.value) == false)
	 alert("Betalningsdatum måste sättas på formatet: ÅÅÅÅ-MM-DD, ex: 2007-09-23. Lämna annars tomt.");
    return true;
}

function checkThatStringContainsSomething(valueString)  {
    if (valueString =="")
	return false;
    return true;
}

function checkThatStringIsOnlyInts(valueString)  {
    var numberForString = new Number(valueString);
    if (isNaN(numberForString))
	return false;
    return true;
}

function checkZipcode(valueString)  {
    var numberForString = new Number(valueString);
    if (isNaN(numberForString))
	return false;
    else 
      return checkThatStringContainsSomething(valueString);
}

function checkThatStringContainsDate(valueString)  {
    var splits =  valueString.split("-");
    
    if (splits.length == 3 &&
	checkThatStringIsOnlyInts(splits[0]) && 
	checkThatStringIsOnlyInts(splits[1]) &&
	checkThatStringIsOnlyInts(splits[2]) &&
	splits[0].length == 4 &&
	(splits[1].length == 1 ||splits[1].length == 2) &&
	(splits[2].length == 1 ||splits[2].length == 2))
	return true;
    return false;
}

function removeSpace(inForm) {
    while(inForm.value.indexOf(" ") != -1)
	inForm.value = inForm.value.replace(" ", '');
    return inForm.value;
}

