// JavaScript Document
/*@cc_on _d=document;eval('var document=_d')@*/
function $(id){ return document.getElementById(id) }
function init(uName){
		$(uName).style.display = "none";
}
function Menu(uName,myName,rank,cName){
	var obj = $(uName).style;
	if(obj.display == "block"){
		init(uName);
		$(myName).innerHTML = "<a href=\"javascript:Menu('"+uName+"','"+myName+"','"+rank+"','"+cName+"'); setCookie('"+cName+"', 1);\">"+rank+"位以下も表示</a> <img src=\"/img/under_navi.gif\" width=\"17\" height=\"17\" align=\"absbottom\">";
	}
	else {
		if (uName == "bookmarkz") show_entries_bookmarkz();
		init(uName);
		$(myName).innerHTML = "<a href=\"javascript:Menu('"+uName+"','"+myName+"','"+rank+"','"+cName+"'); clearCookie('"+cName+"');\">閉じる</a> <img src=\"/img/under_navi_2.gif\" width=\"17\" height=\"17\" align=\"absbottom\">";
		obj.display = "block";
		if (uName == "bookmarkz"){
			var visited = getCookie("Visited");
			if (visited == "on") hide_visiteds(true);
		}
	}
}
function getCookie(key,  tmp1, tmp2, xx1, xx2, xx3) {
    tmp1 = " " + document.cookie + ";";
    xx1 = xx2 = 0;
    len = tmp1.length;
    while (xx1 < len) {
        xx2 = tmp1.indexOf(";", xx1);
        tmp2 = tmp1.substring(xx1 + 1, xx2);
        xx3 = tmp2.indexOf("=");
        if (tmp2.substring(0, xx3) == key) {
            return(unescape(tmp2.substring(xx3 + 1, xx2 - xx1 - 1)));
        }
        xx1 = xx2 + 1;
    }
    return("");
}
function setCookie(key, val, tmp) {
    tmp = key + "=" + escape(val) + "; ";
    tmp += "expires=Tue, 31-Dec-2030 23:59:59; path=/";
    document.cookie = tmp;
}
function clearCookie(key) {
    document.cookie = key + "=" + "xx; expires=Tue, 1-Jan-1980 00:00:00;";
}

/******************** visited ***********************/
function hide_visiteds(){ bkms().each(function(e){ if(is_visite(e))Element.hide(e); }) }
function show_entries(){ bkms().each(function(e){Element.show(e)}); }
function show_entries_bookmarkz(){ bkmz().each(function(e){Element.show(e)}); }
function bkms(e){
	$bookmark = $A((e||$('bookmarks')).childNodes);
	if($bookmark.length == 31 || $bookmark.length == 15){
		$bookmark = $bookmark.concat($A($('bookmarkz').childNodes));
	}
	return $bookmark.findAll(class_name('bookmark')).compact();
}
//	return $A((e||$('bookmarks')).childNodes).concat($A($('bookmarkz').childNodes)).findAll(class_name('bookmark')).compact(); }
function bkmz(e){ return $A((e||$('bookmarkz')).childNodes).findAll(class_name('bookmark')).compact(); }
function class_name(n){ return function(e){ return e.className; } }
function is_visite(e){  return Element.getDimensions($('visited'+get_id(e))).width == 0; }
function get_id(e){
 switch(typeof(e)){
 case 'string': return /^[a-zA-Z]+([0-9]+)$/.test(e) ? (RegExp.$1-0) : 0;
 case 'object':  if((!e) || (! 'nodeType' in e )) return 0;  var n=get_id(e.id);  return (n)? n : get_id(entryitem(e));
 case 'number': return e;
 }
 return get_id(e.toString());
}
function change_visited(e){
var el = this;
var t = el.checked;
var mode = t ? "on" : "off";
setCookie("Visited", mode);
if(mode == "off"){
show_entries();
} else {
hide_visiteds(true);
}
}
