
function sortTable(id, col) {
	var tblEl = document.getElementById(id);
	if (tblEl.reverseSort == null) {
		tblEl.reverseSort = new Array();
		tblEl.lastColumn = 0;
	}

	if (col == tblEl.lastColumn)
		tblEl.reverseSort[col] = !tblEl.reverseSort[col];
		tblEl.lastColumn = col;

		// Set the table display style to "none" - for Netscape 6 browsers.
		var oldDsply = tblEl.style.display;
		tblEl.style.display = "none";

		// Sort the rows based on the content of the specified column using a selection sort.

    var tmpEl;
	var i, j;
	var minVal, minIdx;
	var testVal;
	var cmp;

	for (i = 0; i < tblEl.rows.length - 1; i++) {

		// Assume the current row has the minimum value.
		minIdx = i;
		minVal = getTextValue(tblEl.rows[i].cells[col]);

		// Search the rows that follow the current one for a smaller value.
		for (j = i + 1; j < tblEl.rows.length; j++) {
			testVal = getTextValue(tblEl.rows[j].cells[col]);
			cmp = compareValues(minVal, testVal);

			// Negate the comparison result if the reverse sort flag is set.
			if (tblEl.reverseSort[col])
				cmp = -cmp;
				// Sort by the second column if those values are equal.
				if (cmp == 0 && col != 0)
					cmp = compareValues(getTextValue(tblEl.rows[minIdx].cells[0]), getTextValue(tblEl.rows[j].cells[0]));
					// If this row has a smaller value than the current minimum, remember its position and update the current minimum value.
					if (cmp > 0) {
						minIdx = j;
						minVal = testVal;
					}
			}

				// Have the row with the smallest value. Remove it from the table and insert it before the current row.
		if (minIdx > i) {
			tmpEl = tblEl.removeChild(tblEl.rows[minIdx]);
			tblEl.insertBefore(tmpEl, tblEl.rows[i]);
		}
	}

	// Restore the table's display style.
	tblEl.style.display = oldDsply;

	return false;
}

//-----------------------------------------------------------------------------
// Functions to get and compare values during a sort.
//-----------------------------------------------------------------------------

// This code is necessary for browsers that don't reflect the DOM constants (like IE).
if (document.ELEMENT_NODE == null) {
	document.ELEMENT_NODE = 1;
	document.TEXT_NODE = 3;
}

function getTextValue(el) {

  var i;
  var s;
  
  // Find and concatenate the values of all text nodes contained within the element.
  s = "";
  for (i = 0; i < el.childNodes.length; i++)
    if (el.childNodes[i].nodeType == document.TEXT_NODE)
      s += el.childNodes[i].nodeValue;
    else if (el.childNodes[i].nodeType == document.ELEMENT_NODE && el.childNodes[i].tagName == "BR")
      s += " ";
    else
		// Use recursion to get text within sub-elements.
		s += getTextValue(el.childNodes[i]);
		if ((s=="90-1") || (s=="90-2") || (s=="90-3") || (s=="90-4") || (s=="90-5") || (s=="90-6") || (s=="90-7") || (s=="91-1") || (s=="91-2") || (s=="91-3") || (s=="91-4") || (s=="91-5") || (s=="91-6") || (s=="92-1") || (s=="92-2") || (s=="92-3") || (s=="92-4") || (s=="92-5") || (s=="92-6") || (s=="92-7") || (s=="93-1") || (s=="93-2") || (s=="93-3") || (s=="93-4") || (s=="93-5") || (s=="93-6") || (s=="94-1") || (s=="94-2") || (s=="94-3") || (s=="94-4") || (s=="94-5") || (s=="95-1") || (s=="95-2") || (s=="96-1") || (s=="97-1") || (s=="97-2") || (s=="98-1") || (s=="98-2") || (s=="99-1")){
			s = "19" + s
		}
	  
		var isDate = new Date(s);
		var myDate = new String();
		if (isDate == "NaN"){
            return s;
		}else{          
			strmonth = isDate.getMonth();
			strmonth = strmonth + 1
			if(strmonth<10) strmonth = "0" + strmonth

			strday = isDate.getDate();
			if(strday<10) strday = "0" + strday
	
			myDate = isDate.getFullYear() + " " ;			
			myDate = myDate + strmonth + " ";
			myDate = myDate + strday;
			
			return myDate ;
			s = myDate
			return s;
		}
}




