window.addEvent('domready', function(){						 
									 
										 
	// Table Alternating colors
	function updateTableColors() {
		var count = 0;
		$$('table.styledtable tr').each(function(el) {
			el.addClass(count++ % 2 == 0 ? 'odd' : 'even');
		});
	};
	updateTableColors();

	// Smooth Page Scrolling to Bookmarks
	// var tmp = new SmoothScroll({duration:500, wait: false, wheelStops:true},$(document.body));
	
	
	// Begin Question Wizard
	
	var quest_panel_height = 270;
	var quest_panel_width = 480;
	var quest_panel_padding = 40;
	
	function initQuestions() {
			
		$$('div.quest_mask').each(function(el) {
			el.setStyles({
				width: quest_panel_width,
				height: quest_panel_height,
				visibility: 'visible'
			});

			$$('table.quest_grid tbody tr td').each(function(ele) {
				var questDiv_quest_panel  = new Element('div', {
					'class': 'quest_panel',
					'html': ele.get('html'),
					'styles': {
						'height': (quest_panel_height - (quest_panel_padding * 2)),
						'width': (quest_panel_width - (quest_panel_padding * 2)),
						'padding': (quest_panel_padding)
					}
				});
				ele.erase('html');
				questDiv_quest_panel.inject(ele);
			});
			
		
		});
	}
	initQuestions();
	
	function questMove(direction, multiplier) {
		$$('div.quest_panels').each(function(el) {
			var currentTop = el.getStyle('margin-top').toInt();
			var currentLeft = el.getStyle('margin-left').toInt();
			var moveDistance = 0;
			
			var quest_panels_effect = new Fx.Morph(el, {duration: 'long', transition: Fx.Transitions.Cubic.easeOut});
			
			if (direction == 'up') {
				moveDistance = currentTop + (quest_panel_height * multiplier);
				//el.setStyle('margin-top', moveDistance);
				quest_panels_effect.start({
						'margin-top': [currentTop, moveDistance]
				});
			} else if (direction == 'down') {
				moveDistance = currentTop - (quest_panel_height * multiplier);
				//el.setStyle('margin-top', moveDistance);
				quest_panels_effect.start({
						'margin-top': [currentTop, moveDistance]
				});
			} else if (direction == 'left') {
				moveDistance = currentLeft + (quest_panel_width * multiplier);
				//el.setStyle('margin-left', moveDistance);
				quest_panels_effect.start({
						'margin-left': [currentLeft, moveDistance]
				});
			} else if (direction == 'right') {
				moveDistance = currentLeft - (quest_panel_width * multiplier);
				//el.setStyle('margin-left', moveDistance);
				quest_panels_effect.start({
						'margin-left': [currentLeft, moveDistance]
				});
			} else {
				alert('That direction is not supported.');
			}
		});
	}
	questMove('right',2);
	
	$$('a.quest_up1').each(function(el) {
		el.addEvent('click', function(){
			questMove('up',1);
		});
	});
	$$('a.quest_down1').each(function(el) {
		el.addEvent('click', function(){
			questMove('down',1);
		});
	});
	$$('a.quest_left1').each(function(el) {
		el.addEvent('click', function(){
			questMove('left',1);
		});
	});
	$$('a.quest_right1').each(function(el) {
		el.addEvent('click', function(){
			questMove('right',1);
		});
	});
	
	$('quest_reset').addEvent('click', function(){
		$$('div.quest_panels').each(function(el) {
			el.setStyles({
				'margin-top': '0px',
				'margin-left': '0px'
			});
			questMove('right',2);
		});										  	
	});
	
	 // End Question Wizard
	
}); 
