/*/////////////////////// EVENT RELATED FUNCTIONS ///////////////////////////////*/




/*////////////////// EVENT SEARCH Function //////////////////////////////////*/

function RunSearch() {
     if ( (isBegindate()) )
     document.form1.submit();
	  return true;
}   


function isBegindate() {
 	
	var myselect = document.form0.selectdate.selectedIndex;
    var today = new Date();
	year = today.getYear();
	if (year < 2000)    
	year = year + 1900; 
    switch (myselect) {
	case 0:        
 	  document.form1.SESSIONBEGDATE.value = "";
          break;
        case 1:
	  		 var tbegdate = ( (today.getMonth() + 1) + "/" + (today.getDate()) + "/" + year );
           var tenddate = ( (today.getMonth() + 2) + "/" + (today.getDate()) + "/" + year );
	   document.form1.SESSIONBEGDATE.value = "BETWEEN '" + tbegdate+"' AND '"+tenddate+"'";
           break;
        case 2:
	   var tbegdate = ( (today.getMonth() + 1) + "/" + (today.getDate()) + "/" + year );
           var tenddate = ( (today.getMonth() + 4) + "/" + (today.getDate()) + "/" + year );
	   document.form1.SESSIONBEGDATE.value = "BETWEEN '" + tbegdate+"' AND '"+tenddate+"'";
           break;
        case 3:
	   var tbegdate = ( (today.getMonth() + 1) + "/" + (today.getDate()) + "/" + year );
           var tenddate = ( (today.getMonth() + 1) + "/" + (today.getDate()) + "/" + (year+1));
	   document.form1.SESSIONBEGDATE.value = "BETWEEN '" + tbegdate+"' AND '"+tenddate+"'";
           break;
        default: 
           var MonthDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
 	   var tbegdate = ( myselect-3 + "/" + 01 + "/" + year );
           var tenddate = ( myselect-3 + "/" + MonthDays[ myselect-4] + "/" + year);
	   document.form1.SESSIONBEGDATE.value = "BETWEEN '" + tbegdate+"' AND '"+tenddate+"'";
         
	}
      

    if (document.form1.SESSIONBEGDATE.value == "")
	{
 	   var tbegdate = ( (today.getMonth()+1) + "/" + (today.getDate()-1) + "/" + year );
           document.form1.SESSIONBEGDATE.value="BETWEEN '" + tbegdate+"' AND '01/01/2040'";
	}

      return true;
}

/////Used on the Event Search Page
function setDates(formName){
	var dateString ='';
	if((formName.fromDate.value != '') && (formName.toDate.value != '')){
		dateString = 'BETWEEN '+formName.fromDate.value+' AND '+formName.toDate.value;
	}else if(formName.fromDate.value != ''){
		dateString = '>'+formName.fromDate.value;
	}else if(formName.toDate.value != ''){
		dateString = '<'+formName.toDate.value;
	}else{
		var today = new Date;
		dateString = today.defaultView();
		formName.fromDate.value = dateString;
		dateString = '>' + dateString;
	}
	
	formName.SESSIONBEGDATE.value = dateString;
	//alert(document.abc.SESSIONBEGDATE.value);
	return true;
}






/*/////////////  SINGLE REGISTRATION -- Functions related to Single Registration   //////////////////////*/

//Called upon clicking "single register" link - determines if event status will allow registration and takes user to correct page
function EventRegister(eventstatus, eventcd) { 
	//alert('here!');
	if (eventstatus<2){ 
	
		if (eventstatus==1){ 
			alert('This event is full.')
		}
		
		var value = CUSTOMERCD;
		
		if (value != ""){
			location='../Registerdll.dll/RegistrationForm?sessionaltcd='+eventcd;
		}else{
			alert("Please log in before registering for this event.");
			location.href = '../memberdll.dll/openpage?wrp=MainLogin.htm&REDIRECTURL=../Registerdll.dll/RegistrationForm?sessionaltcd='+eventcd+'&FUNFILTER=RBN';
		} 
		
	}else {
		alert('Event registration not available at this time.'); 
	}
}
 
