function showProjectFeature(index){
	$('fpTitleDiv').innerHTML = '<a href='+projectFeatures[index][3]+'>'+projectFeatures[index][0]+'</a>';
	$('fpBoxTextDiv').innerHTML = '<p>' + projectFeatures[index][2] + '</p>';
	$('fpWYSIWYGDiv').innerHTML = projectFeatures[index][1];
}

function hideSubMenus() {
	var el=document.getElementById("menu").getElementsByTagName("li");
	for (i=0; i<el.length; i++) {
		el[i].className = "hide";
		el[i].onmouseover = function() {
			this.className = "show";
		}
		el[i].onmouseout = function() {
		this.className = "hide";
		}	
	}
}

function hideVerticalMenus() {
	var el=document.getElementById("vertical").getElementsByTagName("li");
	for (i=0; i<el.length; i++) {
		el[i].className = "hide";
		el[i].onmouseover = function() {
		  this.style.zIndex="3";
		  this.className = "show";
		}
		  
		el[i].onmouseout = function() {
		this.className = "hide";
		}
	}
}

var numOfFeatures = 5;
var featureArray = new Array();
var timeObj;
var gCount = 0;

function callThisOnLoad(isFeature, currentPage, memberId){
	s.pageName = currentPage;
	if( memberId != '' ){
		s.prop12 = memberId;
		s.prop16 = "logged in";
	} else{
		s.prop16 = "not logged in";
	}
	s.prop21 = Date();

	var s_code=s.t();if(s_code)document.write(s_code);

	hideSubMenus();
	hideVerticalMenus();
	//init();
	if( isFeature == 'true'){
		var featureString;
		for( i=0; i<numOfFeatures; i++ ){
			featureString = 'feature'+i;
			featureArray[i] = $(featureString).innerHTML;
			$(featureString).setStyle('display', 'none');
		}
		playDivs(0);
	}
}

function showDiv(pos, auto){
	if( !auto ){
		clearTimeout(timeObj);
	}
	$('featureBlock').innerHTML = featureArray[pos];
}

function playDivs(cnt){
	if(cnt >= numOfFeatures){
		cnt = 0;
	}
	gCount = cnt;
	showDiv(cnt, true);
	cnt++;
	timeObj=setTimeout("playDivs("+cnt+")",15000);
}

function pauseFeature(){
	clearTimeout(timeObj);
}

function resumeFeature(){
	playDivs(gCount);
}

function skipDiv(){
	clearTimeout(timeObj);
	gCount = gCount + 1;
	playDivs(gCount);
}

function clickFeature(){
	$('ftd1').setStyle('bgColor', '#000');
}

/* Methods in Registration pages */
var currentValue = '';
function controlOnFocus(othis, defaultText){
	if( othis.value == '' || othis.value == defaultText){
		currentValue = othis.value;
		othis.value = '';
	}
}

function controlOnBlur(othis){
	if( othis.value == '' ){
		//othis.value = currentValue;
	}
}

function toggleOther(othis,oPrefix, pos){
	if( othis.selectedIndex == pos ){
		if( oPrefix.disabled ){
			oPrefix.disabled = false;
		}
	} else{
		if( !oPrefix.disabled ){
			oPrefix.disabled = true;
		}
	}
}

function submitRegistration(pubType){	
	var userName = document.frmAccount.txtUserName.value;
	var userName1 = document.frmAccount.txtUserName1.value;
	var fName = document.frmAccount.txtFName.value;
	var mi = document.frmAccount.txtMI.value;
	var lName = document.frmAccount.txtLName.value;
	var zip = document.frmAccount.txtZIP1.value;
	var pwd = document.frmAccount.txtPwd.value;
	var cPwd = document.frmAccount.txtConfPwd.value;
/*	var cCode = document.frmAccount.captcha_code.value; */

/*	if( userName != '' && fName != '' && lName != '' && zip != '' && pwd != '' && cPwd != '' && cCode != '' ){ */
 	if (userName != userName1) {
 		alert("The e-mail addresses in both the username and e-mail confirmation fields have to match.");
 		return false;
 	}
	if( userName != '' && fName != '' && lName != '' && zip != '' && pwd != '' && cPwd != '' ){
		if( pwd == cPwd ){
			if( pwd.length < 7 ){
				alert("Password length should be between 7 and 12");
			} else{
				if( emailValidator(userName, "Please enter a valid Email address") ){
					if( notEmpty(fName, "Please enter First name") ){
						if( mi == '' || isAlphabet(mi, "Middle Initial should be an alphabet") ){
							if( notEmpty(lName, "Please enter Last name") ){
								if(( isZipCode(zip, "Please enter a valid zip code") ) && (zip != '')){
									if( isAlphanumeric(pwd, "Password should be Alpha Numeric") ){
										if( isAlphanumeric(cPwd, "Password should be Alpha Numeric") ){
											if( pubType == 'Events' || pubType == 'cart' || pubType == 'donation' ||  pubType == 'associate' ){
												var org = document.frmAccount.txtOrg.value;
												var job = document.frmAccount.txtJob.value;
												wSector = document.frmAccount.cmbWSector.selectedIndex;
												var phone1 = document.frmAccount.txtPhone.value;
												var add1 = document.frmAccount.txtAdd1.value;
												var city = document.frmAccount.txtCity.value;
												var state = 'STATE';//dummy value which is not ''
												var cCou1 = document.frmAccount.txtCou1.value;
												if (cCou1 != 'United States')
													state = document.frmAccount.txtState.value;
												else
													state = document.frmAccount.txtState1.value;
												relationship = document.frmAccount.cmbRelation.selectedIndex;
												phone1=phone1.replace(/\ /g,"");
												phone1=phone1.replace(/\(/g,"");
												phone1=phone1.replace(/\)/g,"");
												phone1=phone1.replace(/\+/g,"");
												phone1=phone1.replace(/\-/g,"");
												if (cCou1 != 'United States')
												{
													if( trim(phone1) != '' && trim(add1) != '' && trim(city) != '' ){
														if( isNumeric(phone1, "Please enter only numerics for Phone number") ){
															return true;
														}
													} else{
														alert("Fields marked with * are mandatory");
													}
												}
												else
												{
													if( trim(phone1) != '' && trim(add1) != '' && trim(city) != '' && trim(state) != '' ){
														if( isNumeric(phone1, "Please enter only numerics for Phone number") ){
															return true;
														}
													} else{
														alert("Fields marked with * are mandatory");
													}
												}
											} else{					
												return true;
											}
										}
									}
								}
							}
						}
					}
				}
			}
		} else{
			alert("Password and Confirm Password should be same");
		}
	} else{
		alert("Fields marked with * are mandatory");
	}
	return false;
}

function submitDetailedRegistration()
{
	var cPAd1 = document.frmDetAccount.txtPAd1.value;
	var cCty1 = document.frmDetAccount.txtCty1.value;
	var cCou1 = document.frmDetAccount.txtCou1.value;
	if (cCou1 != 'United States')
		var st1 = document.frmDetAccount.txtState.value;
	else
		var st1 = document.frmDetAccount.txtState1.value;
	var zip1 = document.frmDetAccount.txtZIP1.value;
	var phone1 = document.frmDetAccount.txtPN1.value;
	var pt1 = document.frmDetAccount.PhoneTyp1.value;

	phone1=phone1.replace(/\ /g,"");
	phone1=phone1.replace(/\(/g,"");
	phone1=phone1.replace(/\)/g,"");
	phone1=phone1.replace(/\+/g,"");
	phone1=phone1.replace(/\-/g,"");

	if (cCou1 != 'United States')
	{
		if( cPAd1 == '' || cCty1 == '')
		{
			alert("Please fill out your address and city to complete your registration.");
		}
		else
		{
			if ((cPAd1 == '') || (notEmpty((trim(cPAd1)), "Please enter a your address"))){
				if (isAlphanumeric((trim(phone1)), "Please enter a valid phone number")){
					if (notEmpty((trim(cPAd1)), "Please enter your Address")){
						if(isZipCode(zip1, "Please enter a valid zip code")){
							document.frmDetAccount.submit();
						}
					}
				}
			}
		}
	}
	else
	{
		if( zip1 == '' || cPAd1 == '' || cCty1 == '' || st1 == '')
		{
			alert("Please fill out all the required fields marked with an asterisk (*) to complete your registration.");
		}
		else
		{
			if ((cPAd1 == '') || (notEmpty((trim(cPAd1)), "Please enter a your address"))){
				if (isAlphanumeric((trim(phone1)), "Please enter a valid phone number")){
					if (notEmpty((trim(cPAd1)), "Please enter your Address")){
						if (notEmpty(zip1, "Please enter a zip code")){
							if(madeSelection(st1, "Please Choose a State")){
								if ( cCou1 == 'United States' ){
									if( zip1.length == 5 ){
										document.frmDetAccount.submit();
									}
									else
									{
										alert("Please enter a valid zip code");
									}
								} else{
									document.frmDetAccount.submit();
								}		
							}
						}
					}
				}
			}
		}
	}
}

function submitUserPromoCode()
{
	document.frmUserPromoCode.submit();
}

function get_radio_value(fldNm)
{
alert("got |"+fldNm+"|");
a = fldNm.length;
alert("---->|"+a+"|");
	for (var i=0; i < fldNm.length; i++)
	{
		if (fldNm[i].checked)
		{
			var rad_val = fldNm[i].value;
		}
	}
alert("return |"+rad_val+"|");
	return rad_val;
}


function submitUserMailRegistration(othis)
{
	document.frmDetMailAccount.submit();
}

function submitUserInterestRegistration(othis)
{
	document.frmDetInterestAccount.submit();
}
/* end of methods in Registration pages */

function printBlurb(base){
	//alert("HI");
/*
	var html = '<head><base href="' + base + '" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>';
	html = html + '<link rel="stylesheet" type="text/css" href="views/styles/print.css"/>';
	html = html + '<body><div class="bgTop"><img src="views/images/common/bodybgTop.gif" border="0" /></div><div class="bgLeft"><img src="views/images/common/bodybgLeft.gif" border="0" /></div>';
	html = html + '<div style="float:left"><table border="0" cellpadding="0" cellspacing="0" width="948px"><tr><td width="100%">';
	html = html + $('printBlurb').innerHTML;
	html = html + '</td></tr></table></div>';
	html = html + '<div class="bgRight"><img src="views/images/common/bodybgRight.gif" border="0" /></div>';
	html = html + '	<div class="footerPart"><div class="footerLinks1 footer">HOME | ABOUT AEI | REGISTER | MANAGE PROFILE | CONTACT | SEARCH</div><div class="footerLinks2 footer footerAddress">The American Enterprise Institute | 1150 Seventeenth Street, N.W | Washington, DC 20036</div></div>';
	html = html + '</body>';
*/
//	alert("HI");
	var html = '<head><base href="' + base + '" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>';
	html = html + '<link rel="stylesheet" type="text/css" href="views/styles/print.css"/>';
	html = html + '<body><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="3" valign="top"><img src="views/images/common/bodybgTop.gif" border="0" /></td></tr><tr><td valign="top" align="left"><img src="views/images/common/bodybgLeft.gif" border="0" /></td>';
	html = html + '<td align="left" width="938px" style="padding-left:10px;">';
	html = html + $('printBlurb').innerHTML;
	html = html + '</td><td align="left" valign="top">';
	html = html + '<img src="views/images/common/bodybgRight.gif" border="0" /></td></tr><tr><td colspan="3">&nbsp;</td></tr><tr><td colspan="3">&nbsp;</td></tr><tr><td colspan="3">';
	html = html + '<img src="views/images/common/foot-ribbon.gif" border="0" /></td></tr>';
	html = html + '</table></body>';

	myWindow = window.open('','Testing');
	myWindow.document.write(html);
	myWindow.focus();
	//myWindow.window.print();
}

/*address book */

var chkFormElements = new Array();
var chkFormCounter = 0;
var hackCnt = 0;

function registerChk(chkBoxId){

	try{

		othis = document.getElementById(chkBoxId);
		
		/*if( hackCnt == 0 ){
			alert("Select contact(s) to send email");
			hackCnt++;
		}*/	

		if( othis.checked ){
			chkFormElements[chkFormCounter] = othis;
			chkFormCounter++;
		}
	} catch(e){
		//alert(e);
	}

}

function showHide(elementid){
	
	if (document.getElementById(elementid).style.display == 'none'){
		document.getElementById(elementid).style.display = '';
	} else {
		document.getElementById(elementid).style.display = 'none';
	}

} 

function  cancelAll(othis){
	othis.checkBoxChecked.value = '';

	if(othis.emailEntered.value != '')
	{
		othis.checkBoxChecked.value = othis.emailEntered.value;
	}
	for( var j = 0; j < chkFormElements.length; j++ ){
		if( chkFormElements[j].checked ){
			if(othis.checkBoxChecked.value !='')
			{
					othis.checkBoxChecked.value = othis.checkBoxChecked.value +','+ chkFormElements[j].value;
			}else{
					othis.checkBoxChecked.value = othis.checkBoxChecked.value + chkFormElements[j].value;
			}
			if( j < (chkFormElements.length-1) ){
				othis.checkBoxChecked.value = othis.checkBoxChecked.value + ',';
			}
		}
	}
	//window.close();

	/*for( var j = 0; j < chkFormElements.length; j++ ){
		if( chkFormElements[j].checked ){
			chkFormElements[j].checked = false;
		}
	}

	chkFormElements = new Array();
	chkFormCounter = 0;*/

}

