/*
 * 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;
}


/*Jquery用js
----------------------*/
/*Wink用*/
/*$(function(){
	$("img.wink").hover(function(){
		$(this).css("opacity", "0.2");
		$(this).css("filter", "alpha(opacity=20)");
		$(this).fadeTo("slow", 1.0);
	});
	
});
*/

/*ポップアップ
----------------------*/

function therapy(){
	st = "scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no";
	wx =700;
	wy = screen.height - (screen.height*0.15);
	x = (screen.width  - wx) / 2;
	y = ((screen.height - wy) / 2) - 30;
	newwin = window.open("therapy.html","newWinTherapy","left="+x+",top="+y+",width="+wx+",height="+wy+","+st);
	newwin.focus();
}

function therapyForm()
{
   newWindow=window.open('https://www.nsg.gr.jp/wan/form_therapy/','newWinTForm','width=640,height=500,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');
	 newWindow.focus();
}

function reserve()
{
   newWindow=window.open('https://www.nsg.gr.jp/wan/form_seminar/','newWin','width=640,height=500,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');
	 newWindow.focus();
}

/*2009/11/10追加*/
function reserve_sec()
{
   newWindow=window.open('https://www.nsg.gr.jp/wan/form_seminar_second/','newWin','width=640,height=500,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');
	 newWindow.focus();
}



function oc()
{
   newWindow=window.open('https://www.nsg.gr.jp/wan/form/form_seminar.html','newWin','width=640,height=500,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');
	 newWindow.focus();
}

function require()
{
   newWindow=window.open('https://www.nsg.gr.jp/wan/form/','newWin','width=640,height=500,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');
	 newWindow.focus();
}





/*Flv用ポップアップ*/
function mov01()
{
   newWindow=window.open('movie/movie01.html','movWin','width=830,height=610,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');
	 newWindow.focus();
}

function mov02()
{
   newWindow=window.open('movie/movie02.html','movWin','width=830,height=610,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');
	 newWindow.focus();
}

function mov03()
{
   newWindow=window.open('movie/movie03.html','movWin','width=830,height=610,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');
	 newWindow.focus();
}

function mov04()
{
   newWindow=window.open('movie/movie04.html','movWin','width=830,height=610,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');
	 newWindow.focus();
}

function mov05()
{
   newWindow=window.open('movie/movie05.html','movWin','width=830,height=610,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');
	 newWindow.focus();
}


function tv01()
{
   newWindow=window.open('tv/movie01.html','movWin','width=830,height=710,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');
	 newWindow.focus();
}


/*学校説明会サポート*/
function oc_support(){
	st = "scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no";
	wx =700;
	wy = screen.height - (screen.height*0.15);
	x = (screen.width  - wx) / 2;
	y = ((screen.height - wy) / 2) - 30;
	newwin = window.open("extra/oc_support.html","newWin","left="+x+",top="+y+",width="+wx+",height="+wy+","+st);
	newwin.focus();
}

/*ポップアップ*/
function disp(url){ 
window.open(url, "popup", "width=640,height=550,scrollbars=yes");
}


var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}


/*旧サイト引継ぎ*/
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->


/*popup*/
function noguchiNotHara(url,wx,wy){
	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,"newWin","left="+x+",top="+y+",width="+wx+",height="+wy+","+st);
	newwin.focus();
}



/*2010夏イベント
------------------------------*/

/*Flash上からUserAgent変更*/
function getUserAgent() {
	uAgent = "";
	uAgent = navigator.userAgent;
	if((uAgent.indexOf("Safari") != -1)||(uAgent.indexOf("Opera") != -1)){
	uAgent = 1;
	}
	return uAgent;
}


function oc_summer2010(){
	st = "scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no";
	wx =1000;
	wy = 900;
	x = (screen.width  - wx) / 2;
	y = ((screen.height - wy) / 2) - 50;
	newwin = window.open("extra/2010summerfes.html","summerWin","left="+x+",top="+y+",width="+wx+",height="+wy+","+st);
	newwin.focus();
}
