﻿/*
記事紹介エリア１の操作　 ( 2009.06.14)
*/


//
//
function report00(){				// 記事紹介エリア１の定義
	//
	this.timer01Id=0;				// このエリアの管理用のタイマー
	this.timer01Count=99999;
	this.timerReportChg=10000;
	//
	this.charMax=18;
	this.charNmax=16;
	//
	this.offsetLeft=(kycBlogLeft+200+120)+166;
	this.offsetTop=100+60*4-26;
	this.areaWidth =330;
	this.areaHeight=60*7;
	//
	this.reportNo=9;
	this.element0=new Array(this.reportNo);
	this.element1=new Array(this.reportNo);
	//
	this.newReportElm0=null;
	this.newReportElm1=null;
	//
	this.newReportStr="";
	this.newReportOrgStr=new Array(3);
	//
	this.reportNowNo=-1;
	this.reportNowArea=-1;
	//this.reportStr=new Array(this.reportNo*3);
	//
	this.reportStr=new Array(this.reportNo);
	this.reportOrgStr=new Array(this.reportNo*3);
	//
	//
	for(i=0; i<(this.reportNo*3); i++){
		this.reportOrgStr[i]="";
		this.reportStr[i]="";
	}
	//
	//
	//  メソッド
	//
	/**********************************************************
		表示エリアの初期設定
	***********************************************************/
	//
	//
	//
	//
	//
	this.setColor=report00_setColor;
	//
	function report00_setColor( no, elm0, elm1 ){
		//
		if( no<0 ){
				elm0.style.backgroundColor="#FFD700";
				elm1.style.backgroundColor="#DAA520";
				return;
		}
		//
		//
		//
		if( (no!=this.reportNowArea)||(report0.timer01Count>1) ){
			if( (no%2)==0 ){
				elm0.style.backgroundColor="#DDA0DD";
			}else{
				elm0.style.backgroundColor="#90CC80";
			}
			//
			if( (no%2)==0 ){
				elm1.style.backgroundColor="#FFB6C1";
			}else{
				elm1.style.backgroundColor="#98FB98";
			}
		}else{
				elm0.style.backgroundColor="#FFE4B5";
				elm1.style.backgroundColor="#FFE4B5";
		}
	}



	//
	//
	//
	this.setArea=report00_setArea;
	//
	function report00_setArea(){
		//
		var pos0=new kycPosition();
		//
		//
		//  最新の記事の紹介
		//
		var w=120*4+4*5-8;
		//
		pos0.height=40;
		pos0.top=this.offsetTop;
		pos0.width=w;
		pos0.left=kycBlogLeft+200+124;
		//
		var elm0=document.getElementById('myreport0');
		kycSetStyle(elm0,pos0);
		//
		elm0.style.backgroundColor="#FFD700";			// 最新記事
		//
		//
		pos0.height=40;
		pos0.top=0;
		pos0.width=w-80;
		pos0.left=0;
		this.newReportElm0=kycMakeElement('div',pos0);
		this.newReportElm0.style.font='24px strong "ＭＳ ゴシック"';		// 24px
		this.newReportElm0.style.overflow='hidden';
		this.newReportElm0.align='left';
		elm0.appendChild(this.newReportElm0);
		//
		//
		//
		pos0.width=80;
		pos0.left=w-80;
		this.newReportElm1=kycMakeElement('div',pos0);			// 18
		this.newReportElm1.style.font='18px strong "ＭＳ ゴシック"';
		elm0.appendChild(this.newReportElm1);
		this.setColor( -1, this.newReportElm0, this.newReportElm1 );
		//
		//
		//
		//   過去の記事の紹介
		//
		pos0.height=240-20;
		pos0.top=this.offsetTop+42;
		pos0.width=this.areaWidth;
		pos0.left=this.offsetLeft;
		//
		var elm1=document.getElementById('myreport1');
		kycSetStyle(elm1,pos0);
		elm1.style.backgroundColor="#98FB98";
		//
		for( i=0; i<this.reportNo; i++ ){
			var h=elm1.offsetHeight;
			var h0=h/this.reportNo;
			//
			pos0.height=h0;
			pos0.top=h0*i;
			pos0.width=250;
			pos0.left=0;
			this.element0[i]=kycMakeElement('div',pos0);
			this.element0[i].style.font='12px strong "ＭＳ ゴシック"';
			this.element0[i].style.overflow='hidden';
			this.element0[i].align='left';
			//this.element0[i].style.marginTop='12px';
			elm1.appendChild(this.element0[i]);
			//
			//
			pos0.width=80;
			pos0.left=250;
			this.element1[i]=kycMakeElement('div',pos0);
			elm1.appendChild(this.element1[i]);
			this.setColor( i, this.element0[i], this.element1[i] );
			//
		}
		//
		//elm1.style.backgroundColor="#DDA0DD";
		//
		return;
	}



	//
	//
	//
	this.makeHtml=report00_makeHtml;
	//
	function report00_makeHtml( reportNo ){
		//
		var nn=this.charMax;
		//
		var m=reportNo;
		var rStr=this.reportStr[m];
		var oStr=this.reportOrgStr[m*3+0];
		//
		if(reportNo<0){
			nn=this.charNmax;
			m=kycReportCount-1;
			rStr=this.newReportStr;
			oStr=this.newReportOrgStr[0];
		}
		//
		//
		var n=rStr.length;
		var str1=rStr;
		//
		var str2=str1;
		//
		if( n>nn ){
			//
			if( report0.timer01Count>0 ){
				str2=str1.substring(4,n)+str1.substring(0,4);
				str1=str2;
			}
			//
			str1=str1.substring(0, nn );
		}
		//
		var str0='<div style="margin-top: 6px; margin-left:16px; ">';
			str0=str0+'<a href='+'"http://mgo999.blog14.fc2.com/blog-entry-'+oStr+'.html"';
			str0=str0+'target="_blank"';
			str0=str0+'>'+str1+'</a></div>';
		//
		//
		if(reportNo<0){
			this.newReportStr=str2;
			//alert( str2 );
		}else{
			this.reportStr[m]=str2;	
		}
		//
		return( str0 );
	}



	//
	//
	//
	this.makeHizukeHtml=report00_makeHizukeHtml;
	//
	function report00_makeHizukeHtml( reportNo ){
		//
		var m=reportNo;
		var rStr=this.reportOrgStr[m*3+1];		// 日付
		var oStr=this.reportOrgStr[m*3+0];
		//
		if(reportNo<0){
			m=kycReportCount-1;
			rStr=this.newReportOrgStr[1];
			oStr=this.newReportOrgStr[0];
		}
		//
		//
		var n=rStr.length;
		var str1=rStr;
		//
		var str2=str1;
		//
		var str0="";
		//
		if( reportNo<0 ){
			    str0='<div style="margin-top: 10px;  ">';
				str0=str0+'<a href='+'"http://mgo999.blog14.fc2.com/blog-entry-'+oStr+'.html"';
				str0=str0+'target="_blank"';
				str0=str0+'>'+str1+'</a></div>';
		}
		else{
			    str0='<div style="margin-top: 2px;  ">';
				str0=str0+'<a href='+'"http://mgo999.blog14.fc2.com/blog-entry-'+oStr+'.html"';
				str0=str0+'target="_blank"';
				str0=str0+'>'+str1+'</a></div>';
		}
		//
		return( str0 );
	}



	/**********************************************************
		各タイマーの開始
	***********************************************************/
	//
	this.startTimer=report00_startTimer;
	//
	function report00_startTimer(){
		timer01Id=setTimeout( report00_timer01CallBack,500);
		//
	}
}



