<!-- Begin
function submitIt(formName) {
	var form = document.forms[formName];
	if (validCCForm(form.ccType,form.ccNum,form.ccExp)) {
		form.submit();
	}
}


// Form Field Validation Functions:
//
// isValidExpDate(formField,fieldLabel,required)
//   -- checks for date in the format MM/YY or MM/YYYY against the current date
// isValidCreditCardNumber(formField,ccType,fieldLabel,required)
//   -- checks for valid credit card format using the Luhn check and known digits about various cards
//

function validRequired(formField,fieldLabel)
{
	var result = true;
	
	if (formField.value == "")
	{
		alert('Please enter a value for the "' + fieldLabel +'" field.');
		formField.focus();
		result = false;
	}
	
	return result;
}


function allDigits(str)
{
	return inValidCharSet(str,"0123456789");
}

function inValidCharSet(str,charset)
{
	var result = true;
	
	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))<0)
		{
			result = false;
			break;
		}
	
	return result;
}

function isValidExpDate(formField,fieldLabel,required)
{
	var result = true;
	var formValue = formField.value;

	if (required && !validRequired(formField,fieldLabel))
		result = false;
  
 	if (result && (formField.value.length>0))
 	{
 		var elems = formValue.split("/");
 		
 		result = (elems.length == 2); // should be two components
 		var expired = false;
 		
 		if (result)
 		{
 			var month = parseInt(elems[0]);
 			var year = parseInt(elems[1]);
 			
 			if (elems[1].length == 2)
 				year += 2000;
 			
 			var now = new Date();
 			
 			var nowMonth = now.getMonth() + 1;
 			var nowYear = now.getFullYear();
 			
 			expired = (nowYear > year) || ((nowYear == year ) && (nowMonth > month));
 			
			result = allDigits(elems[0]) && (month > 0) && (month < 13) &&
					 allDigits(elems[1]) && ((elems[1].length == 2) || (elems[1].length == 4));
 		}
 		
  		if (!result)
 		{
 			alert('Please enter a date in the format MM/YY for the "' + fieldLabel +'" field.');
			formField.focus();
		}
		else if (expired)
		{
 			result = false;
 			alert('The date for "' + fieldLabel +'" has expired.');
			formField.focus();
		}
	} 
	
	return result;
}

function isValidCreditCardNumber(formField,ccType,fieldLabel,required)
{
	var result = true;
 	var ccNum = formField.value;

	if (required && !validRequired(formField,fieldLabel))
		result = false;
 
  	if (result && (formField.value.length>0))
 	{ 
 		if (!allDigits(ccNum))
 		{
 			alert('Please enter only numbers (no dashes or spaces) for the "' + fieldLabel +'" field.');
			formField.focus();
			result = false;
		}	

		if (result)
 		{ 
 			
 			if (!LuhnCheck(ccNum) || !validateCCNum(ccType,ccNum))
 			{
 				alert('Please enter a valid card number for the "' + fieldLabel +'" field.');
				formField.focus();
				result = false;
			}	
		} 

	} 
	
	return result;
}

function LuhnCheck(str) 
{
  var result = true;

  var sum = 0; 
  var mul = 1; 
  var strLen = str.length;
  
  for (i = 0; i < strLen; i++) 
  {
    var digit = str.substring(strLen-i-1,strLen-i);
    var tproduct = parseInt(digit ,10)*mul;
    if (tproduct >= 10)
      sum += (tproduct % 10) + 1;
    else
      sum += tproduct;
    if (mul == 1)
      mul++;
    else
      mul--;
  }
  if ((sum % 10) != 0)
    result = false;
    
  return result;
}



function GetRadioValue(rArray)
{
	for (var i=0;i<rArray.length;i++)
	{
		if (rArray[i].checked)
			return rArray[i].value;
	}
	
	return null;
}