function getFunctions(formName)
{
	//alert('in getFunctions!');
	var tmpint ="";
	var tmpqty = "";
	var pos="";
	var size="";
	for (var i=0; i<formName.length; i++){
	   if (formName.elements[i].type == 'text') {
	        if (formName.elements[i].value > 0) {
				tmpint = tmpint + ',' + formName.elements[i].name;
				tmpqty = tmpqty + ','+formName.elements[i].name+'='+formName.elements[i].value;
	        }else if (formName.elements[i].value==0) {
				if (formName.elements[i].name==formName.AUTOFUNCTIONCD.value)
				{
					formName.elements[i].value=1;
					tmpint = tmpint + ',' +formName.elements[i].name;
					tmpqty = tmpqty + ','+formName.elements[i].name+'='+formName.elements[i].value
				}
			}
		}else if (formName.elements[i].type == 'checkbox'){
		 	if (formName.elements[i].checked == true){
				//alert("found "+formName.elements[i].name);
				tmpint = tmpint + ',' + formName.elements[i].name;
				tmpqty = tmpqty + ','+formName.elements[i].name+'='+formName.elements[i].value;
	        }else{
				if (formName.elements[i].name==formName.AUTOFUNCTIONCD.value)
				{
					formName.elements[i].value=1;
					tmpint = tmpint + ',' + formName.elements[i].name;
					tmpqty = tmpqty + ','+formName.elements[i].name+'='+formName.elements[i].value
				}
			}
		}
			
			
	}  

	pos = tmpint.indexOf(',');
	pos = pos +1;
	size = tmpint.length;
	var final = tmpint.substring(pos,size);
	//alert(final);
	formName.FUNCTIONS.value=final;
	
	pos = tmpqty.indexOf(',');
	pos = pos +1;
	size = tmpqty.length;
	var final = tmpqty.substring(pos,size);
	//alert(final);
	formName.FUNCTIONSQTY.value=final;
	
	return true;
}

//Determines if the user has selected a price type and throws error if not
function priceTest(formName){
	var hold="";
	var pricetype ="";
	var priceamt ="";
	for (var i=0; i<formName.PRICETYPESTT.length; i++)
	{
			if(formName.PRICETYPESTT.options[i].selected){
				 hold = formName.PRICETYPESTT.options[i].text;
				 var size = hold.length;	
				 if (formName.PRICETYPESTT.options[0].selected){
				 pos =hold.lastIndexOf('-');
				 pos =pos-1;
				 pricetype = hold.substring(0,pos);
				 priceamt = hold.substring((pos+2),size);
				 }
				 else {
				 pos = hold.lastIndexOf('-')
				 pos =pos-1;
				 pricetype = hold.substring(0,pos);
				 priceamt = hold.substring((pos+2),size);
				 }
		   }
	}

	//alert(priceamt);
	//alert(pricetype);
	if (priceamt==""){
		  alert("\nYou must select the Price Category from the dropdown box.");
		  formName.PRICETYPESTT.focus();
		  return false;
	}else{
		formName.FPRICEAMT.value = priceamt;
		formName.FPRICETYPESTT.value = pricetype;
		return true;
	}
}


//does something upon price change
function priceChanged(formName)
{
	var ss="";
	var after="";
	if (location.href) {ss=location.href.substring(0,255);}
	var pos = ss.lastIndexOf("&ADDCUSTOMERCD=");
	if (pos>-1)
	{
		after = ss.substring(pos, ss.lenght);	 
		ss=ss.substring(0,pos);	
	}
	var pos = ss.lastIndexOf("&PRICETYPESTT=");
	if (pos>-1)
	{
		ss=ss.substring(0,pos);	
	}
	location.href = ss+"&PRICETYPESTT="+formName.PRICETYPESTT.value+after;
}


//checks all function fields to determine if user can add function
function checkAllFunctions(currQty, cancelQty, maxQty, funcQty, funcID, fcode, fqty){
	var willDisable = 0;
	//alert('received: '+currQty+', '+cancelQty+', '+maxQty+', '+funcQty+', '+funcID);
    if (fqty>0)
	{
		var fdate=eval('document.event.D_'+fcode+'.value');
		var ftime=eval('document.event.T_'+fcode+'.value');
		var ftitle=eval('document.event.TITLE_'+fcode+'.value');

		var registered = parseInt(currQty) - parseInt(cancelQty);	
		var seatsLeft = parseInt(maxQty) - parseInt(registered);
		var totalQty = parseInt(registered) + parseInt(funcQty);
		var finalQty = parseInt(maxQty) - parseInt(totalQty);
	
		if(finalQty < 0){
			alert('The function '+ftitle+' only has '+seatsLeft+' seats left. Please select less seats');
		
			//new 3/20/08
			if(document.getElementById(funcID).type == 'checkbox'){
				document.getElementById(funcID).checked = false;
			}else{
				document.getElementById(funcID).value='0';
			}

			//document.event.continueButton.disabled=true;
			willDisable=1;
		}

		for (var i=0; i<document.event.length; i++) 
		{
			if ((document.event.elements[i].type =='text') || ((document.event.elements[i].type == 'checkbox') && (document.event.elements[i].checked)))
	   		{
				if ((document.event.elements[i].name!=fcode) && (document.event.elements[i].value>0)) 
				{
						var cdate=eval('document.event.D_'+document.event.elements[i].name+'.value');
						var ctime=eval('document.event.T_'+document.event.elements[i].name+'.value');
						var ctitle=eval('document.event.TITLE_'+document.event.elements[i].name+'.value');
						if ((cdate==fdate) && (ctime==ftime))
						{
							alert('There is a scheduling conflict between '+ftitle+' and '+ctitle+'. Please choose a different function.');
							
							//new 3/20/08
							//alert(funcID);
							if(document.getElementById(funcID).type == 'checkbox'){
								document.getElementById(funcID).checked = false;
							}else{
								document.getElementById(funcID).value='0';
							}
							willDisable=1;
						}
							
						//Dissallows you from selectin two functions with the exact same name
						/*
						if(ctitle==ftitle){
							alert('You have already signed up for the function '+ftitle+'. Please choose a different function.');
							willDisable=1;
									
							//new 3/20/08
							//alert(funcID);
							if(document.getElementById(funcID).type == 'checkbox'){
								document.getElementById(funcID).checked = false;
							}else{
								document.getElementById(funcID).value='0';
							}
						}*/
						
				}
			}	
		}
		
	}
}



