<!--//

function addLoadEvent(events, func)
{
	if(typeof window.addEventListener == 'function') {
		window.addEventListener(events, func, false);
		return true;
 	} else if(typeof window.attachEvent == 'object') {
		window.attachEvent('on'+events, func);
		return true;
	}
}

function close_win(){
var nvua = navigator.userAgent;
if(nvua.indexOf('MSIE') >= 0){
if(nvua.indexOf('MSIE 5.0') == -1) {
top.opener = '';
}
}
else if(nvua.indexOf('Gecko') >= 0){
top.name = 'CLOSE_WINDOW';
wid = window.open('','CLOSE_WINDOW');
}
top.close();
}

function changeImg(iName,img){
	document.images[iName].src=img;
}

function _JumpURLnewWin(url,sizeX,sizeY) 
{
  if (url != ''){
    win=window.open(url,"a","scrollbars=1,resizable=yes,width=" + sizeX + ",height=" + sizeY);
  }
}
function _TargetWinOpen(url,sizeX,sizeY,target) 
{
  if (url != ''){
    win=window.open(url,target,"scrollbars=1,resizable=yes,width=" + sizeX + ",height=" + sizeY);
  }
}
function SelectJumpURL(obj) 
{
  url = obj.options[obj.selectedIndex].value;
  if (url != '')
  {
    window.location = url;
  }
}
function mOvr(src,clrOver){ 
	if (!src.contains(event.fromElement)){
		src.style.cursor = 'hand'; 
		src.bgColor = clrOver; 
	} 
} 
function mOut(src,clrIn){ 
	if (!src.contains(event.toElement)){ 
		src.style.cursor = 'default'; 
		src.bgColor = clrIn; 
	} 
} 


//showLayer

function showLay(idName){ 
	if(document.getElementById){//NN6,Mozilla,IE5用
		document.getElementById(idName).style.visibility = 'visible';
	}else if(document.all){//IE4用
		document.all(idName).style.visibility = 'visible';
	}else if(document.layers){//NN4用
		document.layers[idName].visibility = 'show';
	}
}

//hideLayer
function hideLay(idName){ 
	if(document.getElementById){//NN6,Mozilla,IE5用
		document.getElementById(idName).style.visibility = 'hidden';
	}else if(document.all){//IE4用
		document.all(idName).style.visibility = 'hidden';
	}else if(document.layers){//NN4用
		document.layers[idName].visibility = 'hide';
	}
}


// スムーススクロール
function SmoothScroll(targetID){
  if( !document.getElementById ) {return true;}
  var step=10;  //初速度
  var max=400;  //最高速度
  var accel=4;  //加速度
  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;
}


function area_map(stNUM,areacd){
	if(document.area_box.area_name01.value == stNUM){
		Duplicate();
	}else if(document.area_box.area_name02.value == stNUM){
		Duplicate();
	}else if(document.area_box.area_name03.value == stNUM){
		Duplicate();
	}else{
	
		if(document.area_box.area_name01.value == ""){
			document.area_box.area_name01.value = stNUM;
			document.area_box.area_cd01.value = areacd;
		}else if(document.area_box.area_name02.value == ""){
			document.area_box.area_name02.value = stNUM;
			document.area_box.area_cd02.value = areacd;
		}else if(document.area_box.area_name03.value == ""){
			document.area_box.area_name03.value = stNUM;
			document.area_box.area_cd03.value = areacd;
		}else{
			Overflow();
		}
	}
	
}

// smartRollover
function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");

		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_rll."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_rll.", "_on."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_rll."));
				}
			}
		}
	}
}
addLoadEvent( "load",  smartRollover );


