//右メニュー

$(function(){

var target = '#right_menu ul li:has(ul)';
var itemW = 202;

$(target).hover(
				
	function(){
		var w = '-' + itemW + 'px';
		$(this).children('ul').css('right',w);
		$(this).addClass('show');
	},
	function(){$(this).removeClass('show');}
);

});



//ドロップダウンメニュー

$(function(){

var target = 'ul.navi li:has(ul)';

$(target).hover(
				
	function(){
		$(this).addClass('show');
	},
	function(){$(this).removeClass('show');}
);

var postfix = '_o';
    $('ul.navi a img').not('[src*="'+ postfix +'."]').each(function() {
        var img = $(this);
        var src = img.attr('src');
        var src_on = src.substr(0, src.lastIndexOf('.'))
                   + postfix
                   + src.substring(src.lastIndexOf('.'));
        $('<img>').attr('src', src_on);
        img.hover(
            function() {
                img.attr('src', src_on);
            },
            function() {
                img.attr('src', src);
            }
        );
    });

});

//object to iframe
$(function(){
	var isIE = /*@cc_on!@*/0;
	if(isIE){
		$('object').each(function(){
			var self = $(this),
				dt = self.attr('data'),
				tt = self.attr('title'),
				wd = self.attr('width'),
				hg = self.attr('height'),
				cls = self.attr('class'),
				id = self.attr('id');
			var rep = $('<iframe></iframe>')
			.attr({
				'src' : dt,
				'title'  : tt,
				'width'  : wd,
				'height' : hg
			})
			.css({
				'border' : 'none'	 
			});
			if(id) rep.attr('id',id);
			if(cls) rep.attr('class',cls);
			self.after(rep).remove();
		});
	}
});




///////////////////////////////////////////////////////////////////////////////////////////


//CSSチェンジ

function OpenComments (c) {
    window.open(c,
                    'comments',
                    'width=480,height=480,scrollbars=yes,status=yes,resizable=yes');
}

function OpenTrackback (c) {
    window.open(c,
                    'trackback',
                    'width=480,height=480,scrollbars=yes,status=yes,resizable=yes');
}

function xSwitch(v) {
a=v+"_1";
b=v+"_2";
if (document.getElementById(a).style.display == "none") {
document.getElementById(a).style.display = "block";
document.getElementById(b).style.display = "none";
} else {
document.getElementById(a).style.display = "none";
document.getElementById(b).style.display = "block";
}
}
function setActiveStyleSheet(title) {
var i, a, main;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
a.disabled = true;
if(a.getAttribute("title") == title) a.disabled = false;
}
}
}

function getActiveStyleSheet() {
var i, a;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
}
return null;
}

function getPreferredStyleSheet() {
var i, a;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1
&& a.getAttribute("rel").indexOf("alt") == -1
&& a.getAttribute("title")
) return a.getAttribute("title");
}
return null;
}

function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}

window.onload = function(e) {
var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
}

window.onunload = function(e) {
var title = getActiveStyleSheet();
createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);



function getDepth(baseDepth){
var toRoot = './'
var path = location.pathname;
var depth = path.split('/').length - 1;
if(depth != baseDepth) toRoot = '';
var i = baseDepth;
while(i < depth){
toRoot += "../";
i++;
}
return toRoot;
}


var firefox = (navigator.userAgent.indexOf("Firefox") != -1)? true : false; 
if(firefox) document.write('<link rel="stylesheet" type="text/css" media="print" href="' + getDepth(1) + 'css/print.css" />');



function orgOpen(){
	window.open("organization_02.html","","width=920,height=600,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0");
}