function submitDelete(formname)
{
	var form = document.forms[formname];
	var submitButton = form.getElementById('submitButton');
	submitButton.value='Delete';
	form.submit();
}

function submitSave(formname, othis)
{
	var emailAddr = $(formname).txtUserEmailAddr.value;
	var fName = $(formname).txtUserFirstName.value;
	var lName = $(formname).txtUserLastName.value;

	emailAddr= LTrim(emailAddr);
	fName = LTrim(fName);
	lName =  LTrim(lName);




	if( emailAddr != '' && fName != '' && lName != ''){
		
				if( emailValidator(emailAddr, "Please enter an valid EMail") )
					{
						if( notEmpty(fName, "Please enter First name") )
							{
							
								if( notEmpty(lName, "Please enter Last names") )
										{
																									
										}else{
													$(formname).txtUserLastName.focus();
													return false;	
												}					
							}else{
									$(formname).txtUserFirstName.focus();
									return false;	
								}
							
					}else{
							$(formname).txtUserEmailAddr.focus();
							return false;	
						}
			
		 
	}else{
		alert("All fields are mandatory");
		$(formname).txtUserFirstName.focus();
		return false;

	}
	
	/*try{
		othis.submit();
	} catch(e){
		//alert(e);
	}*/
}

function submitContactList()
{
	document.forms[contactListForm].submit();
}

function submitEmailContactList()
{
	document.getElementById('emailEntered').value=document.getElementById('taEmails').value;
	document.emailContactListForm.submit();
}


function submitCheckBox(othis)
{
	
	othis.checkBoxChecked.value = '';

	if(othis.emailEntered.value != '')
	{
		othis.checkBoxChecked.value = othis.emailEntered.value;
	}
	for( var j = 0; j < chkFormElements.length; j++ ){
		if( chkFormElements[j].checked ){
			if(othis.checkBoxChecked.value !='')
			{
					othis.checkBoxChecked.value = othis.checkBoxChecked.value +','+ chkFormElements[j].value;
			}else{
					othis.checkBoxChecked.value = othis.checkBoxChecked.value + chkFormElements[j].value;
					
			}
			//if( j < (chkFormElements.length-1) ){
			//	othis.checkBoxChecked.value = othis.checkBoxChecked.value + ',';
			//}
		}
	}
	
	if( othis.checkBoxChecked.value == '' ){
		alert("Please select a contact or Cancel this operation.");
		return false;
	}
}

/* The below functions helps to disable 'DONE' if no checkboxes selected 
var checks=[];
getBoxes();
function getBoxes() {
	alert("dfdf");
  var form = document.forms['checkBoxForm'];
  alert(form);
  var inputs = form.getElementsByTagName("input");
  
  for (var i = 0, len = inputs.length; i < len; i++) {
    if (inputs[i].type == "checkbox") chks.push(inputs[i]);
	inputs[i].onclick = checkBoxes;

  }
}

function checkBoxes() {
  for (var i = 0, len = chks.length; i < len; i++) {
    if (!chks[i].checked) {
  	  document.getElementById("submitBtn").disabled = true;	  
	  return;
	}
  }
}*/

function validateAddSmartURL(othis){
	oldUrl = othis.txtOld.value;
	newUrl = othis.txtNew.value;

	if( oldUrl != '' && newUrl != ''){
		if( oldUrl == newUrl ){
			alert("Old and New URLs can't be same");
			return false;
		} else{
			othis.submit();
		}
	} else{
		alert("Please enter Old/New URL");
		return false;
	}
}
function showHideAdminDiv(elementid, imgIdPosition){
	if (document.getElementById(elementid).style.display == 'none'){
		document.getElementById(elementid).style.display = '';
		document.getElementById('arrowElement'+imgIdPosition).src = 'views/images/admin/arrow.png';
	} else {
		document.getElementById(elementid).style.display = 'none';
		document.getElementById('arrowElement'+imgIdPosition).src = 'views/images/admin/arrowCollpase.png';
	}
}
function deleteCheckValidate(){
	isChecked = deleteCheckValidateRoutine(document.frmEditSmartURL);
	if( !isChecked ){
		alert("Please select any Smart URL record(s) to Update");
	} else{
		if( confirm("Are you sure to delete the selected record(s)?") ){
			return true;
		} else{
			return false;
		}
	}
	return false;
}
function deleteUserCheckValidate(){
	isChecked = deleteCheckValidateRoutine(document.frmEditPwdReset);
	if( !isChecked ){
		alert("Please select any User record(s) to Update");
	} else{
		if( confirm("Are you sure to delete the selected user(s)?") ){
			return true;
		} else{
			return false;
		}
	}
	return false;
}
function deleteCheckDiscountValidate(){
	isChecked = deleteCheckValidateRoutine(document.frmEditDiscount);
	if( !isChecked ){
		alert("Please select any Discount record(s) to Update");
	} else{
		if( confirm("Are you sure to delete the selected record(s)?") ){
			return true;
		} else{
			return false;
		}
	}
	return false;
}
function deleteCheckValidateRoutine(oform){
	numChk = 1;
	isChecked = false;
	numChk = oform.chkDelete.length;
	if( !(numChk > 1) ){
		if( oform.chkDelete.checked ){
			oform.hdnToDelete.value = oform.chkDelete.value + ',';
			isChecked = true;
		}		
	} else{
		for( i = 0; i < numChk; i++ ){
			if( oform.chkDelete[i].checked ){
				isChecked = true;
				oform.hdnToDelete.value = oform.hdnToDelete.value + oform.chkDelete[i].value + ',';
			}
		}
	}
	return isChecked;
}
function addUrlValidate(){
	if( document.frmCreateSmartURL.txtAddSmartUrl.value == '' || document.frmCreateSmartURL.txtAddSmartUrl.value == ' ' ){
		alert("Please enter Smart URL to be created");
		document.frmCreateSmartURL.txtAddSmartUrl.focus();
		return false;
	}
	if( document.frmCreateSmartURL.txtAddTargetUrl.value == '' || document.frmCreateSmartURL.txtAddTargetUrl.value == ' ' ){
		alert("Please enter Target URL before creating Smart URL");
		document.frmCreateSmartURL.txtAddTargetUrl.focus();
		return false;
	}
	return true;
}
function resetPwdValidate(){
	if( (document.frmCreatePwdReset.txtName.value).length == 0 ){
		alert("Please click on Reset Password link for the user whose password has to be reset.");
		document.frmCreatePwdReset.txtName.focus();
		return false;
	}
	newPwd = document.frmCreatePwdReset.txtNewPwd.value;
	confPwd = document.frmCreatePwdReset.txtConfNewPwd.value;
	if( newPwd.length == 0 ){
		alert("Please enter New Password");
		document.frmCreatePwdReset.txtNewPwd.focus();
		return false;
	}
	if( confPwd.length == 0 ){
		alert("Please enter Confirm Password");
		document.frmCreatePwdReset.txtConfNewPwd.focus();
		return false;
	}
	if( newPwd != confPwd ){
		alert("New Password and Confirm Password are not same");
		document.frmCreatePwdReset.txtConfNewPwd.focus();
		return false;
	}
	if( confirm("Are you sure to reset password for user '"+document.frmCreatePwdReset.txtName.value+"' ?") ){
		return true;
	}
	return false;
}
function loadResetControls(userId, name, org){
	document.frmCreatePwdReset.txtName.value = name;
	document.frmCreatePwdReset.txtOrg.value = org;
	document.frmCreatePwdReset.txtUserId.value = userId;
	alert("Please enter New Password");
	document.frmCreatePwdReset.txtNewPwd.focus();

}
function addDiscountValidate(){
	oform = document.frmCreateDiscount;
	if( trim(oform.txtDisCode.value) == '' ){
		alert("Please enter Discount code to be created");
		oform.txtDisCode.focus();
		return false;
	}
	if( trim(oform.txtDateFrom.value) == '' ){
		alert("Please enter start date for discount validity");
		oform.txtDateFrom.focus();
		return false;
	} else{
		//date format validation
	}
	if( trim(oform.txtDateTo.value) == '' ){
		alert("Please enter end date for discount validity");
		oform.txtDateTo.focus();
		return false;
	} else{
		//date format validation
	}
	if( trim(oform.txtDiscount.value) == '' ){
		alert("Please enter discount value");
		oform.txtDiscount.focus();
		return false;
	}
	if( oform.cmbBooks.selectedIndex == -1 ){
		alert("Please select a book to apply discount");
		oform.cmbBooks.focus();
		return false;
	}
	return true;
}
function addDisCollBooksValidate(){
	oform = document.frmCreateDisCollBooks;

	if( trim(oform.txtCBDisCode.value) == '' ){
		alert("Please enter Discount code to be created");
		oform.txtCBDisCode.focus();
		return false;
	}
	if( trim(oform.txtCBDateFrom.value) == '' ){
		alert("Please enter start date for discount validity");
		oform.txtCBDateFrom.focus();
		return false;
	} else{
		//date format validation
	}
	if( trim(oform.txtCBDateTo.value) == '' ){
		alert("Please enter end date for discount validity");
		oform.txtCBDateTo.focus();
		return false;
	} else{
		//date format validation
	}
	if( trim(oform.txtCBDiscount.value) == '' ){
		alert("Please enter discount value");
		oform.txtCBDiscount.focus();
		return false;
	}
	return true;
}
function addEventDiscountValidate(){
	oform = document.frmCreateEventDiscount;
	if( trim(oform.txtEDisCode.value) == '' ){
		alert("Please enter Discount code to be created");
		oform.txtEDisCode.focus();
		return false;
	}
	if( trim(oform.txtEDateFrom.value) == '' ){
		alert("Please enter start date for discount validity");
		oform.txtEDateFrom.focus();
		return false;
	} else{
		//date format validation
	}
	if( trim(oform.txtEDateTo.value) == '' ){
		alert("Please enter end date for discount validity");
		oform.txtEDateTo.focus();
		return false;
	} else{
		//date format validation
	}
	if( trim(oform.txtEDiscount.value) == '' ){
		alert("Please enter discount value");
		oform.txtEDiscount.focus();
		return false;
	}
	if( oform.cmbEvents.selectedIndex == -1 ){
		alert("Please select an event to apply discount");
		oform.cmbEvents.focus();
		return false;
	}
	return true;
}
function addSeriesDiscountValidate(){
	oform = document.frmCreateSeriesDiscount;
	if( trim(oform.txtSDisCode.value) == '' ){
		alert("Please enter Discount code to be created");
		oform.txtSDisCode.focus();
		return false;
	}
	if( trim(oform.txtSDateFrom.value) == '' ){
		alert("Please enter start date for discount validity");
		oform.txtSDateFrom.focus();
		return false;
	} else{
		//date format validation
	}
	if( trim(oform.txtSDateTo.value) == '' ){
		alert("Please enter end date for discount validity");
		oform.txtSDateTo.focus();
		return false;
	} else{
		//date format validation
	}
	if( trim(oform.txtSDiscount.value) == '' ){
		alert("Please enter discount value");
		oform.txtSDiscount.focus();
		return false;
	}
	if( oform.cmbSeries.selectedIndex == -1 ){
		alert("Please select an series to apply discount");
		oform.cmbSeries.focus();
		return false;
	}
	return true;
}
function searchUrlValidate(){
	if( document.frmSearchSmartURL.txtSeaSmartUrl.value == '' && document.frmSearchSmartURL.txtSeaTargetUrl.value == '' ){
		alert("Please enter either Smart/Target URL information to search");
		return false;
	}
	return true;
}
function searchUserValidate(){
	if( document.frmSearchPwdReset.txtSeaName.value == '' && document.frmSearchPwdReset.txtSeaUserId.value == '' ){
		alert("Please enter either User Name/Email information to search");
		return false;
	}
	return true;
}
function searchDiscountValidate(){
	if( document.frmSearchDiscount.txtSeaDisCode.value == '' && document.frmSearchDiscount.txtSeaDescription.value == '' ){
		alert("Please enter either Discount/Description information to search");
		return false;
	}
	return true;
}

function notSelect(elem, helperMsg){
	var numericExpression = /^[1-2]+$/;
	if(elem.match(numericExpression)){
		alert(helperMsg);
		return false;
	}
	return true;
}

function notEmpty(elem, helperMsg){
	if(elem.length == 0){
		alert(helperMsg);
		return false;
	}
	return true;
}

function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.match(numericExpression)){
		return true;
	}else{
		alert(helperMsg);
		return false;
	}
}

function isAlphabet(elem, helperMsg){
		var alphaExp = /^[a-zA-Z]+$/;

	var alphaExp = /^[a-zA-Z]+$/;
	if(elem.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		return false;
	}
}

function isAlphanumeric(elem, helperMsg){
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(elem.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		return false;
	}
}

function lengthRestriction(elem, min, max){
	var uInput = elem;
	if(uInput.length >= min && uInput.length <= max){
		return true;
	}else{
		alert("Please enter between " +min+ " and " +max+ " characters");
		return false;
	}
}

