
/*
Submit Once form validation- 
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

/*
  forms need to look like the following: <form method="POST" onSubmit="submitonce(this)">
  OR we can accomplish the same thing with the line below
  Pages that want to use this script should look like the following (declared after the form):
  <script src='../lib/functions.js'></script>
*/

var serverName = "http://kappaestar.com";
//var serverName = "http://127.0.0.1";


if(document.forms[0] !=null)
	document.forms[0].onsubmit=submitonce;

function submitonce(){
	var theform = document.forms[0];
	//if IE 4+ or NS 6+
	if (document.all||document.getElementById){
		//screen thru every element in the form, and hunt down "submit" 
		for (i=0;i<theform.length;i++){
			var tempobj=theform.elements[i]
			if(tempobj.type.toLowerCase()=="submit")
				//disable em
				tempobj.disabled=true
		}
	}
}


function openHelpWin(pageURL, anchorName){
	var popWin = null;
	pageURL = "" + pageURL
	if(pageURL == 'undefined')
		pageURL = "default.htm"
	if(anchorName=='undefined')
		anchorName = "";
	
	if(!popWin || popWin.closed){
		popWin = window.open(serverName + '/documents/help/' +
		pageURL + "#" + anchorName,'helpWin','scrollbars=yes,width=530,height=300');
	}
	popWin.focus();
}

function openInfoWin(pageURL, anchorName){
	var popWin = null;
	pageURL = "" + pageURL
	if(pageURL == 'undefined')
		pageURL = "default.htm"
	
	if(!popWin || popWin.closed){
		popWin = window.open(serverName + '/documents/' +
		pageURL + "#" + anchorName,'infoWin','scrollbars=yes,width=530,height=400');
	}
	popWin.focus();
}

function windowOpen(url)
{
approverwindow = window.open(url,"approver","directories=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0,width=400,height=300");
approverwindow.self.focus()
}

function Display(name){
//alert(window.opener.document.forms[0].PassDateType.value);
	window.opener.document.forms[0].fname.value = name;
	parent.close();
}

function Display2(name){
//alert(window.opener.document.forms[0].PassDateType.value);
	window.opener.document.forms[0].gradschoolattendedTxBx.value = name;
	parent.close();
}

function OpenWindow2()
{
	Win = window.open("selectauniversity3.asp","Win","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,WIDTH=758,HEIGHT=100");
        Win.location.href = "selectauniversity3.asp"
        if(navigator.appVersion.indexOf("4") != -1){
            Win.moveTo(300,250);
        }
}

function OpenWindow3()
{
	Win = window.open("selectauniversity4.asp","Win","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,WIDTH=758,HEIGHT=100");
        Win.location.href = "selectauniversity4.asp"
        if(navigator.appVersion.indexOf("4") != -1){
            Win.moveTo(300,250);
        }
}

function OpenWindow4()
{
	Win = window.open("selectauniversity5.asp","Win3","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,WIDTH=758,HEIGHT=100");
        Win.location.href = "selectauniversity5.asp"
        if(navigator.appVersion.indexOf("4") != -1){
            Win.moveTo(300,250);
        }
}

function OpenWindow5()
{
	Win = window.open("findabackofficemember.asp","Win2","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,WIDTH=645,HEIGHT=141");
        Win.location.href = "findabackofficemember.asp"
        if(navigator.appVersion.indexOf("4") != -1){
            Win.moveTo(300,250);
        }
}

function OpenWindow6()
{
	Win = window.open("selectauniversity6.asp","Win6","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,WIDTH=645,HEIGHT=165");
        Win.location.href = "selectauniversity6.asp"
        if(navigator.appVersion.indexOf("4") != -1){
            Win.moveTo(300,250);
        }
}
function OpenWindow8()
{
	Win = window.open("selectauniversity8.asp","Win8","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,WIDTH=645,HEIGHT=165");
        Win.location.href = "selectauniversity8.asp"
        if(navigator.appVersion.indexOf("4") != -1){
            Win.moveTo(300,250);
        }
}

//new function BAR

function OpenLookupWindow(pageURL, winW, winH){
	var popWin = null;
	pageURL = "" + pageURL
	if(pageURL == 'undefined')
		pageURL = "http://"+serverName
	
	if(!popWin || popWin.closed){
		popWin = window.open(pageURL,'lookupWin','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width='+winW+',height='+winH);
	}
	popWin.focus();
}

function checkTextCount(fieldname, leftfieldname, count) {
		if (fieldname.value.length > count) {
		
			fieldname.value = fieldname.value.substring(0, count);
			
		} else {
		
			leftfieldname.value = count - fieldname.value.length;
			
		}
	}
function content(url){
	fontwin = window.open(url,"", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,WIDTH=470,HEIGHT=320")
        if(navigator.appVersion.indexOf("4") != -1){
            fontwin.moveTo(0,0);
        }
	fontwin.moveTo(0,0);
}
function poll(){
	pollWin = window.open("poll.asp","pollWin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,WIDTH=500,HEIGHT=300");
        pollWin.location.href = "poll.asp"
        if(navigator.appVersion.indexOf("4") != -1){
            pollWin.moveTo(300,250);
        }
}
function statustextin(txt){ 
	self.status = txt 
} 
function statustextout(){
	self.status = "" 
}


/*
The leftTrim JavaScript function takes one parameter, which is the string that needs to be trimmed. 
The function then loops through each of the characters of this string, starting with the first one. 
If the current character in the loop is a single white space “ “, the function removes it from the 
string and continues with the loop. The loop goes on until it finds character, which is different 
than a single white space or until it reaches the end of the string. After the function exits the 
loop, it returns the left trimmed string.

The rightTrim() JavaScript function works in exactly the same way, except that it trims the white 
spaces at the end of the string:
*/
function leftTrim(sString) {
	while (sString.substring(0,1) == ' '){
		sString = sString.substring(1, sString.length);
		}
	return sString;
}

function rightTrim(sString) {
	while (sString.substring(sString.length-1, sString.length) == ' '){
		sString = sString.substring(0,sString.length-1);
		}
	return sString;
}

/*
  forms need to look like the following: <form method="POST" onSubmit="return verifyLastNameIDFields(this.Last_Name.value, this.MembershipIDTxBx.value)">
*/
function verifyLastNameIDFields(lnVal, idVal){
	lnValTrim=leftTrim(lnVal);
	idValTrim=leftTrim(idVal);
	if((lnValTrim=="" && idValTrim=="") || (lnValTrim.length < 3 && idValTrim.length < 4)){
		alert("Please enter a last name or ID to search by");
		return false;
		}
	
	return true;	
	
}