//
//
//
/**********************************************************

	記事一覧表示用のタイマーのコールバック

***********************************************************/
//
function report00_timer01CallBack(){
	//
	clearTimeout( report0.timer01Id );
	//
	if( report0.timerReportChg<=(500*report0.timer01Count ) ){
		//
		report0.reportNowNo++;;
		report0.reportNowArea++;
		//
		if( report0.reportNowNo  >=kycReportCount )		report0.reportNowNo=0;
		if( report0.reportNowArea>=report0.reportNo ) 	report0.reportNowArea=0;
		//
		var n=report0.reportNowNo;
		var m=report0.reportNowArea;
		//
		report0.reportOrgStr[m*3+0]=kycReportTitle[n*3+0];
		report0.reportOrgStr[m*3+1]=kycReportTitle[n*3+1];		// 日付
		report0.reportOrgStr[m*3+2]=kycReportTitle[n*3+2];		// タイトル
		//
		report0.reportStr[m]=report0.reportOrgStr[m*3+2];
		var n=report0.reportStr[m].length;
		if( n>report0.charMax ){
			report0.reportStr[m]=report0.reportStr[m]+"・・・・・・・・・・・・　　　 ";
		}
		//
		//
		//
		report0.newReportOrgStr[0]=kycReportTitle[(kycReportCount-1)*3+0];
		report0.newReportOrgStr[1]=kycReportTitle[(kycReportCount-1)*3+1];								// 日付
		report0.newReportOrgStr[2]="《最新記事》》》》》》"+kycReportTitle[(kycReportCount-1)*3+2];		// タイトル
		//
		report0.newReportStr=report0.newReportOrgStr[2];
		//alert(report0.newReportStr);
		var n=report0.newReportStr.length;
		if( n>report0.charNmax ){
			report0.newReportStr=report0.newReportStr+"・・・・・・・・・・・・　　　　";
			//++++ alert(report0.newReportStr);
		}
		//
		report0.timer01Count=0;
	}
	//
	for( i=0; i<report0.reportNo; i++ ){
		//
		if( report0.reportOrgStr[i*3+0]!="" ){
			//
			report0.element0[i].innerHTML=report0.makeHtml(i);
			report0.element1[i].innerHTML=report0.makeHizukeHtml(i);
			//
		}
		report0.setColor( i, report0.element0[i], report0.element1[i] );
		//
	}
	//
	//
	//
	report0.newReportElm0.innerHTML=report0.makeHtml(-1);
	report0.newReportElm1.innerHTML=report0.makeHizukeHtml(-1);
	//
	//
	//
	report0.timer01Count++;
	//
	report0.timer01Id=setTimeout( report00_timer01CallBack, 500);
	//
}



//
//
//
/**********************************************************
	このエリアの管理
***********************************************************/
//



var report0;


//
//
//
function kycReport0000Start()
{
	//
	//alert('kycReport0000Start start!!');
	//
	report0=new report00();
	report0.setArea();
	//
	report0.startTimer();
	//
	//alert('kycReport0000Start end!!');
	//
	return;
}
