/*
===========================================================
フォントサイズ変更スクリプト（タイプB）

Last Updated:08/21/2001
　　　10/23/2001最終更新版より下記のURIのみ変更

insomnia!
http://insomnia.jp/
http://insomnia.jp/workshop/
===========================================================
*/


/*
========== ::: ブラウザ判別時に使用する変数 ::: ==========
*/
uaName = navigator.userAgent;
appName = navigator.appVersion;


/*
========== ::: 初期設定 ::: ==========
*/

// 値の単位を設定（必ずダブルクオートかクオートで括る）
var fontSizeUnit = "%";

// 一回の操作で変化させる値を設定（ダブルクオートやクオートで括らない）
var perOrder = 20;

// 初期状態の値を設定（ダブルクオートやクオートで括らない）
var defaultSize = 100;

// クッキーの名前（必ずダブルクオートかクオートで括る）
var ckName = "FSCb";

// クッキーの有効期限（日）（ダブルクオートやクオートで括らない）
var ckDays = 30;

// クッキーのパス（必ずダブルクオートかクオートで括る。指定がいらない場合は"/"にする）
var ckPath = "/"


/*
========== :::ページ読み込み時の値を設定::: ==========
*/

// クッキー読み出し
var fsCK = GetCookie(ckName);

if ( fsCK == null ) {
  currentSize = defaultSize;      //クッキーが無ければ現在の値を初期状態の値に設定
}
else{
  currentSize = Number(fsCK);      //クッキーがあれば現在の値をクッキーの値に設定
}


/*===================================
  [関数 fscRef]
  BODY要素のイベントハンドラ"onload"ならびに関数fscから呼び出される。
  変数"currentSize"の値に従って
  オブジェクトのfontStyleプロパティを変更する
====================================*/

function fscRef(){

  // === ::: 変更を加えるオブジェクトの判定 ::: ===
  //
  //  NN4もしくはMacIE4.0の場合、エラーメッセージを回避
  if (( document.layers )||(( appName.indexOf("Mac",0) != -1 ) && ( uaName.indexOf("MSIE 4.0",0) != -1 ))){
    return false;
  }

  else if( document.body ){
  
  // オブジェクトのfontSizeプロパティを書き換える
    document.body.style.fontSize = currentSize + fontSizeUnit;
  }
  
}

// _______________________________________ end of function fscRef() ___ 


/*===================================
  [関数 fsc]
  引数CMDに渡される値に応じて
  変更後の値を算出しクッキーに書き込む。
====================================*/

function fsc( CMD ){

  // 拡大：現時点の値に一回の操作で変化させる値を加えて操作後の値"newSize"に代入
  if( CMD == "larger" ){
    var newSize = Number( currentSize + perOrder );
    SetCookie( ckName , newSize );      //クッキー書き込み
  }

  // 縮小：現時点の値から一回の操作で変化させる値を引き操作後の値に代入
  // 現時点のサイズの値が一回の操作で変化させる値と同じならそのまま操作後の値に代入
  if( CMD == "smaller" ){
    if ( currentSize != perOrder ){
      var newSize = Number( currentSize - perOrder );
      SetCookie( ckName , newSize );      //クッキー書き込み
    }
    else{
      var newSize=Number(currentSize);
    }
  }

  // 元に戻す：操作後の値を初期値にする
  if( CMD == "default" ){
    var newSize = defaultSize;
    DeleteCookie( ckName );      //クッキー削除
  }


  // NN4もしくはMacIE4.0の場合、エラーメッセージを回避しダイアログを表示する
  // NN4用ダイアログ
  if( document.layers ){
    window.alert( "このスクリプトはNetscape Communicator4.xでは動作しません" );
    return false;
  }

  // MacIE4用ダイアログ
  else if(( appName.indexOf("Mac",0) != -1 ) && ( uaName.indexOf("MSIE 4.0",0) != -1)){
    window.alert( "Sorry! MacIE4.0 is not supported." );
    return false;
  }

  else{
  // 現在の値を操作後の値に変更
  currentSize = newSize;

  // サイズ変更関数を呼び出す
  fscRef();
  }
}

// _______________________________________ end of function fsc() ___ 


/*===================================
  [関数 SetCookie]
  クッキーに値を書き込む
====================================*/

function SetCookie(name,value){
  var dobj = new Date();
  dobj.setTime( dobj.getTime() + 24 * 60 * 60 * ckDays * 1000);
  var expiryDate = dobj.toGMTString();
  document.cookie = name + '=' + escape(value)+ ';expires=' + expiryDate + ';path=' + ckPath;
}


/*===================================
  [関数 GetCookie]
  クッキーを取得する
====================================*/
function GetCookie (name){
  var arg  = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen){
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
    return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
   return null;
}

/*===================================
  [関数 getCookieVal]
  クッキーの値を抽出する
====================================*/
function getCookieVal (offset){
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
  endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset,endstr));
}

