// JavaScript Document(function($){
$(function(){		
	$('a img.morebtn').hover(function(){
		$(this).parent().addClass('morebtn');
		$(this).fadeTo(200,0);
	},function(){
		setTimeout('$(this).parent().removeClass();', 1000);
		$(this).fadeTo(500,1.0);
	});
	
	//Use Swap Rollover
	$.SwapOverImages();
	
	//Use Opacity Rollover
	$.opacityRollOver();
	$('.wink').wink();
	
	//Use yuga.js
	$.scroll();
});

/*---------------------------------------------------------
 * JQuery Plugin : "Opacity Rollover"
 *
 * version 1.1
 *
 * Author : Hiromu Hasegawa
 * Copyright (c) 2008 THE HAM MEDIA (http://h2ham.seesaa.net)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Since:     2008-12-27
 *
 * jQuery 1.2.6
 ---------------------------------------------------------*/
 
//デフォルトセレクタ
$.opacityRollOver = function(settings) {
		c = $.extend({
			selector: '.opacity',
			opacityDef:1.0,
			fadeTime:200,
			opacityOn:0.6,
			opacityOff:1.0
		}, settings);
		opacityRollOverFn(c.selector,c.opacityDef,c.fadeTime,c.opacityOn,c.opacityOff);
};

//ユーザー指定セレクタ(使用方法(Usage)：$('#opacity').opacityRollOver();) 
$.fn.opacityRollOver = function(settings) {
		c = $.extend({
			selector: this,
			opacityDef:1.0,
			fadeTime:200,
			opacityOn:0.6,
			opacityOff:1.0
		}, settings);
		opacityRollOverFn(c.selector,c.opacityDef,c.fadeTime,c.opacityOn,c.opacityOff);
};

//透明度を利用したロールオーバー
function opacityRollOverFn(c,d,e,f,g) {
	$(c).each(function(){
		$(this).css('opacity',d)
			.hover(function(){
				$(this).fadeTo(e,f);
			},
			function(){
				$(this).fadeTo(e,g);
			});
	});
};

/*=====================================================
meta: {
  title: "jquery-opacity-rollover.js",
  version: "2.1",
  copy: "copyright 2009 h2ham (h2ham.mail@gmail.com)",
  license: "MIT License(http://www.opensource.org/licenses/mit-license.php)",
  author: "THE HAM MEDIA - http://h2ham.seesaa.net/",
  date: "2009-07-21"
  modify: "2009-07-23"
}
=====================================================*/
(function($) {
	
	$.fn.wink = function(durationp,op,oa){

		var c = {
			durationp:durationp? durationp:'slow',
			op:op? op:1.0,
			oa:oa? oa:0.2
		};
		
		$(this).each(function(){
			$(this)	.css({
					opacity: c.op,
					filter: "alpha(opacity="+c.op*100+")"
				}).hover(function(){
				$(this).css({
					opacity: c.oa,
					filter: "alpha(opacity="+c.oa*100+")"
				});
				$(this).fadeTo(c.durationp,c.op);
			},function(){
				$(this).css({
					opacity: c.op,
					filter: "alpha(opacity="+c.op*100+")"
				});
			})
		});
	}
	
})(jQuery);

/*----------------------------------------------------------
 * JQuery Plugin : "SwapOverImages"
 ---------------------------------------------------------*/
$.SwapOverImages= function() {
	var image_cache = new Object();
	$("img.swapover").each(function(i) {
		var imgsrc = this.src;
		var dot = this.src.lastIndexOf('.');
		var imgsrc_on = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
		image_cache[this.src] = new Image();
		image_cache[this.src].src = imgsrc_on;
		$(this).hover(
			function() { this.src = imgsrc_on; },
			function() { this.src = imgsrc; });
	});
};

/*----------------------------------------------------------
 * yuga.js 0.7.0 - 優雅なWeb制作のためのJS
 *
 * Copyright (c) 2007 Kyosuke Nakamura (kyosuke.jp)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Since:     2006-10-30
 * Modified:  2008-12-26
 *
 * jQuery 1.3
 * ThickBox 3.1
 ---------------------------------------------------------*/

/*h2ham remake version*/

