
// ■カテゴリー別色分け
// BaseScript : stroll::blog(http://melrose.jugem.cc/?eid=132)
// Customize : sampling.sys(http://yaplog.jp/material/)
function getcategoryNameColor(categoryName) {
// カテゴリー別色の定義
// ['(カテゴリー名)', '(色)']
var categoryColorsS = [
['/material/category_1/', '#deb6b0'], 
['/material/category_3/', '#decfb0'], 
['/material/category_5/', '#cfdeb0'], 
['/material/category_9/', '#cfdeb0'], 
['/material/category_10/', '#b0debc'], 
['/material/category_13/', '#b0c3de'], 
['/material/category_16/', '#c2b0de'], 
['/material/category_18/', '#c2b0de'], 
['/material/category_20/', '#c2b0de'], 
['/material/category_22/', '#deb0d0']
];

// 上記カテゴリー名以外に表示する色
var otherColorS = '#dcdcdc';

// divタグに指定する属性
// 例）var addAttribute = 'class="pict" alt="test"';
var addAttribute = '';

// if ('' == categoryName) {
// if ('' != otherColorS) document.write('<span style="color:'+ Color +'" ' + addAttribute + ' />●<\/span>');
// return;
// }
if (categoryName.indexOf('</a>') > -1) {
var m = categoryName.match(/>.+<\/a>/);
if (null != m) categoryName = m[0].substr(1, m[0].length - 5);
}
for (var i = 0; i < categoryColorsS.length; i++) {
if (categoryColorsS[i][0] == categoryName) {
window.document.write('<span style="color:' + categoryColorsS[i][1] + '" ' + addAttribute + ' />●<\/span>');
return;
}
}
if ('' != otherColorS) window.document.write('<span style="color:'+ otherColorS +'" ' + addAttribute + ' />●<\/span>');
return;
}



// ■セレクトボックス
function popJump(selOBJ)
{
	n = selOBJ.selectedIndex;
	location.href = selOBJ.options[n].value;
}


// ■OpenWin
function openWin1(a) {  return false;
}
var w = window;
function openWin1(a)  {
	if ((w == window) || w.closed) {
		w = open(a, "_blank", "width=400,height=400,left=0,top=0,toolbar=no,status=no,location=no,scrollbars=no,resizable=yes,");
	} else {
		w.focus();
	}
	return(false);
}



// ■新着にアイコン

function getNewIcon(up_time) {
	var last_time='3' //何時間後までアイコン付けるか
	var new_t='<img border=0 src="http://www001.upp.so-net.ne.jp/tohko/yaplog/new.gif" width=5 height=5>' //新着用マーク
	var new_f='' //以外

	var today = new Date()
	var et = new Date(up_time);

	if( today.getTime() <= et.setTime(et.getTime() + (last_time * 60 *60 * 1000)) ){
		document.write(new_t);
	}else{
		document.write(new_f);
	}
}


// ■カレンダー前後移動 テスト中
function getCalenterTitle(date,last) {
var date = date.split("/");
var last = last.split("/");


var prev_mark = '<img src="http://www001.upp.so-net.ne.jp/tohko/yaplog/ar_l.gif" width=8 height=9 alt="≪">';   //前の月へのマーク
var next_mark = '<img src="http://www001.upp.so-net.ne.jp/tohko/yaplog/ar_r.gif" width=8 height=9 alt="≫">';   //次の月へのマーク

var this_month = date[0] + '.' + date[1];   //今月の表示の仕方
//'2005年12月'なら date[0] + '年' + date[1] + '月';
//'2005.12'なら date[0] + '.' + date[1];

var first = new Array('2004','06');   //最初の記事の(年,月)
var base = 'http://yaplog.jp/material/monthly/';

var prev_year = date[0];
var prev_month = date[1] - 1;
var next_year = date[0];
var next_month = ( date[1] - 0 ) +  1;

if ( date[1] == 1 ) {
	prev_year = date[0] - 1;
	prev_month = 12;
}else if ( date[1] == 12 ) {
	next_year = ( date[0] - 0 ) + 1;
	next_month = 1;
}

if (prev_month < 10) { prev_month = '0' + prev_month; }
if (next_month < 10) { next_month = '0' + next_month; }

var prev_link = '<a href="' + base +  prev_year + prev_month + '/">' + prev_mark + '<\/a>';
var next_link = '<a href="' + base +  next_year + next_month + '/">' + next_mark + '<\/a>';
var sp = '&nbsp;&nbsp;&nbsp;';

//var now_date = new Date();
//var now_year = now_date.getYear();
//	if (now_year < 2000) { now_year += 1900; }
//var now_month = now_date.getMonth() + 1;




var inHTML;
if (( first[0] > date[0] ) || (( first[0] == date[0] ) && ( first[1] >= date[1]))){
	inHTML = sp + sp + this_month + sp + next_link + '';
}else if(( date[0] > last[0] ) || (( date[0] == last[0] ) && ( date[1] >= last[1] ))){
	inHTML = prev_link + sp + this_month + sp + sp + '';
}else {
	inHTML = prev_link + sp + this_month + sp + next_link + '';
}
document.write(inHTML);
}


