
function hideDiv() {
document.getElementById("mydiv").style.visibility = "hidden";
if(sprytextfield16 && sprytextfield16.destroy){
	sprytextfield16.resetClasses();
	sprytextfield16.destroy();
	sprytextfield16 = null;
}
}

function showDiv() {
document.getElementById("mydiv").style.visibility = "visible";
sprytextfield16 = new Spry.Widget.ValidationTextField("sprytextfield16");

}

// build validations and delete / destroy them
function val_LF(e){
	// get the value
	value = e.value;

	// see what radion button we have
	if(value == "Local"){
		
		document.getElementById("EnterDLPP_0").checked=false;
		document.getElementById("EnterDLPP_1").checked=false;
		
		document.getElementById("PassportNumber").value="";
		document.getElementById("Nationality").value="";
		document.getElementById("PlaceOfIssuance").value="";
		document.getElementById("IssueDate").value="";
		document.getElementById("ExpirationDate").value="";
		
		document.getElementById("EnterDLPP").style.display = "inline";
		document.getElementById("ParticipantForeign").style.display = "none";
		// if there isn't a validaton build one
		if(!ValidRadio3){
			ValidRadio3 = new Spry.Widget.ValidationRadio("ValidRadio3", {validateOn:["change"]});
		}

	} else if(value == 'Foreign'){

		document.getElementById("DriversLicense").value="";
		document.getElementById("DriversLicenseState").value="";
		document.getElementById("DLExpiryDate").value="";
		
		document.getElementById("ParticipantForeign").style.display = "inline";
		document.getElementById("ParticipantLocal").style.display = "none";

		if(!sprytextfield11){
			sprytextfield11 = new Spry.Widget.ValidationTextField("sprytextfield11");
		}
		if(!sprytextfield12){
			sprytextfield12 = new Spry.Widget.ValidationTextField("sprytextfield12");
		}
		if(!sprytextfield13){
			sprytextfield13 = new Spry.Widget.ValidationTextField("sprytextfield13");
		}
		if(!sprytextfield14){
			sprytextfield14 = new Spry.Widget.ValidationTextField("sprytextfield14", "date", {isRequired:true, useCharacterMasking:true});
		}
		if(!sprytextfield15){
			sprytextfield15 = new Spry.Widget.ValidationTextField("sprytextfield15", "date", {isRequired:true, useCharacterMasking:true});
		}

		if(sprytextfield8 && sprytextfield8.destroy){
			sprytextfield8.resetClasses();
			sprytextfield8.destroy();
			sprytextfield8 = null;
		}
		if(sprytextfield9 && sprytextfield9.destroy){
			sprytextfield9.resetClasses();
			sprytextfield9.destroy();
			sprytextfield9 = null;
		}
		if(sprytextfield10 && sprytextfield10.destroy){
			sprytextfield10.resetClasses();
			sprytextfield10.destroy();
			sprytextfield10 = null;
		}
	}
	
	// proceed with the rest as normal
	return true;
};

// build validations and delete / destroy them
function val_DP(e){
	// get the value
	value = e.value;
	
	// see what radion button we have
	if(value == "EnterDL"){
		
		document.getElementById("PassportNumber").value="";
		document.getElementById("Nationality").value="";
		document.getElementById("PlaceOfIssuance").value="";
		document.getElementById("IssueDate").value="";
		document.getElementById("ExpirationDate").value="";

		document.getElementById("ParticipantLocal").style.display = "inline";
		document.getElementById("ParticipantForeign").style.display = "none";
		// if there isn't a validaton build one
		if(!sprytextfield8){
			sprytextfield8 = new Spry.Widget.ValidationTextField("sprytextfield8");
		}
		if(!sprytextfield9){
			sprytextfield9 = new Spry.Widget.ValidationTextField("sprytextfield9");
		}
		if(!sprytextfield10){
			sprytextfield10 = new Spry.Widget.ValidationTextField("sprytextfield10", "date", {isRequired:true, useCharacterMasking:true});
		}

		// if there is a validation in sprytextfield destroy it, and clear the variable
		if(sprytextfield11 && sprytextfield11.destroy){
			sprytextfield11.resetClasses();
			sprytextfield11.destroy();
			sprytextfield11 = null;
		}
		// same as the rest
		if(sprytextfield12 && sprytextfield12.destroy){
			sprytextfield12.resetClasses();
			sprytextfield12.destroy();
			sprytextfield12 = null;
		}
		if(sprytextfield13 && sprytextfield13.destroy){
			sprytextfield13.resetClasses();
			sprytextfield13.destroy();
			sprytextfield13 = null;
		}
		if(sprytextfield14 && sprytextfield14.destroy){
			sprytextfield14.resetClasses();
			sprytextfield14.destroy();
			sprytextfield14 = null;
		}
		if(sprytextfield15 && sprytextfield15.destroy){
			sprytextfield15.resetClasses();
			sprytextfield15.destroy();
			sprytextfield15 = null;
		}

	} else if(value == 'EnterPP'){
		
		document.getElementById("DriversLicense").value="";
		document.getElementById("DriversLicenseState").value="";
		document.getElementById("DLExpiryDate").value="";

		document.getElementById("ParticipantForeign").style.display = "inline";
		document.getElementById("ParticipantLocal").style.display = "none";

		if(!sprytextfield11){
			sprytextfield11 = new Spry.Widget.ValidationTextField("sprytextfield11");
		}
		if(!sprytextfield12){
			sprytextfield12 = new Spry.Widget.ValidationTextField("sprytextfield12");
		}
		if(!sprytextfield13){
			sprytextfield13 = new Spry.Widget.ValidationTextField("sprytextfield13");
		}
		if(!sprytextfield14){
			sprytextfield14 = new Spry.Widget.ValidationTextField("sprytextfield14", "date", {isRequired:true, useCharacterMasking:true});
		}
		if(!sprytextfield15){
			sprytextfield15 = new Spry.Widget.ValidationTextField("sprytextfield15", "date", {isRequired:true, useCharacterMasking:true});
		}

		if(sprytextfield8 && sprytextfield8.destroy){
			sprytextfield8.resetClasses();
			sprytextfield8.destroy();
			sprytextfield8 = null;
		}
		if(sprytextfield9 && sprytextfield9.destroy){
			sprytextfield9.resetClasses();
			sprytextfield9.destroy();
			sprytextfield9 = null;
		}
		if(sprytextfield10 && sprytextfield10.destroy){
			sprytextfield10.resetClasses();
			sprytextfield10.destroy();
			sprytextfield10 = null;
		}
	}
	
	// proceed with the rest as normal
	return true;
};

