// JavaScript Document

/**
 * なめらかスクロール
 * 
 */
function smoothScroll() {
	$$('a[href^=#]:not([href=#])').each(function(element) {
		element.observe('click', function(event) {
			new Effect.ScrollTo(this.hash.substr(1), {duration: 0.4});
			Event.stop(event);
			}.bindAsEventListener(element))
	})
}

/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/
function initRollovers() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");

		for(var i=0; i < images.length; i++) {
			if (images[i].className == 'rollover') {
				// 画像をプリロードする
				var preImages = new Image();
				if (!images[i].getAttribute("src").match("_on.")) {
					preImages.src = images[i].getAttribute("src").replace(".gif", "_on.gif");
					preImages.src = images[i].getAttribute("src").replace(".jpg", "_on.jpg");
					preImages.src = images[i].getAttribute("src").replace(".png", "_on.png");
			} else {
					preImages.src = images[i].getAttribute("src").replace("_on.gif", ".gif");
					preImages.src = images[i].getAttribute("src").replace("_on.jpg", ".jpg");
					preImages.src = images[i].getAttribute("src").replace("_on.png", ".png");
				}
			
				images[i].onmouseover = function() {
					if (!this.getAttribute("src").match("_on.")) {
						this.setAttribute("src", this.getAttribute("src").replace(".gif", "_on.gif"));
						this.setAttribute("src", this.getAttribute("src").replace(".jpg", "_on.jpg"));
						this.setAttribute("src", this.getAttribute("src").replace(".png", "_on.png"));
					}
				}
				images[i].onmouseout = function() {
					if (this.getAttribute("src").match("_on.")) {
						this.setAttribute("src", this.getAttribute("src").replace("_on.gif", ".gif"));
						this.setAttribute("src", this.getAttribute("src").replace("_on.jpg", ".jpg"));
						this.setAttribute("src", this.getAttribute("src").replace("_on.png", ".png"));
					}
					if (this.getAttribute("src").match("_stay.")) {
						this.setAttribute("src", this.getAttribute("src").replace("_stay.gif", ".gif"));
						this.setAttribute("src", this.getAttribute("src").replace("_stay.jpg", ".jpg"));
						this.setAttribute("src", this.getAttribute("src").replace("_stay.png", ".png"));
					}
				}
			}
		}
	}
}