function validateCCNum(cardType,cardNum)
{
	var result = false;
	cardType = cardType.toUpperCase();
	
	var cardLen = cardNum.length;
	var firstdig = cardNum.substring(0,1);
	var seconddig = cardNum.substring(1,2);
	var first4digs = cardNum.substring(0,4);

	switch (cardType)
	{
		case "VISA":
			result = ((cardLen == 16) || (cardLen == 13)) && (firstdig == "4");
			break;
		case "AMEX":
			var validNums = "47";
			result = (cardLen == 15) && (firstdig == "3") && (validNums.indexOf(seconddig)>=0);
			break;
		case "MASTERCARD":
			var validNums = "12345";
			result = (cardLen == 16) && (firstdig == "5") && (validNums.indexOf(seconddig)>=0);
			break;
		case "DISCOVER":
			result = (cardLen == 16) && (first4digs == "6011");
			break;
		case "DINERS":
			var validNums = "068";
			result = (cardLen == 14) && (firstdig == "3") && (validNums.indexOf(seconddig)>=0);
			break;
	}
	return result;
}

function validCCForm(ccTypeField,ccNumField,ccExpField)
{
	var result = isValidCreditCardNumber(ccNumField,ccTypeField.value,"Credit Card Number",true) &&
		isValidExpDate(ccExpField,"Expiration Date",true);
	return result;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//******************************************************
//Toggle a form element "on" or "off" (disabled or enabled)
//******************************************************
function toggleElement (targetElement, onOff) {

  if (onOff == 'off') {
   document.forms['Edit'].elements[targetElement].disabled = true;
    if (!document.all && !document.getElementById) {
      targetElement.oldOnFocus = 
      targetElement.onfocus ? targetElement.onfocus : null;
      targetElement.onfocus = skip;
    }
  }
  else {
    document.forms['Edit'].elements[targetElement].disabled = false;
    if (!document.all && !document.getElementById) {
      targetElement.onfocus = targetElement.oldOnFocus;
    }
  }
}

function skip () { this.blur(); }


//******************************************************
//Function that checks for required and/or properly formatted fields.
//Only used for prediction contests
//
//******************************************************
function contestValidate(current_form){
	if (validate(current_form)){
		var nbrSelections = 0;
		var contestType = 1;
		var step = 1;
		nbrSelections = parseInt(current_form.elements['nbrSelections'].value);
		contestType = parseInt(current_form.elements['contestType'].value);
		step = parseInt(current_form.elements['step'].value);
		if (step == 1){
			return true;
		}
		else{	
			if (contestType == 1){		
				var selections = new Array(nbrSelections);
				// Loop through all the selection elements
				for (counter = 0; counter < current_form.length; counter++) {
					var fieldName = current_form[counter].name;
					if (its_integer(fieldName)){				
						if ((nbrSelections >= parseInt(fieldName)) && (parseInt(fieldName) >= 1)){
							selections[parseInt(fieldName) -1] = parseInt(current_form[counter].value);	
						}
					}
				}
				
				var nextStep = true;
				for (i = selections.length -1; i >= 0; i--){
					for (j = selections.length - 1; j >= 0; j--){
						if (i != j){
							if (selections[i] == selections[j]){
								nextStep = false;
								alert("Duplicate selections for different point values are not allowed. " + (j + 1) + " is a duplicate of " + (i + 1))						
								break
							}
						}
					}
					
					if (! nextStep){
						break				
					}
				}	
			}
			else if (contestType == 2){
				var selections = new Array(nbrSelections);
				// Loop through all the selection elements
				for (counter = 0; counter < current_form.length; counter++) {
					var fieldName = current_form[counter].name;
					if (its_integer(fieldName)){				
						if ((nbrSelections >= parseInt(fieldName)) && (parseInt(fieldName) >= 1)){
							selections[parseInt(fieldName) -1] = parseInt(current_form[counter].value);	
						}
					}
				}
				
				var nextStep = true;
				for (i = 0; i <= selections.length -1; i++){
					for (j = 0; j <= selections.length - 1; j++){
						if (i != j){
							if (selections[i] == selections[j]){
								nextStep = false;
								alert("Duplicate athletes for a single event are not allowed. " + (j + 1) + " is a duplicate of " + (i + 1))						
								break
							}
						}
					}
					
					if (! nextStep){
						break				
					}
				}
			}
			else if (contestType == 3){
				var selectionsPerEvent = parseInt(current_form.elements['selectionsPerEvent'].value);
				var nextStep = true;
				// Loop through all the selection elements
				for (counter = 0; counter < current_form.length; counter++) {
					var fieldName = current_form[counter].name;
					//check if '_' is in string, split on '_', check to see if both the two array elements are integers
					var selection = fieldName.split("_");  
					if (selection.length == 2)
					{
						if (its_integer(selection[0]) && its_integer(selection[1]))
						{
							if (parseInt(selection[1]) == 1)
							{
								var eventSelections = Array(selectionsPerEvent); 
								for (i = 1; i <= selectionsPerEvent; i++)
								{
									var nextField = counter + i - 1;
									eventSelections[i - 1] = parseInt(current_form[nextField].value);    
									//current_form[counter].options[current_form[counter].selectedIndex].value
								}
								
								for (i = 0; i <= eventSelections.length -1; i++){
									for (j = 0; j <= eventSelections.length - 1; j++){
										if (i != j){
											if (eventSelections[i] == eventSelections[j]){
												nextStep = false;
												current_form[counter].focus();
												alert("Error! Duplicate athletes for a single event are not allowed.")						
												break;
											}
										}
									}
									
									if (! nextStep){
										break;
									}
								}
							}
						}
						
						if (! nextStep){
							break;
						}
					}
				}
			}
			
			if (! nextStep){
				return false
			}	
			else{
				return true
			}
		}
	}
	else{
		return false
	}
}


//******************************************************
//Function that checks for required and/or properly formatted fields.
//
//******************************************************

function validate(current_form) {
  	
  	if (current_form.elements['checkRequired'].value == 'true') {
  		nextStep = checkRequiredFields(current_form);
  	} else {
  		nextStep = true
  	}
	
  	if (nextStep) {
  		nextStep = checkNumberFields(current_form);
  	} 
	else {
		return false
	}
	
  	if (nextStep) {
  		nextStep = checkFieldLengths(current_form);
  	} 
	else {
		return false
	}
  	if (nextStep) {
  		nextStep = checkEmailFields(current_form);			
  	}
	else {
		return false
	}
	if (nextStep) {
  		nextStep = checkEmailConfirmation(current_form);
  	} 
	else {
		return false
	}
  	if (nextStep) {
  		nextStep = checkPasswords(current_form);
  	}
	else {
		return false
	}		
  	if (nextStep) {
  		return true
  	} else {return false}
  
}




//******************************************************
//confirm that password fields are the same
//******************************************************
function checkPasswords(current_form) {
    
    var missing_fields = new Array()
    var total_missing = 0
    var password = ""
		var passwordConfirm = ""
    // Loop through all the form elements
    for (counter = 0; counter < current_form.length; counter++) {
    
        // Find the elements with custom attributes of "Password"
				// and "Password Confirm"
        if (current_form[counter].password) {
					password = current_form[counter].value				
     		}       
				if (current_form[counter].passwordConfirm) {
					passwordConfirm = current_form[counter].value				
     		}  
    }
		
		//Compare Password to Password Confirm
		
   	if (password == passwordConfirm) {
			return true
		}
    else {    
       alert("Your passwords don't match!")        
    }
}

//******************************************************
//confirm that email fields are the same
//******************************************************
function checkEmailConfirmation(current_form) {
    
    var missing_fields = new Array()
    var total_missing = 0
    var email = ""
		var emailConfirm = ""
    // Loop through all the form elements
    for (counter = 0; counter < current_form.length; counter++) {
    
        // Find the elements with custom attributes of "Password"
				// and "Password Confirm"
        if (current_form[counter].email) {
					email = current_form[counter].value				
     		}       
				if (current_form[counter].emailConfirm) {
					emailConfirm = current_form[counter].value				
     		}  
    }
		
		//Compare Password to Password Confirm
		
   	if (email == emailConfirm) {
			return true
		}
    else {    
       alert("Your eamil addresses don't match!")        
    }
}

//******************************************************
//check to make sure certain fields are not empty
//******************************************************

function checkRequiredFields(current_form) {
    
    var missing_fields = new Array()
    var total_missing = 0
    
    // Loop through all the form elements
    for (counter = 0; counter < current_form.length; counter++) {
    
        // Is this a field that's mandatory?
        if (current_form[counter].mandatory) {
            
            // Is it an empty text field?
            if ((current_form[counter].type == "text" ||
						current_form[counter].type == "password" ||
						current_form[counter].type == "textarea") &&
						its_empty(current_form[counter].value)) {
              
                // If so, add the field to the array of missing fields
                missing_fields[total_missing] = current_form[counter]
                total_missing++
								
						// Does it contain only whitespace?
            } else if ((current_form[counter].type == "text" ||
						current_form[counter].type == "password" ||
						current_form[counter].type == "textarea") &&
						its_whitespace(current_form[counter].value)) {
              
                // If so, add the field to the array of missing fields
                missing_fields[total_missing] = current_form[counter]
                total_missing++
								
						// Is it a single-select list with no value?
            } else if ( current_form[counter].type == "select-one" && 
												current_form[counter].selectedIndex == "") {
              
                // If so, add the field to the array of missing fields
                missing_fields[total_missing] = current_form[counter]
                total_missing++
								
						// Is it a multi-select with no values?
            } else if ( current_form[counter].type == "select-multiple") {
              	// Check to see if all values are empty
								var somethingIsSelected = 0
								for (var i = 0; i < current_form[counter].options.length; i ++) {
										if (current_form[counter].options[i].selected) {
											somethingIsSelected = 1
										}
									}
								if (somethingIsSelected == 0) {	
                	// If so, add the field to the array of missing fields
                	missing_fields[total_missing] = current_form[counter]
                	total_missing++
								}
		//Is it a checkbox that hasn't been checked?								
            } else if ((current_form[counter].type == "checkbox") && (! current_form[counter].checked)){
		// If so, add the field to the array of missing fields
		missing_fields[total_missing] = current_form[counter]
                total_missing++
            }
            
        }
    }

    // Were there any fields missing?
    if (total_missing > 0) {
    
        // Start the message
        var missing_message = "Fields marked with '*' are required.\nPlease complete the following " +
			  (total_missing == 1 ? " field" : " fields\n") +
				" and then click the submit button again. " +
        "\n______________________________\n\n"
        
        // Loop through the missing fields
        for (counter = 0; counter < missing_fields.length; counter++) {
            missing_message += missing_fields[counter].name + "\n"
        }
    
        // Finish up and display the message
        missing_message += "\n______________________________\n\n" 
        alert(missing_message)
        
        // For emphasis, put the focus on the first missing field
        missing_fields[0].focus()
    }
    else {
    
        // Otherwise, go ahead and submit
        return true
    }
}

//******************************************************
//Check a string to see if it's empty (used by checkRequiredFields)
//******************************************************
function its_empty(string_value) {

    // Check for the empty string and null
    if (string_value == "" || string_value == null) {
    
        // If either, it's empty so return true
        return true
    }
    
    // Otherwise, it's not empty so return false
    return false
}


//******************************************************
//Check a string to see if it contains only whitespace (used by checkRequiredFields)
//******************************************************
function its_whitespace(string_value) {

    // These are the whitespace characters
    var whitespace = " \n\r\t"

    // Run through each character in the string
    for (var counter = 0; counter < string_value.length; counter++) {
        
        // Get the current character
        current_char = string_value.charAt(counter)
        
        // If it's not in the whitespace characters string,
        // return false because we found a non-whitespace character
        if (whitespace.indexOf(current_char) == -1) {
            return false
        }
    }
    
    // Otherwise, the string has nothing but
    // whitespace characters, so return true
    return true
}

//******************************************************
//check to make sure certain fields contain only numbers
//******************************************************

function checkNumberFields(current_form) {
    
    var non_numeric_fields = new Array()
    var total_non_numeric = 0
    
    // Loop through all the form elements
    for (counter = 0; counter < current_form.length; counter++) {
    
        // Is this a text field with custom attribute "numeric"?
        if ( (current_form[counter].type == "text" ||
						current_form[counter].type == "password" ||
						current_form[counter].type == "textarea") &&
						current_form[counter].numeric) {
            //trim the leading and trailing whitespace from all numeric fields
			current_form[counter].value = trim(current_form[counter].value)
            // If so, is it a non integer?
            if (!its_integer(current_form[counter].value)) {
              
                // If so, add the field to the array of non_numeric fields
                non_numeric_fields[total_non_numeric] = current_form[counter]
                total_non_numeric++
            }
        }
    }

    // Were there any fields non_numeric?
    if (total_non_numeric > 0) {
    
        // Start the message
        var non_numeric_message = "Fields which take numeric input must not contain letters or special\n" +
															"characters such as currency symbols, commas, spaces or decimals.\n" +
															"Please correct the following" +
			  (total_non_numeric == 1 ? " field" : " fields\n") +
				"and then click the submit button again. " +
        "\n______________________________\n\n"
        
        // Loop through the non_numeric fields
        for (counter = 0; counter < non_numeric_fields.length; counter++) {
            non_numeric_message += non_numeric_fields[counter].name + "\n"
        }
    
        // Finish up and display the message
        non_numeric_message += "\n______________________________\n\n" 
        alert(non_numeric_message)
        
        // For emphasis, put the focus on the first non_numeric field
        non_numeric_fields[0].focus()
    }
    else {
    
        // Otherwise, go ahead and submit
        return true
    }
}

//******************************************************
//Checks a string to see if it's an integer (used by checkNumberFields)
//******************************************************
function its_integer(string_value) {

    // Run through each character in the string
    for (var counter = 0; counter < string_value.length; counter++) {
        
        // Get the current character
        current_char = string_value.charAt(counter)
        
        // If it's not a digit, return false
        if (!its_a_digit(current_char)) {
            return false
        }
    }
    
    // Otherwise, the string has nothing but
    // digits, so return true
    return true
}

//******************************************************
//Checks a character to see if it's a digit (used by its_integer)
//******************************************************
function its_a_digit(character) {

    var digit_characters = "0123456789"

    // If it's not in the digit_characters string,
    // then it's not a digit so return false
    
    if (digit_characters.indexOf(character) == -1) {
        return false
    }
    
    // Otherwise, it's a digit, so return true
    return true
}

/////////////////////////////////////////////////
//check to make sure certain fields do not exceed a specified length
////////////////////////////////////////////////

function checkFieldLengths(current_form) {
    
    var too_long_fields = new Array()
    var total_too_long = 0
    
    // Loop through all the form elements
    for (counter = 0; counter < current_form.length; counter++) {
    
        // Is this a text field with a custom maxchars attribute?
        if ( current_form[counter].type == "text" ||
						current_form[counter].type == "password" ||
						current_form[counter].type == "textarea" &&
						current_form[counter].maxchars > 0) {
            
            // Is the actual length of the field value longer than the maxchar setting?
            if (current_form[counter].value.length > current_form[counter].maxchars) {
              	
                // If so, add the field to the array of too_long fields
                too_long_fields[total_too_long] = current_form[counter]
                total_too_long++
            } 
        }
    }

    // Were there any fields too_long?
    if (total_too_long > 0) {
    
        // Start the message
        var too_long_message = "The following" +
			  (total_too_long == 1 ? " field" : " fields") +
				(total_too_long == 1 ? " exceeds" : " exceed") +
				" the specified chacter limit.\n Please check the character limit" +
				" and then click the submit button again. " +
        "\n______________________________\n\n"
        
        // Loop through the too_long fields
        for (counter = 0; counter < too_long_fields.length; counter++) {
            too_long_message += too_long_fields[counter].name + "\n"
        }
    
        // Finish up and display the message
        too_long_message += "\n______________________________\n\n" 
        alert(too_long_message)
        
        // For emphasis, put the focus on the first too_long field
        too_long_fields[0].focus()
    }
    else {
    
        // Otherwise, go ahead and submit
        return true
    }
}

//******************************************************
//check email fields to make sure they contain well-formatted addresses
//******************************************************

function checkEmailFields(current_form) {
    
    var email_fields = new Array()
    var total_email = 0
    
    // Loop through all the form elements
    for (counter = 0; counter < current_form.length; counter++) {
    
        // Is this a field with custom property "email"?
        if (current_form[counter].email) {
            
            // Is it empty? If so, ignore and don't validate (just submit)
						  if (its_empty(current_form[counter].value)) {
								return true
							}
							if (its_whitespace(current_form[counter].value)) {
								return true
							}
						
						// If not empty, does the field not contain a well-formatted address?
            if (!valid_email(current_form[counter].value)) {
              
                // If so, add the field to the array of email fields
                email_fields[total_email] = current_form[counter]
                total_email++
            } 
        }
    }

    // Were there any fields containing bad email addresses?
    if (total_email > 0) {
    
        // Start the message
        var email_message = "The follwing email" +
			  (total_email == 1 ? " address is" : " addresses are\n") +
				" not properly formatted.\n Please correct any errors " +				
				"and then click the submit button again. " +
        "\n______________________________\n\n"
        
        // Loop through the email fields
        for (counter = 0; counter < email_fields.length; counter++) {
            email_message += email_fields[counter].name + "\n"
        }
    
        // Finish up and display the message
        email_message += "\n______________________________\n\n" 
        alert(email_message)
        
        // For emphasis, put the focus on the first email field
        email_fields[0].focus()
    }
    else {
    
        // Otherwise, go ahead and submit
        return true
    }
}

//******************************************************
//Take a string and determine if it represents a well-formatted email address
//Used by checkEmailFields
//******************************************************
function valid_email(email_address) {

   
		//alert(email_address)
		// Check the length
    if (email_address.length < 5) {
        return false
    }
    
    // Check @ and .
    at_location = email_address.indexOf("@")
    dot_location = email_address.lastIndexOf(".")
    
    if (at_location == -1 || dot_location == -1 || at_location > dot_location ) {
        return false
    }

    // Is there at least one character before @?
    if (at_location == 0) {
        return false
    }
    
    // Is there at least one character between @ and .?
    if (dot_location - at_location < 2 ) {
        return false
    }

    // Is there at least one character after .?
    if (email_address.length - dot_location < 2) {
        return false
    }

    // Otherwise, it's a valid address, so return true
    return true
}





function displayWorkflowKey () {
	openKeyWindow()
}



function openKeyWindow(){
var popurl="../workflow_key.asp"
winpops=window.open(popurl,"","width=500,height=338,status,scrollbars,menubar,resizable,")
}


//******************************************************
//trim leading and trailing whitespace from the string argument
//******************************************************
function trim(strText) { 
    // this will get rid of leading spaces 
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);

    // this will get rid of trailing spaces 
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);

   return strText;
}

