var RecaptchaOptions = {
   theme : 'clean'
};


//--------------------------------------------
function trim(str)
{
   return str.replace(/^\s+|\s+$/g,'');
};
//-------------------------------------------

function getPhotos()
{
	a= $('albums').value;
	var ok = false;
	
	if(a != '')
	{
		$('photos').update('<em>Retrieving Photos&hellip;</em>');
		new Ajax.Updater('photos','getphotos.php',
	  {
		method:'post',
		parameters: {album: a},	
		onSuccess: function(transport){
		  var response = transport.responseText || "no response text";
          
          lightwindowInit();
          
		},
		onComplete: function(){lightwindowInit();},
		onFailure: function(){ alert('Something went wrong...') }
	  });
	}
	
	
		
}

//-------------------------------------------
function ie6Nav()
{

        var nav = $('main_navigation').select('li.sub');
        cnt = nav.length;
        var x;
        for(i=0; i< cnt; i++){
	nav[i].onmouseover = function(){

	  var dec = this.descendants();
	  list = dec[1];
	  list.addClassName('see');
	  clearTimeout(x);
	};

	nav[i].onmouseout = function(){

	  var dec = this.descendants();
	  list = dec[1];
	  x = setTimeout("list.removeClassName('see')",250);
	};

};
};
//--------------------------------------------
function checkEmail(address)
{
	
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
  
    return reg.test(address);
	
};

//---------------------------------------------
function submitPoll ()
{
	new Ajax.Updater('pollSection','process_poll.php',
  {
    method:'post',
	parameters: $('pollForm').serialize(true),	
    onSuccess: function(transport){
      var response = transport.responseText || "no response text";
      //alert("Success! \n\n" + response);
    },
    onFailure: function(){ alert('Something went wrong...') }
  });
};
//---------------------------------------
function membershipCost()
{

	var field = $('type');	
	var text = $('costText');
	var cost = $('cost');
	var amount = $('amount');
	var money;
	
	switch($('type').selectedIndex)
	{
		case 0:
		   money = 0;
		   break;    
		case 1:
		  money = 30;
		  break;
		case 2:
		  money = 20;
		  break;
		case 3:
		 case 4:
		  money = 0;
                  alert("Please contact us about School District Memberships");
		  break;
		default:
		  alert("Invalid Selection");
	};
	
	text.update('$' + money + '.00');
	cost.value = money + '.00';
	amount.value = money + '.00';
};
//--------------------------------
function voiceShipping()
{
	var field = $('quantity');	
	var text = $('shipText');
	var ship = $('shipping');
	
	var money;
	
	switch(field.selectedIndex)
	{
		case 0:
		   money = 0;
		   break;    
		case 1:
		case 2:
		case 3:
		case 4:
		  money = 5.95;
		  break;
		case 4:
		case 5:
		case 6:
		case 7:
		  money = 7.95;
		  break;
		case 8:
		case 9:
		case 10:
		case 11:
		case 12:
		  money = 8.95;
		  break;  
		default:
		  alert("Invalid Selection");
	};
	
	ship.value = money;
	text.update('$' + money);
	
};
//--------------------------------------
function showVideo()
{
	var v = $('video');
	
	v.setStyle({display:'block'});
	return false;
};
//--------------------------------------
function hideVideo()
{
	var v = $('video');
	
	v.setStyle({display:'none'});
	return false;
};
//--------------------------------------
function showVideo2()
{
	var v = $('video2');
	
	v.setStyle({display:'block'});
	return false;
};
//--------------------------------------
function hideVideo2()
{
	var v = $('video2');
	
	v.setStyle({display:'none'});
	return false;
};
//---------------------------------------
function showMore()
{
	var d = $('moreinfo');
	var a = $('morelink');
	
	d.setStyle({display:'block'});
	a.update('&hellip;show less&hellip;')
	a.onclick = function(){showLess(); return false;};
};

