// JavaScript Document

MJL.event.add(window, "load", function() {
	//
    // 画像とテキスト (based on jQuery)
    //
    // 画像とテキストの並列処理を行う関数を返す高階関数
    function getImgParallelStyler(side) {
        // side は既定値しか認めない
        if ("left" != side && "right" != side) {
            throw Error("invalid side type: '"+side+"'");
        }
        // 実行関数
        return function() {
            var obj = $(this);
            var imgBlock = $("div.image:first-child", obj);
            var imgWidth = $("p.image img", imgBlock).width(); // 画像幅
            imgBlock.css("width", imgWidth+15+"px"); // 画像幅を強制
            // 別カラムの margin を調整
            $("div.column", obj).css("margin-"+side,
                                     imgBlock[0].offsetWidth+"px");
        };
    }
    // 実行
    $(".image-parallel.image-L").each(getImgParallelStyler("left"));
    $(".image-parallel.image-R").each(getImgParallelStyler("right"));
	
    // MJL に関係するコードはこの中に記述
    MJL.enable.flash("flash");
    MJL.enable.window("popup",{width:"700",height:"700",top:"0",left:"0",toolbar:"no",status:"no",menubar:"no",location:"no",scrollbars:"yes"});
    MJL.enable.tab("tabs");
    MJL.enable.styleSwitcher("styleSwitcher");
    MJL.enable.heightEqualizer("equalize");
	MJL.enable.heightEqualizer("list-col2", {groupBy : 2});
	MJL.enable.heightEqualizer("list-col3", {groupBy : 3});
	MJL.enable.heightEqualizer("news-contents");
	MJL.enable.rollover("roll", {
        switchers : {
            on  : { cond : /_o(\.[^\.]+)$/, replace : "_h$1" },
            off : { cond : "",            replace : "" }
        },
		active : "active",
		disable : "disable"
    });
});


// MJL と無関係なコードはこの先に記述
(function() {
var f = document.getElementById('cse-search-box');
if (!f) {
f = document.getElementById('searchbox_demo');
}
if (f && f.q) {
var q = f.q;
var n = navigator;
var l = location;
var su = function () {
var u = document.createElement('input');
var v = document.location.toString();
var existingSiteurl = /(?:[?&]siteurl=)([^&#]*)/.exec(v);
if (existingSiteurl) {
v = decodeURI(existingSiteurl[1]);
}
var delimIndex = v.indexOf('://');
if (delimIndex >= 0) {
v = v.substring(delimIndex + '://'.length, v.length);
}
u.name = 'siteurl';
u.value = v;
u.type = 'hidden';
f.appendChild(u);
};
if (n.appName == 'Microsoft Internet Explorer') {
var s = f.parentNode.childNodes;
for (var i = 0; i < s.length; i++) {
        if (s[i].nodeName == 'SCRIPT' &&
            s[i].attributes['src'] &&
            s[i].attributes['src'].nodeValue == unescape('http:\x2F\x2Fwww.google.com\x2Fcse\x2Fbrand?form=cse-search-box\x26lang=ja')) {
          su();
          break;
        }
      }
    } else {
      su();
    }

    
    if (n.platform == 'Win32') {
      q.style.cssText = 'border: 1px solid #7e9db9; padding: 2px;';
    }

    
    if (window.history.navigationMode) {
      window.history.navigationMode = 'compatible';
    }

    var b = function() {
      if (q.value == '') {
        q.style.background = '#FFFFFF url(http:\x2F\x2Fwww.google.com\x2Fcse\x2Fintl\x2Fja\x2Fimages\x2Fgoogle_custom_search_watermark.gif) left no-repeat';
      }
    };

    var f = function() {
      q.style.background = '#ffffff';
    };

    q.onfocus = f;
    q.onblur = b;

    
    if (!/[&?]q=[^&]/.test(l.search)) {
      b();
    }
  }

})();


//マウスオンでツールチップ表示
$(document).ready(function(){
	var area_ele = $(".tooltip");
	
	area_ele.mouseover(function(e){
		var name = e.target.id;
		var div_ele = $("p." + name);
		div_ele.css({"opacity":0, "display":"block"});
		div_ele.fadeTo("normal", 1);
	});
	area_ele.mousemove(function(e){
		var name = e.target.id;
		var div_ele = $("p." + name);
		
		var x = e.pageX + 15;
		var y = e.pageY + 10;
		div_ele.css("left", x);
		div_ele.css("top", y);
	});
	area_ele.mouseout(function(e){
		var name = e.target.id;
		var div_ele = $("p." + name);
		div_ele.css({"display":"none"});
	});
	
	
	var area_ele2 = $(".tooltip02");
	area_ele2.mouseover(function(e){
		var name = e.target.id;
		var div_ele = $("p." + name);
		div_ele.css({"opacity":0, "display":"block"});
		div_ele.fadeTo("normal", 1);
	});
	area_ele2.mousemove(function(e){
		var name = e.target.id;
		var div_ele = $("p." + name);
		var x = e.pageX - 300;
		var y = e.pageY + 20;
		div_ele.css("left", x);
		div_ele.css("top", y);
	});
	area_ele2.mouseout(function(e){
		var name = e.target.id;
		var div_ele = $("p." + name);
		div_ele.css({"display":"none"});
	});
});
