window.addEvent('domready', function() {
  /*  alert("The DOM is ready."); */
});


window.addEvent('domready', function(){
			var scroll = new Fx.Scroll('wrapper', {
				wait: false,
				duration: 1000,
				offset: {'x': 0, 'y':0},
				transition: Fx.Transitions.Quad.easeInOut
			});
			
			$('morph2').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('hallinta');
			});
			
			$('morph1').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('etusivu');
			});
			
			$('etusivu1').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('etusivu');
			});
			
			$('etusivu2').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('etusivu');
			});
			
			$('etusivu3').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('etusivu');
			});
			
			$('etusivu4').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('etusivu');
			});
			
			$('toimii1').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('toimii');
			});
			$('toimii2').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('toimii');
			});
			$('toimii3').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('toimii');
			});
			$('toimii4').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('toimii');
			});
			
			$('tukee1').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('tukee');
			});
			$('tukee2').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('tukee');
			});
			$('tukee3').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('tukee');
			});
			$('tukee5').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('tukee');
			});
			
			$('maksaa1').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('paljonko');
			});
			$('maksaa2').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('paljonko');
			});
			$('maksaa3').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('paljonko');
			});
			$('tilaa1').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('tilaa');
			});
			$('tilaa2').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('tilaa');
			});
			$('tilaa3').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('tilaa');
			});
			$('tilaa4').addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('tilaa');
			});
			
}); 
window.addEvent('domready', function(){
			Fx.Morph = Fx.Styles.extend({
			
				start: function(className){
					
					var to = {};
					
					$each(document.styleSheets, function(style){
						var rules = style.rules || style.cssRules;
						$each(rules, function(rule){
							if (!rule.selectorText.test('\.' + className + '$')) return;
							Fx.CSS.Styles.each(function(style){
								if (!rule.style || !rule.style[style]) return;
								var ruleStyle = rule.style[style];
								to[style] = (style.test(/color/i) && ruleStyle.test(/^rgb/)) ? ruleStyle.rgbToHex() : ruleStyle;
							});
						});
					});
					return this.parent(to);
				}
				
			});
			
			Fx.CSS.Styles = ["backgroundColor", "backgroundPosition", "color", "margin", "width", "height", "left", "top", "bottom", "right", "fontSize", "letterSpacing", "lineHeight", "textIndent", "opacity"];
			
			Fx.CSS.Styles.extend(Element.Styles.padding);
			Fx.CSS.Styles.extend(Element.Styles.margin);
			
			Element.Styles.border.each(function(border){
				['Width', 'Color'].each(function(property){
					Fx.CSS.Styles.push(border + property);
				});
			});
			
			var myMorph = new Fx.Morph('morpher', {wait: false});
			
			$('morph1').addEvent('click', function(e){
				new Event(e).stop();
				
				myMorph.start('morph1');
				
			});
			
			$('morph2').addEvent('click', function(e){
				new Event(e).stop();
				
				myMorph.start('morph2');
				
			});
});