/*///////////// MULTI-REGISTRATION -- Functions related to Multi Registration  //////////////////////////*/
function EventMultiRegister(eventstatus, eventcd){ 
	if (eventstatus<2){ 
		if (eventstatus==1){ 
			alert('This event is full.')
		}
		
		var value = CUSTOMERCD;
		
		if (value != ""){
			location='../../cgi-bin/Registerdll.dll/RegistrationForm?sessionaltcd='+eventcd+'&FUNFILTER=EN&MULTIREG=Y&ONLYOPTIONS=Y&RESPONSEPAGE=MultiRegForm.htm';
		}else{
			alert("Please log in before registering for this event.");
			/*location.href = '../memberdll.dll/openpage?wrp=MainLogin.htm&REDIRECTURL=../Registerdll.dll/RegistrationForm?sessionaltcd='+eventcd+'&FUNFILTER=EN&MULTIREG=Y&ONLYOPTIONS=Y&RESPONSEPAGE=MultiRegForm.htm';*/
			location.href = '../memberdll.dll/openpage?wrp=MainLogin.htm';
		} 
	}else {
		alert('Event registration not available at this time.'); 
	}	
}



//opens search page with intentional no-records (leave weird email as is)
function openSearchGuests(orgName)
{
	//window.open("../memberdll.dll/list?email=3929093jjoijjji&whp=guestSearch_header.htm&wbp=guestSearch_list.htm&wnr=guestSearch_noRec.htm&wmt=../main_Template_none.htm&sort=lastname","","fullscreen=no,location=no,toolbar=no,menubar=yes,scrollbars=yes,resizable=yes,width=640,height=400")
	window.open("../memberdll.dll/list?email=3929093jjoijjji&whp=guestSearch_header.htm&wbp=guestSearch_list.htm&wnr=guestSearch_noRec.htm&wmt=main_Template_none.htm&sort=lastname","","fullscreen=no,location=no,toolbar=no,menubar=yes,scrollbars=yes,resizable=yes,width=640,height=400")
	return true;
}

//opens search page of all users from current user's org
function openSearchGuestsOrg(orgcd)
{
	//var searchURL = "../memberdll.dll/list?orgcd="+orgcd+"&whp=guestSearchOrg_header.htm&wbp=guestSearchOrg_list.htm&wnr=guestSearchOrg_noRec.htm&wmt=../main_Template_none.htm&sort=lastname"
	var searchURL = "../memberdll.dll/list?orgcd="+orgcd+"&whp=guestSearchOrg_header.htm&wbp=guestSearchOrg_list.htm&wnr=guestSearchOrg_noRec.htm&wmt=main_Template_none.htm&sort=lastname"
	window.open(searchURL,"","fullscreen=no,location=no,toolbar=no,menubar=yes,scrollbars=yes,resizable=yes,width=640,height=400")
	return true;
}


//runs search for guests to add
function searchGuests(formName){
		if(formName.LASTNAME.value != ''){
			formName.LASTNAME.value += '~';
		}
		if(formName.ORGNAME.value != ''){
			formName.ORGNAME.value += '~';
		}
	
		formName.submit();
		//location.href = "List?EMAIL="+document.resultlist.searchf.value+"&SORT=LASTNAME&RANGE=1/100&WHP=searchHeader.htm&WBP=CustomerSearch.htm&WMT=none&WNR=norec.htm";
}