// If the values are numeric, convert them to floats.
function compareValues(v1, v2) {

  var f1, f2;
  //f1 = parseFloat(v1);
  //f2 = parseFloat(v2);
  //if (!isNaN(f1) && !isNaN(f2)) {
  //  v1 = f1;
  //  v2 = f2;
  //}

  // Compare the two values.
  if (v1 == v2)
    return 0;
  if (v1 > v2)
    return 1
  return -1;
}

// Regular expressions for normalizing white space.
//var whtSpEnds = new RegExp("^\\s*|\\s*$", "g");
//var whtSpMult = new RegExp("\\s\\s+", "g");

//function normalizeString(s) {

  //s = s.replace(whtSpMult, " ");  // Collapse any multiple whites space.
  //s = s.replace(whtSpEnds, "");   // Remove leading or trailing white space.

//  return s;
//}

function highLightMenu( oElem )
{
	oElem.style.backgroundColor = "#99ccff";
	oElem.style.color = "#ffffff";
}

function unHighLightMenu( oElem )
{
	oElem.style.backgroundColor = "#283090";
	oElem.style.color = "#000000";
}

//----------------------------------------------------------------------------------------
  	function VlidData(frmEnter){
		if (frmEnter.FirstName.value == ""){
			alert("You must complete the First Name");
			frmEnter.FirstName.focus()
		}else if (frmEnter.LastName.value == ""){
			alert("You must complete the Last Name");
			frmEnter.LastName.focus()
		}else if (frmEnter.site.value == ""){
			alert("You must select the Site");
			frmEnter.site.focus()
		}else if ((frmEnter.site.options[frmEnter.site.selectedIndex].text == "Other:") && (frmEnter.siteOther.value == "")){
			alert("You must complete the Site in the text box");
			frmEnter.siteOther.focus()
		}else if (frmEnter.organization.value == ""){
			alert("You must complete the Organization");
			frmEnter.organization.focus()
		}else if (frmEnter.email.value == ""){
			alert("You must complete the Email");
			frmEnter.email.focus()
		}else if (!(checkemail(frmEnter.email.value)) && ((frmEnter.email.value != ""))) {
			alert("You must enter a valid Email");
			frmEnter.email.focus()
		
		}else if (frmEnter.address1.value == ""){
			alert("You must complete the Address1");
			frmEnter.address1.focus()
		}else if (frmEnter.city.value == ""){
			alert("You must complete the City");
			frmEnter.city.focus()
		}else if (frmEnter.state.value == ""){
			alert("You must complete the State");
			frmEnter.state.focus()
		}else if (frmEnter.zip.value == ""){
			alert("You must complete the Zip");
			frmEnter.zip.focus()

		}else if (!(checkzip(frmEnter.zip.value)) && ((frmEnter.zip.value != ""))) {
			alert("You must enter a valid Zip");
			frmEnter.zip.focus()

		}else if (frmEnter.phone.value == ""){
			alert("You must complete the Phone");
			frmEnter.phone.focus()		
	    }else{
			frmEnter.action="Regist2.asp"
			frmEnter.submit();
		}
	}

	function checkzip(String){
		String += "";
		if (String.length == 5) { 
			for (var i=0; i<String.length; i++){
				var oneChar = String.substring(i, i+1)
				if (oneChar <"0" || oneChar>"9"){
					return false
					break;
				}
			}
			return true
        }else if (String.length == 10) {
			for (var i=0; i<4; i++){
				var oneChar = String.substring(i, i+1)
				if (oneChar <"0" || oneChar>"9"){
					return false
					break;
				}
			}
			if (String.indexOf("-") > 0) {
				return true
			}
		}
    }

	function checkemail(str) {
		return (str.indexOf(".") > 0) && (str.indexOf("@") > 0);
 
	}


//-------------------------------- Select Sites ---------------------------------
	function cksite(){
		frm = document.forms[0]
		if (frm.site.options[frm.site.selectedIndex].text == "Other:"){
			frm.action="Regist1.asp?ssy=y"
			frm.submit();
		}else if (frm.site.options[frm.site.selectedIndex].text != "Other:"){
			frm.action="Regist1.asp?ssy=n"
			frm.submit();
		}
	}

//-------------------------------------------------------------------------------

function defaultSel(strBegin){
	var para = strBegin
	var frm = document.forms[0];
	if (para == "1"){
		frm.FirstName.focus()
	}else{
		frm.site.focus()
	}
}