function madeSelection(elem, helperMsg){
	if(elem == "Please Choose"){
		alert(helperMsg);
		return false;
	}else{
		return true;
	}
}

function emailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.match(emailExp)){
		return true;
	}else{
		alert(helperMsg);
		return false;
	}
}

function isZipCode(elem, helperMsg){
	var alphaExp = /^[0-9a-zA-Z\-\ ]+$/;
	if(elem.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		return false;
	}
}

function enablePeriod(){
	document.frmSupportGO.cmbFromMonth.disabled = false;
	document.frmSupportGO.cmbFromYear.disabled = false;
	document.frmSupportGO.cmbToMonth.disabled = false;
	document.frmSupportGO.cmbToYear.disabled = false;
}

function disablePeriod(){
	document.frmSupportGO.cmbFromMonth.disabled = true;
	document.frmSupportGO.cmbFromYear.disabled = true;
	document.frmSupportGO.cmbToMonth.disabled = true;
	document.frmSupportGO.cmbToYear.disabled = true;
}

function disableMonthPeriod(){
	disablePeriod();
	document.frmSupportGO.rdMonthType[0].disabled = true;
	document.frmSupportGO.rdMonthType[1].disabled = true;
}

function enableMonthPeriod(){
	document.frmSupportGO.rdMonthType[0].disabled = false;
	document.frmSupportGO.rdMonthType[1].disabled = false;
}

function supportGOValidate(){

	oform = document.frmSupportGO;
	isAmountSelected = false;
	
	var cardSel = document.getElementById('txtCardType');
	var cardType = cardSel.options[cardSel.selectedIndex].value;
	var cardNo = oform.txtCardNo.value;
	var secCode = oform.txtSecCode.value;
	var cName = oform.txtCName.value;

	var monSel = document.getElementById('txtMonth');
	var month = monSel.options[monSel.selectedIndex].value;

	var yearSel = document.getElementById('txtYear');
	var year = yearSel.options[yearSel.selectedIndex].value;

	numRd = oform.rdGOAmount.length;
	for( i=0; i < numRd; i++ ){
		if( oform.rdGOAmount[i].checked ){
			if( oform.rdGOAmount[i].value == 'other' ){
				if( oform.txtOther.value == '' || oform.txtOther.value <= 0 ){
					alert("Please enter donation amount");
					oform.txtOther.focus();
					return false;					
				} else if( oform.txtOther.value > 10000 ){
					alert("If you would like to make a donation of more than $10,000, please call Kerri Polce at (800) 862-5801 ext. 5854 for personal assistance.");
					oform.txtOther.focus();
					return false;
				} 
				if( !isNumeric(oform.txtOther.value, "Please enter only numerics for donation amount") ){
					return false;
				}
			}
			isAmountSelected = true;
		}
	}
	if( isAmountSelected ){
		numRd = oform.rdGOType.length;
		isTypeSelected = false;

		var xx=new Date();
		var dd=xx.getDate();
		var mm=xx.getMonth()+1;
		var yy=xx.getFullYear();

		//oform.cmbFromMonth.value = mm;
		//oform.cmbFromYear.value = yy;		

		for( i=0; i < numRd; i++ ){
			if( oform.rdGOType[i].checked ){
				/*if( oform.rdGOType[i].value == 'month' ){
					if( (!oform.rdMonthType[0].disabled && !oform.rdMonthType[1].disabled) && (oform.rdMonthType[0].checked || oform.rdMonthType[1].checked) ){
						if( oform.rdMonthType[0].checked ){
							if( oform.cmbToMonth.selectedIndex == 0 ){
								alert("Please select the ending month for monthly gift");
								return false;
							} else if( oform.cmbToYear.selectedIndex == 0 ){
								alert("Please select the ending year for monthly gift");
								return false;
							} else{
								if( (mm == oform.cmbToMonth.value) && (yy == oform.cmbToYear.value) ){
									alert("Ending periods can't be same as current month. Please select different Ending month");
									return false;
								} else{
									if( yy > oform.cmbToYear.value ){
										alert("Ending period can't be less than current year. Please check the Year(s) selected.");
										return false;
									} else{
										if( (yy == oform.cmbToYear.value) && (mm > oform.cmbToMonth.value) ){
											alert("Ending period can't be less than the current month. Please check the month(s) selected.");
											return false;
										} else{
											isTypeSelected = true;
										}
									}
								}
							}
						} else{
							isTypeSelected = true;
						}
					} else{
						alert("Please select the term or Indefinite for your monthly donation");
						return false;					
					}
				} else{
					isTypeSelected = true;
				}*/
				isTypeSelected = true;
			}
		}
		if( isTypeSelected ){

			if( oform.rdnPayMethod[0].checked ){
				if(cardType == '' && cardNo == '' && secCode == '' && cName == '' && month == '' && year == ''){
					alert("All credit card fields are mandatory");
					oform.txtCardType.focus();
					return false;
				}else if(cardType == ''){
					alert("Please enter card Type");
					oform.txtCardType.focus();
					return false;
				}else if(cardNo == ''){
					alert("Please enter a valid credit card number.");
					oform.txtCardNo.focus();
					return false;
				}else if(secCode == ''){
					alert("Please enter your credit card's security code.");
					oform.txtSecCode.focus();
					return false;
				}else if(cName == ''){
					alert("Please enter the credit card holder's name.");
					oform.txtCName.focus();
					return false;
				}else if(month == ''){
					alert("Please enter month");
					oform.txtMonth.focus();
					return false;
				}else if(year == ''){
					alert("Please enter Year");
					oform.txtYear.focus();
					return false;
				}else if( cardType != '' && cardNo != '' && secCode != '' && cName != '' && month != '' && year != '' ){
					
					if(isAlphabetAssocPay(oform.txtCardType,cardType)){
						if(cardType.toUpperCase() == 'MASTERCARD' || cardType.toUpperCase() == 'VISA' || cardType.toUpperCase() == 'AMERICANEXPRESS' )
						{
							
							if(isNumericAssocPay(oform.txtCardNo,cardNo)){
								if(isCardTypeCorrect(cardNo,cardType.toUpperCase()))
								{
									if(isNumericAssocPay(oform.txtSecCode,secCode)){
										
										if(isAlphaNumericSpace(oform.txtCName,cName)){
											if(isNumericPay(oform.txtMonth,month, "Please enter numerics for month")){
												if(isNumericPay(oform.txtYear,year, "Please enter numerics for year")){

													if(isValidDate(year,month))
													{
															if( oform.action.value == 'booksPayment' )
															{
																oform.grandTotal.value = document.frmBookSC.grandTotalFromSC.value;
															}
															return true;

													}else
													{
														alert("The expiration date you specified has already passed. Please double-check your card's expiration date and specify a date in the future, or choose another credit card to make this purchase.");
														oform.txtMonth.focus();
														return false;
													}
												}
											}
										}else{
											alert("Please enter only letters for cardholder's name");
											oform.txtCName.focus();
											return false;

										}
									}else{
										alert("Please enter numerics for security code");
										oform.txtSecCode.focus();
										return false;

									}
								}else{
									alert("Please enter valid card number");
									oform.txtCardNo.focus();
									return false;
								}
							}else{alert("Please enter only numerics for card number");
									oform.txtCardNo.focus();
									return false;
								
							}
						}else
						{
							alert("Please select a valid credit card type.");
							oform.txtCardType.focus();
							return false;
						}
					}else{
						alert("Please enter only letters for card type");
						oform.txtCType.focus();
						return false;

					}
							
				}
			}
		} else{
			alert("Please select whether you would like to make a one-time or recurring donation.");
			return false;
		}
	} else{
		alert("Please select the amount you wish to donate from one of the contribution options.");
		return false;
	}	
}

function isAlphaNumericSpace(objValue,name)
{
   var ret = true;

    var charpos = objValue.value.search("[^A-Za-z0-9\\s]"); 
    if(objValue.value.length > 0 &&  charpos >= 0) 
    { 
      ret = false; 
    }
 return ret;
}

function addCartQuantity(bookId){
	qty = (document.frmCartQty.cartQty.selectedIndex+1);
	document.frmCartQty.qty.value = qty;
	document.frmCartQty.submit();
}

function removeCartItem(bookId){
	document.frmBookSC.cartaction.value = "delete";
	document.frmBookSC.bookId.value = bookId;
	document.frmBookSC.submit();
}

function pwdChangeValidate(){
	var oldPwd = document.frmPwdChange.oldPassword.value;
	var newPwd = document.frmPwdChange.newPassword.value;
	var confPwd = document.frmPwdChange.confPassword.value;
	formSubmit = 1;
	if( oldPwd == '' || newPwd == '' || confPwd == '' ){
		alert("All fields are mandatory");
		formSubmit = 0;
	}
	if( oldPwd == newPwd ){
		alert("New & Old Passwords should not be same");
		formSubmit = 0;
	}
	if( newPwd != confPwd ){
		alert("New & Confirm Passwords should be same");
		formSubmit = 0;
	}
	if( formSubmit == 1 ){
		return true;
	} else{
		return false;
	}
}

var guestInfoGlobal = '';//This variable is to store the actual (single) guest information html content to append each time
function addGuest(eventType, eventPrice){
	var guestInfo = $('GuestDiv').innerHTML;
	var guestCnt = document.frmEditEvnt.hdnGuestCount.length;
	if( guestCnt < 3 || !$defined(guestCnt) ){
		if( !$defined(guestCnt) ){	//ie., for the first time
			guestInfoGlobal = guestInfo;
		}
		if( guestCnt == 2 ){
			addGuestInfo = $('AddFinalGuest').innerHTML;
		} else{
			addGuestInfo = $('AddGuest').innerHTML;
		}
		if( eventType == 'paid' ){
			addGuestInfo = addGuestInfo + '<br /><br />Please note that there will also be a registration fee of <strong>$' +eventPrice+ '</strong> for each additional guest.<br /><font class="byline">(Registration is limited to <strong><u>3</u></strong> additional guests)</font><br /><br />' + guestInfoGlobal;
		} else{
			addGuestInfo = addGuestInfo + '<br /><br /><font class="byline">(Registration is limited to <strong><u>3</u></strong> additional guests)</font><br /><br />' + guestInfoGlobal;
		}
		if( guestCnt == 2 ){
			$('AddFinalGuest').innerHTML = addGuestInfo;
		} else{
			$('AddGuest').innerHTML = addGuestInfo;
		}		
	} else{
		alert("We are sorry. Maximum of 3 guests are allowed for Events at AEI");
	}
}

function completeEditEvntReg(){
	var guestCnt = document.frmEditEvnt.hdnGuestCount.length;
	var guestNameToBeSubmitted = '';
	var guestLastNameToBeSubmitted = '';
	var guestOrgToBeSubmitted = '';
	var guestJobToBeSubmitted = '';
	var guestEmailToBeSubmitted = '';

	if( $defined(guestCnt) ){
		for( i = 0; i < guestCnt; i++ ){
			guestNameToBeSubmitted = guestNameToBeSubmitted + document.frmEditEvnt.txtGusetName[i].value;
			guestLastNameToBeSubmitted = guestLastNameToBeSubmitted + document.frmEditEvnt.txtGusetLastName[i].value;
			guestOrgToBeSubmitted = guestOrgToBeSubmitted + document.frmEditEvnt.txtOrg[i].value;
			guestJobToBeSubmitted = guestJobToBeSubmitted + document.frmEditEvnt.txtJob[i].value;
			guestEmailToBeSubmitted = guestEmailToBeSubmitted + document.frmEditEvnt.txtEmail[i].value;
			
			guestNameToBeValidated = document.frmEditEvnt.txtGusetName[i].value;
			guestLastNameToBeValidated = document.frmEditEvnt.txtGusetLastName[i].value;
			guestOrgToBeValidated = document.frmEditEvnt.txtOrg[i].value;
			guestJobToBeValidated = document.frmEditEvnt.txtJob[i].value;
			guestEmailToBeValidated = document.frmEditEvnt.txtEmail[i].value;
			if( !((guestNameToBeValidated != '' && guestLastNameToBeValidated != '' && guestOrgToBeValidated != '' && guestJobToBeValidated != '' && guestEmailToBeValidated != '') || (guestNameToBeValidated == '' && guestOrgToBeValidated == '' && guestJobToBeValidated == '' && guestEmailToBeValidated == '')) ){
				alert("Please enter all details for guests added");
				document.frmEditEvnt.txtGusetName[i].focus();
				return false;
			}
			if( i < (guestCnt - 1) ){
				guestNameToBeSubmitted = guestNameToBeSubmitted + ',';
				guestLastNameToBeSubmitted = guestLastNameToBeSubmitted + ',';
				guestOrgToBeSubmitted = guestOrgToBeSubmitted + ',';
				guestJobToBeSubmitted = guestJobToBeSubmitted + ',';
				guestEmailToBeSubmitted = guestEmailToBeSubmitted + ',';
			}
		}
	} else{
		guestNameToBeSubmitted = document.frmEditEvnt.txtGusetName.value;
		guestLastNameToBeSubmitted = document.frmEditEvnt.txtGusetLastName.value;
		guestOrgToBeSubmitted = document.frmEditEvnt.txtOrg.value;
		guestJobToBeSubmitted = document.frmEditEvnt.txtJob.value;
		guestEmailToBeSubmitted = document.frmEditEvnt.txtEmail.value;

		if( !((guestNameToBeSubmitted != '' && guestLastNameToBeSubmitted != '' && guestOrgToBeSubmitted != '' && guestJobToBeSubmitted != '' && guestEmailToBeSubmitted != '') || (guestNameToBeSubmitted == '' && guestOrgToBeSubmitted == '' && guestJobToBeSubmitted == '' && guestEmailToBeSubmitted == '')) ){
			alert("Please enter all details for guest added");
			document.frmEditEvnt.txtGusetName.focus();
			return false;
		}
	
	}

	document.frmEditEvnt.hdnGuestName.value = guestNameToBeSubmitted;
	document.frmEditEvnt.hdnGuestLastName.value = guestLastNameToBeSubmitted;
	document.frmEditEvnt.hdnGuestOrg.value = guestOrgToBeSubmitted;
	document.frmEditEvnt.hdnGuestJob.value = guestJobToBeSubmitted;
	document.frmEditEvnt.hdnGuestEmail.value = guestEmailToBeSubmitted;
	//document.frmEditEvnt.btnComEvnt.value = 'reg';
	return true;
}

