/** icon Script **/
image = new Image();
image.src="https://www.optmedia.jp/favicon.ico";
//-->




function attachDummyValue(inputObj, dummyVal, replaceVal)
{
	if (!inputObj._isDefinedBlurFunc) {
		inputObj._isDefinedBlurFunc = true;
		inputObj._dummyVal          = dummyVal;
		inputObj._replaceVal        = replaceVal;
		inputObj.onblur = function ()
		{
			if (this._replaceVal != this.value) {
				return;
			}
			
			this.value = this._dummyVal;
		};
	}
	
	if (inputObj.value != inputObj._dummyVal) {
		return;
	}
	
	inputObj.value = inputObj._replaceVal;
}

/** faq **/
/*
var
////////////////// 編集箇所 ///////////////////////////////////////
 mouse_on_color = '#0000CC',             // マウスオンの文字色
 mouse_on_background_color = '#ffffff',  // マウスオンの背景色
 mouse_out_color = '#0000CC',            // マウスアウトの文字色
 mouse_out_background_color = '#fff'; // マウスアウトの背景色

///////////////////////////////////////////////////////////////////
function setToggleFunc() {

 var elm;

 if ( document.getElementsByTagName ) {
  for ( var i=1;elm=(document.getElementsByTagName( "*" )[i]);i++ ) {
   if ( !elm.className ) continue;
   if ( elm.parentNode.firstChild == elm ) {
    elm.className.replace( /\bjs_[open|close]\b/, '' );
    continue;
   }
   if ( !elm.className.match(/js_[open|close]/) ) continue;
   var objTrigger = elm.previousSibling;

   while( !objTrigger || objTrigger.nodeType != 1 ) {
    objTrigger = objTrigger.previousSibling;
   }
   if ( !objTrigger ) continue;

   objTrigger.style.cursor = 'pointer';
   objTrigger.className += ' js_mouse_out';
   objTrigger.title += ( elm.className.match(/js_close/) ) ? ' ( click to open )' : ' ( click to close )';
   
   objTrigger.onclick = function () {
    var objTarget = this.nextSibling;
    while ( objTarget.nodeType != 1 ) {
     objTarget = objTarget.nextSibling;
    }

    objTarget.flag = objTarget.className.match(/js_close/);
    if ( objTarget.flag ) {
     objTarget.className = objTarget.className.replace( /\bjs_close\b/, 'js_open' );
     this.title = this.title.replace( /click to open/, 'click to close' );
    } else {
     objTarget.className = objTarget.className.replace( /\bjs_open\b/, 'js_close' );
     this.title = this.title.replace( /click to close/, 'click to open' );
    }
   }

   objTrigger.onmouseover = function () {
    this.className = this.className.replace( /\bjs_mouse_out\b/, 'js_mouse_on' );
    //this.style.color = mouse_on_color;
    //this.style.backgroundColor = mouse_on_background_color;
   }

   objTrigger.onmouseout = function () {
    this.className = this.className.replace( /\bjs_mouse_on\b/, 'js_mouse_out' );
    this.style.color = mouse_out_color;
    this.style.backgroundColor = mouse_out_background_color;
   }

  }
 }
}

var _OK = false;
if ( navigator.appVersion.match( /MSIE (\d+\.\d+)/i ) ) {
 if ( ( RegExp.$1+0 ) >= 5.5 ) _OK = true;
} else _OK = true

function window_onload( f ) {
 if ( _OK ) {
  if ( window.addEventListener ) {
   window.addEventListener( "load", f, false );
  } else if ( window.attachEvent ) {
   window.attachEvent( "onload", f );
  }
 }
}

window_onload( setToggleFunc );

with ( document ) {
 if ( _OK && getElementsByTagName ) {
  var s = "<style type='text\/css'> .js_open { display: block} .js_close { display: none; } .js_mouse_on { color: " + mouse_on_color + " !important; background-color: " + mouse_on_background_color + " !important; } .js_mouse_out { color: " + mouse_out_color + " !important; background-color: " + mouse_out_background_color + " !important; }<\/style>";
  write(s);
 }
}
*/
/*--- wrapscroll.js ---*/
//var wrapScroll=function(){this.initialize.apply(this,arguments);};wrapScroll.prototype={Version:'0.9.5',Interval:500,Duration:60,marginTop:0,marginBottom:0,_timer:0,_obj:null,initialize:function(e,p,r){this.attach(window,'load',this.bind(this.prepare,arguments));},prepare:function(e,p,r){if(o=document.getElementById(e)){this._obj={'e':o,'p':(p)?document.getElementById(p):o.parentNode,'r':(r)?document.getElementById(r):null};o.style.position='absolute';if((c=o.offsetTop)!=(v=((o.style.top=o.offsetTop+'px')!='')?o.offsetTop:0)){o.style.marginTop=0;o.style.top=c+(v-c)+'px';}this.callback();}},callback:function(){f=this.event.update(this,this._obj);setTimeout(this.bind(this.callback),(f)?10:this.Interval);},bind:function(method,arg){var _this=this;var _arg=(arg)?arg:[];return function(){method.apply(_this,_arg);}},attach:function(e,name,func,cap){if(e.addEventListener){e.addEventListener(name,func,cap);}else if(e.attachEvent){e.attachEvent('on'+name,func);}},setTween:function(f,d){if(f){this.tween=f;}if(d){this.Duration=d;}},tween:function(t,b,c,d){return c*(t/=d)*t+b;}};wrapScroll.prototype.event={update:function(t,o){var tpos=Math.max(this.scroll(),(o.r)?this.offset(o.r)+this.height(o.r):this.offset(o.p));var bpos=(this.offset(o.p)+this.height(o.p))-(this.height(o.e)+t.marginBottom);var s=this.offset(o.e);var e=Math.min(bpos,tpos+t.marginTop);if((t._prev!=e)||(t._timer>t.Duration)){t._timer=0;}if((t._prev=e)!=s){o.e.style.top=t.tween(t._timer++,s,e-s,t.Duration,o.e.style)+'px';return true;}return false;},scroll:function(){return document.body.scrollTop||document.documentElement.scrollTop;},height:function(o){return o.offsetHeight||document.body.scrollHeight||document.documentElement.scrollHeight;},offset:function(o){y=o.offsetTop;if(o.style.position=='absolute')return y;while(o=o.offsetParent){y+=o.offsetTop;}return y;}};









	var twin2 = null;
	var swin2 = null;
	var pageVers = {};
	pageVers.tdid = null;
	function setAddress2(tdid) {
	  var url = document.getElementById('hiddenPhpParams').rootPath.value + 'swin/pref/';
	  var param = "?tdid="+tdid;
	  param += "&arg=2";
	  url = url + param;
	  twin2 = new Window( { className: 'spread', url: url,
	    title: '葬儀を行う都道府県を選択', width:655,
	    height:300, destroyOnClose: true, recenterAuto:false, showEffect:Element.show, hideEffect:Element.hide  } );
	  twin2.showCenter();
	}
	function setShiku2(tdid, shid) {
		  var url = document.getElementById('hiddenPhpParams').rootPath.value + 'swin/city/';
		  var param = "?tdid="+tdid;
		  param += "&shid="+shid;
		  param += "&arg=2";
		  url = url + param;
		  swin2 = new Window( { className: 'spread', url: url,
		    title: '葬儀を行う市区町村を選択', width:655,
		    height:650, destroyOnClose: true, recenterAuto:false, showEffect:Element.show, hideEffect:Element.hide });
		  swin2.showCenter();
		}
	function setTdData2(tdid, tdnm, tdkey) {
		var form = document.near_search_form;
		//都道府県情報をセット
		form.todouhuken_id.value = tdid;
		form.todouhuken_url.value = tdkey;
		form.searchshiku_id.value = '';

		var innserHtml1 = '<span class="area1"><a href="#" onclick="setAddress('+form.todouhuken_id.value+')">'+tdnm+'</a></span>　　　';
		innserHtml1 += '<span class="area2" id="shiku_area2"><a href="#" onclick="setShiku2('+form.todouhuken_id.value+', 0)">市区町村を選択</a></span>';
		document.getElementById("adarea2").innerHTML = innserHtml1;
		closetwin2();

		setShiku2(tdid, 0);
	}
	function setShData2(shid, shnm) {
		var form = document.near_search_form;
		//都道府県情報をセット
		form.searchshiku_id.value = shid;

		var innserHtml1 = '<a href="#" onclick="setShiku2('+form.todouhuken_id.value+', '+shid+')">'+shnm+'</a>';
		document.getElementById("shiku_area2").innerHTML = innserHtml1;
		closeSWin2();
	}
	function closetwin2() {
		twin2.close();
	}
	function closeSWin2() {
		swin2.close();
	}
	function jumpNearPage() {
		var form = document.near_search_form;
		if (form.todouhuken_url.value == "" || form.searchshiku_id.value == "") {
			alert('都道府県・市区町村を選択して下さい。');
			return false;
		}
		var url = "<?php echo CMN_TOP_DIR; ?>"+form.todouhuken_url.value+"/search/sakutto/"+form.searchshiku_id.value+"/";
		location.href=url;
	}

	function setPref(id, nm)
	{
		pageVers.tdid = id;
		document.getElementById('prefNm').innerHTML = nm;
		document.getElementById('pref').value = id;
		
		document.getElementById('formAreaDefault').style.display = 'none';
		document.getElementById('formAreaSelected').style.display = 'block';
		
		document.getElementById('cityNm').innerHTML = '市区町村を選択';
		document.getElementById('city').value = '';
		closetwin2();
		
		setShiku2(pageVers.tdid);
	}

	function setCity(id, nm)
	{
		document.getElementById('cityNm').innerHTML = nm;
		document.getElementById('city').value = id;
		
		document.getElementById('formAreaDefault').style.display = 'none';
		document.getElementById('formAreaSelected').style.display = 'block';
		closeSWin2();
	}

	function formRequest()
	{
		if (!document.getElementById('pref').value) {
			alert('都道府県が選択されていません。');
			return false;
		}
		
		/*
		if (!document.getElementById('city').value) {
			alert('市区町村が選択されていません。');
			return false;
		}
		*/
		
		if (!document.getElementById('zip1').value || document.getElementById('zip1').value == '000' || document.getElementById('zip1').value.length != 3) {
			alert('郵便番号が入力されていません。');
			return false;
		}
		
		if (!document.getElementById('zip2').value || document.getElementById('zip2').value == '0000' || document.getElementById('zip2').value.length != 4) {
			alert('郵便番号が入力されていません。');
			return false;
		}
		var form = document.requestForm;
		var inputArea = document.getElementById('nowreq');
		if (!inputArea) {
			inputArea = document.getElementById('form');
		}
		var inputList = inputArea.getElementsByTagName('input');
		var selectList = inputArea.getElementsByTagName('select');
		
		var i = 0;
		var el;
		for (i = 0; i < inputList.length; i++) {
			el = inputList[i];
			form.appendChild(el);
		}
		
		for (i = 0; i < selectList.length; i++) {
			el = selectList[i];
			form.appendChild(el);
		}
		
		form.submit();
	}