window.addEvent('domready', function(){
			Fx.Morph = Fx.Styles.extend({
			
				start: function(className){
					
					var to = {};
					
					$each(document.styleSheets, function(style){
						var rules = style.rules || style.cssRules;
						$each(rules, function(rule){
							if (!rule.selectorText.test('\.' + className + '$')) return;
							Fx.CSS.Styles.each(function(style){
								if (!rule.style || !rule.style[style]) return;
								var ruleStyle = rule.style[style];
								to[style] = (style.test(/color/i) && ruleStyle.test(/^rgb/)) ? ruleStyle.rgbToHex() : ruleStyle;
							});
						});
					});
					return this.parent(to);
				}
				
			});
			
			Fx.CSS.Styles = ["backgroundColor", "backgroundPosition", "display", "color", "margin", "width", "height", "left", "top", "bottom", "right", "fontSize", "letterSpacing", "lineHeight", "textIndent", "opacity"];
			
			Fx.CSS.Styles.extend(Element.Styles.padding);
			Fx.CSS.Styles.extend(Element.Styles.margin);
			
			Element.Styles.border.each(function(border){
				['Width', 'Color'].each(function(property){
					Fx.CSS.Styles.push(border + property);
				});
			});
			
			var myMorph = new Fx.Morph('morpher2', {wait: false});
			
			$('morph1').addEvent('click', function(e){
				new Event(e).stop();
				
				myMorph.start('morph3');
				
			});
			
			$('morph2').addEvent('click', function(e){
				new Event(e).stop();
				
				myMorph.start('morph4');
				
			});
});
window.addEvent('domready', function(){
			Fx.Morph = Fx.Styles.extend({
			
				start: function(className){
					
					var to = {};
					
					$each(document.styleSheets, function(style){
						var rules = style.rules || style.cssRules;
						$each(rules, function(rule){
							if (!rule.selectorText.test('\.' + className + '$')) return;
							Fx.CSS.Styles.each(function(style){
								if (!rule.style || !rule.style[style]) return;
								var ruleStyle = rule.style[style];
								to[style] = (style.test(/color/i) && ruleStyle.test(/^rgb/)) ? ruleStyle.rgbToHex() : ruleStyle;
							});
						});
					});
					return this.parent(to);
				}
				
			});
			
			Fx.CSS.Styles = ["backgroundColor", "backgroundPosition", "display", "color", "margin", "width", "height", "left", "top", "bottom", "right", "fontSize", "letterSpacing", "lineHeight", "textIndent", "opacity"];
			
			Fx.CSS.Styles.extend(Element.Styles.padding);
			Fx.CSS.Styles.extend(Element.Styles.margin);
			
			Element.Styles.border.each(function(border){
				['Width', 'Color'].each(function(property){
					Fx.CSS.Styles.push(border + property);
				});
			});
			
			var myMorph = new Fx.Morph('morpher3', {wait: false});
			
			$('morph1').addEvent('click', function(e){
				new Event(e).stop();
				
				myMorph.start('morph5');
				
			});
			
			$('morph2').addEvent('click', function(e){
				new Event(e).stop();
				
				myMorph.start('morph6');
				
			});
});
window.addEvent('domready', function(){
			Fx.Morph = Fx.Styles.extend({
			
				start: function(className){
					
					var to = {};
					
					$each(document.styleSheets, function(style){
						var rules = style.rules || style.cssRules;
						$each(rules, function(rule){
							if (!rule.selectorText.test('\.' + className + '$')) return;
							Fx.CSS.Styles.each(function(style){
								if (!rule.style || !rule.style[style]) return;
								var ruleStyle = rule.style[style];
								to[style] = (style.test(/color/i) && ruleStyle.test(/^rgb/)) ? ruleStyle.rgbToHex() : ruleStyle;
							});
						});
					});
					return this.parent(to);
				}
				
			});
			
			Fx.CSS.Styles = ["backgroundColor", "backgroundPosition", "display", "color", "margin", "width", "height", "left", "top", "bottom", "right", "fontSize", "letterSpacing", "lineHeight", "textIndent", "opacity"];
			
			Fx.CSS.Styles.extend(Element.Styles.padding);
			Fx.CSS.Styles.extend(Element.Styles.margin);
			
			Element.Styles.border.each(function(border){
				['Width', 'Color'].each(function(property){
					Fx.CSS.Styles.push(border + property);
				});
			});
			
			var myMorph = new Fx.Morph('wrapper', {wait: false});
			
			$('morph1').addEvent('click', function(e){
				new Event(e).stop();
				
				myMorph.start('wrapper');
				
			});
			
			$('morph2').addEvent('click', function(e){
				new Event(e).stop();
				
				myMorph.start('wrapper2');
				
			});
});
window.addEvent('domready', function(){
			$('myForm').addEvent('submit', function(e) {
				/**
				 * Prevent the submit event
				 */
				new Event(e).stop();
			
				/**
				 * This empties the log and shows the spinning indicator
				 */
				var log = $('log_res').empty().addClass('ajax-loading');
			
				/**
				 * send takes care of encoding and returns the Ajax instance.
				 * onComplete removes the spinner from the log.
				 */
				this.send({
					update: log,
					onComplete: function() {
						log.removeClass('ajax-loading');
					}
				});
			});
});	