function completeEvntPayReview(){
	oform = document.frmEvntPayReview;
	cName = oform.txtCName.value;
	sCode = oform.txtSCode.value;
	cNum = oform.txtCNumber.value;

	if( !oform.paymentType[0].checked && !oform.paymentType[1].checked ){
		alert("Please select payment option");
		return false;
	}
	if( oform.paymentType[0].checked && ( cName == '' || sCode == '' || cNum == '' ) ){
		alert("All credit card details are mandatory before completing the payment");
		return false;
	} else if( oform.paymentType[0].checked || oform.paymentType[1].checked ){
		creditCardValidationReturn = false;
		if( oform.paymentType[1].checked ){
			oform.payOption.value = oform.paymentType[1].value;
			creditCardValidationReturn = true;
		} else{
			if( notEmpty(cName, "Please enter valid Card Holder name") ){
				if( isNumeric(sCode, "Please enter only numerics for security code") ){
					if( isNumeric(cNum, "Please enter only numerics for card number") ){
						creditCardValidationReturn = true;
					}
				}
			}
			oform.payOption.value = oform.paymentType[0].value;
			if( !creditCardValidationReturn ){
				return false;
			}
		}
		isGuestExists = true;
		try{
			ex = oform.hdnGuestCount.length;
		} catch(e){
			isGuestExists = false;
		}
		var guestNameToBeSubmitted = '';
		var guestLastNameToBeSubmitted = '';
		var guestOrgToBeSubmitted = '';
		var guestJobToBeSubmitted = '';
		var guestEmailToBeSubmitted = '';

		if( isGuestExists ){
			var guestCnt = oform.hdnGuestCount.length;

			if( $defined(guestCnt) ){	//There are more than one guests
				for( i = 0; i < guestCnt; i++ ){
					guestNameToBeSubmitted = guestNameToBeSubmitted +oform.txtGusetName[i].value;
					guestLastNameToBeSubmitted = guestLastNameToBeSubmitted +oform.txtGusetLastName[i].value;
					guestOrgToBeSubmitted = guestOrgToBeSubmitted +oform.txtOrg[i].value;
					guestJobToBeSubmitted = guestJobToBeSubmitted +oform.txtJob[i].value;
					guestEmailToBeSubmitted = guestEmailToBeSubmitted +oform.txtEmail[i].value;
					if( i < (guestCnt - 1) ){
						guestNameToBeSubmitted = guestNameToBeSubmitted + ',';
						guestLastNameToBeSubmitted = guestLastNameToBeSubmitted + ',';
						guestOrgToBeSubmitted = guestOrgToBeSubmitted + ',';
						guestJobToBeSubmitted = guestJobToBeSubmitted + ',';
						guestEmailToBeSubmitted = guestEmailToBeSubmitted + ',';
					}
				}
			} else{
				guestNameToBeSubmitted =oform.txtGusetName.value;
				guestLastNameToBeSubmitted =oform.txtGusetLastName.value;
				guestOrgToBeSubmitted =oform.txtOrg.value;
				guestJobToBeSubmitted =oform.txtJob.value;
				guestEmailToBeSubmitted =oform.txtEmail.value;
			}
		}
		oform.hdnGuestName.value = guestNameToBeSubmitted;
		oform.hdnGuestLastName.value = guestLastNameToBeSubmitted;
		oform.hdnGuestOrg.value = guestOrgToBeSubmitted;
		oform.hdnGuestJob.value = guestJobToBeSubmitted;
		oform.hdnGuestEmail.value = guestEmailToBeSubmitted;
		if( creditCardValidationReturn ){
			return true;
		}
		return false;
	}
}

function loadBillingAddress(addr, addr2, city, state, zip){
	document.frmPayment.txtAddress1.value = addr;
	document.frmPayment.txtAddress2.value = addr2;
	document.frmPayment.txtCity.value = city;

	var x = document.frmPayment.txtState;
	for (i=0;i<x.length;i++){
		if( x.options[i].value == state ) x.options[i].selected = true;
	}
	//document.frmPayment.txtState.value = state;
	document.frmPayment.txtZip.value = zip;
}

function submitPayment(){
	oform = document.frmPayment;
	var sName = oform.txtSName.value;
	var sAddr1 = oform.txtSAddress1.value;
	var sAddr2 = oform.txtSAddress2.value;
	var sCity = oform.txtSCity.value;
	var sState = oform.txtSState.value;
	var sCountrySel = oform.txtSCountry;
	var sCountry = sCountrySel.options[sCountrySel.selectedIndex].value;
	var sZip = oform.txtSZip.value;

	var bName = oform.txtBName.value;
	var bAddr1 = oform.txtBAddress1.value;
	var bAddr2 = oform.txtBAddress2.value;
	var bCity = oform.txtBCity.value;
	var bState = oform.txtBState.value;
	var bCountrySel = oform.txtBCountry;
	var bCountry = bCountrySel.options[bCountrySel.selectedIndex].value;
	var bZip = oform.txtBZip.value;

	var cardSel = document.getElementById('txtCardType');
	var cardType = cardSel.options[cardSel.selectedIndex].value;
	var cardNo = oform.txtCardNo.value;
	var secCode = oform.txtSecCode.value;
	var cName = oform.txtCName.value;

	var monSel = document.getElementById('txtMonth');
	var month = monSel.options[monSel.selectedIndex].value;

	var yearSel = document.getElementById('txtYear');
	var year = yearSel.options[yearSel.selectedIndex].value;

	oform.txtDiscountCode.value= document.forms['frmBookSC'].elements['txtDiscountCode'].value;

	checkForCardValidation = false;
	checkForBillingValidation = false;

	if( oform.rdShip[1].checked ){
		if( sName == '' || sAddr1 == '' || sCity == '' || sState == '' || sZip == '' ){
			alert("Please provide new Shipping address details");
		} else{
			if(isAlphabetPay(oform.txtSCity, sCity, "Please enter only letters for city in shipping address")){
				if(isAlphabetPay(oform.txtSState, sState, "Please enter only letters for state in shipping address")){
					if(isNumericPay(oform.txtSZip,sZip, "Please enter only numerics for ZIP in shipping address")){
						
						oform.orgSName.value = sName;
						oform.orgSAddress.value = sAddr1;
						oform.orgSA2Address.value = sAddr2;
						oform.orgSCity.value = sCity;
						oform.orgSState.value = sState;
						oform.orgSZip.value = sZip;
						oform.orgSCountry.value = sCountry;
						
						if( oform.rdBill[0].checked ){
							checkForCardValidation = true;
						} else{
							checkForBillingValidation = true;
						}
					}
				}
			}
		}
	} else{
		if( oform.rdBill[0].checked ){
			checkForCardValidation = true;
		} else{
			checkForBillingValidation = true;
		}
	}

	if( checkForBillingValidation ){
		if( bName == '' || bAddr1 == '' || bCity == '' || bState == '' || bZip == '' ){
			alert("Please provide new Billing address details");
		} else{
			if(isAlphabetPay(oform.txtBCity, bCity, "Please enter only letters for city in billing address")){
				if(isAlphabetPay(oform.txtBState, bState, "Please enter only letters for state in billing address")){
					if(isNumericPay(oform.txtBZip,bZip, "Please enter only numerics for ZIP in billing address")){
						
						oform.orgBName.value = bName;
						oform.orgBAddress.value = bAddr1;
						oform.orgBA2Address.value = bAddr2;
						oform.orgBCity.value = bCity;
						oform.orgBState.value = bState;
						oform.orgBZip.value = bZip;
						oform.orgBCountry.value = bCountry;

						checkForCardValidation = true;
					}
				}
			}
		}
	}

	if( checkForCardValidation ){
		if(cardType == '' && cardNo == '' && secCode == '' && cName == '' && month == '' && year == ''){
			alert("All credit card fields are mandatory");
			oform.txtCardType.focus();

		}else if(cardType == ''){
			alert("Please enter card Type");
			oform.txtCardType.focus();

		}else if(cardNo == ''){
			alert("Please enter a valid credit card number.");
			oform.txtCardNo.focus();

		}else if(secCode == ''){
			alert("Please enter your credit card's security code.");
			oform.txtSecCode.focus();

		}else if(cName == ''){
			alert("Please enter the credit card holder's name.");
			oform.txtCName.focus();

		}else if(month == ''){
			alert("Please enter month");
			oform.txtMonth.focus();

		}else if(year == ''){
			alert("Please enter Year");
			oform.txtYear.focus();

		}else if( cardType != '' && cardNo != '' && secCode != '' && cName != '' && month != '' && year != '' ){
			
			if(isAlphabetPay(oform.txtCardType,cardType, "Please enter only letters for card type")){

				if(cardType.toUpperCase() == 'MASTERCARD' || cardType.toUpperCase() == 'VISA' || cardType.toUpperCase() == 'AMERICANEXPRESS' )
				{
					
					if(isNumericPay(oform.txtCardNo,cardNo, "Please enter only numerics for card number")){
						if(isCardTypeCorrect(cardNo,cardType.toUpperCase()))
						{
							if(isNumericPay(oform.txtSecCode,secCode, "Please enter a numerics for security code")){
								if(notEmpty(cName, "Please enter cardholder's name")){
									if(isNumericPay(oform.txtMonth,month, "Please enter a numerics for month")){
										if(isNumericPay(oform.txtYear,year, "Please enter a numerics for year")){

											if(isValidDate(year,month))
											{
													if( oform.action.value == 'booksPayment' )
													{
														oform.grandTotal.value = document.frmBookSC.grandTotalFromSC.value;
													}
													oform.submit();

											}else
											{
												alert("The expiration date you specified has already passed. Please double-check your card's expiration date and specify a date in the future, or choose another credit card to make this purchase.");
												oform.txtMonth.focus();

											}
										}
									}
								}
							}
						}else{
							alert("Please enter valid card number");
							oform.txtCardNo.focus();
						}
					}else{oform.txtCardNo.focus();
							return false;

							}					
				}else
				{
					alert("Please select a valid credit card type.");
					oform.txtCardType.focus();
				}
			}
		}
	}
}


function isAlphabetPay(id,elem, helperMsg){
	var alphaExp = /^[a-zA-Z]+$/;
	if(elem.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		id.focus();
		return false;
	}
}

function isNumericPay(id,elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.match(numericExpression)){
		return true;
	}else{
		alert(helperMsg);
		id.focus();
		return false;
	}
}


/*function isValidCardNumber (strNum)
{
   var nCheck = 0;
   var nDigit = 0;
   var bEven = false;
   
   for (n = strNum.length - 1; n >= 0; n--)
   {
      var cDigit = strNum.charAt (n);
      if (isDigit (cDigit))
      {
         var nDigit = parseInt(cDigit, 10);
         if (bEven)
         {
            if ((nDigit *= 2) > 9)
               nDigit -= 9;
         }
         nCheck += nDigit;
         bEven = ! bEven;
      }
      else if (cDigit != ' ' && cDigit != '.' && cDigit != '-')
      {
         return false;
      }
   }
   return (nCheck % 10) == 0;
}*/
function isDigit (c)
{
   var strAllowed = "1234567890";
   return (strAllowed.indexOf (c) != -1);
}

function isCardTypeCorrect (strNum, type)
{
   var nLen = 0;
   for (n = 0; n < strNum.length; n++)
   {
      if (isDigit (strNum.substring (n,n+1)))
         ++nLen;
   }
   
   if (type == 'VISA')
      return ((strNum.substring(0,1) == '4') && (nLen == 13 || nLen == 16));
   else if (type == 'AMERICANEXPRESS')
      return ((strNum.substring(0,2) == '34' || strNum.substring(0,2) == '37') && (nLen == 15));
   else if (type == 'MASTERCARD')
      return ((strNum.substring(0,2) == '51' || strNum.substring(0,2) == '52'
              || strNum.substring(0,2) == '53' || strNum.substring(0,2) == '54'
              || strNum.substring(0,2) == '55') && (nLen == 16));
   else
      return false;
   
}