// build validations and delete / destroy them
function val(e){
	// get the value
	value = e.value;
	
	// see what radion button we have
	if(value == "Local"){
		
		document.getElementById("PassportNumber").value="";
		document.getElementById("Nationality").value="";
		document.getElementById("PlaceOfIssuance").value="";
		document.getElementById("IssueDate").value="";
		document.getElementById("ExpirationDate").value="";

		document.getElementById("ParticipantLocal").style.display = "inline";
		document.getElementById("ParticipantForeign").style.display = "none";
		// if there isn't a validaton build one
		if(!sprytextfield8){
			sprytextfield8 = new Spry.Widget.ValidationTextField("sprytextfield8");
		}
		if(!sprytextfield9){
			sprytextfield9 = new Spry.Widget.ValidationTextField("sprytextfield9");
		}
		if(!sprytextfield10){
			sprytextfield10 = new Spry.Widget.ValidationTextField("sprytextfield10", "date", {isRequired:true, useCharacterMasking:true});
		}

		// if there is a validation in sprytextfield destroy it, and clear the variable
		if(sprytextfield11 && sprytextfield11.destroy){
			sprytextfield11.resetClasses();
			sprytextfield11.destroy();
			sprytextfield11 = null;
		}
		// same as the rest
		if(sprytextfield12 && sprytextfield12.destroy){
			sprytextfield12.resetClasses();
			sprytextfield12.destroy();
			sprytextfield12 = null;
		}
		if(sprytextfield13 && sprytextfield13.destroy){
			sprytextfield13.resetClasses();
			sprytextfield13.destroy();
			sprytextfield13 = null;
		}
		if(sprytextfield14 && sprytextfield14.destroy){
			sprytextfield14.resetClasses();
			sprytextfield14.destroy();
			sprytextfield14 = null;
		}
		if(sprytextfield15 && sprytextfield15.destroy){
			sprytextfield15.resetClasses();
			sprytextfield15.destroy();
			sprytextfield15 = null;
		}
		
	} else if(value == 'Foreign'){
		
		document.getElementById("DriversLicense").value="";
		document.getElementById("DriversLicenseState").value="";
		document.getElementById("DLExpiryDate").value="";

		document.getElementById("ParticipantForeign").style.display = "inline";
		document.getElementById("ParticipantLocal").style.display = "none";
		document.getElementById("EnterDLPP").style.display = "none";

		if(!sprytextfield11){
			sprytextfield11 = new Spry.Widget.ValidationTextField("sprytextfield11");
		}
		if(!sprytextfield12){
			sprytextfield12 = new Spry.Widget.ValidationTextField("sprytextfield12");
		}
		if(!sprytextfield13){
			sprytextfield13 = new Spry.Widget.ValidationTextField("sprytextfield13");
		}
		if(!sprytextfield14){
			sprytextfield14 = new Spry.Widget.ValidationTextField("sprytextfield14", "date", {isRequired:true, useCharacterMasking:true});
		}
		if(!sprytextfield15){
			sprytextfield15 = new Spry.Widget.ValidationTextField("sprytextfield15", "date", {isRequired:true, useCharacterMasking:true});
		}

		if(sprytextfield8 && sprytextfield8.destroy){
			sprytextfield8.resetClasses();
			sprytextfield8.destroy();
			sprytextfield8 = null;
		}
		if(sprytextfield9 && sprytextfield9.destroy){
			sprytextfield9.resetClasses();
			sprytextfield9.destroy();
			sprytextfield9 = null;
		}
		if(sprytextfield10 && sprytextfield10.destroy){
			sprytextfield10.resetClasses();
			sprytextfield10.destroy();
			sprytextfield10 = null;
		}
	}
	
	// proceed with the rest as normal
	return true;
};
