/*
 * common.js
 * スパム対策、ページスクロール
*/

/*スパム対策*/
<!--
function vspam(im,domain) {
  maddress = "mailto:" + im + "@" + domain;
  window.location.href = maddress;
}
// -->


/*ページスクロール*/
function SmoothScroll(targetID){
  if( !document.getElementById ) {return true;}
  var step=1;  //初速度
  var max=200;  //最高速度
  var accel=1;  //加速度
  var interval=1;  //加速インターバル
  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;
}



/*ポップアップ:サンプル
----------------------*/
function openMap(url,wName,pro){
	winMap = window.open(url,wName,pro);	
	winMap.document.close();
}

/*本番URL
function reserve()
{
   adWindow=window.open('http://●●●●/reseve.php','newWin','width=600,height=800,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');
}
*/

function enqWin() { 
	st = "scrollbars=yes,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no";
	wx = 960;
	wy = 800;
	x = (screen.width  - wx) / 2;
	y = ((screen.height - wy) / 2) - 30;
	newwin = window.open("http://mm.show-net.jp/enquete/enq100621/pc/inputform.html","enqWin","left="+x+",top="+y+",width="+wx+",height="+wy+","+st);
	newwin.focus();
}


function dreamsWin() { 
	st = "scrollbars=yes,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no";
	wx = 1020;
	wy = 800;
	x = (screen.width  - wx) / 2;
	y = ((screen.height - wy) / 2) - 30;
	newwin = window.open("dreams/index.html","dreamsWin","left="+x+",top="+y+",width="+wx+",height="+wy+","+st);
	newwin.focus();
}

/*popup*/
function noguchiNotHara(url,wx,wy,wName){
	var st = "";
	
	st = "scrollbars=yes,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no";
	if(wy == ''){
		wy = screen.height - (screen.height*0.15);
	}
	x = (screen.width  - wx) / 2;
	y = ((screen.height - wy) / 2) - 30;
	newwin = window.open(url,wName,"left="+x+",top="+y+",width="+wx+",height="+wy+","+st);
	newwin.focus();
}

$(function() {
	anchorScroll();
	$("#topicPath li:last").addClass("last");
	
   	$(".pickup_box").click(function(){
         window.location=$(this).find("a").attr("href");
         return false;
    });

});

function anchorScroll(){
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
   			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
   			if ($target.length) {
  				var targetOffset = $target.offset().top;
  				$('html,body')
  				.animate({scrollTop: targetOffset}, 1000);
    			return false;
			}
		}
 	});
}

