function Headline() {
    this.name =" Headline";
    this.item = new Array();
    this.itemcount = 0;
    this.currentspeed = 0;
    this.scrollspeed = 50;
    this.pausedelay = 1000;
    this.pausemouseover = false;
    this.stop = false;
    this.type = 1;
    this.height = 16;
    this.width = 150;
    this.stopHeight=0;

    this.add =function () {
	var text = arguments[0];
	this.item[this.itemcount] = text;
	this.itemcount = this.itemcount + 1;
    };

    this.start = function () {
	this.display();
	this.currentspeed = this.scrollspeed;
	setTimeout(this.name+'.scroll()',this.currentspeed);
    };

    this.display =function () {
	document.write('<div id="'+this.name+'" style="height:'+this.height+'px;width:'+this.width+'px;position:relative;overflow:hidden;" OnMouseOver="'+this.name+'.onmouseover();" OnMouseOut="'+this.name+'.onmouseout();">');
	for(var i = 0; i < this.itemcount; i++) {
            if ( this.type == 1) {
		document.write('<div id="'+this.name+'item'+i+'"style="left:0px;width:'+this.width+'px;position:absolute;top:'+(this.height*i+1)+'px;">');
                document.write(this.item[i]);
                document.write('</div>');
            } else if ( this.type == 2 ) {
                document.write('<div id="'+this.name+'item'+i+'"style="left:'+(this.width*i+1)+'px;width:'+this.width+'px;position:absolute;top:0px;">');
                document.write(this.item[i]);
                document.write('</div>');
            }
	}
	document.write('</div>');
    };

    this.scroll = function () {
	this.currentspeed = this.scrollspeed;
	if ( !this.stop ) {
            for (i = 0; i < this.itemcount; i++) {
                obj = document.getElementById(this.name+'item'+i).style;
                if ( this.type == 1 ) {
                    var t = obj.top.replace(/p[tx]$/, '') - 1;
                    obj.top = t + 'px';
                    if (t <= this.height*(-1) ) 
                        obj.top = (this.height * (this.itemcount-1)) + 'px';
                    if ( t == 0 || ( this.stopHeight > 0 && this.stopHeight - t == 0 )) 
                        this.currentspeed = this.pausedelay;
                } else if ( this.type == 2 ) {
                    var l = obj.left.replace(/p[tx]$/, '') - 1;
                    obj.left = l + 'px';
                    if (l <= this.left*(-1) ) 
                        obj.left = (l* (this.itemcount-1)) + 'px';
                    if (l == 0 ) 
                        this.currentspeed = this.pausedelay;
                }
            }
	}
	window.setTimeout(this.name+".scroll()",this.currentspeed);
    };

    this.onmouseover = function () {
	if ( this.pausemouseover ) {
            this.stop = true;
	}
    };

    this.onmouseout = function () {
	if ( this.pausemouseover ) {
            this.stop = false;
	}
    };

}

				

var mnTemp = {
    "01":"Jan",
    "02":"Feb",
    "03":"Mar",
    "04":"Apr",
    "05":"May",
    "06":"Jun",
    "07":"Jul",
    "08":"Aug",
    "09":"Sep",
    "10":"Oct",
    "11":"Nov",
    "12":"Dec"
}

function blogheadline(){
        var script1 = document.createElement('script');
        script1.src = 'http://pipes.yahoo.com/pipes/pipe.run?_id=651e4f6874e412dc57f852f48546977e&_render=json&_callback=getJSONP';
        document.body.appendChild(script1);
    
}

function getJSONP(){
    this.objt = arguments[0];
    this.ttl = this.objt.value.items[0]["content"];
    this.dat = this.objt.value.items[1]["content"];
    this.loc = this.objt.value.items[2]["content"];
    this.crt = this.objt.value.items[3]["content"];
    this.dat = this.dat.replace(/T/g, "_").replace(/\+/g, "_").replace(/-/g, "_").split("_");
    this.time_str = mnTemp[this.dat[1]] + " " + this.dat[2] + " " + this.dat[3] + " " + this.dat[0];
    this.disp_time = mnTemp[this.dat[1]] + ". " + this.dat[2] + ", " + this.dat[0] + " " + this.dat[3];
    this.parse_time = Date.parse(this.time_str);
    this.now = new Date();
    this.now = this.now.getTime() - (this.now.getTimezoneOffset() + 9 * 60) * 60 *1000;
    this.diff = (this.now - this.parse_time) / 1000;
    
    this.past = "";
    if(this.diff<(45*60)){
        this.past=Math.floor(this.diff/60)+"分前";
    }else if(this.diff<(90*60)){
        this.past="約1時間前";
    }else if(this.diff<(24*60*60)){
        this.past="約"+Math.floor(this.diff/3600)+"時間前";
    }else if(this.diff<(48*60*60)){
        this.past="1日前";
    }else{
        this.past=Math.floor(this.diff/86400)+"日前";
    }
    
    //<apikey>
    this.api_key = "30A28ABF30AB67FB30CF898130E98ACB";
    //</apikey>
    this.op = "ブログ:&nbsp;<a href=\"" + this.loc + "\" class=\"blog_loc\">" + this.ttl + "</a>"  + " <span style=\"color:#666666;\">[ " + this.past + " ] </span>";
    document.getElementById("blognews").innerHTML = this.op;
}

