Ozein.PinPoint = new Class.create();
Ozein.PinPoint.prototype = {
    initialize: function(node, options) {
        this.node = node;
        var modules = this._getModule(node);
        for (var i = 0; i<modules.length; i++) {
            var attributeName = modules[i].getAttribute('ozein_module');
            if(attributeName == 'input') {
                Event.observe(modules[i], 'click', this.showWindow.bindAsEventListener(this, modules[i]));
            } else if(attributeName == 'back'){
                Event.observe(modules[i], 'click', this.showBackWindow.bindAsEventListener(this, modules[i]));
            }
        }
        
    },
    /**
     *ピンポイント問合せ入力画面表示
     */
    showWindow : function(e, node) {
        var baseUri  = node.getAttribute('ozein_link');
        new Ajax.Request(
            baseUri,
            {
                method: 'get',
                requestHeaders : ['If-Modified-Since','Wed, 15 Nov 1995 00:00:00 GMT'],
                onSuccess: function(o) {
                    $('pinpointdiv').innerHTML = o.responseText;
                }.bind(this)
            }
        );
    },
    _getModule : function (baseNode) {
        return document.getElementsByAttribute('ozein_module', '*', '*');
    }
},
/**
* ピンポイント問合せHowtoタグ制御
*/
Ozein.SwitchHowto = function() {
  //全てのチェックがOFFなら全ての項目を表示する
  var how1 = document.getElementById('howto1').checked;
  var how2 = document.getElementById('howto2').checked;
  var how4 = document.getElementById('howto4').checked;
  var how8 = document.getElementById('howto8').checked;
  if(!how1 && !how2 && !how4 && !how8) {
    $('divMail').style.display = '';
    $('divTel').style.display = '';
    $('divFax').style.display = '';
    $('divAddr').style.display = '';
    $('email').value = '';
    $('tel1').value = '';
    $('tel2').value = '';
    $('tel3').value = '';
    $('fax1').value = '';
    $('fax2').value = '';
    $('fax3').value = '';
    $('zip1').value = '';
    $('zip2').value = '';
    document.getElementById('prefecture').options.selectedIndex=0;
    $('address_addr1_2').value = '';
    $('address_addr2').value = '';
    $('address_addr3').value = '';
    //IFrameの高さ変更
    Ozein.FixPinpointFrame();
    return true;
  }
  if(how1) {
    $('divMail').style.display = '';
  } else {
    $('divMail').style.display = 'none';
    $('email').value = '';
  }

  if(how2) {
    $('divTel').style.display = '';
  } else {
    $('divTel').style.display = 'none';
    $('tel1').value = '';
    $('tel2').value = '';
    $('tel3').value = '';
  }
  if(how4) {
    $('divFax').style.display = '';
  } else {
    $('divFax').style.display = 'none';
    $('fax1').value = '';
    $('fax2').value = '';
    $('fax3').value = '';
  }
  
  if(how8) {
    $('divAddr').style.display = '';
  } else {
    $('divAddr').style.display = 'none';
    $('zip1').value = '';
    $('zip2').value = '';
    document.getElementById('prefecture').options.selectedIndex=0;
    $('address_addr1_2').value = '';
    $('address_addr2').value = '';
    $('address_addr3').value = '';
  }
  //IFrameの高さ変更
  Ozein.FixPinpointFrame();
  return true;
},
/**
 * Submit実行
 */
Ozein.SubmitPinpoint = function() {
	//document.getElementById('frmPinpoint').style.display = '';
    $('f_inq').target = 'frmPinpoint';
    $('f_inq').submit();
    return true;
},
Ozein.SubmitPinpointBack = function() {
    $('f_inq').inquireStep.value = 9;
    $('f_inq').target = 'frmPinpoint';
    $('f_inq').submit();
    return true;
},
/**
 * 指定IDのタグ以下を空要素に
 */
Ozein.ClearPinpoint = function(node) {
    node.innerHTML = '';
    node.style.zIndex = -1;
    return true;
},
/**
* IFrameの高さ変更
*/
Ozein.FixPinpointFrame = function() {
  changeH = 0;
  if(/MSIE/.test(navigator.userAgent)){
    changeH = parent.document.getElementById('frmPinpoint').contentWindow.document.body.scrollHeight + 'px';
  } else {
    changeH = parent.document.getElementById('frmPinpoint').contentWindow.document.body.offsetHeight + 'px';
  }
  parent.document.getElementById('frmPinpoint').height = changeH;
  return true;
}