function isValidDate(year,month)
{

	var d = new Date();
	var today = d.getTime();

	var expiryDate = new Date(year,month,d.getDay());
	if(expiryDate.getTime() > today)
	{
		return true;
	}else
	{
		return false;
	}

}



function submitEventsPayment()
{

	var cardType = document.frmPayment.txtCardType.value;
	var cardNo = document.frmPayment.txtCardNo.value;
	var secCode = document.frmPayment.txtSecCode.value;
	var cName = document.frmPayment.txtCName.value;
	var month = document.frmPayment.txtMonth.value;
	var year = document.frmPayment.txtYear.value;
	
		
		if(cardType == '' && cardNo == '' && secCode == '' && cName == '' && month == '' && year == ''){
						alert("All credit card fields are mandatory");
						document.frmPayment.txtCardType.focus();

					}else if(cardType == ''){
						alert("Please enter card Type");
						document.frmPayment.txtCardType.focus();

					}else if(cardNo == ''){
						alert("Please enter a valid credit card number.");
						document.frmPayment.txtCardNo.focus();

					}else if(secCode == ''){
						alert("Please enter your credit card's security code.");
						document.frmPayment.txtSecCode.focus();

					}else if(cName == ''){
						alert("Please enter the credit card holder's name.");
						document.frmPayment.txtCName.focus();

					}else if(month == ''){
						alert("Please enter month");
						document.frmPayment.txtMonth.focus();

					}else if(year == ''){
						alert("Please enter Year");
						document.frmPayment.txtYear.focus();

					}else if( cardType != '' && cardNo != '' && secCode != '' && cName != '' && month != '' && year != '' ){
						
						if(isAlphabetPay(document.frmPayment.txtCardType,cardType, "Please enter only letters for card type")){

							if(cardType.toUpperCase() == 'MASTERCARD' || cardType.toUpperCase() == 'VISA' || cardType.toUpperCase() == 'AMERICANEXPRESS' )
							{
								
								if(isNumericPay(document.frmPayment.txtCardNo,cardNo, "Please enter only numerics for card number")){
									if(isCardTypeCorrect(cardNo,cardType.toUpperCase()))
									{
										if(isNumericPay(document.frmPayment.txtSecCode,secCode, "Please enter a numerics for security code")){
											if(isAlphabetPay(document.frmPayment.txtCName,cName, "Please enter a letters for cardholder's name")){
												if(isNumericPay(document.frmPayment.txtMonth,month, "Please enter a numerics for month")){
													if(isNumericPay(document.frmPayment.txtYear,year, "Please enter a numerics for year")){

														if(isValidDate(year,month))
														{
																document.frmPayment.submit();

														}else
														{
															alert("The expiration date you specified has already passed. Please double-check your card's expiration date and specify a date in the future, or choose another credit card to make this purchase.");
															document.frmPayment.txtMonth.focus();

														}
													}
												}
											}
										}
									}else{
										alert("Please enter valid card number");
										document.frmPayment.txtCardNo.focus();
									}
								}					
							}else
							{
								alert("Please select a valid credit card type.");
								document.frmPayment.txtCardType.focus();
							}
						}
		}
}


function emailpopup(url,pubType, pubId, hostName){
	var memId;
	if (getCookie('userMemId').length>0) {
		var results1 = document.cookie.match ( '(^|;) ?' + "userMemId" + '=([^;]*)(;|$)' );
		memId = results1[2];
	} else {
		memId = '';
	}

	if(memId !='')
	{
		var screenWidth = screen.width;
		var screenHeight = screen.height;
		var ttvmarg = 100;
		var firefox_tvs_width = 530;
		var firefox_tvs_height = 590;
		var Ie_tvs_width = 530;
		var Ie_tvs_height = 570;

		ff_Left = (screenWidth - firefox_tvs_width)/2;
		ff_Top = (screenHeight - firefox_tvs_height)/2;
		IE_Left = (screenWidth -Ie_tvs_width)/2;
		ff_Top = (screenHeight - Ie_tvs_height)/2;
		
		if (navigator.appName=='Netscape'){   
			tvow=eval("window.open('"+url+"','so','toolbar=0,scrollbars=1,location=0,status=0,menubars=0,resizable=1,width="+firefox_tvs_width+",height="+firefox_tvs_height+",top=" + ff_Top + ",left="+ff_Left+",maximize=null')")			
		}else{
			tvow=eval("window.open('"+url+"','so','toolbar=1,scrollbars=1,location=1,status=1,menubars=1,resizable=1,width="+Ie_tvs_width+",height="+Ie_tvs_height+",top=" + ff_Top + ",left="+IE_Left+",maximize=null')")
		}

		if (tvow.opener == null) tvow.opener = self;

		tvow.focus();
	}
	else
	{
//		alert("You are not a registered User.Please login to send the mail");
		currentHref = window.location.href;
		encodedCurrentHref = currentHref.replace(/&/, "^v^");
		formattedPubType = (pubType.substr(0,1)).toUpperCase()+pubType.substr(1,(pubType.length-1));	//This line is to format pubType ex: 'articles' to 'Articles'
		window.location.assign('https://'+hostName+'/aeisecure/accReg?pub='+formattedPubType+'&pubId='+pubId+'&mail=1&getThis=1&path='+encodedCurrentHref);
	}
}

function enablePayPeriod(){
	document.frmPayment.cmbFromMonth.disabled = false;
	document.frmPayment.cmbFromYear.disabled = false;
	document.frmPayment.cmbToMonth.disabled = false;
	document.frmPayment.cmbToYear.disabled = false;
}

function disablePayPeriod(){
	document.frmPayment.cmbFromMonth.disabled = true;
	document.frmPayment.cmbFromYear.disabled = true;
	document.frmPayment.cmbToMonth.disabled = true;
	document.frmPayment.cmbToYear.disabled = true;
}

function enableOther()
{
document.frmSupportGO.txtOther.disabled = false;
}

function disableOther()
{
document.frmSupportGO.txtOther.disabled = true;
}



function supportPayGOValidate(){

	oform = document.frmPayment;
	isAmountSelected = false;
	numRd = oform.rdGOAmount.length;
	for( i=0; i < numRd; i++ ){
		if( oform.rdGOAmount[i].checked ){
			isAmountSelected = true;
		}
	}
	if( isAmountSelected ){
		numRd = oform.rdGOType.length;
		isTypeSelected = false;
		for( i=0; i < numRd; i++ ){
			if( oform.rdGOType[i].checked ){
				if( oform.rdGOType[i].value == 'month' ){
					if( oform.cmbFromMonth.selectedIndex == 0 ){
						alert("Please select the starting month for monthly gift");
						return false;
					} else if( oform.cmbFromYear.selectedIndex == 0 ){
						alert("Please select the starting year for monthly gift");
						return false;
					} else if( oform.cmbToMonth.selectedIndex == 0 ){
						alert("Please select the ending month for monthly gift");
						return false;
					} else if( oform.cmbToYear.selectedIndex == 0 ){
						alert("Please select the ending year for monthly gift");
						return false;
					} else{
						if( (oform.cmbFromMonth.selectedIndex == oform.cmbToMonth.selectedIndex) && (oform.cmbFromYear.selectedIndex == oform.cmbToYear.selectedIndex) ){
							alert("Starting and Ending periods can't be same. Please select different Ending month");
							return false;
						} else{
							if( oform.cmbFromYear.selectedIndex > oform.cmbToYear.selectedIndex ){
								alert("Starting period should be less than ending period. Please check the Year(s) selected.");
								return false;
							} else{
								if( (oform.cmbFromYear.selectedIndex == oform.cmbToYear.selectedIndex) && (oform.cmbFromMonth.selectedIndex > oform.cmbToMonth.selectedIndex) ){
									alert("Starting period should be less than ending period. Please check the month(s) selected.");
									return false;
								} else{
									isTypeSelected = true;
								}
							}

						}
					}
				} else{
					isTypeSelected = true;
				}
			}
		}
		if( isTypeSelected ){
			return true;
		} else{
			alert("Please select whether you would like to make a one-time or recurring donation.");
			return false;
		}
	} else{
		alert("Please select the amount you wish to donate from one of the contribution options.");
		return false;
	}	
}

function loggedIn(memberId,hostName,option)
{

	var user = document.getElementById('memberId').value;

	if (option == 1)
	{
		if (user == '')
		{
			alert("Please login first, then manage your profile."+hostName);
			window.open('http://'+hostName+'/login','_self');
		}
		else
		{
			window.open('http://'+hostName+'/acctReg','_self');
		}
	}
	else
	{
		if (user == '')
		{
			alert("Please login first, then manage your profile."+hostName);
			window.open('http://'+hostName+'/login','_self');
		}
		else
		{
			window.open('http://'+hostName+'/acctReg?page=2&getThis=1','_self');
		}
	}
}
function toggleGiveOnlieReg(oform, memberInstance, isDetailReg){

	
	if( memberInstance != null && memberInstance != '' ){
		if( isDetailReg == true ){
			oform.submit();
		} else{
			//alert("Please update your profile at detailed registration before making donation");
			oform.method = "POST";
			oform.action= "acctReg";
			oform.submit();			
		}
	} else{
		//alert("Please sign in to AEI before making donation");
		oform.method = "POST";
		oform.action= "accReg";
		oform.submit();
	}
}



function validateContact()
{

	var emailAddr = document.addContact.txtUserEmailAddr.value;
	var fName = document.addContact.txtUserFirstName.value;
	var lName = document.addContact.txtUserLastName.value;

	emailAddr = LTrim(emailAddr);
	fName = LTrim(fName);
	lName = LTrim(lName);


	if( emailAddr != '' && fName != '' && lName != ''){
		
				if( emailValidator(emailAddr, "Please enter an valid EMail") )
					{
						if( notEmpty(fName, "Please enter Last names") )
							{
							
								if( notEmpty(lName, "Please enter Last names") )
										{
																									
										}else{
													document.addContact.txtUserLastName.focus();
													return false;	
												}					
							}else{
									document.addContact.txtUserFirstName.focus();
									return false;	
								}
							
					}else{
							document.addContact.txtUserEmailAddr.focus();
							return false;	
						}
			
		 
	}else{
		alert("All fields are mandatory");
		document.addContact.txtUserFirstName.focus();
		return false;

	}
	

}
var http = createQCObject(); 
function createQCObject()
   { 
	   var req; 
		   if(window.XMLHttpRequest){ 
			  // Firefox, Safari, Opera... 
			  req = new XMLHttpRequest(); 
		   } else if(window.ActiveXObject) { 
			  // Internet Explorer 5+ 
			  req = new ActiveXObject("Microsoft.XMLHTTP"); 
		   } else { 
			  alert('Problem creating the XMLHttpRequest object'); 
		   } 
	   return req; 
   } 

function emailSent(emailSent,savecontacts,to,hostname,memberId)
{
	if(emailSent !='' )
	{
		if(savecontacts == 'false')
		{
		alert(emailSent);
		window.close();
		}else{
			var answer = confirm("The e-mail has been sent to the selected recipients. Do you want to save the recipients' email address?"); 
						
			if (answer){							
				
					http.open('get', 'http://'+hostname+'/addressBook?saveContacts='+to+'&memberId='+memberId);

					http.onreadystatechange = function() {
					if(http.readyState == 4)
					{ 
							var response = http.responseText;
							alert(to+' saved in your contact list');
							window.close();
					}
				}
				http.send(null); 		
			
			}else{
				window.close();
			}
						
	}
	}

}

function toggleShippingControls(oform, bool){
	oform.txtSName.disabled = bool;
	oform.txtSAddress1.disabled = bool;
	oform.txtSAddress2.disabled = bool;
	oform.txtSCountry.disabled = bool;
	oform.txtSCity.disabled = bool;
	oform.txtSState.disabled = bool;
	oform.txtSZip.disabled = bool;
}
function toggleBillingControls(oform, bool){
	oform.txtBName.disabled = bool;
	oform.txtBAddress1.disabled = bool;
	oform.txtBAddress2.disabled = bool;
	oform.txtBCountry.disabled = bool;
	oform.txtBCity.disabled = bool;
	oform.txtBState.disabled = bool;
	oform.txtBZip.disabled = bool;
}

function passemail(memberId,subject){
	newwindow=window.open('forgotPassword','ForgotMyPassword','height=850,width=1250,left=5,top=5');
	if (window.focus) {newwindow.focus()}
	return false;
}

function LTrim(str)
{
  var whitespace = new String(" \t\n\r");

  var s = new String(str);

  if (whitespace.indexOf(s.charAt(0)) != -1) {
    

    var j=0, i = s.length;

    while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
    j++;


    
    s = s.substring(j, i);
  }

  return s;
}

function submitForgotPassword()
{
	document.frmForgotPassword.submit();
}

function showHideState(country,selectedIndex)
{
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);

	if ((sPage == 'acctReg') || (sPage == 'accReg') || (sPage == 'login'))
	{
		if (country == '')
		{
			if (selectedIndex != '')
				userCountry = document.getElementById('txtCou1').options[selectedIndex].value;
			else
				userCountry = 'United States';
		}
		else
		{
			userCountry = country;
		}

		objS = document.getElementById('showStateS');
		objT = document.getElementById('showStateT');

		if( $defined(objS) && $defined(objT) ){
			if (userCountry == 'United States')
			{
				objS.style.display = 'block';
				objT.style.display = 'none';
			}
			else
			{
				objS.style.display = 'none';
				objT.style.display = 'block';
			}
		}
	}
}

