var True = true;
var False = false;
var modalPopup = null;
var nonModalPopup = null;
// validateAndPostBack
function validateAndPostBack(controlName, postBackArgument) {
var okToSubmit = true;
if (typeof(VAM_ValOnClick) == 'function') {
VAM_ValOnClick('', '');
okToSubmit = VAM_ValOnSubWGrp('');
}
else {
if (typeof(Page_ClientValidate) == 'function') {
Page_ClientValidate();
okToSubmit = okToSubmit && Page_IsValid;
}
}
if (okToSubmit) {
__doPostBack(controlName, postBackArgument);
return true
}
else {
return false;
}
}
// validatePage
function validatePage() {
var pageValid = true;
if (typeof(Page_ClientValidate) == 'function') {
Page_ClientValidate();
pageValid = Page_IsValid;
}
if (typeof(VAM_ValOnClick) == 'function') {
VAM_ValOnClick('', '');
pageValid = pageValid && VAM_ValOnSubWGrp('');
}
return pageValid;
}
// openPopup
function openPopup(popupUrl, popupName, popupWidth, popupHeight, modal, useScrollBar) {
var left = Math.floor((screen.width - popupWidth) / 2);
var top = Math.floor((screen.height - popupHeight) / 2) - 50;
var features = "width=" + popupWidth + ",height=" + popupHeight + ",left=" + left + ",top=" + top + ",resizable=yes,status=no,toolbar=no,menubar=no,location=no";
if (useScrollBar == true) {
features = features + ",scrollbars=yes";
}
if (modal == true) {
modalPopup = window.open(popupUrl, popupName, features);
modalPopup.focus();
return modalPopup;
}
else {
nonModalPopup = window.open(popupUrl, popupName, features);
nonModalPopup.focus();
return nonModalPopup;
}
}
// popupCalendar
function popupCalendar(url) {
var left = Math.floor((screen.width - 200) / 2);
var top = Math.floor((screen.height - 180) / 2) - 50;
features = "width=200,height=180,left=" + left + ",top=" + top + ",resizable=yes,status=no,toolbar=no,menubar=no,location=no";
modalPopup = window.open(url, "calendar", features);
}
// popupCalendarForTextbox
function popupCalendarForTextbox(textBoxControl) {
popupCalendar("/controls/calendar.aspx?textbox=" + textBoxControl.id);
}
// popupCalendarForFunction
function popupCalendarForFunction(functionName) {
popupCalendar("/controls/calendar.aspx?functionName=" + functionName);
}
// bodyOnFocus
function bodyOnFocus() {
if (modalPopup == null) {
return;
}
setTimeout(returnToModalPopup, 50);
}
// returnToModalPopup
function returnToModalPopup() {
if ((modalPopup != null) && (!modalPopup.closed)) {
modalPopup.focus();
}
}
// showPrintablePage
function showPrintablePage(contentContainerName, pageTitle, addTable, tableAttributes, clubThemeFolder, clubName, clubUrl) {
var contentContainer = document.getElementById(contentContainerName);
if (contentContainer == null) {
return;
}
var printWindow = window.open("", "print", "menubar=yes,width=500,height=400,resizable=yes,scrollbars=yes");
printWindow.document.write("
");
printWindow.document.write("" + pageTitle + "");
printWindow.document.write("");
printWindow.document.write("");
printWindow.document.write("");
printWindow.document.write("");
printWindow.document.write("" + clubName + "
" + clubUrl + "
" + pageTitle + "
");
if (addTable == true) {
printWindow.document.write("");
}
var text = contentContainer.innerHTML;
var regex;
// hide print link
regex = new RegExp("");
text = text.replace(regex, "");
// remove all scripts
regex = new RegExp("");
if (window.print) {
printWindow.document.write("");
}
else {
printWindow.document.write("");
}
printWindow.document.close();
}
// image management stuff
var fileInputControl = null;
var imagePreviewControl = null;
var testImage = null;
var resizeRequired = false;
var maxImageWidth;
var maxImageHeight;
var imageSuccessFunction;
var imageErrorFunction;
var showResizeMessage;
// browserCanShowPreview
function browserCanShowPreview() {
return (window.navigator.appName == "Microsoft Internet Explorer");
}
// getPreviewFileName
function getPreviewFileName(fullFileName) {
var startPosition = fullFileName.lastIndexOf("\\");
return fullFileName.substring(startPosition + 1);
}
// previewImage
function previewImage(fileInputControlName, imagePreviewControlName, maxWidth, maxHeight, successFunction, errorFunction, resizeMessageRequired) {
fileInputControl = document.getElementById(fileInputControlName);
previewImageWithFileName(fileInputControl.value, imagePreviewControlName, maxWidth, maxHeight, successFunction, errorFunction, resizeMessageRequired);
}
// previewImageWithFileName
function previewImageWithFileName(fileName, imagePreviewControlName, maxWidth, maxHeight, successFunction, errorFunction, resizeMessageRequired) {
imagePreviewControl = document.getElementById(imagePreviewControlName);
maxImageWidth = maxWidth;
maxImageHeight = maxHeight;
if (successFunction) {
imageSuccessFunction = successFunction;
}
if (errorFunction) {
imageErrorFunction = errorFunction;
}
if (resizeMessageRequired == true) {
showResizeMessage = true;
}
else {
showResizeMessage = false;
}
imagePreviewControl.style.visibility = "hidden";
testImage = new Image();
testImage.onload = resizePreview;
if (imageErrorFunction) {
testImage.onerror = imageErrorFunction;
}
// fileName = "file:///" + fileName.replace(/\\/g, "/");
testImage.src = fileName;
}
// resizePreview
function resizePreview() {
testImage.onload = null;
testImage.onerror = null;
var originalWidth = testImage.width;
var widthRatio = 1;
if (originalWidth > maxImageWidth) {
testImage.width = maxImageWidth;
widthRatio = originalWidth / maxImageWidth;
testImage.height = testImage.height / widthRatio;
resizeRequired = true;
}
if (testImage.height > maxImageHeight) {
var heightRatio = testImage.height / maxImageHeight;
testImage.height = testImage.height / heightRatio;
testImage.width = testImage.width / heightRatio;
resizeRequired = true;
}
imagePreviewControl.onload = showImage;
if (imageErrorFunction) {
imagePreviewControl.onerror = imageErrorFunction;
}
imagePreviewControl.width = testImage.width;
imagePreviewControl.height = testImage.height;
imagePreviewControl.src = testImage.src;
if ((resizeRequired == true) && (showResizeMessage)) {
alert("The image will be resized as shown to fit the available space");
}
resizeRequired = false;
}
// showImage
function showImage() {
imagePreviewControl.onload = null;
imagePreviewControl.onerror = null;
if (testImage == null) {
return;
}
imagePreviewControl.width = testImage.width;
imagePreviewControl.height = testImage.height;
imagePreviewControl.style.visibility = "visible";
testImage = null;
if (imageSuccessFunction) {
imageSuccessFunction();
}
}
// refreshPage
function refreshPage() {
var submitButton = document.getElementById(submitButtonName);
if (submitButton == null) {
var currentUrl = window.location.href;
if (currentUrl.indexOf("action=") == 0) {
window.location.reload();
}
else {
var regex = new RegExp("action=[^&]*&?");
newUrl = currentUrl.replace(regex, "");
window.location.href = newUrl;
}
}
else {
submitButton.onclick();
//__doPostBack(submitButtonName, "");
}
}
// formatNumber
function formatNumber(number, decimalPlaces, dollarSign, scaleFactor) {
if (isNaN(parseFloat(number))) {
return "NaN";
}
if (isNaN(parseInt(decimalPlaces))) {
decimalPlaces = 2;
}
if (decimalPlaces == 0) {
return Math.round(number).toString();
}
if (isNaN(parseInt(scaleFactor))) {
scaleFactor = 0;
}
var numberString = "" + Math.round(number * Math.pow(10, (decimalPlaces - scaleFactor)));
while (numberString.length <= decimalPlaces) {
numberString = "0" + numberString;
}
var decimalPosition = numberString.length - decimalPlaces;
if (dollarSign == true) {
dollarSign = "$ ";
}
else {
dollarSign = "";
}
return dollarSign + numberString.substring(0, decimalPosition) + "." + numberString.substring(decimalPosition, numberString.length);
}
// getAjaxObject
function getAjaxObject() {
if (window.ActiveXObject){ // IE
return new ActiveXObject("Microsoft.XMLHTTP");
}
else {
if (window.XMLHttpRequest) { // Non-IE browsers
return new XMLHttpRequest();
}
else {
return null;
}
}
}
// trimString
function trimString(input) {
var regex = new RegExp("^\\s+");
var output = input.replace(regex, "");
regex = new RegExp("\\s+$");
output = output.replace(regex, "");
return output;
}
// resizeFileInput
function resizeFileInput(newSize) {
for (var counter = 0; counter < document.forms[0].elements.length; counter ++) {
var element = document.forms[0].elements[counter];
if (element.type == "file") {
element.size = newSize;
break;
}
}
}
// keyDownHandler
function keyDownHandler(e) {
var keyNumber = 0;
var source;
if (e) {
// netscape/mozilla code
keyNumber = e.which;
source = e.target;
}
else {
// ie code
keyNumber = window.event.keyCode;
source = window.event.srcElement;
}
// let alpha, numeric, and standard punctuation keys go
if ((keyNumber >= 32) && (keyNumber <= 97)) {
return true;
}
// escape
if (keyNumber == 27) {
var cancelButton = document.getElementById(cancelButtonName);
if (cancelButton == null) {
if (doCancel) {
doCancel();
}
}
else {
window.setTimeout(cancelButton.onclick, 20);
}
return false;
}
// F1
if (keyNumber == 112) {
var helpControl = document.getElementById("help_link");
if (helpControl != null) {
helpControl.onclick();
}
}
// enter (return)
if (keyNumber == 13) {
if (source.type == "textarea") {
return true;
}
else {
var submitButton = document.getElementById(submitButtonName);
if (submitButton != null) {
submitButton.onclick();
}
return false; // return false for enter keys so that there are no accidental form submits
}
}
// default
return true;
} // keyDownHandler
// connect keyHandler function to key down event
document.onkeydown = keyDownHandler;