//for org guest search, adds all selected guests to page
function addGuestsOrg(formName){
	var isChecked = false;
	
	if(formName.ADDGUEST.length == undefined){
		if(formName.ADDGUEST[i].checked == true){
			var name = formName.ADDGUEST.id.split('|');;
			var lastName = name[0];
			var firstName = name[1];
			var customercd = formName.ADDGUEST.value;
			addGuest(customercd, lastName, firstName);
			isChecked = true;
		}
	}
	
	for(var i=0;i<formName.ADDGUEST.length;i++){
		if(formName.ADDGUEST[i].checked == true){
			var name = formName.ADDGUEST[i].id.split('|');
			var lastName = name[0];
			var firstName = name[1];
			var customercd = formName.ADDGUEST[i].value;
			//debug(customercd+', '+lastName+', '+firstName);
			addGuestsOrg_helper(customercd, lastName, firstName);
			isChecked = true;
		}
	}
	
	if(isChecked){
		window.opener.focus();
		window.close();
	}else{
		alert('Please select at least one user from the list before submitting this form.');
	}
}


//adds additional user to the registration
function addGuestsOrg_helper(linkname, lastname, firstname) 
{ 
	//REQUIRES PROTOTYPE
	//use AJAX to retrieve correct price for user and write user price and other info to opening page
	var sessionaltcd = window.opener.document.getElementById('SESSIONALTCD').value;
	var priceURL = '../registerdll.dll/registrationform?sessionaltcd='+sessionaltcd+'&customercd='+linkname+'&wrp=guestPrice.htm&pricelist=guestPriceList.htm&wmt=none&wnr=none';
	//debug("priceURL is: "+priceURL);
	
	new Ajax.Request(priceURL, 
		{method:'get',asynchronous:false,
		onSuccess: function(content){
			var response = content.responseText || '';
			
			//check for no prices
			if(response == ''){ alert("ERROR: There are no prices which apply to the user "+firstname+" "+lastname+". This user will not be added to the registration."); }
			//alert(response);
			var priceSplit = response.split('@');
			var priceInfo = priceSplit[0];
			priceSplit = priceInfo.split('|');
			var priceCode = priceSplit[0];
			var priceName = priceSplit[1];
			var pricePrice = priceSplit[2];
			
			//alert('Price is: -'+priceCode+'--'+priceName+'--'+pricePrice);
			
			var defaultform = '<div class="attendee">' + '<input type="checkbox" name="CUSTOMERCD" value="'+linkname+'" checked> ' + lastname + ', ' + firstname +  '<div class="attendee"  id="cust'+linkname+'">'+
			
			'<span class="attendee"><b>Registration:</b><BR>'+priceName+' ('+pricePrice+')</span>'+
			
			'</div>' +
			' <input type="button" value="Select Guest Price and Functions" name="addb'+linkname+'" onClick="addGuestFunctions('+linkname+')">'+
			' <input type="hidden" name="PRICETYPESTT'+linkname+'" value="'+priceCode+'">'+
			' <input type="hidden" name="FUNCTIONS'+linkname+'" value="">'+
			' <input type="hidden" name="FUNCTIONNAMES'+linkname+'" value="">'+
			' </div><HR><br />';
			
			//alert("GOING TO INSERT:\n\n"+defaultform);
			
			var dupuser = window.opener.document.getElementsByName('PRICETYPESTT'+linkname);
			if (dupuser.length != 0)
			{
				alert("This member has been already selected");
			}
			else
			{
				var itemfunc=window.opener.document.getElementById("AddUser"); 
				if (itemfunc.insertAdjacentText) 
				{
					itemfunc.innerHTML  += defaultform;
				} 
				else if(typeof(itemfunc.innerHTML) != 'undefined' ) 
				{
					itemfunc.innerHTML +=  defaultform;
				}	
			}	
			
			
			//itemfunc.innerHTML =  "<span class='attendee'><b>Registration:</b><BR>"+hold+"</span>";
		},
		onFailure: function(){alert('An AJAX error has occured. Please ensure that you have Javascript-enabled browser and re-load the page to try again.');}
	});
	

}



//adds additional user to the registration
function addGuest(linkname, lastname, firstname) 
{ 

	var defaultform = '<div class="attendee">' + '<input type="checkbox" name="CUSTOMERCD" value="'+linkname+'" checked> ' + lastname + ', ' + firstname +  '<div class="attendee"  id="cust'+linkname+'"></div>' +
		' <input type="button" value="Select Guest Price and Functions" name="addb'+linkname+'" onClick="addGuestFunctions('+linkname+')">'+
		' <input type="hidden" name="PRICETYPESTT'+linkname+'" value="">'+
		' <input type="hidden" name="FUNCTIONS'+linkname+'" value="">'+
		' <input type="hidden" name="FUNCTIONNAMES'+linkname+'" value="">'+
  		' </div><HR><br />';
		

	var dupuser = window.opener.document.getElementsByName('PRICETYPESTT'+linkname);
	if (dupuser.length != 0)
	{
		alert("This member has been already selected");
	}
	else
	{
		var itemfunc=window.opener.document.getElementById("AddUser"); 
 		if (itemfunc.insertAdjacentText) 
		{
			itemfunc.innerHTML  += defaultform;
		} 
		else if(typeof(itemfunc.innerHTML) != 'undefined' ) 
		{
			itemfunc.innerHTML +=  defaultform;
	    }	
		window.opener.focus();
		window.close();
	}	
}