function addOption(selectbox,value,text )
{
	var optn = document.createElement("OPTION");
	optn.value = text;
	optn.text = value;
	if( $defined(selectbox) ){
		selectbox.options.add(optn);
	}
}

function countryList(country)
{
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	couObj = document.getElementById('txtCou1');
	if ((sPage == 'acctReg') || (sPage == 'accReg') || (sPage == 'login'))
	{
		addOption(couObj,"United States","United States");
		addOption(couObj,"Canada","Canada");
		addOption(couObj,"Afghanistan","Afghanistan");
		addOption(couObj,"Albania","Albania");
		addOption(couObj,"Algeria","Algeria");
		addOption(couObj,"American Samoa","American Samoa");
		addOption(couObj,"Andorra","Andorra");
		addOption(couObj,"Angola","Angola");
		addOption(couObj,"Anguilla","Anguilla");
		addOption(couObj,"Antarctica","Antarctica");
		addOption(couObj,"Antigua and Barbuda","Antigua and Barbuda");
		addOption(couObj,"Argentina","Argentina");
		addOption(couObj,"Armenia","Armenia");
		addOption(couObj,"Aruba","Aruba");
		addOption(couObj,"Australia","Australia");
		addOption(couObj,"Austria","Austria");
		addOption(couObj,"Azerbaidjan","Azerbaidjan");
		addOption(couObj,"Bahamas","Bahamas");
		addOption(couObj,"Bahrain","Bahrain");
		addOption(couObj,"Bangladesh","Bangladesh");
		addOption(couObj,"Barbados","Barbados");
		addOption(couObj,"Belarus","Belarus");
		addOption(couObj,"Belgium","Belgium");
		addOption(couObj,"Belize","Belize");
		addOption(couObj,"Benin","Benin");
		addOption(couObj,"Bermuda","Bermuda");
		addOption(couObj,"Bhutan","Bhutan");
		addOption(couObj,"Bolivia","Bolivia");
		addOption(couObj,"Bosnia-Herzegovina","Bosnia-Herzegovina");
		addOption(couObj,"Botswana","Botswana");
		addOption(couObj,"Bouvet Island","Bouvet Island");
		addOption(couObj,"Brazil","Brazil");
		addOption(couObj,"British Indian Ocean Territory","British Indian Ocean Territory");
		addOption(couObj,"Brunei Darussalam","Brunei Darussalam");
		addOption(couObj,"Bulgaria","Bulgaria");
		addOption(couObj,"Burkina Faso","Burkina Faso");
		addOption(couObj,"Burundi","Burundi");
		addOption(couObj,"Cambodia","Cambodia");
		addOption(couObj,"Cameroon","Cameroon");
		addOption(couObj,"Cape Verde","Cape Verde");
		addOption(couObj,"Cayman Islands","Cayman Islands");
		addOption(couObj,"Central African Republic","Central African Republic");
		addOption(couObj,"Chad","Chad");
		addOption(couObj,"Chile","Chile");
		addOption(couObj,"China","China");
		addOption(couObj,"Christmas Island","Christmas Island");
		addOption(couObj,"Cocos (Keeling) Islands","Cocos (Keeling) Islands");
		addOption(couObj,"Colombia","Colombia");
		addOption(couObj,"Comoros","Comoros");
		addOption(couObj,"Congo","Congo");
		addOption(couObj,"Cook Islands","Cook Islands");
		addOption(couObj,"Costa Rica","Costa Rica");
		addOption(couObj,"Croatia","Croatia");
		addOption(couObj,"Cuba","Cuba");
		addOption(couObj,"Cyprus","Cyprus");
		addOption(couObj,"Czech Republic","Czech Republic");
		addOption(couObj,"Denmark","Denmark");
		addOption(couObj,"Djibouti","Djibouti");
		addOption(couObj,"Dominica","Dominica");
		addOption(couObj,"Dominican Republic","Dominican Republic");
		addOption(couObj,"East Timor","East Timor");
		addOption(couObj,"Ecuador","Ecuador");
		addOption(couObj,"Egypt","Egypt");
		addOption(couObj,"El Salvador","El Salvador");
		addOption(couObj,"Equatorial Guinea","Equatorial Guinea");
		addOption(couObj,"Eritrea","Eritrea");
		addOption(couObj,"Estonia","Estonia");
		addOption(couObj,"Ethiopia","Ethiopia");
		addOption(couObj,"Falkland Islands","Falkland Islands");
		addOption(couObj,"Faroe Islands","Faroe Islands");
		addOption(couObj,"Fiji","Fiji");
		addOption(couObj,"Finland","Finland");
		addOption(couObj,"Former Czechoslovakia","Former Czechoslovakia");
		addOption(couObj,"Former USSR","Former USSR");
		addOption(couObj,"France","France");
		addOption(couObj,"France (European Territory)","France (European Territory)");
		addOption(couObj,"French Guyana","French Guyana");
		addOption(couObj,"French Southern Territories","French Southern Territories");
		addOption(couObj,"Gabon","Gabon");
		addOption(couObj,"Gambia","Gambia");
		addOption(couObj,"Georgia","Georgia");
		addOption(couObj,"Germany","Germany");
		addOption(couObj,"Ghana","Ghana");
		addOption(couObj,"Gibraltar","Gibraltar");
		addOption(couObj,"Great Britain","Great Britain");
		addOption(couObj,"Greece","Greece");
		addOption(couObj,"Greenland","Greenland");
		addOption(couObj,"Grenada","Grenada");
		addOption(couObj,"Guadeloupe (French)","Guadeloupe (French)");
		addOption(couObj,"Guam (USA)","Guam (USA)");
		addOption(couObj,"Guatemala","Guatemala");
		addOption(couObj,"Guinea","Guinea");
		addOption(couObj,"Guinea Bissau","Guinea Bissau");
		addOption(couObj,"Guyana","Guyana");
		addOption(couObj,"Haiti","Haiti");
		addOption(couObj,"Heard and McDonald Islands","Heard and McDonald Islands");
		addOption(couObj,"Honduras","Honduras");
		addOption(couObj,"Hong Kong","Hong Kong");
		addOption(couObj,"Hungary","Hungary");
		addOption(couObj,"Iceland","Iceland");
		addOption(couObj,"India","India");
		addOption(couObj,"Indonesia","Indonesia");
		addOption(couObj,"Iran","Iran");
		addOption(couObj,"Iraq","Iraq");
		addOption(couObj,"Ireland","Ireland");
		addOption(couObj,"Israel","Israel");
		addOption(couObj,"Italy","Italy");
		addOption(couObj,"Ivory Coast (Cote D&#39;Ivoire)","Ivory Coast (Cote D&#39;Ivoire)");
		addOption(couObj,"Jamaica","Jamaica");
		addOption(couObj,"Japan","Japan");
		addOption(couObj,"Jordan","Jordan");
		addOption(couObj,"Kazakhstan","Kazakhstan");
		addOption(couObj,"Kenya","Kenya");
		addOption(couObj,"Kiribati","Kiribati");
		addOption(couObj,"Kuwait","Kuwait");
		addOption(couObj,"Kyrgyzstan","Kyrgyzstan");
		addOption(couObj,"Laos","Laos");
		addOption(couObj,"Latvia","Latvia");
		addOption(couObj,"Lebanon","Lebanon");
		addOption(couObj,"Lesotho","Lesotho");
		addOption(couObj,"Liberia","Liberia");
		addOption(couObj,"Libya","Libya");
		addOption(couObj,"Liechtenstein","Liechtenstein");
		addOption(couObj,"Lithuania","Lithuania");
		addOption(couObj,"Luxembourg","Luxembourg");
		addOption(couObj,"Macau","Macau");
		addOption(couObj,"Macedonia","Macedonia");
		addOption(couObj,"Madagascar","Madagascar");
		addOption(couObj,"Malawi","Malawi");
		addOption(couObj,"Malaysia","Malaysia");
		addOption(couObj,"Maldives","Maldives");
		addOption(couObj,"Mali","Mali");
		addOption(couObj,"Malta","Malta");
		addOption(couObj,"Marshall Islands","Marshall Islands");
		addOption(couObj,"Martinique (French)","Martinique (French)");
		addOption(couObj,"Mauritania","Mauritania");
		addOption(couObj,"Mauritius","Mauritius");
		addOption(couObj,"Mayotte","Mayotte");
		addOption(couObj,"Mexico","Mexico");
		addOption(couObj,"Micronesia","Micronesia");
		addOption(couObj,"Moldavia","Moldavia");
		addOption(couObj,"Monaco","Monaco");
		addOption(couObj,"Mongolia","Mongolia");
		addOption(couObj,"Montserrat","Montserrat");
		addOption(couObj,"Morocco","Morocco");
		addOption(couObj,"Mozambique","Mozambique");
		addOption(couObj,"Myanmar","Myanmar");
		addOption(couObj,"Namibia","Namibia");
		addOption(couObj,"Nauru","Nauru");
		addOption(couObj,"Nepal","Nepal");
		addOption(couObj,"Netherlands","Netherlands");
		addOption(couObj,"Netherlands Antilles","Netherlands Antilles");
		addOption(couObj,"Neutral Zone","Neutral Zone");
		addOption(couObj,"New Caledonia (French)","New Caledonia (French)");
		addOption(couObj,"New Zealand","New Zealand");
		addOption(couObj,"Nicaragua","Nicaragua");
		addOption(couObj,"Niger","Niger");
		addOption(couObj,"Nigeria","Nigeria");
		addOption(couObj,"Niue","Niue");
		addOption(couObj,"Norfolk Island","Norfolk Island");
		addOption(couObj,"North Korea","North Korea");
		addOption(couObj,"Northern Mariana Islands","Northern Mariana Islands");
		addOption(couObj,"Norway","Norway");
		addOption(couObj,"Oman","Oman");
		addOption(couObj,"Pakistan","Pakistan");
		addOption(couObj,"Palau","Palau");
		addOption(couObj,"Panama","Panama");
		addOption(couObj,"Papua New Guinea","Papua New Guinea");
		addOption(couObj,"Paraguay","Paraguay");
		addOption(couObj,"Peru","Peru");
		addOption(couObj,"Philippines","Philippines");
		addOption(couObj,"Pitcairn Island","Pitcairn Island");
		addOption(couObj,"Poland","Poland");
		addOption(couObj,"Polynesia (French)","Polynesia (French)");
		addOption(couObj,"Portugal","Portugal");
		addOption(couObj,"Puerto Rico","Puerto Rico");
		addOption(couObj,"Qatar","Qatar");
		addOption(couObj,"Reunion (French)","Reunion (French)");
		addOption(couObj,"Romania","Romania");
		addOption(couObj,"Russian Federation","Russian Federation");
		addOption(couObj,"Rwanda","Rwanda");
		addOption(couObj,"S. Georgia & S. Sandwich Isls.","S. Georgia & S. Sandwich Isls.");
		addOption(couObj,"Saint Helena","Saint Helena");
		addOption(couObj,"Saint Kitts & Nevis Anguilla","Saint Kitts & Nevis Anguilla");
		addOption(couObj,"Saint Lucia","Saint Lucia");
		addOption(couObj,"Saint Pierre and Miquelon","Saint Pierre and Miquelon");
		addOption(couObj,"Saint Tome (Sao Tome) and Principe","Saint Tome (Sao Tome) and Principe");
		addOption(couObj,"Saint Vincent & Grenadines","Saint Vincent & Grenadines");
		addOption(couObj,"Samoa","Samoa");
		addOption(couObj,"San Marino","San Marino");
		addOption(couObj,"Saudi Arabia","Saudi Arabia");
		addOption(couObj,"Senegal","Senegal");
		addOption(couObj,"Seychelles","Seychelles");
		addOption(couObj,"Sierra Leone","Sierra Leone");
		addOption(couObj,"Singapore","Singapore");
		addOption(couObj,"Slovak Republic","Slovak Republic");
		addOption(couObj,"Slovenia","Slovenia");
		addOption(couObj,"Solomon Islands","Solomon Islands");
		addOption(couObj,"Somalia","Somalia");
		addOption(couObj,"South Africa","South Africa");
		addOption(couObj,"South Korea","South Korea");
		addOption(couObj,"Spain","Spain");
		addOption(couObj,"Sri Lanka","Sri Lanka");
		addOption(couObj,"Sudan","Sudan");
		addOption(couObj,"Suriname","Suriname");
		addOption(couObj,"Svalbard and Jan Mayen Islands","Svalbard and Jan Mayen Islands");
		addOption(couObj,"Swaziland","Swaziland");
		addOption(couObj,"Sweden","Sweden");
		addOption(couObj,"Switzerland","Switzerland");
		addOption(couObj,"Syria","Syria");
		addOption(couObj,"Tadjikistan","Tadjikistan");
		addOption(couObj,"Taiwan","Taiwan");
		addOption(couObj,"Tanzania","Tanzania");
		addOption(couObj,"Thailand","Thailand");
		addOption(couObj,"Togo","Togo");
		addOption(couObj,"Tokelau","Tokelau");
		addOption(couObj,"Tonga","Tonga");
		addOption(couObj,"Trinidad and Tobago","Trinidad and Tobago");
		addOption(couObj,"Tunisia","Tunisia");
		addOption(couObj,"Turkey","Turkey");
		addOption(couObj,"Turkmenistan","Turkmenistan");
		addOption(couObj,"Turks and Caicos Islands","Turks and Caicos Islands");
		addOption(couObj,"Tuvalu","Tuvalu");
		addOption(couObj,"Uganda","Uganda");
		addOption(couObj,"Ukraine","Ukraine");
		addOption(couObj,"United Arab Emirates","United Arab Emirates");
		addOption(couObj,"United Kingdom","United Kingdom");
		addOption(couObj,"Uruguay","Uruguay");
		addOption(couObj,"USA Minor Outlying Islands","USA Minor Outlying Islands");
		addOption(couObj,"Uzbekistan","Uzbekistan");
		addOption(couObj,"Vanuatu","Vanuatu");
		addOption(couObj,"Vatican City State","Vatican City State");
		addOption(couObj,"Venezuela","Venezuela");
		addOption(couObj,"Vietnam","Vietnam");
		addOption(couObj,"Virgin Islands (British)","Virgin Islands (British)");
		addOption(couObj,"Virgin Islands (USA)","Virgin Islands (USA)");
		addOption(couObj,"Wallis and Futuna Islands","Wallis and Futuna Islands");
		addOption(couObj,"Western Sahara","Western Sahara");
		addOption(couObj,"Yemen","Yemen");
		addOption(couObj,"Yugoslavia","Yugoslavia");
		addOption(couObj,"Zaire","Zaire");
		addOption(couObj,"Zambia","Zambia");
		addOption(couObj,"Zimbabwe","Zimbabwe");

		if( $defined(couObj) ){
			for (var i=0; i<couObj.options.length; i++)
			{
				if (couObj.options[i].value==country)
				{
					couObj.options[i].selected = country;
					break;
				}
			}
		}
	}
}

