/*-----------------------------------------------------------------
	scroll2top Version 0.2
	Last updated on 2003/11/28
	Script written by saz & masaki omi.
-----------------------------------------------------------------*/

// Sampla code
// <a href="#top" onClick="if(swScrollStart()){return false;}">
// ↑"#top"の部分は一番上の要素のid名もしくはclass名を入れて下さい

// const
var SW_SCROLL_SPD=0.36;	//scroll speed
var SW_SCROLL_INTERVAL=33;	//timer interval (msec)

// vars
var cnt;			//counter for speed test

function swScrollStart() {
	// if scrolling is possible, return true.
cnt=0;
	if(window.pageYOffset){
		// NN3 is not supported.
		window.scroll(0,Math.floor(window.pageYOffset*0.94));
		timScroll=setTimeout("swScrollNN()",SW_SCROLL_INTERVAL);
		return true;
	}else if (document.all && document.getElementById && (document.compatMode=='CSS1Compat')) {
		// ウィンドウズIE 6・標準モード。
		window.scroll(0,Math.floor(document.documentElement.scrollTop*0.94));
		timScroll=setTimeout("swScrollIE6()",SW_SCROLL_INTERVAL);
		return true;
	}else if(document.body && document.body.scrollTop){
		window.scroll(0,Math.floor(document.body.scrollTop*0.94));
		timScroll=setTimeout("swScrollIE()",SW_SCROLL_INTERVAL);
		return true;
	}else{
		return false;
	}
}

function swScrollIE6(){
	clearTimeout(timScroll);
	var y=Math.floor(document.documentElement.scrollTop*SW_SCROLL_SPD);
	if(y>0){
		// scroll main
		window.scroll(0,y);
		timScroll=setTimeout("swScrollIE6()",SW_SCROLL_INTERVAL);
	}else{
		//scroll end
		window.scroll(0,0);
	}
}
function swScrollIE(){
	clearTimeout(timScroll);
	var y=Math.floor(document.body.scrollTop*SW_SCROLL_SPD);
	if(y>0){
		// scroll main
		window.scroll(0,y);
		timScroll=setTimeout("swScrollIE()",SW_SCROLL_INTERVAL);
	}else{
		//scroll end
		window.scroll(0,0);
	}
}
function swScrollNN(){
	clearTimeout(timScroll);
	var y=Math.floor(window.pageYOffset*SW_SCROLL_SPD);
	if(y>0){
		// scroll main
		window.scroll(0,y);
		timScroll=setTimeout("swScrollNN()",SW_SCROLL_INTERVAL);
	}else{
		//scroll end
		window.scroll(0,0);
	}
}

/*-- Rollover --*/
function initRollovers() {
	if (!document.getElementById) return

	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {	
		if (aImages[i].className == 'ov') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);

			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;

			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	

			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

function init() {
	initRollovers();
}

window.onload = init;

