/*==============================================
	Cookie plugin
	Copyright (c) 2006 Klaus Hartl (stilbuero.de)
	Dual licensed under the MIT and GPL licenses:
	http://www.opensource.org/licenses/mit-license.php
	http://www.gnu.org/licenses/gpl.html
==============================================*/
jQuery.cookie=function(B,I,L){if(typeof I!="undefined"){L=L||{};if(I===null){I="";L.expires=-1}var E="";if(L.expires&&(typeof L.expires=="number"||L.expires.toUTCString)){var F;if(typeof L.expires=="number"){F=new Date();F.setTime(F.getTime()+(L.expires*24*60*60*1000))}else{F=L.expires}E="; expires="+F.toUTCString()}var K=L.path?"; path="+(L.path):"";var G=L.domain?"; domain="+(L.domain):"";var A=L.secure?"; secure":"";document.cookie=[B,"=",encodeURIComponent(I),E,K,G,A].join("")}else{var D=null;if(document.cookie&&document.cookie!=""){var J=document.cookie.split(";");for(var H=0;H<J.length;H++){var C=jQuery.trim(J[H]);if(C.substring(0,B.length+1)==(B+"=")){D=decodeURIComponent(C.substring(B.length+1));break}}}return D}}

/*==============================================
	New window Module
	Copyright (c) 2008 SERAKU Co.,Ltd.
==============================================*/
$(function(){
	$("a.blank,[href*='.pdf']").each(function(){
		var i=$('a.blank').attr('title');
		i?void(0):$('a.blank').attr('title','新規ウィンドウで開きます');
	});
	$("a.blank,[href*='.pdf']").click(function(){
		window.open(this.href,'_blank');
		return false;
	});
});

/*==============================================
	Popup window Module
==============================================*/
$(function(){
	$('a.popup').each(function(){
		var i=$('a.popup').attr('title');
		i?void(0):$('a.popup').attr('title','ポップアップウィンドウが開きます');
	});
	$('a[class*="popup"]').click(function(){
		var url=this.href;
		var i=$(this).attr('class').substr($(this).attr('class').indexOf('{'),$(this).attr('class').indexOf('}'));
		i=i.split('{')[1].split('}')[0];
		param=i.split(',')
		var left=param[0].split(':')[1];
		var top=param[1].split(':')[1];
		var height=param[2].split(':')[1];
		var width=param[3].split(':')[1];
		var menu=param[4].split(':')[1];
		var scroll=param[5].split(':')[1];
		var status=param[6].split(':')[1];
		var tool=param[7].split(':')[1];
		var locat=param[8].split(':')[1];
		var dir=param[9].split(':')[1];
		var resise=param[10].split(':')[1];
		window.open(url,'','width='+width+',height='+height+',screenX='+left+',left='+left+',screenY='+top+',top='+top+',location='+locat+',scrollbars='+scroll+',directories='+dir+',menubar='+menu+',toolbar='+tool+',resizable='+resise+',titlebar=1,status='+status+',fullscreen=0');
		return false;
	});
});

/*==============================================
	Swap image Module
	Copyright (c) 2008 SERAKU Co.,Ltd.
==============================================*/
$(function(){
	var image_cache=new Object();
	$('img.swap, .swapBox img').not("[src*='_ovr.']").each(function(i){
		var i=$(this).attr('class');
		if(i!='noneSwap'){
			var imgsrc=this.src;
			var dot=this.src.lastIndexOf('.');
			var imgsrc_ovr=this.src.substr(0,dot)+'_ovr'+this.src.substr(dot,4);
			image_cache[this.src]=new Image();
			image_cache[this.src].src=imgsrc_ovr;
			$(this).hover(function(){
				this.src=imgsrc_ovr;
			},function(){
				this.src=imgsrc;
			});
		}
	});
});

/*==============================================
	Word Break Module
	Copyright (c) 2008 SERAKU Co.,Ltd.
==============================================*/
$(function(){
	var i='.wbr';
	if($.browser.msie){
		$(i).css({
			wordBreak:'break-all',
			display:'block'
		});
	}else{
		var j=(function x(){})[-6]=='x';
		$(i).each(function(){
			j?$(this).html($(this).text().split('').join('<wbr />')):$(this).html($(this).text().split('').join(String.fromCharCode(8203)));
		});
	}
});

/*==============================================
	Close window Module
==============================================*/
$(function(){
	$('div.pageClose p img').each(function(){
		$(this).click(function(){
			window.close();
		}).mouseover(function(){
			$(this).css('cursor','pointer');
		});
	});
});

/*==============================================
	Print Module
==============================================*/
$(function(){
	$('img.print').each(function(){
		var i=$('img.print').attr('title');
		i?void(0):$('img.print').attr('title','印刷ウィンドウが開きます');
		$(this).click(function(){
			window.print();
			return false;
		}).mouseover(function(){
			$(this).css('cursor','pointer');
		});
	});
});


/*==============================================
	Font Size Module
==============================================*/
$(function(){
	var i=$.cookie('nerimaswf');
	i?$('div#container').css('font-size',i+'%'):$('div#container').css('font-size','100%');
});

function setFontsize(i){
	$('div#container').css('font-size',i+'%');
	$.cookie('nerimaswf',i,{expires:30,path:'/'});
}

var sd,td,gd,so,to,go;
$(function(){
	if($('div#utility dl dt').attr('class')){
		$('div#utility dl').css('display','block');
		sd=$('div#utility dl dd.item01 img').attr('src');
		td=$('div#utility dl dd.item02 img').attr('src');
		gd=$('div#utility dl dd.item03 img').attr('src');
		so=getOvrPath(sd);
		to=getOvrPath(td);
		go=getOvrPath(gd);
		var j=$.cookie('nerimaswf');
		var k=Number(j);
		setBtns(k);
		$('div#utility dl dd img').each(function(i){
			$(this).click(function(){
				switch(i){
					case 0:
					setFontsize(85);
					setBtns(85);
					break;
					case 1:
					setFontsize(100);
					setBtns(100);
					break;
					case 2:
					setFontsize(123.1);
					setBtns(123.1);
					break;
				}
			}).mouseover(function(){
				$(this).css('cursor','pointer');
			});
		})
	}
});

function getOvrPath(i){
	var j=i.lastIndexOf('.');
	var k=i.substr(0,j)+'_ovr'+i.substr(j,4);
	return k;
}

function setBtns(i){
	$('div#utility dl dd.item01 img').attr('src',sd);
	$('div#utility dl dd.item02 img').attr('src',td);
	$('div#utility dl dd.item03 img').attr('src',gd);
	switch(i){
		case 85:
		$('div#utility dl dd.item01 img').attr('src',so);
		break;
		case 100:
		$('div#utility dl dd.item02 img').attr('src',to);
		break;
		case 123.1:
		$('div#utility dl dd.item03 img').attr('src',go);
		break;
		default:
		$('div#utility dl dd.item02 img').attr('src',to);
		break;
	}
}