function stateList(state)
{
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);

	stObj = document.getElementById('txtState1');
	if ((sPage == 'acctReg') || (sPage == 'accReg') || (sPage == 'login'))
	{
		addOption(stObj,"Alaska","Alaska");
		addOption(stObj,"Alabama","Alabama");
		addOption(stObj,"Arkansas","Arkansas");
		addOption(stObj,"Arizona","Arizona");
		addOption(stObj,"California","California");
		addOption(stObj,"Colorado","Colorado");
		addOption(stObj,"Connecticut","Connecticut");
		addOption(stObj,"District of Columbia","District of Columbia");
		addOption(stObj,"Delaware","Delaware");
		addOption(stObj,"Florida","Florida");
		addOption(stObj,"Georgia","Georgia");
		addOption(stObj,"Hawaii","Hawaii");
		addOption(stObj,"Iowa","Iowa");
		addOption(stObj,"Idaho","Idaho");
		addOption(stObj,"Illinois","Illinois");
		addOption(stObj,"Indiana","Indiana");
		addOption(stObj,"Kansas","Kansas");
		addOption(stObj,"Kentucky","Kentucky");
		addOption(stObj,"Louisiana","Louisiana");
		addOption(stObj,"Massachusetts","Massachusetts");
		addOption(stObj,"Maryland","Maryland");
		addOption(stObj,"Maine","Maine");
		addOption(stObj,"Michigan","Michigan");
		addOption(stObj,"Minnesota","Minnesota");
		addOption(stObj,"Missouri","Missouri");
		addOption(stObj,"Mississippi","Mississippi");
		addOption(stObj,"Montana","Montana");
		addOption(stObj,"North Carolina","North Carolina");
		addOption(stObj,"North Dakota","North Dakota");
		addOption(stObj,"Nebraska","Nebraska");
		addOption(stObj,"New Hampshire","New Hampshire");
		addOption(stObj,"New Jersey","New Jersey");
		addOption(stObj,"New Mexico","New Mexico");
		addOption(stObj,"Nevada","Nevada");
		addOption(stObj,"New York","New York");
		addOption(stObj,"Ohio","Ohio");
		addOption(stObj,"Oklahoma","Oklahoma");
		addOption(stObj,"Oregon","Oregon");
		addOption(stObj,"Pennsylvania","Pennsylvania");
		addOption(stObj,"Rhode Island","Rhode Island");
		addOption(stObj,"South Carolina","South Carolina");
		addOption(stObj,"South Dakota","South Dakota");
		addOption(stObj,"Tennessee","Tennessee");
		addOption(stObj,"Texas","Texas");
		addOption(stObj,"Utah","Utah");
		addOption(stObj,"Virginia","Virginia");
		addOption(stObj,"Vermont","Vermont");
		addOption(stObj,"Washington","Washington");
		addOption(stObj,"Wisconsin","Wisconsin");
		addOption(stObj,"West Virginia","West Virginia");
		addOption(stObj,"Wyoming","Wyoming");

		if( $defined(stObj) ){
			for (var i=0; i<stObj.options.length; i++)
			{
				if (stObj.options[i].value==state)
				{
					stObj.options[i].selected = state;
					break;
				}
			}
		}
	}
}

function RegistrationOnLoad(pageTab,country,state)
{
	AcctReg_ManageDisplay(pageTab);
	showHideState(country,'');
	countryList(country);
	stateList(state);
}

function ltrimy(str) { 
	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
	return str.substring(k, str.length);
}
function rtrim(str) {
	for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
	return str.substring(0,j+1);
}
function trim(str) {
	return ltrimy(rtrim(str));
}
function isWhitespace(charToCheck) {
	var whitespaceChars = " \t\n\r\f";
	return (whitespaceChars.indexOf(charToCheck) != -1);
}

function deleteEvntGuest(guestNameToBeDeleted){
	oform = document.frmEvntPayReview;
	var guestNameToBeSubmitted = '';
	var guestLastNameToBeSubmitted = '';
	var guestOrgToBeSubmitted = '';
	var guestJobToBeSubmitted = '';
	var guestEmailToBeSubmitted = '';

	var guestCnt = oform.hdnGuestCount.length;

	if( $defined(guestCnt) ){	//There are more than one guests
		for( i = 0; i < guestCnt; i++ ){
			if( guestNameToBeDeleted != (oform.txtGusetName[i].value + ' ' + oform.txtGusetLastName[i].value)  ){
				guestNameToBeSubmitted = guestNameToBeSubmitted +oform.txtGusetName[i].value;
				guestLastNameToBeSubmitted = guestLastNameToBeSubmitted +oform.txtGusetLastName[i].value;
				guestOrgToBeSubmitted = guestOrgToBeSubmitted +oform.txtOrg[i].value;
				guestJobToBeSubmitted = guestJobToBeSubmitted +oform.txtJob[i].value;
				guestEmailToBeSubmitted = guestEmailToBeSubmitted +oform.txtEmail[i].value;
				if( i < (guestCnt - 1) ){
					guestNameToBeSubmitted = guestNameToBeSubmitted + ',';
					guestLastNameToBeSubmitted = guestLastNameToBeSubmitted + ',';
					guestOrgToBeSubmitted = guestOrgToBeSubmitted + ',';
					guestJobToBeSubmitted = guestJobToBeSubmitted + ',';
					guestEmailToBeSubmitted = guestEmailToBeSubmitted + ',';
				}
			}
		}
	} else{
		if( guestNameToBeDeleted != (oform.txtGusetName.value + ' ' +  oform.txtGusetLastName.value) ){
			guestNameToBeSubmitted =oform.txtGusetName.value;
			guestLastNameToBeSubmitted =oform.txtGusetLastName.value;
			guestOrgToBeSubmitted =oform.txtOrg.value;
			guestJobToBeSubmitted =oform.txtJob.value;
			guestEmailToBeSubmitted =oform.txtEmail.value;
		}
	}

	oform.hdnGuestName.value = guestNameToBeSubmitted;
	oform.hdnGuestLastName.value = guestLastNameToBeSubmitted;
	oform.hdnGuestOrg.value = guestOrgToBeSubmitted;
	oform.hdnGuestJob.value = guestJobToBeSubmitted;
	oform.hdnGuestEmail.value = guestEmailToBeSubmitted;
	oform.submit();
}

function applyEventPromo(){
	oform = document.frmEvntPayReview;
	var guestNameToBeSubmitted = '';
	var guestLastNameToBeSubmitted = '';
	var guestOrgToBeSubmitted = '';
	var guestJobToBeSubmitted = '';
	var guestEmailToBeSubmitted = '';

	var guestCnt = null;
	if( $defined(oform.hdnGuestCount) ){
		guestCnt = oform.hdnGuestCount.length;
		if( $defined(guestCnt) ){	//There are more than one guests
			for( i = 0; i < guestCnt; i++ ){
				guestNameToBeSubmitted = guestNameToBeSubmitted +oform.txtGusetName[i].value;
				guestLastNameToBeSubmitted = guestLastNameToBeSubmitted +oform.txtGusetLastName[i].value;
				guestOrgToBeSubmitted = guestOrgToBeSubmitted +oform.txtOrg[i].value;
				guestJobToBeSubmitted = guestJobToBeSubmitted +oform.txtJob[i].value;
				guestEmailToBeSubmitted = guestEmailToBeSubmitted +oform.txtEmail[i].value;
				if( i < (guestCnt - 1) ){
					guestNameToBeSubmitted = guestNameToBeSubmitted + ',';
					guestLastNameToBeSubmitted = guestLastNameToBeSubmitted + ',';
					guestOrgToBeSubmitted = guestOrgToBeSubmitted + ',';
					guestJobToBeSubmitted = guestJobToBeSubmitted + ',';
					guestEmailToBeSubmitted = guestEmailToBeSubmitted + ',';
				}
			}
		} else{
			guestNameToBeSubmitted =oform.txtGusetName.value;
			guestLastNameToBeSubmitted =oform.txtGusetLastName.value;
			guestOrgToBeSubmitted =oform.txtOrg.value;
			guestJobToBeSubmitted =oform.txtJob.value;
			guestEmailToBeSubmitted =oform.txtEmail.value;
		}

		oform.hdnGuestName.value = guestNameToBeSubmitted;
		oform.hdnGuestLastName.value = guestLastNameToBeSubmitted;
		oform.hdnGuestOrg.value = guestOrgToBeSubmitted;
		oform.hdnGuestJob.value = guestJobToBeSubmitted;
		oform.hdnGuestEmail.value = guestEmailToBeSubmitted;
	}

	oform.submit();
}

function editAssociatePay()
{
	
	var form = document.forms['frmAssociatePayReview'];
	var subAction = form.subAction;
	
	subAction.value='back';
	form.submit();
}
function enableAddress()
{
if(document.frmAssociatesPay.txtAddress1.disabled == true)
	{
		document.frmAssociatesPay.txtAddress1.disabled = false;
		document.frmAssociatesPay.txtAddress2.disabled = false;
		document.frmAssociatesPay.txtCou1.disabled = false;
		document.frmAssociatesPay.txtCity.disabled = false;
		document.frmAssociatesPay.txtState.disabled = false;
		document.frmAssociatesPay.txtZip.disabled = false;
		document.frmAssociatesPay.rdAddress.checked=false;
	}else{
			document.frmAssociatesPay.txtAddress1.disabled = true;
			document.frmAssociatesPay.txtAddress2.disabled = true;
			document.frmAssociatesPay.txtCou1.disabled = true;
			document.frmAssociatesPay.txtCity.disabled = true;
			document.frmAssociatesPay.txtState.disabled = true;
			document.frmAssociatesPay.txtZip.disabled = true;

	}
}


