//var toplocation = location.hostname;
//locationhome = location.href.substr(0,location.href.indexOf(toplocation) + toplocation.length);
//var FONT_CSS_URL  = locationhome + '/css/base_f';
var FONT_CSS_URL  = 'http://www.chusyokin.co.jp/css/base_f';

/************************************************************************************
 * 文字サイズ切替用
 ************************************************************************************/

//------------------------------
//オンロードイベント
//------------------------------
$(function(){
    var size = getFontStyle();
    setFontStyle(size);






try { 
document.execCommand('BackgroundImageCache', false, true); 
} catch(e) {} 

});

var FONT_SMALL  = 0;
var FONT_MEDIUM = 1;
var FONT_LARGE  = 2;

/**
 * 文字サイズ変更
 */
function switchFontStyle(size) {
    saveFontStyle(size);
    setFontStyle(size);
}
/**
 * 文字サイズの保存
 */
function saveFontStyle(size) {
    var date = new Date();
    //30日保存
    date.setTime(date.getTime()+(30*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
    document.cookie = "chubu_font_style="+size+expires+"; path=/";
}
/**
 * 文字サイズの設定
 */
function setFontStyle(size) {
    var intSize=parseInt(size);
    if ( intSize >= FONT_SMALL && intSize <= FONT_LARGE ) {
        //スタイルの設定
        changeCSS(FONT_CSS_URL + size + '.css');
    }
    else {
        return false;
    }
}

/**
 * 文字サイズの取得
 */
function getFontStyle() {
    var nameEQ = "chubu_font_style=";
    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 changeCSS(cssfile) {
    if($.browser.msie && Number($.browser.version) < 7) {
        document.createStyleSheet(cssfile);
    } else {
        $("#css_chubu").attr("href", cssfile);
    }
}