//opens the "select price category" window for guests
function addGuestFunctions(idname)
{
	//Mozilla bug!!!!!!!!!!!!!!!!
	//var addpath = "../Registerdll.dll/RegistrationForm?sessionaltcd="+sessionaltcd+"&RESPONSEPAGE=RegistrationForm_guest.htm&WMT=../main_template_none.htm&WFL=FunctionList_guest.htm&CUSTOMERCD="+idname;
	var addpath = "../Registerdll.dll/RegistrationForm?sessionaltcd="+sessionaltcd+"&RESPONSEPAGE=RegistrationForm_guest.htm&WMT=main_template_none.htm&WFL=FunctionList_guest.htm&CUSTOMERCD="+idname;
	if ( eval('document.event.PRICETYPESTT'+idname +'.value != "" '))
	{
		addpath =  addpath+'&PRICETYPESTT='+eval('document.event.PRICETYPESTT'+idname +'.value');
	}
	window.open(addpath,"","fullscreen=no,location=no,toolbar=no,menubar=yes,scrollbars=yes,resizable=yes,width=700,height=400");
	return true;
}


//returns the funtions and prices the guest selected to the first screen
function passGuestFunctions_old(formName) 
{
    if ( getGuestFunctions(formName) )
	 {
			// get customercd from location.href
			var RedirectStr=location.href;
			var customercd="";
	  		var pos = RedirectStr.lastIndexOf("&CUSTOMERCD=");
			if (pos>-1)
			{
				customercd=RedirectStr.substring(pos+12);	
				pos = customercd.indexOf("&");
				if (pos>-1)
				{
					customercd = customercd.substring(0, pos);	
				}
			}
		   
		   //fill out the price description field
		   	var hold = "";
			for (var i=0; i<formName.PRICETYPESTT.length; i++)
			{
				if(formName.PRICETYPESTT.options[i].selected)
				{
					 hold = formName.PRICETYPESTT.options[i].text;
					 break;
			    }
			}
//		   eval('window.opener.formName.REGPRICE'+customercd+'.value=hold');

		   //write function description list into the appropriate div section
		   var itemfunc=window.opener.document.getElementById("cust"+customercd); 		   

			if (itemfunc.insertAdjacentText) 
			{
				if(formName.FUNCTIONDESC.value == ''){
					itemfunc.innerHTML =  "<span class='attendee'><b>Registration:</b><BR>"+hold+"</span>";
				}else{
					itemfunc.innerHTML =  "<span class='attendee'><b>Registration:</b><BR>"+hold+"<BR><b>Functions:</b><br>"+formName.FUNCTIONDESC.value+"</span>";
				}
			} 
			else if(typeof(itemfunc.innerHTML) != 'undefined' ) 
			{
				if(formName.FUNCTIONDESC.value == ''){
					itemfunc.innerHTML =  "<span class='attendee'><b>Registration:</b><BR>"+hold+"</span>";
				}else{
					itemfunc.innerHTML =  "<span class='attendee'><b>Registration:</b><BR>"+hold+"<BR><b>Functions:</b><br>"+formName.FUNCTIONDESC.value+"</span>";
				}
					
		 	}	

		   //fill out hidden fields 
		 //  alert(formName.name);
		  // alert(formName.value);
		   eval('window.opener.document.'+formName.name+'.PRICETYPESTT'+customercd+'.value=document.'+formName.name+'.PRICETYPESTT.value');
		   eval('window.opener.document.'+formName.name+'.FUNCTIONS'+customercd+'.value=document.'+formName.name+'.FUNCTIONS.value');
   	   
		   //check checkbox
		   var objs = window.opener.document.getElementsByName("CUSTOMERCD");
			for (var i=0; i<objs.length; i++) 
			{
				if (objs[i].value==customercd)
				{
					objs[i].checked = true;
					break;
				}
			}

		   window.close();
	       return true;
	  }  
} 

