document.observe('dom:loaded', function(){
	var pkg = {
		tag: 'body',
		list: [{script: 'js/lib/scriptaculous.js'},
			{script: 'js/lib/effects.js'},			
			{script: 'js/lib/qmFormValidator.js', 
				callback: function() {					
					$('sendContactForm').observe('click', function(event){				
						for(var i=0; i<document.forms.length; i++) {
				        	if(document.forms[i].id == 'contactForm') {
								var fv = new qm.FormValidator();
				            	if(fv.validate('contactForm') == true) {
									new Ajax.Request('contact.php', {
										method: 'post',
										parameters: $('contactForm').serialize(),
										onSuccess: function(r) {
											alert('Thank you for contacting Evolution Academy Charter School!');
											$('contactForm').reset();
										},
										onFailure: function(r) {
											alert('Your email could not be sent at this time. Please try again later.');
											$('contactForm').reset();
										}
									});				                	
				               	}
								break;
				           	}
				        }
					 });			
				}
			},
			{script: 'js/lib/qmRandomizeImage.js',
				callback: function() {	
					var imgs = [
						'images/page_blurb_1.png',
						'images/page_blurb_2.png',
						'images/page_blurb_3.png'		
					];		
					var ri = new qm.RandomizeImage();
					ri.randomize(imgs, 'banner');
				}
			}
		]
	};	
	qm.use(pkg);
	$('contactForm').reset();
});