//rollover
$(document).ready(function($) {
	var postfix = '_on';
	$('#rightmain a img, #pagetop_bt a img').not('[src*="'+ postfix +'."]').each(function() {
		var img = $(this);
		var src = img.attr('src');
		var src_on = src.substr(0, src.lastIndexOf('.'))
		           + postfix
		           + src.substring(src.lastIndexOf('.'));
		$('<img>').attr('src', src_on);
		img.hover(
			function() {
				img.attr('src', src_on);
			},
			function() {
				img.attr('src', src);
			}
		);
	});
});


//innerfade
$(document).ready(
	function(){
		$('ul#imageswitch').innerfade({
			speed: 4000,
			timeout: 7000,
			type: 'sequence'
            });
});


//contentsslider
$(document).ready(function(){
	$("#myController").jFlow({
		slides: "#slides",
		controller: ".jFlowControl", // must be class, use . sign
		slideWrapper : "#jFlowSlide", // must be id, use # sign
		selectedWrapper: "jFlowSelected",  // just pure text, no sign
		auto: true,		//auto change slide, default true
		width: "400px",
		height: "240px",
		duration: 400,
		prev: ".jFlowPrev", // must be class, use . sign
		next: ".jFlowNext" // must be class, use . sign
	});
});


//textresizer
$(document).ready(function() {
	if($.cookie('TEXT_SIZE')) {
		$('#contentsarea').addClass($.cookie('TEXT_SIZE'));
	}
	$('#resizer a').click(function() {
		var textSize = $(this).parent().attr('class');
		$('#contentsarea').removeClass('small medium large').addClass(textSize);
		$.cookie('TEXT_SIZE',textSize, { path: '/', expires: 10000 });
		return false;
	});
});

//rightclick
$(document).ready(function(){
	$(document).bind("contextmenu",function(e){
		return false;
	});
});



    google.load("feeds", "1");
 
    function initialize() {
      var feed = new google.feeds.Feed("http://d.hatena.ne.jp/shukokan/rss");
      feed.setNumEntries(5)
      feed.load(function(result) {
        if (!result.error) {
          var container = document.getElementById("feed");

          var htmlstr = "";
          htmlstr += "<ul>";

          for (var i = 0; i < result.feed.entries.length; i++) {
            var entry = result.feed.entries[i];
			
			if(entry.title.match(/^PR:/)) {
			}
             else{

            //var div = document.createElement("div");

            htmlstr += '<li>'

			var strdate = createDateString(entry.publishedDate);
			htmlstr += '[' + strdate + ']&nbsp;&nbsp;';
			
            htmlstr += '<a href="' + entry.link + '" target="_blank">' + entry.title + '</a>';

            htmlstr += "</li>"
			}

          }
          htmlstr += "</ul>";
          container.innerHTML = htmlstr;
        }
      });
    }
//日付の表示方法を変更
function createDateString(publishedDate)
{
 var pdate = new Date(publishedDate);
 var pday = pdate.getDate();
 if (pday < 10) {pday = "0" + pday;}
 var pmonth = pdate.getMonth() + 1;
 if (pmonth < 10) {pmonth = "0" + pmonth;}
 var pyear = pdate.getFullYear();
 var phour = pdate.getHours();
 var pminute = pdate.getMinutes();
 var psecond = pdate.getSeconds(); 
 //var strdate = pyear + "年" + pmonth + "月" + pday + "日" + phour + "時" + pminute + "分" + psecond + "秒";
 var strdate = pyear + "." + pmonth + "." + pday ;
 return strdate;
} 
    google.setOnLoadCallback(initialize);
