		var tmpFrm = document.securityForm;
		function secureOpen(param1, param2, param3, param4, param5)
		{
			if(param3 == 0)
			{
				ftnDoLogin(1);
				return false;
			}

			if(param2 == 0)
			{
				ftnDoLogin(2);
				return false;
			}

			var szURL = "http://www.aaae.org/_templates/OpenDoc.cfm?param1=" + param1 + "&param2=" + param2 + "&param3=" + param3 + "&param4=" + param4 + "&param5=" + param5;
			window.open(szURL,'PopUp','toolbar=no,title=AAAE,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
			return true;
		}

		function ftnDoLogin(param1)
		{
			if(param1 == 1)
			{
				if(window.confirm("The document or area you requested, requires you to Login.\n     - Click OK to go to the login page.\n     - Click Cancel to abort request."))
					location.href="http://www.aaae.org/restricted_members.html";
			}
			else
			{
				//if(window.confirm("The document or area you requested, requires you to Login.\n     - Click OK to go to the login page.\n     - Click Cancel to abort request."))
				location.href="http://www.aaae.org/restricted_users.html";
			}
			return true;
		}


function OrgSearchPopUp()
{	
	var f = document.forms.mbrprofile;
	var Url
	var SearchType
	alert('wheres the popup?')
	Url = 'OrgSearch.cfm?Do=Search'//+'&Type='+SearchType
	var strFeatures="toolbar=yes,status=no,menubar=yes,location=yes"
	strFeatures=strFeatures+",scrollbars=yes,resizable=yes,height=550,width=600"
	
	newWin = window.open(Url,"TellObj",strFeatures);
	   newWin.opener = top;
}
	
function DontWannaLookForCompany()
{
		
	var CompanyAddress 
	var NoParentMbrID;
	var NoParentMType;
	
	var f = document.forms.AddUser;
	
	NoParentMbrID = '000000';
	NoParentType = 'C';
	NoParentMType = 'NP';
	
	 ParentID = NoParentMbrID;
	 f.hdnOrgMbrID.value = NoParentMbrID
	 f.hdnParentID.value = NoParentMbrID
	 f.hdnParentMType.value = NoParentMType
	 f.hdnParentType.value = NoParentType
	 f.OrgName.value = 'N/A'
	 f.title.focus();
	

}


function PossibleMemberChk()
{
		var f = document.forms.PossibleMbr;
		var MemberID = f.MemberID.value
		var ZipCode = f.ZipCode.value
		
		var ErrColor = "#FF0000";
		var NonErrColor = "#3959A5";		
		
		//-----------------------------------------------------
		//Reset any errors that might be all ready highlighted.
		//-----------------------------------------------------
		MbrIDErr.style.color = NonErrColor;	
		ZipCodeErr.style.color = NonErrColor;
		
		if (isWhitespace(MemberID) && isWhitespace(ZipCode))
		{
		alert('Please supply your Member ID and/or Zip Code.');
		MbrIDErr.style.color = ErrColor;	
		ZipCodeErr.style.color = ErrColor;
		return false;
		}
		else
		{
			f.action = 'MPHome.cfm?do=CheckVisitorAgainstAMIS';
			f.submit();
			return true;
		}
}

	function validatePO()
	{
		var f = document.forms.CheckOut;
		var POnbr = f.PONbr.value;
		
		if (POnbr == '')
			{
				alert('Purchase Order Number required.');
				f.PONbr.focus();
				szForm.ProcessBtn.disabled = false;
				return false;
			}
		else
			{
			f.action = 'MPHome.cfm?do=ProcessOrder'
			f.submit();
			return true;					
			}
		
	}
	
	function ProcessPOCC()
	{
		//Process Purchase Order or Credit Card

		var f = document.forms.CheckOut;

		//Disable the Process button to prevent double clicking.
		f.ProcessBtn.disabled = true;

		var POnbr = f.PONbr.value;
		
		var cardNumber = trim(f.CCNbr.value);
		var cardType = trim(f.CCType.value);
		var cardMonth = trim(f.CCExpMo.value);
		var cardYear = trim(f.CCExpYr.value);
		var EmailAddr = trim(f.PayeeEmail.value);	
		var cardData = ''
		cardData = cardNumber+cardType+cardMonth+cardYear;
		
		if (!isWhitespace(POnbr) && !isWhitespace(cardData) )
			{
			alert('Please pay by Credit Card OR Purchase Order Number.');
			f.PONbr.focus();
			f.ProcessBtn.disabled = false;
			return false;
			}
		else
			if (isWhitespace(POnbr) && isWhitespace(cardData) )
			{
			alert('Please indicate a method of Payment');
			f.ProcessBtn.disabled = false;

			return false;
			}
				else
				if (!isWhitespace(POnbr))
				{
				validatePO();
				return false;
				}
				else
				{
				validateCard();
				}
		
	}
	

function ReceiptPopUp()
{	

	var Url

	Url = 'MyReceipt.htm?Do=Search'//+'&Type='+SearchType
	var strFeatures="toolbar=yes,status=no,menubar=yes,location=yes"
	strFeatures=strFeatures+",scrollbars=yes,resizable=yes,height=320,width=600"
	
	newWin = window.open(Url,"TellObj",strFeatures);
	   newWin.opener = top;
}

// Setfocus to the next field after maxlength of 'n' characters
function nextField(element, element2, n) 
{
var strSeperator = '-';
if (element.value.length == n) {
		element2.focus();
	}
}

function NumericCheck()
{
	if (event.keyCode < 48 || event.keyCode > 57) 
	{
		if (event.keyCode != 45 && event.keyCode != 46) 
			event.returnValue = false;		
	}
}

function toggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

function toggleDfltAddr(obj) {

	
	if (obj == 'W')
	{
		document.getElementById('W').style.display = "";
		document.getElementById('H').style.display = "none";
		document.getElementById('A').style.display = "none";

	}
	if (obj == 'H')
	{
		document.getElementById('H').style.display = "";
		document.getElementById('W').style.display = "none";
		document.getElementById('A').style.display = "none";

	}
	if (obj == 'A')
	{
		document.getElementById('A').style.display = "";
		document.getElementById('H').style.display = "none";
		document.getElementById('W').style.display = "none";

	}
	
	
}

function AlphaCheck_Mbr()
{
	if (event.keyCode != 46 && event.keyCode != 32 && event.keyCode < 65 || event.keyCode > 90 
		&& event.keyCode < 97 || event.keyCode > 122 ) 
		event.returnValue = false;
}


function setNickName_Mbr(element, setElement)
{
	//changeCase(element, szForm.cbManualOverwrite.checked);	
	setElement.value = element.value;
}

function isDefined(field)
{
        if(typeof(field) !="undefined")
                return true;
        else
                return false;
}

function ExpDatePopulate2(Date1, Date2)
{
	var szOddMtArr = "01,03,05,07,08,10,12";	
	var szEvenMtArr = "04,06,09,11";
	var szInvalidDt = 0;

	if (szInvalidDt == 0 && Date1.value.length != 0)
	{
		var szDD, szMM, szYY;
		var szForm = document.MembershipApp;
		var szEvenDD = '30';
		var szOddDD = '31';
		var szFebDD = '28';
		szJoinDt = 	Date1.value;
		if(szJoinDt.length <= 0)
			return false;

		var szJDtArr = szJoinDt.split("/");
		szDD = szJDtArr[1];
		szMM = szJDtArr[0] - 1;
		szYY = parseInt(szJDtArr[2]);					
		if(szMM == 0)
		{
			szMM = 12;
			szDD  = 31;
			szYY  = szYY;
		}
		else
			szYY = parseInt(szYY) + 1;
		szMM = Ftn_GetNumFormated(szMM, 2);
		
		/* Check for leap year */
		var szLeapYY = szYY/4;
		szLeapYY = szLeapYY.toString();
		
		if (szLeapYY.indexOf('.') == -1)
			szLeapYY = 1;
		else
			szLeapYY = 0;		

		/*If the month in Join Dt is Feb - 
		populate expdate as 29 if the year is leap year*/
		if (szMM == '02')
			if (szLeapYY == 1)
				szDD = '29';
			else
				szDD = '28'; 	
		/* If the month in Join Dt is in the list "01,03,05,07,08,10,12" 
		populate expDate as 30*/
		else if (szOddMtArr.indexOf(szMM) == -1)
			szDD = szEvenDD;						
		/* If the month in Join Dt is "04,06,09,11" 
		populate expDate as 31*/
		else
			szDD = szOddDD;
		
		szExpDate = szMM + '/' + szDD + '/' + szYY;
		if(Date2 == '')
			return szExpDate
		else
			Date2.value = szExpDate;
	}
	else
		Date2.value = '';			
		
	szInvalidDt = 0;		
}

	function Ftn_GetNumFormated(iNum, iDigitsReq)
	{
		iNum = iNum.toString();
		if(iNum.length > 0)
		{
			iNumLen = iNum.length;
			if(iDigitsReq == iNumLen)
			{
				return iNum;
			}
			else
			{
				iLenToFill = iDigitsReq - iNumLen;
				iTmp = iNum;
				for(i=1; i<= iLenToFill;i++)
				{
					iTmp = '0' + iTmp.toString();
				}
				return iTmp;
			}
		}
	}


function ViewCart()
{
		location.href='MPHome.cfm?do=Cart&action=view';
}

function AddToCart(Module,SubModule)
{
		location.href='MPHome.cfm?do=Cart&action=Add&Module='+Module+'&SubModule='+SubModule;
}


function CheckOut(NonMtgInd,Url)
{
		location.href=Url;
}



function CheckOutOld(NonMtgInd,Url)
{
	if (NonMtgInd==1)
		{
		CheckOutMsg=confirm(" Notice:\n There are non-Meeting related items in your cart.\n Only meetings related items can be paid by PO.\n As such you must: \n\n (a) Remove the non-meetings items if paying by PO\n OR \n (b) pay via credit card upon checkout.\n\n\n click OK to continue to checkout\n click CANCEL to stay here and remove the non-meeting items from your cart if paying by PO.");
		if (CheckOutMsg==true)
		
			{
				location.href=Url;
			}
		else
			return false;
		}
	else
		{
			location.href=Url;
		}
}

function RemoveCartItem(Module,SubModule, cartIndex)
{
	if (Module == 'mbrDues' &&  SubModule == 'mbrShipApplication')
		{
		DelMbrShipApp=confirm("Warning:\n\n Removing your Membership Application will also\n\n remove any existing meeting/event registrations that may be in your cart\n\nClick OK to Remove Membership Application");
	
		if (DelMbrShipApp==true)
			
			{
				goTo = 'MPHome.cfm?do=Cart&action=RemoveItem&Module='+Module+'&cartIndex='+cartIndex;
				if (!isWhitespace(SubModule))
					{
					goTo = goTo+'&SubModule='+SubModule
					}
				else
					{
					goTo = goTo+'&SubModule=x'
					}
				location.href=goTo;
			}
		
		else
			{ 
			alert ("Membership Application removal canceled."); 
			}
		}
	else
	
		{
		RemoveCartITem=confirm("Remove this item from your cart?\n\nClick OK to Remove this item.");
	
		if (RemoveCartITem==true)
		
			{
			if (Module == 'RegMtg')
				{
				goTo = 'MPHome.cfm?do=Cart&action=RemoveMtg&Module='+SubModule+'&cartIndex='+cartIndex;
				location.href=goTo;
				}

			else if (Module == 'RegEvt')
				{
				goTo = 'MPHome.cfm?do=Cart&action=RemoveEvent&SubModule='+SubModule+'&cartIndex='+cartIndex;
				location.href=goTo;
				}
			else if (Module == 'Spouse')
				{
				goTo = 'MPHome.cfm?do=Cart&action=RemoveItem&Module='+Module+'&MbrID='+cartIndex;
				location.href=goTo;
				}
			else
				{
				goTo = 'MPHome.cfm?do=Cart&action=RemoveItem&Module='+Module+'&SubModule='+SubModule+'&cartIndex='+cartIndex;
				location.href=goTo;
				}
			/*
			if (Module == 'PROFDEV')
				{
				goTo = 'MPHome.cfm?do=Cart&action=RemoveItem&Module='+Module+'&SubModule='+SubModule;
				location.href=goTo;
				}
			if (Module == 'Publication')
				{
				goTo = 'MPHome.cfm?do=Cart&action=RemoveItem&Module='+Module+'&SubModule='+SubModule;
				location.href=goTo;
				}
			if (Module == 'INVOICETOPAY')
				{
				goTo = 'MPHome.cfm?do=Cart&action=RemoveItem&Module='+Module+'&SubModule='+SubModule;
				location.href=goTo;
				}
			if (Module == 'Spouse')
				{
				alert('Removing Spose...');
				goTo = 'MPHome.cfm?do=Cart&action=RemoveItem&Module='+Module;
				location.href=goTo;
				}
			*/	
			}
		
		else
			{ 
			alert ("Removal canceled."); 
			}

			
		}
		
		
		
		

}


function RemoveSpouseFromCartTest(SpouseMbrID)
{
		goTo = 'MPHome.cfm?do=Cart&action=RemoveSpouse&SpouseMbrID='+SpouseMbrID;
		location.href=goTo;
}


function RemoveSpouseFromCart()
{
		alert('Hey...');
		return false;
		//goTo = 'MPHome.cfm?do=Cart&action=RemoveSpouse&SpouseMbrID='+SpouseMbrID;
		
		//location.href=goTo;
}


function ProcessOrder()
{
		alert('Processing Order...');
		var f = document.forms.CheckOut;
		f.action = 'MPHome.cfm?do=ProcessOrder'
		f.submit();
		return true;
}


/* Validate the State entered */
function ValidateState(szCntry, szState, szZip, szAllStates)
{
	
	alert('In ValidateState...')
	alert(szCntry);
	alert(szState);
	alert(szZip);
	alert(szAllStates);

	var iStateOK = 0;
	if (szCntry.value != 'USAX' && szCntry.value != 'US')
	{
		if (szState.value != '')		
		{
			var szAllStates = eval(szAllStates);
			var szStateValue = szState.value.toUpperCase();
			var arStatesList = szAllStates.value.split(",");

		  	for (var iCnt = 0; iCnt < arStatesList.length; iCnt++)
			{
			 	if(arStatesList[iCnt] == szStateValue) 
				{
					szState.value = szStateValue;
					iStateOK = 1;		
			 		break;
				}
			}

			if(iStateOK == 0)
			{
				alert(szStateValue + ' is not a valid State Code in the United States.\n\nProvide a valid 2-character State code.');
				szState.value = '';
				szState.focus();
				return false;
			}
		}

//		Ftn_zipCall(szZip, szCntry);
	}

//	Ftn_regionCall(szCntry, szState, szAllStates); -- for future use?
	return true;
}	

function Ftn_zipCall(szZipObj, szCntryObj)
{
	alert('In Ftn_zipCall...');
	if(trim(szZipObj.value) != '')
	{
		if (!Ftn_zipCheck(szZipObj.value,szCntryObj.value))
		{
			alert("Invalid Zip Code value/format.\n  - Valid format for US: 12345 or 12345-1234.\n\nClick OK to Continue.");
			if (szZipObj.disabled == false && szZipObj.readOnly == false && szZipObj.type != 'hidden')
			{
				szZipObj.select();
				szZipObj.focus();
			}
			return(false);
		}
	}
	return true;
}

function Ftn_zipCheck(iZip,szCntry)
{
		alert('In Ftn_zipCheck...');
	if((szCntry == 'US') || (szCntry =='USA'))
	{
		var zipStr = /^(\d{5}||\d{5}-\d{4})$/;	//build a RegExp string
		if (!zipStr.test(iZip)) 
			return false;
	}
	return true;
}

function isWhitespace(s)
{
	var whitespace = " \t\n\r";				
	var i;
   	if (isEmpty(s)) return true;
    	for (i = 0; i < s.length; i++)
		{   
			var c = s.charAt(i);
			if (whitespace.indexOf(c) == -1) return false;
	    }
   	return true;
}

function isEmpty(s)
{
	return ((s == null) || (s.length == 0))
}

function isDefined(field)
{
        if(typeof(field) !="undefined")
                return true;
        else
                return false;
}


function isValidURL(url){ 
    //var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/; 
 	var RegExp = /[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;
 
    if(RegExp.test(url)){ 
        return true; 
    }else{ 
        return false; 
    } 
}

function elementMask(element, n) 
{
var strSeperator = '-';	
if (element.value.length == n) {
	element.value= element.value+strSeperator;
	}
}

function trim(str) {     if (str != null) {        var i;         for (i=0; i<str.length; i++) {            if (str.charAt(i)!=" ") {                str=str.substring(i,str.length);                 break;            }         }             for (i=str.length-1; i>=0; i--) {            if (str.charAt(i)!=" ") {                str=str.substring(0,i+1);                 break;            }         }                 if (str.charAt(0)==" ") {            return "";         } else {            return str;         }    }}