// ■1年前は？
function linkLastyear(date){

// リンクする文字
var text = '1年前は？';

// divに付加する属性。rightは右寄せ。フォントサイズ。
var inCSS = '';

// 最初の記事の1年後。これ以前の場合はリンクが表示されない。
noLastyear = new Date('2005/6/16');

entryDay = new Date(date);
	if ( entryDay >= noLastyear ){
		var date = date.split("/");
		date[0] -- ;
		var thisUrl = String(window.location).split("/");
		var LastYearDay = '/' + thisUrl[3] + '/daily/' + date[0] + date[1] + '/' + date[2];
		var inHTML = '&nbsp;&nbsp;→&nbsp;<span style="' + inCSS + '"><a href="'  + LastYearDay + '">' + text + '<\/a><\/span>';
		document.write(inHTML);
	}
}


// ■ページ移動（テスト中。メインのみ。アーカイブはわからん）
function ShowPageSelect(){
var tmpText = document.archiveform.number.value.split("/");
var sum = 0;
	for (i = 0; i < tmpText.length; i++) {
		sum = sum + Number(tmpText[i]);
	}
var pageNum = sum/10 + 1;
var thisUrl = String(window.location).split("/");

var inHTML;
inHTML = '<form action="#">Page:<select onchange="window.location.href = this.value">';
	for (i = 1; i<= pageNum; i++) {
		inHTML = Array(inHTML,'<option value="/',thisUrl[3],'/',i,'"').join('');
		if (i == thisUrl[4]) inHTML = Array(inHTML,' selected="selected"').join('');
		inHTML = Array(inHTML,'>',i,'<\/option>').join('');
	}
inHTML = Array(inHTML,'<\/select><\/form>').join('');
document.write(inHTML);
}



// ■コメントプレビューON/OFF テスト中
function cm_preview(div_id){
	if(document.getElementById){
		obj = document.getElementById(div_id).style;
		obj.display == 'none' ? obj.display = 'block' : obj.display = 'none';
	}else if(document.all){
		obj = document.all(div_id).style;
		obj.display == 'none' ? obj.display = 'block' : obj.display = 'none';
	}
}


// ■追記文章の折りたたみ用スクリプト（改）by 小粋空間さん
function showHide(entryID, entryLink, htmlObj) {
	extTextDivID = ('Text' + (entryID));
	extLinkDivID = ('Link' + (entryID));
	if( document.getElementById ) {
		if( document.getElementById(extTextDivID).style.display ) {
			if( entryLink != 0 ) {
				document.getElementById(extTextDivID).style.display = "block";
				document.getElementById(extLinkDivID).style.display = "none";
				htmlObj.blur();
			} else { 
				document.getElementById(extTextDivID).style.display = "none";
				document.getElementById(extLinkDivID).style.display = "block";
			}
		} else {
			location.href = entryLink;
			return true;
		}
	} else {
		location.href = entryLink;
		return true;
	}
}