//******************************************************
//check email fields to make sure they contain well-formatted addresses
//******************************************************
function submitToNewWindow(current_form){
	var strSearchURL = "/directory/search_results.asp"
	strSearchURL = strSearchURL + buildQueryString(current_form)
	newWindow(strSearchURL)
	return false
}

//******************************************************
//manage a search submission window
//******************************************************
// this is needed for function newWindow below
var newWin = null
function newWindow(content, width, height){

	if (newWin != null){
		newWin.close()
	}
	
	if (width == null){
		width == 300
	}
	
	if (height == null){
		height == 300
	}
	newWin = window.open(content, 'newWin','width=' + width + ',height=' + height + ',scrollbars=yes,toolbar=yes,menubar=yes,location=yes,directories=no,status=yes,resizable=yes')
	newWin.focus()
}

function buildDisciplines(current_form){
	var inKey = "discipline"
	var outKey = "disciplines"
	var values = ""
	var firstValue = 1
	
	for (counter = 0; counter < current_form.length; counter++){
		if (current_form[counter].type == "checkbox"){
			if ((current_form[counter].checked) && (current_form[counter].name == inKey)){
				if (firstValue == 0){
					values = values + "," + current_form[counter].value
				}
				else{
					firstValue = 0
					values = current_form[counter].value
				}
			}
		}
	}
	//alert(values)	
	current_form[outKey].value = values

}