function passGuestFunctions(formName) 
{
    if ( getGuestFunctions(formName) )
	 {
			// get customercd from location.href
			var RedirectStr=location.href;
			var customercd="";
	  		var pos = RedirectStr.lastIndexOf("&CUSTOMERCD=");
			if (pos>-1)
			{
				customercd=RedirectStr.substring(pos+12);
				pos = customercd.indexOf("&");
				if (pos>-1)
				{
					customercd = customercd.substring(0, pos);
				}
				pos = customercd.indexOf("#");
				if (pos>-1)
				{
					customercd = customercd.substring(0, pos);
				}
			}
		   
		   //fill out the price description field
		   	var hold = "";
			for (var i=0; i<formName.PRICETYPESTT.length; i++)
			{
				if(formName.PRICETYPESTT.options[i].selected)
				{
					 hold = formName.PRICETYPESTT.options[i].text;
					 break;
			    }
			}

		   //write function description list into the appropriate div section
		   var itemfunc=window.opener.document.getElementById("cust"+customercd);

		if(formName.FUNCTIONDESC.value == ''){
			itemfunc.innerHTML =  "<span class='attendee'><b>Registration:</b><BR>"+hold+"</span>";
		}else{
			itemfunc.innerHTML = "<span class='attendee'><b>Registration:</b><BR>"+hold+"<BR><b>Functions:</b><br>"+formName.FUNCTIONDESC.value+"</span>";
				}
					
		   //fill out hidden fields 
		 //  alert(formName.name);
		  // alert(formName.value);
		   eval('window.opener.document.'+formName.name+'.PRICETYPESTT'+customercd+'.value=document.'+formName.name+'.PRICETYPESTT.value');
		   eval('window.opener.document.'+formName.name+'.FUNCTIONS'+customercd+'.value=document.'+formName.name+'.FUNCTIONS.value');
   	   
		   //check checkbox
		   var objs = window.opener.document.getElementsByName("CUSTOMERCD");
			for (var i=0; i<objs.length; i++) 
			{
				if (objs[i].value==customercd)
				{
					objs[i].checked = true;
					break;
				}
			}

		   window.close();
	       return true;
	  }  
} 


//collects functions selceted from the guest page
function getGuestFunctions(formName){
	var tmpint ="";
	var tmpdesc="";
	var pos="";
	var size="";
	for (var i=0; i<formName.length; i++)  {
			if (formName.elements[i].type =='text'){
				if (formName.elements[i].value>0) {
					tmpint = tmpint + ',' + formName.elements[i].name+"="+formName.elements[i].value;
					tmpdesc = tmpdesc + '<br>'+formName.elements[i].title+" x"+formName.elements[i].value;
			   } //make sure auto registration price is checked
	//			else if (formName.elements[i].checked==false) {
	//	        		if (formName.elements[i].name==formName.AUTOFUNCTIONCD.value)
	//					{
	//					formName.elements[i].checked=true;
	//	        		tmpint = tmpint + ',' + formName.elements[i].name;
	//					}
	//				}
			}else if(formName.elements[i].type == 'checkbox'){
				if (formName.elements[i].checked == true) {
					tmpint = tmpint + ',' + formName.elements[i].name+"="+formName.elements[i].value;
					tmpdesc = tmpdesc + '<br>'+formName.elements[i].title+" x"+formName.elements[i].value;
			   }	
			}
			
	}  
	pos = tmpint.indexOf(',');
	pos = pos +1;
	var finalvalue = tmpint.substring(pos);
	formName.FUNCTIONS.value=finalvalue;
	
	pos = tmpdesc.indexOf('<br>');
	pos = pos +4;
	var finalvalue = tmpdesc.substring(pos);
	//alert(final);
	formName.FUNCTIONDESC.value=finalvalue;
	
	return true;
	}

//collects all info and submits multi-registraion to next page
function submitMultiReg(formName)
{
		 var tmpint ="";
		 for (var i=0; i<formName.length; i++) 
		 {
			if (formName.elements[i].type =='text') 
			{
				if (formName.elements[i].value >0)
				{
					tmpint  = tmpint+","+formName.elements[i].name+"="+formName.elements[i].value;
				}
			}
			
			if (formName.elements[i].type == 'checkbox'){
				if((formName.elements[i].checked == true) && (formName.elements[i].name != 'CUSTOMERCD')){
					tmpint  = tmpint+","+formName.elements[i].name+"="+formName.elements[i].value;
				}
			}
		}		
		pos = tmpint.indexOf(',');
		pos = pos +1;
		var finalvalue = tmpint.substring(pos);
		formName.FUNCTIONS.value=finalvalue;
		
		var objs = document.getElementsByName('CUSTOMERCD');
		var emptyprice = false;
		for (var i=0; i<objs.length; i++) 
		{
			if (objs[i].checked == true)
			{
				if (eval('document.'+formName.name+'.PRICETYPESTT'+objs[i].value+'.value==""') )
				{
					alert('Please select a price category for yourself and each of your guests.');
					eval('document.'+formName.name+'.addb'+objs[i].value+'.select()') ;
					eval('document.'+formName.name+'.addb'+objs[i].value+'.focus()'); 
					emptyprice = true;
					break;
				}
			}
		}
		if (!emptyprice)
		{
			formName.submit();
		}

//		formName.submit();
} 


