//Backtotop Smooth Scroll
function backtotop() {
  var x1 = x2 = x3 = 0;
  var y1 = y2 = y3 = 0;
  if (document.documentElement) {
      x1 = document.documentElement.scrollLeft || 0;
      y1 = document.documentElement.scrollTop || 0;
  }
  if (document.body) {
      x2 = document.body.scrollLeft || 0;
      y2 = document.body.scrollTop || 0;
  }
  x3 = window.scrollX || 0;
  y3 = window.scrollY || 0;
  var x = Math.max(x1, Math.max(x2, x3));
  var y = Math.max(y1, Math.max(y2, y3));
  window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));
  if (x > 0 || y > 0) {
      window.setTimeout("backtotop()", 25);
  }
}

//smoothscroll
function SmoothScroll(targetID){
  if( !document.getElementById ) {return true;}
  var step=100;  //初速度
  var max=1000;  //最高速度
  var accel=5;  //加速度
  var interval=30;  //加速インターバル
  var current_y = document.body.scrollTop  || document.documentElement.scrollTop;
  var element=document.getElementById(targetID);
  if (!element){return true;}
  var target_y = 0;
  for (i = element;i.offsetParent;i=i.offsetParent ){
    target_y += i.offsetTop;
  }
  var count=0;
  if ( current_y > target_y ){ step = -(step); accel = -(accel);}
  var timerid = setInterval( function(){
    if (step<max) step += (count*accel);
    if ( Math.abs(current_y-target_y) < Math.abs(step) ){
      window.scrollTo((document.body.scrollTop  || document.documentElement.scrollTop),target_y);
      clearInterval(timerid);
      return false;
    }else{
      window.scrollBy(0,step);
      current_y += step;
      count++;
    }
  },interval);
  return false;
}

//View flash
function viewFlash(file,width,height){
  document.write('<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+'">\n');
  document.write('<param name="movie" value="'+file+'">\n');
  document.write('<param name="quality" value="high">\n');
  document.write('<param name="wmode" value="transparent">\n');
  document.write('<embed src="'+file+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed>\n');
  document.write('</object>\n');
}

function viewFlashMov(file,width,height){
  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8.0.35.0" width="'+width+'" height="'+height+'">\n');
  document.write('<param name="movie" value="'+file+'">\n');
  document.write('<param name="quality" value="high">\n');
  document.write('<param name="wmode" value="opaque">\n');
  document.write('<param name="swfversion" value="8.0.35.0">\n');
  <!-- このパラメータタグにより、Flash Player 6.0 または 6.5 以降を使用して、Flash Player   の最新バージョンをダウンロードするようメッセージが表示されます。ユーザにメッセージを表示させないようにする場合はパラメータタグを削除します。 -->
  document.write('<param name="expressinstall" value="../../flash/expressInstall.swf">\n');
  document.write('<embed src="'+file+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed>\n');
  document.write('</object>\n');
}

function popup(di,wi,he){
  filez = 'http://www.everlife.jp/company/' + di + '.html';
  prop = 'toolbar=yes,scrollbars=yes,resizable=yes,menubar=no,directories=no,status=0,locationbar=no,width=' + wi + ',height=' + he;
  nam = di;
  win_name = window.open(filez,nam,prop);
}

function btnConform(){
	var inputs = document.getElementsByTagName("input");
	for( var i=0,j=inputs.length; i<j; i++){
		var btn = inputs[i]; 
		if(btn.getAttribute("class") == "input_btn"){
			btn.onmouseover = function(){
				this.style.backgroundPosition = 'left -53px';
				return false;
			}
			btn.onmouseout = function(){
				this.style.backgroundPosition = 'left top';
				return false;
			}
		}

		else if(btn.getAttribute("className") == "input_btn"){
			btn.onmouseover = function(){
				this.style.backgroundPosition = 'left -53px';
				return false;
			}
			btn.onmouseout = function(){
				this.style.backgroundPosition = 'left top';
				return false;
			}
		}

	}
}

window.onload = btnConform;
