function initPopups() {
	// add an onclick event to every hyperlink with a class of 'popup'
	var els = document.getElementsByTagName("a");
	for(var i = 0; i < els.length; i++) {
		if (els[i].className.indexOf("popup") !=- 1) {
			els[i].onclick=popup;
		}
	}
}

function popup() {
	var newwindow=window.open(this.href, "popup", "width=350,height=250");
	if (window.focus) {newwindow.focus()}
	// prevent the hyperlink from doing its default behaviour
	return false; 
}

// Prevent double-clicking on form submit buttons
// Check to make sure required fields are present

var firstSubmit = true;

function CheckSubmit(form) {
	var errorMsg = '';
	if ( window.requiredFields && window.fieldLabels ) {
		for ( i = 0; i < requiredFields.length; i++ ) {
			var field = requiredFields[i];
			var obj = eval( "form." + field );
			var present = 0;

			if ( obj.length ) {
				if ( ( obj[0].type == 'radio' ) || ( obj[0].type == 'checkbox' ) ) {
					for( j = 0; j < obj.length; j++ ) {
						if ( obj[j].checked ) present = 1;
					}
				} else if ( ( obj.type == 'select-one' ) || ( obj.type == 'select' ) ) {
					myindex = obj.selectedIndex;
					if ( obj.options[myindex].value ) present = 1;
	
				} else {
					for( j = 0; j < obj.length; j++ ) {
						if ( obj[j].value ) present = 1;
					}
				}
	
			} else if ( ( obj.type == 'checkbox' ) || ( obj.type == 'radio' ) ) {
				if ( obj.checked ) {
					present = 1;
				}
	
			} else if ( obj.value ) {
				present = 1;
			}

			if ( !present ) {
				errorMsg = errorMsg + fieldLabels[i] + "\n";
			}
		}
	}
	
	if ( errorMsg != '' ) {
		errorMsg = "The following fields are required:\n\n" + errorMsg;
		alert( errorMsg );
		return false;
	
	} else {
		if (firstSubmit) {
			firstSubmit = false;
			return true;
		} else {
			return false;
		}
	}
							
	return true;
}