$.Uri = function(path){
	var self = this;
	this.originalPath = path;
	//絶対パスを取得
	this.absolutePath = (function(){
		var e = document.createElement('span');
		e.innerHTML = '<a href="' + path + '" />';
		return e.firstChild.href;
	})();
	//絶対パスを分解
	var fields = {'schema' : 2, 'username' : 5, 'password' : 6, 'host' : 7, 'path' : 9, 'query' : 10, 'fragment' : 11};
	var r = /^((\w+):)?(\/\/)?((\w+):?(\w+)?@)?([^\/\?:]+):?(\d+)?(\/?[^\?#]+)?\??([^#]+)?#?(\w*)/.exec(this.absolutePath);
	for (var field in fields) {
		this[field] = r[fields[field]];
	}
	this.querys = {};
	if(this.query){
		$.each(self.query.split('&'), function(){
			var a = this.split('=');
			if (a.length == 2) self.querys[a[0]] = a[1];
		});
	}
};

//ページ内リンクはするするスクロール
$.scroll = function(options) {
	//ドキュメントのスクロールを制御するオブジェクト
	var scroller = (function() {
		var c = $.extend({
			easing:100,
			step:30,
			fps:60,
			fragment:''
		}, options);
		c.ms = Math.floor(1000/c.fps);
		var timerId;
		var param = {
			stepCount:0,
			startY:0,
			endY:0,
			lastY:0
		};
		//スクロール中に実行されるfunction
		function move() {
			if (param.stepCount == c.step) {
				//スクロール終了時
				setFragment(param.hrefdata.absolutePath);
				window.scrollTo(getCurrentX(), param.endY);
			} else if (param.lastY == getCurrentY()) {
				//通常スクロール時
				param.stepCount++;
				window.scrollTo(getCurrentX(), getEasingY());
				param.lastY = getEasingY();
				timerId = setTimeout(move, c.ms); 
			} else {
				//キャンセル発生
				if (getCurrentY()+getViewportHeight() == getDocumentHeight()) {
					//画面下のためスクロール終了
					setFragment(param.hrefdata.absolutePath);
				}
			}
		}
		function setFragment(path){
			location.href = path
		}
		function getCurrentY() {
			return document.body.scrollTop  || document.documentElement.scrollTop;
		}
		function getCurrentX() {
			return document.body.scrollLeft  || document.documentElement.scrollLeft;
		}
		function getDocumentHeight(){
			return document.documentElement.scrollHeight || document.body.scrollHeight;
		}
		function getViewportHeight(){
			return (!$.browser.safari && !$.browser.opera) ? document.documentElement.clientHeight || document.body.clientHeight || document.body.scrollHeight : window.innerHeight;
		}
		function getEasingY() {
			return Math.floor(getEasing(param.startY, param.endY, param.stepCount, c.step, c.easing));
		}
		function getEasing(start, end, stepCount, step, easing) {
			var s = stepCount / step;
			return (end - start) * (s + easing / (100 * Math.PI) * Math.sin(Math.PI * s)) + start;
		}
		return {
			set: function(options) {
				this.stop();
				if (options.startY == undefined) options.startY = getCurrentY();
				param = $.extend(param, options);
				param.lastY = param.startY;
				timerId = setTimeout(move, c.ms); 
			},
			stop: function(){
				clearTimeout(timerId);
				param.stepCount = 0;
			}
		};
	})();
	$('a[href^=#], area[href^=#]').not('a[href=#], area[href=#]').each(function(){
		this.hrefdata = new $.Uri(this.getAttribute('href'));
	}).click(function(){
		var target = $('#'+this.hrefdata.fragment);
		if (target.length == 0) target = $('a[name='+this.hrefdata.fragment+']');
		if (target.length) {
			scroller.set({
				endY: target.offset().top,
				hrefdata: this.hrefdata
			});
			return false;
		}
	});
};

(jQuery)


google.load("feeds", "1");

(function($){
$(function() {
    var feed = new google.feeds.Feed("http://b.hatena.ne.jp/entrylist?mode=rss&url=http%3A%2F%2Fh2ham.seesaa.net%2F&sort=count&threshold=3");
    feed.setNumEntries(10);
    feed.load(function(result) {
        if (!result.error) {
            var useFeed = "";
             for (var i = 0; i < result.feed.entries.length; i++) {
                var entry = result.feed.entries[i];
                var Title = entry.title.replace(" | THE HAM MEDIA" , "");
                useFeed += '<li><a href="' + entry.link + '">'+ Title + '</a><a href="http://b.hatena.ne.jp/entry/' + entry.link + '"><img src="http://b.hatena.ne.jp/entry/image/' + entry.link + '" class="noborder" /></a></li>';
            }
        $("ul#entrylist").html(useFeed);
        
        	$('ul#entrylist a[href^="http://"],ul#entrylist a[href^="https://"]').not('a[href^="http://h2ham.seesaa.net"]').not('a[href^="http://h2ham.up.seesaa.net/"]').click(function(){
		window.open(this.href, '_blank');
		return false;
	}).addClass("external-link");
        
    }
    });
});
})(jQuery);

/*
 * Easy Retweet Button
 * http://ejohn.org/blog/retweet/
 *   by John Resig (ejohn.org)
 *
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 */

(function(){

window.RetweetJS = {
	// Your Bit.ly Username
	bitly_user: "h2ham",

	// Your Bit.ly API Key
	// Found here: http://bit.ly/account
	bitly_key: "R_9e16e8814cb82017eac7333f7a8e4816",

	// The text to replace the links with
	link_text: (/windows/i.test( navigator.userAgent) ? "&#9658;" : "&#9851;") +
		"&nbsp;Retweet",

	// What # to show (Use "clicks" for # of clicks or "none" for nothing)
	count_type: "clicks",

	// Tweet Prefix text
	// "RT @jeresig " would result in: "RT @jeresig Link Title http://bit.ly/asdf"
	prefix: "RT @h2ham ",

	// Style information
	styling: "a.retweet { font: 12px Helvetica,Arial; color: #000; text-decoration: none; border: 0px; }" +
		"a.retweet span { color: #FFF; background: #3D3DFF; margin-left: 2px; border: 1px solid #000099; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; padding: 3px; }" +
		"a.retweet:hover span { color: #FFF; background: #ff05ff; margin-left: 2px; border: 1px solid #ff00ff; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; padding: 3px; }" +
		"a.vert { display: block; text-align: center; font-size: 16px; float: left; margin: 4px; }" +
		"a.retweet strong.vert { display: block; margin-bottom: 4px; background: #F5F5F5; border: 1px solid #EEE; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; padding: 3px; }" +
		"a.retweet span.vert { display: block; font-size: 12px; margin-left: 0px; }"
};

//////////////// No Need to Configure Below Here ////////////////

var loadCount = 1;

// Asynchronously load the Bit.ly JavaScript API
// If it hasn't been loaded already
if ( typeof BitlyClient === "undefined" ) {
	var head = document.getElementsByTagName("head")[0] ||
		document.documentElement;
	var script = document.createElement("script");
	script.src = "http://bit.ly/javascript-api.js?version=latest&login=" +
		RetweetJS.bitly_user + "&apiKey=" + RetweetJS.bitly_key;
	script.charSet = "utf-8";
	head.appendChild( script );

	var check = setInterval(function(){
		if ( typeof BitlyCB !== "undefined" ) {
			clearInterval( check );
			head.removeChild( script );
			loaded();
		}
	}, 10);

	loadCount = 0;
}

if ( document.addEventListener ) {
	document.addEventListener("DOMContentLoaded", loaded, false);

} else if ( window.attachEvent ) {
	window.attachEvent("onload", loaded);
}

function loaded(){
	// Need to wait for doc ready and js ready
	if ( ++loadCount < 2 ) {
		return;
	}

	var elems = [], urlElem = {}, hashURL = {};

	BitlyCB.shortenResponse = function(data) {
		for ( var url in data.results ) {
			var hash = data.results[url].userHash;
			hashURL[hash] = url;

			var elems = urlElem[ url ];

			for ( var i = 0; i < elems.length; i++ ) {
				elems[i].href += hash;
			}

			if ( RetweetJS.count_type === "clicks" ) {
				BitlyClient.stats(hash, 'BitlyCB.statsResponse');
			}
		}
	};

	BitlyCB.statsResponse = function(data) {
		var clicks = data.results.clicks, hash = data.results.userHash;
		var url = hashURL[ hash ], elems = urlElem[ url ];

		if ( clicks > 0 ) {
			for ( var i = 0; i < elems.length; i++ ) {
				var strong = document.createElement("strong");
				strong.appendChild( document.createTextNode( clicks + " " ) );
				elems[i].insertBefore(strong, elems[i].firstChild);

				if ( /(^|\s)vert(\s|$)/.test( elems[i].className ) ) {
					elems[i].firstChild.className = elems[i].lastChild.className = "vert";
				}
			}
		}

		hashURL[ hash ] = urlElem[ url ] = null;
	};

	if ( document.getElementsByClassName ) {
		elems = document.getElementsByClassName("retweet");
	} else {
		var tmp = document.getElementsByTagName("a");
		for ( var i = 0; i < tmp.length; i++ ) {
			if ( /(^|\s)retweet(\s|$)/.test( tmp[i].className ) ) {
				elems.push( tmp[i] );
			}
		}
	}

	if ( elems.length && RetweetJS.styling ) {
		var style = document.createElement("style");
		style.type = "text/css";

		try {
			style.appendChild( document.createTextNode( RetweetJS.styling ) );
		} catch (e) {
			if ( style.styleSheet ) {
				style.styleSheet.cssText = RetweetJS.styling;
			}
		}

		document.body.appendChild( style );
	}

	for ( var i = 0; i < elems.length; i++ ) {
		var elem = elems[i];

		if ( /(^|\s)self(\s|$)/.test( elem.className ) ) {
			elem.href = window.location;
			elem.title = document.title;
		}

		var origText = elem.title || elem.textContent || elem.innerText,
			href = elem.href;

		elem.innerHTML = "<span>" + RetweetJS.link_text + "</span>";
		elem.title = "";
		elem.href = "http://twitter.com/home?status=" +
			encodeURIComponent(RetweetJS.prefix + origText + " http://bit.ly/");

		if ( urlElem[ href ] ) {
			urlElem[ href ].push( elem );
		} else {
			urlElem[ href ] = [ elem ];
			BitlyClient.shorten(href, 'BitlyCB.shortenResponse');
		}
	}
	$('a[href^="http://twitter.com/home?status"]').click(function(){
		window.open(this.href, '_blank');
		return false;
	}).addClass("external-link");
}

})();