function associatesPayValidate()
{
	oform = document.frmAssociatesPay;
	isAmountSelected= false;
	isDonationTypeSelected = false;

	numRd = oform.rdGOAmount.length;
	typeLen = oform.rdGOType.length;

	for( i=0; i < numRd; i++ ){
		if( oform.rdGOAmount[i].checked ){
							
			isAmountSelected = true;
		}
	}

	for( j=0; j < typeLen; j++ ){
		if( oform.rdGOType[j].checked ){
								
			isDonationTypeSelected = true;
			
		}
	}
	


	var cardSel = document.getElementById('txtCardType');
	var cardType = cardSel.options[cardSel.selectedIndex].value;

	var monSel = document.getElementById('txtMonth');
	var month = monSel.options[monSel.selectedIndex].value;

	var yearSel = document.getElementById('txtYear');
	var year = yearSel.options[yearSel.selectedIndex].value;
	
	
	
	var cardNo = document.frmAssociatesPay.txtCardNo.value;
	var secCode = document.frmAssociatesPay.txtSecCode.value;
	var cName = document.frmAssociatesPay.txtCName.value;
	
	if(isAmountSelected )
		{	
		if(isDonationTypeSelected)
			{
	
				if(cardType == '' && cardNo == '' && secCode == '' && cName == '' && month == '' && year == ''){
						alert("All credit card fields are mandatory");
						document.frmAssociatesPay.txtCType.focus();

					}else if(cardType == ''){
						alert("Please enter card Type");
						document.frmAssociatesPay.txtCardType.focus();

					}else if(cardNo == ''){
						alert("Please enter a valid credit card number.");
						document.frmAssociatesPay.txtCardNo.focus();
						return false;

					}else if(secCode == ''){
						alert("Please enter your credit card's security code.");
						document.frmAssociatesPay.txtSecCode.focus();
						return false;

					}else if(cName == ''){
						alert("Please enter the credit card holder's name.");
						document.frmAssociatesPay.txtCName.focus();
						return false;

					}else if(month == ''){
						alert("Please enter month");
						document.frmAssociatesPay.txtMonth.focus();

					}else if(year == ''){
						alert("Please enter Year");
						document.frmAssociatesPay.txtYear.focus();

					}else if( cardType != '' && cardNo != '' && secCode != '' && cName != '' && month != '' && year != '' ){
						
						if(isAlphabetAssocPay(document.frmAssociatesPay.txtCType,cardType)){

							if(cardType.toUpperCase() == 'MASTERCARD' || cardType.toUpperCase() == 'VISA' || cardType.toUpperCase() == 'AMERICANEXPRESS' )
							{
								
								if(isNumericAssocPay(document.frmAssociatesPay.txtCardNo,cardNo)){
									if(isCardTypeCorrect(cardNo,cardType.toUpperCase()))
									{
										if(isNumericAssocPay(document.frmAssociatesPay.txtSecCode,secCode)){
											if(isAlphaNumericSpace(document.frmAssociatesPay.txtCName,cName)){
												if(isNumericAssocPay(document.frmAssociatesPay.txtMonth,month)){
													if(isNumericAssocPay(document.frmAssociatesPay.txtYear,year)){

														if(isValidDate(year,month))
														{
																document.frmAssociatesPay.submit();


														/*if(document.frmAssociatesPay.chkAddress.checked)
															{
															document.getElementById('checkBoxChecked').value="true";
																var countrySel = document.getElementById('txtCou1');
																	var country = countrySel.options[countrySel.selectedIndex].value;

																var add1 = document.frmAssociatesPay.txtAddress1.value;
																		var add2 = document.frmAssociatesPay.txtAddress2.value;
																		
																		var city = document.frmAssociatesPay.txtCity.value;
																		var state = document.frmAssociatesPay.txtState.value;
																		var zip = document.frmAssociatesPay.txtZip.value;
																		
																		if( add1 == '' || add2 == '' || country == '' || city == '' || state=='' || zip=='' )
																		{
																			alert("All address fields are mandatory");
																			document.frmAssociatesPay.txtAddress1.focus();
																			return false;
																		}
																		else
																		{
																			if ((add1 == '') || (notEmpty((trim(add1)), "Please enter a your address"))){
																				
																					if (notEmpty((trim(add2)), "Please enter your Address")){
																						if(isNumericAssocPay(document.frmAssociatesPay.txtZip, zip)){
																							if(isAlphabetAssocPay(document.frmAssociatesPay.txtState, state)){
																								document.frmAssociatesPay.submit();
																							}else{
																								alert("Please enter letters for State");
																								document.frmAssociatesPay.txtState.focus();
																								return false;
																								}
																					
																						}else{
																								alert("Please enter valid ZIP code");
																								document.frmAssociatesPay.txtZip.focus();
																								return false;
																							}
																					
																				}else{
																				alert("Please enter a your address 2");
																				document.frmAssociatesPay.txtAddress2.focus();
																				return false;

																				}
																			}else{
																				alert("Please enter a your address 1");
																				document.frmAssociatesPay.txtAddress1.focus();
																				return false;

																			}
																		}

															}else{

																	document.frmAssociatesPay.submit();
															}*/



														}else
														{
															alert("The expiration date you specified has already passed. Please double-check your card's expiration date and specify a date in the future, or choose another credit card to make this purchase.");
															document.frmAssociatesPay.txtMonth.focus();
															return false;

														}
													}else{
												alert("Please select the year");
												document.frmAssociatesPay.txtYear.focus();
												return false;
												}
												}else{
												alert("Please select the month");
												document.frmAssociatesPay.txtMonth.focus();
												return false;
												}
											}else{
												alert("Please enter only letters for the Cardholder's name");
												document.frmAssociatesPay.txtCName.focus();
												return false;
												}
										}else{
												alert("Please enter numbers for security code");
												document.frmAssociatesPay.txtSecCode.focus();
												return false;
												}
									}else{
										alert("Please enter valid card number");
										document.frmAssociatesPay.txtCardNo.focus();
										return false;
									}
								}else{
									alert("Please enter only numerics for card number");
										document.frmAssociatesPay.txtCardNo.focus();
										return false;
									
								}
							}else
							{
								alert("Please select a valid credit card type.");
								document.frmAssociatesPay.txtCType.focus();
								return false;
							}
						}else{
								alert("Please enter only letters for card type");
								document.frmAssociatesPay.txtCType.focus();
								return false;

						}
		}
		}else{

			alert("Please select the type of donation gift");
			return false;


		}
		}else{

			alert("Please select the donation amount");
			return false;


		}
										
}

function isAlphabetAssocPay(id,elem){
	var alphaExp = /^[a-zA-Z]+$/;
	if(elem.match(alphaExp)){
		return true;
	}else{		
		return false;
	}
}

function isNumericAssocPay(id,elem){
	var numericExpression = /^[0-9]+$/;
	if(elem.match(numericExpression)){
		return true;
	}else{		
		return false;
	}
}

function sendEmail()
{
	var form = document.forms['frmEmail'];

	if(form.taEmails.value == '')
	{
		alert("Please enter your recipient's e-mail address");
		form.taEmails.focus();
		return false
	}
	
	if(document.getElementById('CC').checked)
	{
		form.cc.value = 'true';
	}
	
	form.submit();

}

function submitEnrollmentBooks()
{
	var form = document.forms['frmSupportAssociates'];
	
	
		var bonusBooks=""
			for(var i=0; i < document.frmSupportAssociates.enrollBonus.length; i++)
			{
				if(document.frmSupportAssociates.enrollBonus[i].checked)
				{
					if(bonusBooks != '')
					{
						bonusBooks +=","+document.frmSupportAssociates.enrollBonus[i].value ;
					}else{
						bonusBooks =document.frmSupportAssociates.enrollBonus[i].value ;
					}
				}
			}

		form.bonusBookIds.value = bonusBooks;
			


}
/*Upon clicking on the teaser image,the teaser player starts */
function showteaser(divNum)
{
	var imgdiv=document.getElementById("teaserImgDiv"+divNum);
	imgdiv.style.display="none";

	var teaser = document.getElementById("teaserDiv"+divNum);
	teaser.style.display="";

}
function paginationSubmit(pageNo,sort)
{
	var form = document.forms['pagination'];
	
	//document.getElementById("start").value = pageNo - 1 ;	
	form.start.value =  pageNo - 1 ;
	if(sort != '')
	{
	form.sortBy.value =  sort;
	}	
	form.submit();
}


function validateOneTimeOnly(value)
{
	oform = document.frmSupportGO;
	if( value == 'Invoice' ){
		if( !oform.rdGOType[0].checked ){
			if( confirm("You can only make a one-time payment if you would like to be sent an invoice. Do you want to continue making this donation?") ){
				oform.rdGOType[0].checked = true;		
				oform.rdGOType[1].disabled = true;		
				oform.rdGOType[2].disabled = true;
			} else{
				oform.rdnPayMethod[1].checked = false;
				oform.rdnPayMethod[0].checked = true;
			}
		} else{
			oform.rdGOType[1].disabled = true;		
			oform.rdGOType[2].disabled = true;
		}
	}  else if( value =='CreditCard' ){
		oform.rdGOType[1].disabled = false;		
		oform.rdGOType[2].disabled = false;		
	}
}

function readCookie(cookie_name) {
	secure='https://'+location.host+'/aeisecure/';
	nonsecure='http://'+location.host+'/';
	var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
	if ( results ) {
		a = "<a>Hello, " + results[2] + "</a><font class=\"pipe\">&nbsp;|&nbsp;</font><a href=\""+nonsecure+"portal\">My AEI.org</a> <font class=\"pipe\">&nbsp;|&nbsp;</font><a href=\""+nonsecure+"login?logout=1\">Sign Out</a>";
		document.write(a);
		return ( unescape ( results[2] ) );
	} else {
		a="<a href=\""+secure+"accReg\">Register on AEI.org</a> <font class=\"pipe\">&nbsp;|&nbsp;</font> <a href=\""+secure+"login\">Log In</a>";
		document.write(a);
		return null;
	}
}

function readCookie2(cookie_name) {
	var results2 = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
	if ( results2 ) {
		c = "<input type=\"hidden\"  id=\"loginEmail\" name=\"loginEmail\" value=\"" + results2[2] + "\" />";
		document.write(c);
		return ( unescape ( results2[2] ) );
	} else {
		return null;
	}
}

function readCookie1(cookie_name) {
	var results1 = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
	if ( results1 ) {
		b = "<input type=\"hidden\"  id=\"memberId\" name=\"memberId\" value=\"" + results1[2] + "\" />";
		document.write(b);
		return ( unescape ( results1[2] ) );
	} else {
		return null;
	}
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
	return ""
}

function chkEvent(ucEventId,fromWhere)
{
	secure='https://'+location.host+'/aeisecure/';
	var loginEmail;
	if (getCookie('loginEmail').length>0) {
		var results1 = document.cookie.match ( '(^|;) ?' + "loginEmail" + '=([^;]*)(;|$)' );
		loginEmail = unescape(results1[2]);
		ckNm = "Evt"+ucEventId;
		if (getCookie('isDetailReg').length>0) {
			if (getCookie(ckNm).length>0) {
				if (fromWhere == 1) {
					a = "<img src=\"views/images/common/UnRegister.gif\" border=\"0\" class=\"UnRegister\" title=\"You are registered for this Event\" alt=\"You are registered for this Event\" /></a>";
				} else {
					a = "<img src=\"views/images/common/UnRegister.gif\" border=\"0\" class=\"vmiddle\" title=\"You are registered for this Event\" alt=\"You are registered for this Event\" /></a>";
				}
				document.write(a);
			} else {
				a = "<a href=\""+secure+"editEvntReg?pubId="+ucEventId+"&getThis=1\"><img src=\"views/images/common/Register.gif\" border=\"0\" class=\"RegisterImage\" title=\"Register for this Event\" alt=\"Register for this Event\" /></a>";
				document.write(a);
			}
		} else {
			a = "<a href=\""+secure+"acctReg?sessEvt="+ucEventId+" \"><img src=\"views/images/common/Register.gif\" border=\"0\" class=\"RegisterImage\" title=\"Register for this Event\" alt=\"Register for this Event\" /></a>";
			document.write(a);
		}
	} else {
		loginEmail = '';
		a = "<a href=\""+secure+"accReg?pub=Events&pubId="+ucEventId+"&getThis=1\"><img src=\"views/images/common/Register.gif\" border=\"0\" class=\"RegisterImage\" title=\"Register for this Event\" alt=\"Register for this Event\" /></a>";
		document.write(a);
	}
}

function userEvts()
{
	var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December');
	var bb=document.cookie.split(';');
	var evts = 1;
	if (bb.length>0) {
		var results1 = document.cookie.match ( '(^|;) ?' + "userFName" + '=([^;]*)(;|$)' );
		memId = unescape(results1[2]);
		for (i=0; i<bb.length; i++) {
			if (bb[i].indexOf('Evt') != -1) {
				if (evts == 1) {
					var evts = 0;
				}
				if (evts == 0) {
					a=memId+", you are registered for the following events:<br>";
					document.write(a);
					var evts = 2;
				}
				var chk = bb[i];
				var cc = chk.substr(4,4);
				var dd = bb[i].split("=");
				var ee = dd[1].split("%7C");
				var gg = unescape(ee[0]);
				var hh=gg.split('+');
				var ii = '';
				for (j=0; j<hh.length; j++) {
					ii += hh[j];
					ii += " ";
				}
				var jj=unescape(ee[1]);
				var kk = jj.replace( "+", " " );
				var ll=kk.split(' ');
				var mm=ll[0];
				var oo=mm.split('-');
				var pp=parseFloat(oo[1]);
				var qq=pp-1;
				var nn = MONTH_NAMES[qq]+' '+oo[2]+', '+oo[0];
				ab = "<div class=\"eCalEvents\"><b><a href=\"event/"+cc+"\" class=\"gray\">"+unescape(ii)+"</a></b> <font class=\"date\">("+nn+")</font><br /><a href=\"cancelEvntReg/"+cc+"\">Cancel Registration</a></div>";
				document.write(ab);
			}
		}
		if (evts == 1) {
			a=memId+", you haven't registered for any events:<br>";
			document.write(a);
		}
	}
}

function userProfile()
{
		var results1 = document.cookie.match ( '(^|;) ?' + "userFName" + '=([^;]*)(;|$)' );
		fName = unescape(results1[2]);
		if (fName != '') {
			a="<div style=\"text-align:right\"><font class=\"byline\"><a href=\"portal\">View Profile</a></font></div>";
			document.write(a);
		}
}
