var cocoTrouble = {
//  ===
    newperiod       :   {   /* 表示期間(終了日時からの時間(hours))  */
        trouble         :   48
    ,   maintenance     :   24
    }
,   notrouble       :   {   /* 情報無しの場合表示する文字列 */
        trouble         :   'ありません。'
    ,   maintenance     :   'ありません。'
    }
//  ===
,   info            :   new Array()
//  ===
,   loadComplete    :   function ( kind ) {
        var list = document.getElementById('cocoTrouble-'+kind) ;
        if ( !list ) return false ;
        var printInfo = '' ;
        for ( var ci=0; ci < this.info[kind].data.length-1; ci++ ) {
            var info = this.info[kind].data[ci] ;
            var now = (new Date()).getTime() ;
            var todate = Date.parse(info.to) ;
            if ( isNaN(todate) == true || ( this.newperiod[kind] && (now-todate) < (this.newperiod[kind]*60*60*1000) ) ) {
                var content = info.content ;
                content = content.replace(/<font.*<\/font>/g,'') ;
                content = content.replace(/<br[^>]*>/g,'') ;
                content = content.replace(/左記/g,'上記') ;
                if ( !isNaN(Date.parse(info.from)) ) {
	                printInfo += [
	                	'<div class="' + ( ((isNaN(todate)==true)||(0<=(todate-now))) ?'cocoTroubleDate':'cocoTroubleDatePassed' ) + '">'
	                ,	info.from
	                ,	'～'
	                ,	info.to
	                ,	'</div>'
	                ].join('\n') ;
                }
	            printInfo += '<div class="cocoTroubleContent">' + content + '</div>' ;
            }
        }
        var	listObj = document.createElement('li') ;
        if ( printInfo != '' ) {
//          list.innerHTML = printInfo ;
			listObj.innerHTML = printInfo ;
        }
        else if ( this.notrouble[kind] ) {
//          list.innerHTML = '<li>' + this.notrouble[kind] + '</li>' ;
			listObj.innerHTML = this.notrouble[kind] ;
        }
		list.appendChild(listObj) ;
		
        var div = document.getElementById('cocoTrouble-update-'+kind) ;
        if ( div && this.info[kind].update ) {
//          div.innerHTML = 'Update: ' + this.info[kind].update ;
			var	txtObj = document.createTextNode('Update: ' + this.info[kind].update) ;
			div.appendChild(txtObj) ;
        }
        return true ;
    }   //  end of loadComplete()
//  ===
,   loadScript      :   function ( src, charset ) {
/*
//	NG on Firefox[from]
//		var callScript = document.createElement("script") ;
//		callScript.type = "text/javascript" ;
//		callScript.charset = ( charset ) ? charset : "utf-8" ;
//		callScript.src = src ;
//		var target = document.getElementById('cocoTrouble') ;
//		if ( target ) {
//			var	addscript = function () {
//				target.appendChild( callScript ) ;
//			}
//			setTimeout( addscript, 0 ) ;
//		}
//	NG on Firefox[ to ]
*/
		var	scriptStr = [
			'<scr' + 'ipt type="text/javascript" '
		,	'charset="' + ((charset)?charset:'utf-8') + '" '
		,	'src="' + src + '"></scr' + 'ipt>'
		].join('') ;
        document.write( scriptStr ) ;
    }   //  end of loadScript()
//  ===
,   init            :   function () {
        this.loadScript( "http://homepage3.nifty.com/furyu/cocoMaintenance.js?reload=" + (new Date).getTime() ) ;
        this.loadScript( "http://homepage3.nifty.com/furyu/cocoTrouble.js?reload=" + (new Date).getTime() ) ;
    }   //  end of init()
}   //  end of cocoTrouble object definition

