
/*
--------------------------------------------------
  Scrolling Script (2006.07.26)
  (C)2006 avex network All rights reserved.

  ex :::> onclick="goToTop(); return false;"

--------------------------------------------------*/

// Screen WinIE
var ua = navigator.userAgent.toLowerCase();
var Win = ua.indexOf("windows") != -1 ? true:false;
var IE = ua.indexOf("msie") != -1 ? true:false;
// Preference
var timerID;
var targetX = 0;
var targetY = 0;
if (Win && IE) {
	var deccel = 2;
} else {
	var deccel = 3;
}
var fps = 30;
var setDist = 0.75;
// Execute
function goToTop() {
	timerID = setInterval("scrolling()", 1000 / fps);
}
// Make scrolling progress
function scrolling() {
	var distX = targetX - getLeft();
	var distY = targetY - getTop();
	speedX = distX / deccel;
	speedY = distY / deccel;
	if (Math.abs(speedX) <= setDist && Math.abs(speedY) <= setDist) {
		window.scrollTo(targetX,targetY);
		clearInterval(timerID);
	} else {
		window.scrollBy(speedX,speedY);
	}
}
// Current position form TOP
function getTop() {
	if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
		return document.documentElement.scrollTop;
	} else if (document.body && document.all) { // all other Explorers
		return document.body.scrollTop;
	} else if (window.pageYOffset != undefined) { // all except Explorer
		return window.pageYOffset;
	} else {
		return targetY;
	}
}
// Current position form LEFT
function getLeft() {
	if (document.documentElement && document.documentElement.scrollLeft) { // Explorer 6 Strict
		return document.documentElement.scrollLeft;
	} else if (document.body && document.all) { // all other Explorers
		return document.body.scrollLeft;
	} else if (window.pageXOffset != undefined) { // all except Explorer
		return window.pageXOffset;
	} else {
		return targetX;
	}
}



/* Write Flash Object + flashVars (05.08.2006)
--------------------------------------------------*/
function flashWriter(SOURCE, WIDTH, HEIGHT, PAGE) {
	var flashValue = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + WIDTH + '" height="' + HEIGHT + '">';
	flashValue += '<param name="movie" value="' + SOURCE + '?page=' + PAGE + '">';
	flashValue += '<param name="menu" value="false">';
	flashValue += '<param name="quality" value="high">';
	flashValue += '<embed src="' + SOURCE + '?page=' + PAGE + '" quality="high" menu="fasle" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + WIDTH + '" height="' + HEIGHT + '"></embed>';
	flashValue += '</object>';
	document.write(flashValue);
}