/*/////////////////////////////////////////////////////////////////////////*/

/*/////////////////////////////////////////////////////////////////////////*/

/*/////////////////////////////////////////////////////////////////////////*/

/*/////////////////////////////////////////////////////////////////////////*/

/*/////////////////////////////////////////////////////////////////////////*/

/*/////////////////////////////////////////////////////////////////////////*/

/*/////////////////////////////////////////////////////////////////////////*/

/*////////////////////// UNUSED FUNCTIONS ////////////////////////////////*/

//called by default upon changing price list sometimes

function RegistrationPriceChange(){
	//Use only when functions tied to event price.  
		var ss="";
                if (location.href) {ss=location.href.substring(0,255);}
                var pos = ss.lastIndexOf("&PRICETYPESTT=");
                if (pos>-1)
                {
                                ss=ss.substring(0,pos);  
                }
                location.href = ss+"&PRICETYPESTT="+document.event.PRICETYPESTT.value;

	//Use when functions are not tied to event price.
	//return true;
}

	

//single reg checkautofunctions
function checkAutoFunctions() {
 var functioncd = document.event.AUTOFUNCTIONCD.value;
 for (var i=0; i<document.event.length; i++) {
	   if (document.event.elements[i].type =='text') {
	        //alert(document.event.elements[i].name + functioncd);
	        if (document.event.elements[i].name==functioncd) {
	        		document.event.elements[i].value=1;
	        }
	     }  
    }
 }
 
 //multi-reg checkautofunctions on registrationform_guest.htm template
function checkAutoFunctions() 
{
     //select AUTO functions
//	 var functioncd = document.event.AUTOFUNCTIONCD.value;	 
	 var RedirectStr=location.href;
 var customercd="";
 var pos = RedirectStr.lastIndexOf("&CUSTOMERCD=");
   if (pos>-1)
   {
//    customercd=RedirectStr.substring(pos+12, RedirectStr.lenght); 
    customercd=RedirectStr.substring(pos+12); 
	pos = customercd.indexOf("&");
    if (pos>-1)
    {
     customercd = customercd.substring(0, pos); 
    }
   }
 var functlist = eval('window.opener.document.event.FUNCTIONS'+customercd+'.value');
 if (functlist!="") functlist=","+functlist+",";
// 		functioncd = ","+functioncd+","+functlist;

	 for (var i=0; i<document.event.length; i++) 
	 {
		if (document.event.elements[i].type =='text') 
		{
	        var elementname = ","+document.event.elements[i].name+"=";
			if (functlist.indexOf(elementname) != -1) 
   		    {
					var posqty = functlist.indexOf(elementname);
					var strqty = functlist.substring(posqty);		
					posqty=strqty.indexOf("=");
					strqty = strqty.substring(posqty+1);				
					strqty = getQty(strqty);
					document.event.elements[i].value=strqty;
	        }					
/*  		    elementname = ", "+document.event.elements[i].name+",";
			if (functioncd.indexOf(elementname) != -1) 
			{
	    	   		document.event.elements[i].value=1;
	        }*/
		}	
	}	
 }


//from multiRegForm.htm template
function checkAutoFunctions() 
{
     //select AUTO functions
	 var functioncd = document.event.AUTOFUNCTIONCD.value;
	 functioncd = ","+functioncd+",";
	 var saved="";
	 if (location.href) {fullpath=location.href.substring(0,255);}
  	 var pos=fullpath.indexOf("&SAVEDFUNCTIONS=");
	 if (pos>-1)
	 {
   	    saved=fullpath.substring(pos+16);
		pos = saved.indexOf("&");
		if (pos == -1)
		{
			pos = saved.lenght;
		}
  		saved=","+saved.substring(0, pos)+",";		
     }	 
	 for (var i=0; i<document.event.length; i++) 
	 {
		if (document.event.elements[i].type =='text') 
		{
	    	var functioncode = "";
	        var elementname = ","+document.event.elements[i].name+"=";
			if (saved.indexOf(elementname) != -1) 
	        {
					var posqty = saved.indexOf(elementname);
					var strqty = saved.substring(posqty);		
					posqty=saved.indexOf("=");
					strqty = strqty.substring(posqty+1);				
					strqty = getQty(strqty);
					document.event.elements[i].value=strqty;
					functioncode = document.event.elements[i].name+"="+strqty;
	        }
			else
			{
				if (saved == "") 
				{
					if (functioncd.indexOf(elementname) != -1) 
	    		    {
	        			document.event.elements[i].value=1;
						functioncode = document.event.elements[i].name+"=1";
			        }					
			        elementname = ", "+document.event.elements[i].name+",";
					if (functioncd.indexOf(elementname) != -1) 
			        {
	    	    		document.event.elements[i].value=1;
						functioncode = document.event.elements[i].name+"=1";
			        }
				}	
			}
			if (functioncode != "")
			{
				if (document.event.FUNCTIONS.value == "") 
				{
					document.event.FUNCTIONS.value  = functioncode;
				}
				else
				{
					document.event.FUNCTIONS.value  = document.event.FUNCTIONS.value+","+functioncode;
				}
		     }  
		  }
      }	
 }