//---------------------------------------
function showLess()
{
	var d = $('moreinfo');
	var a = $('morelink');
	
	d.setStyle({display:'none'});
	a.update('&hellip;read more&hellip;')
	a.onclick = function(){showMore(); return false;};
};
//---------------------------------------------
function verifyChangePW ()
{
	new Ajax.Request('checkPW.php',
  {
    method:'post',
	parameters: $('pwform').serialize(true),	
    onSuccess: function(transport){
      var response = transport.responseText;
	  
	  switch(response)
	  {
		  case '1':
		  $('pwform').submit();
		  break;
		  
		  case '300':  //new password same as old
		  $('pageInfo').update('The new password cannot be the same as the old one');
		  $('pwform').reset();
		  break;
		  
		  case '303':  //current password incorrect
		  $('pageInfo').update('You entered an incorrect current password');
		  $('pwform').reset();
		  break;
		  
		  case '305': //new passwords don't match
		  $('pageInfo').update('New password cannot be confirmed');
		  $('pwform').reset();
		  break;
		  default:
		  $('pageInfo').update('An error occured' + response);
		  $('pwform').reset();
		  
	  };
	  
	  
    },
    onFailure: function(){ alert('Something went wrong...') }
  });

	return false;
};

//---------------------------------------------
function getMembers ()
{
	new Ajax.Updater('memberlist','membersearch.php',
  {
    method:'post',
	parameters: $('searchForm').serialize(true),	
    onSuccess: function(transport){
      var response = transport.responseText || "no response text";
      //alert("Success! \n\n" + response);
    },
    onFailure: function(){ alert('Something went wrong...') }
  });
};
//---------------------------------------------
function verifyRedemption (description)
{
	var code = trim($('code').value);
	var email = trim($('email').value);

	new Ajax.Request('checkCode.php',
	  {
		method:'post',
		parameters: 'e='+email+'&code='+code+'&desc='+description,	
		onSuccess: function(transport){
		  var response = transport.responseText || "no response text";
		  
		  responseArray = response.split('-');
		  switch(responseArray[0])
		  {
			  case '0':
			  	alert('This redemption code does not exist');
				 break;
			  case '3':
			  	alert('This redemption code has already been used for the '+description);
				 break;
			  case '2':
			  	$('verifycode').update('[code has expired]');
				$('verifycode').setStyle({color: '#900'});
				break;	
			  case '1': //This is valid
			  	if(responseArray[1] == 'percent')
				{
			   		$('verifycode').update('[You save '+ responseArray[2]+'%]');
				}
				else
				{
			   		$('verifycode').update('[You save $'+ responseArray[2]+']');
				}
				
				$('verifycode').setStyle({color: '#090'});
			  break;
			  default:
			     alert('Code'+ response+': could not be verified. Please be sure that you have properly entered your code');
			 	 break;
		  }
		},
		onFailure: function(){ alert('Something went wrong...') }
	  });
	
	return false;
};