function buildAggregate(current_form, inKey, outKey){
	var values = ""
	var firstValue = 1
	
	for (counter = 0; counter < current_form.length; counter++){
		if (current_form[counter].type == "checkbox"){
			if ((current_form[counter].checked) && (current_form[counter].name == inKey)){
				if (firstValue == 0){
					values = values + "," + current_form[counter].value
				}
				else{
					firstValue = 0
					values = current_form[counter].value
				}
			}
		}
	}
	//alert(values)	
	current_form[outKey].value = values

}

//******************************************************
//
//******************************************************
function buildQueryString(current_form){
	var strQueryString = ""
	var strKeyValuePair = ""
	var firstElement = 1
	// Loop through all the form elements
    for (counter = 0; counter < current_form.length; counter++) {
		strKeyValuePair = ""
		if ( current_form[counter].type == "select-one" && !current_form[counter].selectedIndex == "") {
              strKeyValuePair = current_form[counter].name + "=" + current_form[counter].options[current_form[counter].selectedIndex].value
		} 
		// Is it a multi-select with no values?
        else if ( current_form[counter].type == "select-multiple") {
				var firstSelectedValue = 1
				for (var i = 0; i < current_form[counter].options.length; i ++) {
					if (current_form[counter].options[i].selected && current_form[counter].options[i].value != "0" && current_form[counter].options[i].value != "") {
						if (firstSelectedValue != 1){
							strKeyValuePair = strKeyValuePair + "&" +current_form[counter].name + "=" + current_form[counter].options[i].value
						}
						else{
							firstSelectedValue = 0
							strKeyValuePair = current_form[counter].name + "=" + current_form[counter].options[i].value
						}
					}
				}								
        } 
        //Is it a checkbox that hasn't been checked?
        else if ((current_form[counter].type == "checkbox") || (current_form[counter].type == "radio")){
			if(current_form[counter].checked){
				strKeyValuePair = current_form[counter].name + "=" + current_form[counter].value
			}
        }
        // Is it an empty text field?
        else if ((current_form[counter].type == "text" ||
						current_form[counter].type == "password" ||
						current_form[counter].type == "textarea" || current_form[counter].type == "hidden") &&
						!its_empty(current_form[counter].value) && !its_whitespace(current_form[counter].value)) {
				strKeyValuePair = current_form[counter].name + "=" + escape(current_form[counter].value)
        }
        
        if (strKeyValuePair != ""){
			if (firstElement != 1){
				strQueryString = strQueryString + "&" + strKeyValuePair
			}
			else{
				firstElement = 0
				strQueryString = "?" + strKeyValuePair
			}
        }
    
    }
	return strQueryString
}


//-->
