/**
 *	Class:		ContentShield
 *	Purpose:		Collection of functions used to
 *					validate age, etc for shielded content
 *
 */
var ContentShield = {

	//Static holder of birthday string
	birthday : null,

	//Static holder of month value
	sel_month : null,

	//Static holder of day value
	sel_day : null,
	
	//Static holder of year value
	sel_year : null,
		
	
	/**
	 *	Function:	setMonthValue
	 *	Purpose:		Set the one of the birthday components
	 *
	 *	@param string component ~The value to set, ie month, day, year
	 *	@return void
	 */
	setDateValue : function(component) {
		
		//Try to grab the month object
		var obj = document.getElementById(component);
		
		//Make sure there is a month object
		if(obj == undefined) {
			
			alert('invalid form');
			return;
		}
		
		//See if they are still on the default
		if(obj.value == 0) {
			
			alert('Invalid selection');
			return;
		}
		
		//Set the class variable based on the selection
		switch(component) {
			
			case 'month':
				ContentShield.sel_month = obj.value;
				break;
			case 'day':
				ContentShield.sel_day = obj.value;
				break;			
			case 'year':
				ContentShield.sel_year = obj.value;
				break;			
			default:
				alert('Invalid selection');
				break;			
		}
		
		return;		
	},
	
	/**
	 *	Function:	validateBday
	 *	Purpose:		Make sure there is a valid birthday - build
	 *					the birthday string, and submit the form
	 *
	 *	@return void
	 */
	validateBday : function() {
		
		//Make sure the object has these set
		if((ContentShield.sel_month == null) ||
			(ContentShield.sel_day == null) ||
			(ContentShield.sel_year == null)) {
				
			alert('Please complete the form.');
			return;				
		}		
		
		//Build the birtday string
		ContentShield.birthday = '';
		ContentShield.birthday += ContentShield.sel_month + '-';
		ContentShield.birthday += ContentShield.sel_day + '-';
		ContentShield.birthday += ContentShield.sel_year;
		
		var obj = document.getElementById('birthday');
		
		//Make sure there is birthday object to submit
		if(obj == undefined) {
			
			alert('Invalid form.');
			return;
		}
		
		//Set the object
		obj.value = ContentShield.birthday;
		
		//Submit the form
		document.forms['age_check_form'].submit();
		return;
	}
}