//from registrationForm_guest.htm 
function getQty(strqty)
{
	var qty="";
	for (var i=0; i<strqty.length; i++)
	{
		if ((i==strqty.length-1) || (strqty.charAt(i)==",") || (strqty.charAt(i)=="&"))
		{
			return qty;
		}
		qty=qty+strqty.charAt(i);
	} 
}

 
  

//from registrationForm_guest.htm 
function RefreshPage()
{
	var ss="";
	if (location.href) {ss=location.href.substring(0,255);}
	var pos = ss.lastIndexOf("&PRICETYPESTT=");
	if (pos>-1)
	{
		ss=ss.substring(0,pos);	
	}
	location.href = ss+"&PRICETYPESTT="+document.event.PRICETYPESTT.value;
}







//????
function GetSentValue(paramname)
{
	var bStr=location.search;
	var pos = bStr.indexOf(paramname);
	if (pos != -1)
	{
		bStr = bStr.substring(pos+paramname.length+1, bStr.length);		
		if (bStr.indexOf("&") != -1 )
		{
			bStr = bStr.substring(0, bStr.indexOf("&"));		
		}
		else
		{
			bStr = bStr.substring(0, bStr.length);	
		}		
		return bStr.replace(/%20/g," "); 
	}
	else
	{
		return "";
	}

}


//from multiRegForm.htm
function AddCustomercd()
{
    var tmpsearch = document.event.ORGCD.value;
	if (tmpsearch.length < 1) 
	{
 	   alert('Your organization is not currently in our database.  Please contact us to set up your organization so that you may register other applicants only.  Currently you may only register those individuals that are not associated with your organization.');
	   return false;
	}  
    else 
	{
    	window.open("../../cgi-bin/memberdll.dll/List?ORGCD=<#ORGCD>&SORT=LASTNAME&RANGE=1/100&WHP=searchHeader.htm&WBP=CustomerSearch.htm&WMT=none&WNR=norec.htm","","fullscreen=no,location=no,toolbar=no,menubar=yes,scrollbars=yes,resizable=yes,width=640,height=250") 
        return true;
    }
}

//from multiRegform.htm
function RunSearch() {	
var tmpsearch = document.event.ORGCD.value;
if (tmpsearch.length < 1) {
   alert('Your cannot register at this time. You must contact aca for further instruction.');
   return false;
 }  
else 
{
window.open("../../cgi-bin/memberdll.dll/List?ORGCD="+tmpsearch+"&SORT=LASTNAME&RANGE=1/100&WHP=searchHeader2.htm&WBP=CustomerSearch2.htm&WPF=none&WPH=none","","fullscreen=no,location=yes,toolbar=no,menubar=yes,scrollbars=yes,resizable=yes,width=640,height=250")
      return true;
	  }
}   



/*function AddNewUser()
{
   	window.open("../../cgi-bin/memberdll.dll/openpage?RESPONSEPAGE=Customer_NewStaffMember.htm&ORGCD=<#ORGCD>&ORGNAME=<#ORGNAME>&ADDRESS1=<#ADDRESS1>&ADDRESS2=<#ADDRESS2>&CITY=<#CITY>&STATECD=<#STATECD>&ZIP=<#ZIP>","","fullscreen=no,location=no,toolbar=no,menubar=yes,scrollbars=yes,resizable=no,width=750,height=600")
    return true;
}

function AddNewNonStaffUser()
{
   	window.open("../../cgi-bin/memberdll.dll/openpage?RESPONSEPAGE=Customer_NewNonStaff.htm&PARENTCD=<#CUSTOMERCD>&ADDRESS1=<#ADDRESS1>&ADDRESS2=<#ADDRESS2>&CITY=<#CITY>&STATECD=<#STATECD>&ZIP=<#ZIP>","","fullscreen=no,location=no,toolbar=no,menubar=yes,scrollbars=yes,resizable=no,width=750,height=600")
    return true;
}*/