/*===================================
  [関数 DeleteCookie]
  クッキーを削除する
====================================*/
function DeleteCookie(name){
  if (GetCookie(name)) {
    document.cookie = name + '=' +
    '; expires=Thu, 01-Jan-70 00:00:01 GMT;path='+ckPath;
  }
}

//EOF


/****************************************
[jquery] jquery.cmn.js
****************************************
[index list]
* jquery.rollover.js
* jquery.cookie.js
* jquery.fontresize.js
* jquery.stylesheetswitcher.js
****************************************/

/****************************************
[jquery] jquery.cookie.js
****************************************
* http://plugins.jquery.com/project/cookie
* 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(name, value, options) {
if (typeof value != 'undefined') { // name and value given, set cookie
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
var expires = '';
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
}
// CAUTION: Needed to parenthesize options.path and options.domain
// in the following expressions, otherwise they evaluate to undefined
// in the packed version for some reason...
var path = options.path ? '; path=' + (options.path) : '';
var domain = options.domain ? '; domain=' + (options.domain) : '';
var secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
} else { // only name given, get cookie
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
};

/****************************************
[jquery] jquery.fontcontroll.js
****************************************
* sizedown class  = SmallFont
* sizeup class  = DefaultFont
* reset class  = LargeFont
* disabled class  = Disabled
* jquery.cookie.jsが必要です。
* Original Source : http://cool-javascripts.com/jquery/building-a-reusabe-font-size-controller-interface-using-jquery.html
****************************************/

function fontSize(container, target, minSize, defSize, maxSize) {

//Read cookie & sets the fontsize
if ($.cookie != undefined) {
var cookie = target.replace(/[#. ]/g,'');
var value = $.cookie(cookie);
if (value !=null) {
$(target).css('font-size', parseInt(value));
}
}

//on clicking small font button, font size is decreased by 1px
$('[class="DecreaseFont"]').click(function(){
curSize = parseInt($(target).css("font-size"));
newSize = curSize *0.75;
if (newSize >= minSize) {
$(target).css('font-size', newSize);
}
updatefontCookie(target, newSize); //sets the cookie

});

//on clicking default font size button, font size is reset
$('[class="ResetFont"]').click(function(){
$(target).css('font-size', defSize);
updatefontCookie(target, defSize);
});

//on clicking large font size button, font size is incremented by 1 to the maximum limit
$('[class="IncreaseFont"]').click(function(){
curSize = parseInt($(target).css("font-size"));
newSize = curSize *1.25;
if (newSize <= maxSize) {
$(target).css('font-size', newSize);
}
updatefontCookie(target, newSize);
});

function updatefontCookie(target, size) {
if ($.cookie != undefined) { //If cookie plugin available, set a cookie
var cookie = target.replace(/[#. ]/g,'');
$.cookie(cookie, size,{expires:30,path:'/'});
}
}
}

$(document).ready(function(){
fontSize('[class="FontResizeToggle"] img', 'body', 12, 16, 999);
});


/****************************************
* Styleswitch stylesheet switcher built on jQuery
* http://ideas.nty3.com/jquery-styleswitcher.html
****************************************/

(function($)
{
$(document).ready(function() {
$('.StyleSwitch').click(function()
{
switchStylestyle(this.getAttribute("rel"));
return false;
});
var c = readCookie('style');
if (c) switchStylestyle(c);
});

function switchStylestyle(styleName)
{
$('link[@rel*=style][title]').each(function(i) 
{
this.disabled = true;
if (this.getAttribute('title') == styleName) this.disabled = false;
});
createCookie('style', styleName, 365);
}
})(jQuery);
// cookie functions http://www.quirksmode.org/js/cookies.html
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 var 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;
}
function eraseCookie(name)
{
createCookie(name,"",-1);
}
// /cookie functions

/****************************************
[jquery] jquery.rollover.js
****************************************
* Rollover class = ImgOver
* Rollover FileName = ***_on.jpg/gif/png
* Original Source : http://peps.ca/blog/easy-image-rollover-script-with-jquery/
****************************************/

$(document).ready(function()
{
PEPS.rollover.init();
});
PEPS = {};
PEPS.rollover =
{
init: function()
{
this.preload();
$('.ImgOver').hover(
function () { $(this).attr( 'src', PEPS.rollover.newimage($(this).attr('src')) ); },
function () { $(this).attr( 'src', PEPS.rollover.oldimage($(this).attr('src')) ); }
);
},
preload: function()
{
$(window).bind('load', function() {
$('.ImgOver').each( function( key, elm ) { $('<img>').attr( 'src', PEPS.rollover.newimage( $(this).attr('src') ) ); });
});
},
newimage: function( src ) { return src.substring( 0, src.search(/(\.[a-z]+)/) ) + '_on' + src.match(/(\.[a-z]+)/)[0]; },
oldimage: function( src ){ return src.replace(/_on/, ''); }
};

/****************************************
swapimage.js
****************************************/

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}