window.addEvent('domready', function(){
			$('myForm').addEvent('submit', function(e) {
				/**
				 * Prevent the submit event
				 */
				new Event(e).stop();
			
				/**
				 * This empties the log and shows the spinning indicator
				 */
				var log = $('log_res').empty().addClass('ajax-loading');
			
				/**
				 * send takes care of encoding and returns the Ajax instance.
				 * onComplete removes the spinner from the log.
				 */
				this.send({
					update: log,
					onComplete: function() {
						log.removeClass('ajax-loading');
					}
				});
			});
});	

window.addEvent('domready', function(){
			$('myForm2').addEvent('submit', function(e) {
				/**
				 * Prevent the submit event
				 */
				new Event(e).stop();
			
				/**
				 * This empties the log and shows the spinning indicator
				 */
				var log = $('log_res2').empty().addClass('ajax-loading');
			
				/**
				 * send takes care of encoding and returns the Ajax instance.
				 * onComplete removes the spinner from the log.
				 */
				this.send({
					update: log,
					onComplete: function() {
						log.removeClass('ajax-loading');
					}
				});
			});
});	

window.addEvent('domready', function(){
			$('myForm3').addEvent('submit', function(e) {
				/**
				 * Prevent the submit event
				 */
				new Event(e).stop();
			
				/**
				 * This empties the log and shows the spinning indicator
				 */
				var log = $('log_res3').empty().addClass('ajax-loading');
			
				/**
				 * send takes care of encoding and returns the Ajax instance.
				 * onComplete removes the spinner from the log.
				 */
				this.send({
					update: log,
					onComplete: function() {
						log.removeClass('ajax-loading');
					}
				});
			});
});	

window.addEvent('domready', function(){
			$('myForm4').addEvent('submit', function(e) {
				/**
				 * Prevent the submit event
				 */
				new Event(e).stop();
			
				/**
				 * This empties the log and shows the spinning indicator
				 */
				var log = $('log_res4').empty().addClass('ajax-loading');
			
				/**
				 * send takes care of encoding and returns the Ajax instance.
				 * onComplete removes the spinner from the log.
				 */
				this.send({
					update: log,
					onComplete: function() {
						log.removeClass('ajax-loading');
					}
				});
			});
});	

window.addEvent('domready', function(){
			$('myForm5').addEvent('submit', function(e) {
				/**
				 * Prevent the submit event
				 */
				new Event(e).stop();
			
				/**
				 * This empties the log and shows the spinning indicator
				 */
				var log = $('log_res5').empty().addClass('ajax-loading');
			
				/**
				 * send takes care of encoding and returns the Ajax instance.
				 * onComplete removes the spinner from the log.
				 */
				this.send({
					update: log,
					onComplete: function() {
						log.removeClass('ajax-loading');
					}
				});
			});
});	

function clearForms()
{
  var i;
  for (i = 0; (i < document.forms.length); i++) {
    document.forms[i].reset();
  }
}

window.addEvent('domready',function() { new SmoothScroll({ duration:  1000 }); });

window.addEvent('domready', function(){
			var accordion = new Accordion('h3.atStart', 'div.atStart', {
				opacity: false,
				onActive: function(toggler, element){
					toggler.setStyle('color', '#006de1');
				},
				
				onBackground: function(toggler, element){
					toggler.setStyle('color', '#222');
				}
			}, $('accordion'));
			
			accordion.addSection(newTog, newEl, 0);
}); 