//---------------------------------------------
function getPoll(poll)
{
	new Ajax.Updater('content_right','getPoll.php',
  {
    method:'post',
	parameters: {'poll':poll},	
    onSuccess: function(transport){
      var response = transport.responseText || "no response text";
      //alert("Success! \n\n" + response);
    },
    onFailure: function(){ alert('Something went wrong...') }
  });
	return false;	
};
//---------------------------------------------
function validateSignUp ()
{
	
    clear = 1;
	errMsg = '';
	
	if(trim($('type').value) == '' || (trim($('type').value) != 'adult' && trim($('type').value) != 'student') && trim($('type').value) != 'school' && trim($('type').value) != 'district')
	{
	   clear = 0;
	   errMsg += '<li>You must select a valid membership type</li>';
	};
	
	if(trim($('payment').value) == '' || (trim($('payment').value) != 'paypal' && trim($('payment').value) != 'check'))
	{
	   clear = 0;
	   errMsg += '<li>You must select a valid payment type</li>';
	};
	
	if(trim($('firstname').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your first name</li>';
	};
	
	if(trim($('lastname').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your last name</li>';
	};
	
	if(trim($('address').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your address</li>';
	};
	
	if(trim($('city').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your city</li>';
	};
	
	if(trim($('state').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your state</li>';
	};
	
	if(trim($('phone1').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your phone number</li>';
	};
	
	if(trim($('email').value) == '' || !checkEmail($('email').value))
	{
	   clear = 0;
	   errMsg += '<li>You must enter your email address</li>';
	};
	
	if(clear == 1)
	{
		return true;
	}
	else
	{
		
		errBox = $('error');
		errBox.setStyle({
  backgroundColor: '#FFC',
  border: '1px solid #FF6',
  padding: '5px 10px',
	margin_bottom: '15px'
});
		errMsg = '<h4>Please fix the following errors:</h4><ul>' + errMsg + '</ul>';
		errBox.update(errMsg);
		
		document.location = '#error';
		
		return false;
	};
};
//------------------------------------------------
function validateSchoolSignUp ()
{
	
    clear = 1;
	errMsg = '';
	
	if(trim($('type').value) == '' || (trim($('type').value) != 'new' &&trim($('type').value) != 'renewal' ))
	{
	   clear = 0;
	   errMsg += '<li>You must select a valid membership type</li>';
	};
	
	if(trim($('payment').value) == '' || (trim($('payment').value) != 'paypal' && trim($('payment').value) != 'check'))
	{
	   clear = 0;
	   errMsg += '<li>You must select a valid payment type</li>';
	};
	
	if(trim($('firstname').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your first name</li>';
	};
	
	if(trim($('lastname').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your last name</li>';
	};
	
	if(trim($('school').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your school\'s name</li>';
	};
	
	if(trim($('address').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your address</li>';
	};
	
	if(trim($('city').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your city</li>';
	};
	
	if(trim($('state').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your state</li>';
	};
	
	if(trim($('phone1').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your phone number</li>';
	};
	
	if(trim($('email').value) == '' || !checkEmail($('email').value))
	{
	   clear = 0;
	   errMsg += '<li>You must enter your email address</li>';
	};
	
	if(clear == 1)
	{
		return true;
	}
	else
	{
		
		errBox = $('error');
		errBox.setStyle({
  backgroundColor: '#FFC',
  border: '1px solid #FF6',
  padding: '5px 10px',
	margin_bottom: '15px'
});
		errMsg = '<h4>Please fix the following errors:</h4><ul>' + errMsg + '</ul>';
		errBox.update(errMsg);
		
		document.location = '#error';
		
		return false;
	};
};
//---------------------------------------------
function validateClinicSignUp ()
{
	
    clear = 1;
	errMsg = '';
	if(trim($('clinic').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must select a clinic</li>';
	};
	if(trim($('type').value) == '' || (trim($('type').value) != 'adult' && trim($('type').value) != 'student') && trim($('type').value) != 'school' && trim($('type').value) != 'district')
	{
	   clear = 0;
	   errMsg += '<li>You must select a valid membership type</li>';
	};
	
	if(trim($('payment').value) == '' || (trim($('payment').value) != 'paypal' && trim($('payment').value) != 'check'))
	{
	   clear = 0;
	   errMsg += '<li>You must select a valid payment type</li>';
	};
	
	if(trim($('firstname').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your first name</li>';
	};
	
	if(trim($('lastname').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your last name</li>';
	};
	
	if(trim($('address').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your address</li>';
	};
	
	if(trim($('city').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your city</li>';
	};
	
	if(trim($('state').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your state</li>';
	};
	
	if(trim($('phone1').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your phone number</li>';
	};
	
	if(trim($('email').value) == '' || !checkEmail($('email').value))
	{
	   clear = 0;
	   errMsg += '<li>You must enter your email address</li>';
	};
	
	if(clear == 1)
	{
		return true;
	}
	else
	{
		
		errBox = $('error');
		errBox.setStyle({
  backgroundColor: '#FFC',
  border: '1px solid #FF6',
  padding: '5px 10px',
	margin_bottom: '15px'
});
		errMsg = '<h4>Please fix the following errors:</h4><ul>' + errMsg + '</ul>';
		errBox.update(errMsg);
		
		document.location = '#error';
		
		return false;
	};
};
//---------------------------------------------
function validateJobPost ()
{
    return true;
	checkboxes = $$("#level input");
    clear = 1;
	errMsg = '';
    checkVals = new Array();
    count = checkboxes.length;
    for(i=0; i< count; i++){
        temp = checkboxes.shift();
       
        checkVals.push(temp.getValue());
    }
    valStr = checkVals.toString();
    alert(valStr.replace(",","")); //checkVals.join(",")	
    return(false);	
	if(trim($('entity').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter the name of the entity</li>';
	};
	
	if(trim($('sports').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter the sports to be announced</li>';
	};
	
    if(trim($('contact_name').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your contact\'s name</li>';
	};
    
	if(trim($('contact_address').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your contact\'s address</li>';
	};
	
	if(trim($('contact_city').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your contact\'s city</li>';
	};
	
	if(trim($('contact_state').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your contact\'s state</li>';
	};
	
	if(trim($('contact_phone').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your contact\'s phone number</li>';
	};
	
	if(trim($('contact_email').value) == '' || !checkEmail($('contact_email').value))
	{
	   clear = 0;
	   errMsg += '<li>You must enter a valid email address for your contact</li>';
	};
	
	if(clear == 1)
	{
		return true;
	}
	else
	{
		
		errBox = $('error');
		errBox.setStyle({
  backgroundColor: '#FFC',
  border: '1px solid #FF6',
  padding: '5px 10px',
	margin_bottom: '15px'
});
		errMsg = '<h4>Please fix the following errors:</h4><ul>' + errMsg + '</ul>';
		errBox.update(errMsg);
		
		document.location = '#error';
		
		return false;
	};
};


//---------------------------------------------
function playAudio(track){
    $('mediaplayer').update('<OBJECT ID="player" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab# Version=5,1,52,701" STANDBY="Loading Microsoft Windows® Media Player components..." TYPE="application/x-oleobject" width="50" height="10"> <param name="fileName" value="http://www.naspaa.net/_docs/aoty_voice/'+track+'.m3u"><param name="animationatStart" value="true"><param name="transparentatStart" value="true"><param name="showControls" value="false"><param name="Volume" value="-300"><embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="http://www.naspaa.net/_docs/aoty_voice/'+ track +'.m3u" name="MediaPlayer1" width=50 height=10 autostart=1 showcontrols=0 volume=-300></OBJECT>' );
    
    return false;
}
//---------------------------------------------
function validateVoiceOrder ()
{
	
    clear = 1;
	errMsg = '';

	if(trim($('payment').value) == '' || (trim($('payment').value) != 'paypal' && trim($('payment').value) != 'check'))
	{
	   clear = 0;
	   errMsg += '<li>You must select a valid payment type</li>';
	};
	
	if($('quantity').selectedIndex == 0 ||  Number($('quantity').value) < 1 || Number($('quantity').value) > 12)
	{
	   clear = 0;
	   errMsg += '<li>You must have at least one copy '+  $('quantity').value +'</li>';
	};
	
	if(trim($('name').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your name</li>';
	};
		
	if(trim($('address').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your address</li>';
	};
	
	if(trim($('city').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your city</li>';
	};
	
	if(trim($('state').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your state</li>';
	};
	
	if(trim($('phone').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your phone number</li>';
	};
	
	if(trim($('email').value) == '' || !checkEmail($('email').value))
	{
	   clear = 0;
	   errMsg += '<li>You must enter a valid email address</li>';
	};
	
	if(clear == 1)
	{
		return true;
	}
	else
	{
		
		errBox = $('error');
		errBox.setStyle({backgroundColor: '#FFC', border: '1px solid #FF6', padding: '5px 10px'});
		errMsg = '<h4>Please fix the following errors:</h4><ul>' + errMsg + '</ul>';
		errBox.update(errMsg);
		
		document.location = '#error';
		
		return false;
	};
};
//---------------------------------------------
function validateCourse ()
{
	
    clear = 1;
	errMsg = '';

	if(trim($('payment').value) == '' || (trim($('payment').value) != 'paypal' && trim($('payment').value) != 'check'))
	{
	   clear = 0;
	   errMsg += '<li>You must select a valid payment type</li>';
	};
	
	if(trim($('firstname').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your firstname</li>';
	};
	
	if(trim($('lastname').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your lastname</li>';
	};
		
	if(trim($('address').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your address</li>';
	};
	
	if(trim($('city').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your city</li>';
	};
	
	if(trim($('state').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your state</li>';
	};
	
	if(trim($('phone').value) == '')
	{
	   clear = 0;
	   errMsg += '<li>You must enter your phone number</li>';
	};
	
	if(trim($('email').value) == '' || !checkEmail($('email').value))
	{
	   clear = 0;
	   errMsg += '<li>You must enter a valid email address</li>';
	};
	
	if(clear == 1)
	{
		return true;
	}
	else
	{
		
		errBox = $('error');
		errBox.setStyle({ backgroundColor: '#FFC', border: '1px solid #FF6', padding: '5px 10px'});
		errMsg = '<h4>Please fix the following errors:</h4><ul>' + errMsg + '</ul>';
		errBox.update(errMsg);
		
		document.location = '#error';
		
		return false;
	};
};