/*/////////////////////// 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){
	if(formName.fromDate.value != ''){
		dateFrom = new Date(formName.fromDate.value);
		formName.CALVIEW.value = dateFrom.getFullYear();
	}	
	
	/*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, majorcat) { 
	//alert('here!');
	if (eventstatus<2){ 
	
		if (eventstatus==1){ 
			alert('This event is full. If you would like to be placed on a waiting list please select OK to complete the registration form.')
		}
		
		var value = GetCookieValue("customercd");
		
		var wrp="";
		if (majorcat == "Webinar")
		{
			wrp="&WRP=eLearningAgreement.htm"
		}
		if (eventcd=="100376")
		{
			wrp="&WRP=BoothRegForm.htm"
		}

		if (value != ""){
			
			location='../Registerdll.dll/RegistrationForm?sessionaltcd='+eventcd+wrp;
		}else{
			alert("Please log in or create an account before registering for this event.");
			location.href = '../memberdll.dll/openpage?wrp=mainlogin.htm&REDIRECTURL=../Registerdll.dll/RegistrationForm?sessionaltcd='+eventcd+wrp;
		} 
		
	}else {
		alert('This event is closed.'); 
	}
}


 
 //retrieves fucntions from the page for single registration
function getFunctions(formName)
{
	//alert('in getFunctions!');
	var tmpint ="";
	var tmpqty = "";
	var pos="";
	var size="";

	var FListStr= formName.AUTOFUNCTIONCD.value;
	//alert("autoFunctioncD is: "+formName.AUTOFUNCTIONCD.value);
	FunctionList=FListStr.split(",");

	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) {
				//check auto functions
				for (var j=0; j<FunctionList.length; j++)
				{
        				if (formName.elements[i].name==FunctionList[j])
					{
						//alert('found autofunction: '+FunctionList[j]);
						tmpint = tmpint + ',' + formName.elements[i].name;
						tmpqty = tmpqty + ','+formName.elements[i].name+'=1';
						FunctionList[j]='';	
						
					}
				}
			}
		}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{
				//check auto functions
				for (var j=0; j<FunctionList.length; j++)
				{
        				if (formName.elements[i].name==FunctionList[j])
					{
						//alert('found autofunction: '+FunctionList[j]);
						tmpint = tmpint + ',' + formName.elements[i].name;
						tmpqty = tmpqty + ','+formName.elements[i].name+'=1';
						FunctionList[j]='';	
						
					}
				}
			}
		}
			
			
	}  

	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;
						}
							
						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. If you would like to be placed on a waiting list please select OK to complete the registration form.')
		}
		
		var value = GetCookieValue("memberid");
		
		if (value != ""){
			location='../../cgi-bin/Registerdll.dll/RegistrationForm?sessionaltcd='+eventcd+'&FUNFILTER=EN&MULTIREG=Y&ONLYOPTIONS=Y&RESPONSEPAGE=MultiRegForm.htm';
		}else{
			alert("Please log in or create an account 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';
		} 
	}else {
		alert('This event is closed.'); 
	}	
}



//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","","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"
	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;
	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(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;
	  }  
} 

//collects functions selceted from the guest page
function getGuestFunctions(formName){
	//debug('in getGuestFunctions');
	var tmpint ="";
	var tmpdesc="";
	var pos="";
	var size="";
	
	//GET FUNCTIONS
	var FListStr= formName.AUTOFUNCTIONCD.value;
	//debug(formName.AUTOFUNCTIONCD.value);
	FunctionList=FListStr.split(",");
		 
	
	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;
			  	 }else{
					 //auto functions
					for (var j=0; j<FunctionList.length; j++)
					{
						//check autofunctionlist
						if (formName.elements[i].name==FunctionList[j])
						{
							//debug('foudn match! '+FunctionList[j]);
							tmpint = tmpint + ','+formName.elements[i].name+'=1';
							tmpdesc = tmpdesc + '<br>'+formName.elements[i].title;
							FunctionList[j]='';				
						} 
					}
				 }
			}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;
			    }else{
					//auto functions
					for (var j=0; j<FunctionList.length; j++)
					{
						//check autofunctionlist
						if (formName.elements[i].name==FunctionList[j])
						{
							tmpint = tmpint + ','+formName.elements[i].name+'=1';
							tmpdesc = tmpdesc + '<br>'+formName.elements[i].title;
							FunctionList[j]='';				
						}
					}
					
					
				}
			}
			
	}  
	//debug(tmpint);
	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 ="";
		 
		 //GET FUNCTIONS
		 var FListStr= formName.AUTOFUNCTIONCD.value;
		FunctionList=FListStr.split(",");
		 
		 
		 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;
				}else{
					//auto functions
					for (var j=0; j<FunctionList.length; j++)
					{
						//check autofunctionlist
						if (formName.elements[i].name==FunctionList[j])
						{
							tmpint = tmpint + ','+formName.elements[i].name+'=1';
							FunctionList[j]='';				
						}
					}
					
				}
			}
			
			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;
				}else{
						//check autofunctionlist
						if (formName.elements[i].name==FunctionList[j])
						{
							tmpint = tmpint + ','+formName.elements[i].name+'=1';
							FunctionList[j]='';		
						}
					
				}
				
			}
		}		
		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();
} 

function GetMultiRegMessage() 
{
	var memberopt = GetCookieValue('memberoptions');
	var pos = memberopt.indexOf('SUPER');
	if (pos != -1) 
	{
		var txt = 'If you would like to register someone else from your organization <a href="#" onClick="RunSearchORGmember()">Click here</a>';
		return txt;
	}
	else
	{
		return '';
	}
}

function GetMultiRegMessageConfPage(sess) 
{
	var memberopt = GetCookieValue('memberoptions');
	var pos = memberopt.indexOf('SUPER');
	if (pos != -1) 
	{
		var txt = 'Would you like to register someone else for this same event? <a href="../../cgi-bin/Registerdll.dll/RegistrationForm?sessionaltcd='+sess+'">Click Here</a>';
		return txt;
	}
	else
	{
		return '';
	}
}

function RunSearchORGmember() {	
var tmpsearch = document.abc.ORGCD.value;
if (tmpsearch.length < 1) {
   alert('Organization code is not available for this individual.');
   return false;
 }  
else 
{
window.open("../../cgi-bin/memberdll.dll/List?ORGCD="+tmpsearch+"&SORT=LASTNAME&WHP=CustomerSearchReg_Header.htm&WBP=CustomerSearch.htm&WMT=../main_template_none.htm","","fullscreen=no,location=yes,toolbar=no,menubar=yes,scrollbars=yes,resizable=yes,width=640,height=480")
      return true;
	  }
}  


function checkOrgCD()
{
	var org = GetCookieValue("orgcd");
	if(org !='')
	{
		location.href = '../eventsdll.dll/EventInfo?sessionaltcd=100376&WRP=BoothSales.htm';
	}
	else
	{
		alert("You must login to validate your organization before requesting a booth. Booth registration is only available to individuals that are tied to an organization that is registered with NWPPA. If you have logged in and are receiving this message, please call NWPPA at 360.254.0109 for assistance.");
		//location.href = '../memberdll.dll/openpage?wrp=mainlogin.htm';
		location.href = '../memberdll.dll/openpage?wrp=BoothSaleslogin.htm&REDIRECTURL=../eventsdll.dll/EventInfo?sessionaltcd=100376&WRP=BoothSales.htm';
		
	}
}

function pCheckOrgCD()
{
	var porg = GetCookieValue("orgcd");
	if(porg !='')
	{
		return true;
	}
	else
	{
		alert("You must login to validate your organization before requesting a booth. Booth registration is only available to individuals that are tied to an organization that is registered with NWPPA. If you have logged in and are receiving this message, please call NWPPA at 360.254.0109 for assistance.");
		//location.href = '../memberdll.dll/openpage?wrp=mainlogin.htm';
		location.href = '../memberdll.dll/openpage?wrp=BoothSaleslogin.htm&REDIRECTURL=../eventsdll.dll/EventInfo?sessionaltcd=100376&WRP=BoothSales.htm';		
		
	}
}

function CheckEvent(sessionCode)
{
	if (sessionCode=="100376")
	{
		location.href = '../eventsdll.dll/EventInfo?sessionaltcd=100376&WRP=BoothSales.htm';	
	}
	else
	{
		location.href = "../eventsdll.dll/EventInfo?sessionaltcd="+sessionCode;	
	}
}




function getBoothPrice()
{
	var memtype = GetCookieValue("ismember");
	if(memtype !='Y')
	{
		document.event.PRICETYPESTT.value=13094;
	}
	else
	{
		document.event.PRICETYPESTT.value=13093;
		
		
	}
}
 
function showDuration(begdate, enddate)
{
	if (begdate==enddate)
	{
		document.write(begdate);
	}
	else
	{
		document.write(begdate+' - '+ enddate);
	}
}


function showDate(begdate, enddate){
	var finalDate = '';

	var dateArr1 = begdate.split(',');
	var dateArr2 = enddate.split(',');
	
	var month1 = dateArr1[0];
	var month2 = dateArr2[0];

	var day1 = dateArr1[1];
	var day2 = dateArr2[1];
	
	var year1 = dateArr1[2];
	var year2 = dateArr2[2];

	if(day1 == "1"){
		day1 = "1st";
	}else if(day1 == "2"){
		day1 = "2nd";
	}else if(day1 == "3"){
		day1 = "3rd";
	}else if(day1 == "21"){
		day1 = "21st";
	}else if(day1 == "22"){
		day1 = "22nd";
	}else if(day1 == "23"){
		day1 = "23rd";
	}else if(day1 == "31"){
		day1 = "31st";	
	}else{
		day1 += "th";
	}

	
	if(day2 == "1"){
		day2 = "1st";
	}else if(day2 == "2"){
		day2 = "2nd";
	}else if(day2 == "3"){
		day2 = "3rd";
	}else if(day2 == "21"){
		day2 = "21st";
	}else if(day2 == "22"){
		day2 = "22nd";
	}else if(day2 == "23"){
		day2 = "23rd";
	}else if(day2 == "31"){
		day2 = "31st";	
	}else{
		day2 += "th";
	}
	
	
	if(begdate != enddate){
		if(year1 == year2){
			if(month1 == month2){
				finalDate = month1;
				finalDate += ' '+day1+' - '+day2+', '+year1;
			}else{
				finalDate = month1+' '+day1+' -  '+month2+' '+day2+', '+year2;
			}
		}else{
			finalDate = month1+' '+day1+', '+year1+' - '+month2+' '+day2+', '+year2;
		}
	}else{
		finalDate = month1+' '+day1+', '+year1;
	}
	
	document.write(finalDate);
}


/*/////////////////////////////////////////////////////////////////////////*/

/*/////////////////////////////////////////////////////////////////////////*/

/*/////////////////////////////////////////////////////////////////////////*/

/*/////////////////////////////////////////////////////////////////////////*/

/*/////////////////////////////////////////////////////////////////////////*/

/*/////////////////////////////////////////////////////////////////////////*/

/*/////////////////////////////////////////////////////////////////////////*/

/*////////////////////// 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;
}*/
