/*** 依存ライブラリ
 *    - styleswitcher.js
 */


/** cookieには、小ボタンを押したときに「size-s」、大ボタンを押したときに「size-l」、
 *  中ボタンを押したときに「null」が格納されている。
 *  このクッキーに保存された表示文字サイズに合わせて、文字サイズ変更ボタンのデフォルトを変更する。
 */
function switch_size_btn(cookie) {
    var $ = jQuery;
    if ( cookie == "size-s" ) {
	// 小ボタンが選択されていたら：
	$("#size-s").attr("class", "selected-s");
	$("#size-m").attr("class", "");
	$("#size-l").attr("class", "");
    } else if ( cookie == "size-l" ) {
	// 大ボタンが選択されていたら：
	$("#size-s").attr("class", "");
	$("#size-m").attr("class", "");
	$("#size-l").attr("class", "selected-s");
    } else if ( cookie == "null" ) {
	// 中ボタンが選択されていたら：
	$("#size-s").attr("class", "");
	$("#size-m").attr("class", "selected-s");
	$("#size-l").attr("class", "");
    } else { }
}


/** styleswitcherを用いて、css切り替えを行いフォントサイズ変更処理を行い、
 *  divのidを#size-s, #size-m, #size-lに変更することで、押下状態に変更する。
 */
function onclick_size(fontname, thisobj) {
    // 選択状態だったボタンの状態を解除
    var selected = jQuery(".selected-s");
    selected.attr('class', '');

    var name = 'size-'+fontname;
    var idname = "#"+name;
    var thisobj = jQuery(thisobj);
    setActiveStyleSheet(name);			// CSS変更
    var switcher = jQuery(idname, thisobj);
    switcher.attr('class', 'selected-s');
}


/** expand-btnクラスボタンのonclickをトグル形式のslideボタンにする関数
 */
function toggle_btns($) {
    $(".expand-btn").click(function() {
	    var thisobj = $(this);
	    var btn = $('div', thisobj);
	    var clsname = btn.attr('class');
	    var expand_window = thisobj.parent().parent();
	    var expandarea = $(".expand-area", expand_window);
	    expandarea.slideToggle("fast");
	    // ボタンを変更
	    if ( clsname == 'expand' ) {
		btn.attr('class', 'unexpand');
	    } else {
		btn.attr('class', 'expand');
	    }
	    
	    return false;
	});
}

