var yenspa = {};
yenspa.util = {};
yenspa.util.submitForm = function(form_id, method, url){
	jQuery('#' + form_id);
	if(method){jQuery('#' + form_id).attr({'method':method});}
	if(url){jQuery('#' + form_id).attr({'action':url});}
	jQuery('#' + form_id)[0].submit();
};
yenspa.siderankdata = {
	'type1': [
		{
			"link":"http://www.accesstrade.net/at/c.html?rk=01007as00064bl",
			"img":"http://www.accesstrade.net/at/r.html?rk=01007as00064bl",
			"txt":"マネーパートナーズFX"
		},
		{
			"link":"http://www.accesstrade.net/at/c.html?rk=01002ms70064bl",
			"img":"http://www.accesstrade.net/at/r.html?rk=01002ms70064bl",
			"txt":"【MJ】取引手数料無料のオンライン外国為替取引"
		},
		{
			"link":"http://www.accesstrade.net/at/c.html?rk=01006enm0064bl",
			"img":"http://www.accesstrade.net/at/r.html?rk=01006enm0064bl",
			"txt":"フォレックス・トレード"
		}
	],
	'type2': [
		{
			"link":"https://register.min-fx.tv/count.do?id=10091",
			"img":"http://yenspa.jp/uploads/wp-yenspa/banner_emcom/bnr_minfx_120x60.gif",
			"txt":"トレイダーズ証券【みんなのFX】"
		},
		{
			"link":"http://www.accesstrade.net/at/c.html?rk=01006dk90064bl",
			"img":"http://www.accesstrade.net/at/r.html?rk=01006dk90064bl",
			"txt":"ＧＦＴ"
		},
		{
			"link": "http://www.accesstrade.net/at/c.html?rk=01001mpt0064bl",
			"img": "http://www.accesstrade.net/at/r.html?rk=01001mpt0064bl",
			"txt": "クリック証券"
		}
	],
	'type3': [
		{
			"link": "http://www.accesstrade.net/at/c.html?rk=01001mpt0064bl",
			"img": "http://www.accesstrade.net/at/r.html?rk=01001mpt0064bl",
			"txt": "クリック証券"
		},
		{
			"link":"http://www.accesstrade.net/at/c.html?rk=01004ix10064bl",
			"img":"http://www.accesstrade.net/at/r.html?rk=01004ix10064bl",
			"txt":"DMM.com証券【DMM FX】"
		},
		{
			"link":"http://www.accesstrade.net/at/c.html?rk=01003e310064bl",
			"img":"http://www.accesstrade.net/at/r.html?rk=01003e310064bl",
			"txt":"【マネースクウェア・ジャパン】外国為替取引"
		}
	]
};
yenspa.sideRankRender = function(a, type){
	if(!type){type = 1;}
	jQuery('#widgetSideFxRanking > ul.ulTab > li > a').removeClass().addClass('tabNr');
	var data = yenspa.siderankdata;
	type = 'type' + type;
	var r = '';
	var i=0;
	var len = data[type].length;
	for(i=0; i<len; i++){
		r += '<li class="rank rank' + (i+1) + '">';
		r += '<a href="' + data[type][i].link + '" target="_blank">';
		r += '<img src="' + data[type][i].img + '" border="0" />';
		r += '<span class="ttl">' + data[type][i].txt;
		r += '</span></a></li>';
	}
	if(a){
		jQuery(a).removeClass().addClass('tabNrAct');
	}
	jQuery('#widgetSideFxRanking ol.ulRank').empty().append(r);
};

yenspa.sbm = function(){
	var url_this = location.href;
	var title_this = document.title;
	// Yahoo!ブックマーク
	document.write('<a href="http://bookmarks.yahoo.co.jp/bookmarklet/showpopup?t=' + encodeURIComponent(title_this) + '&u=' + encodeURIComponent(url_this) + '&opener=bm&ei=UTF-8" target="_blank"><img src="http://i.yimg.jp/images/sicons/ybm16.gif" width="16" height="16" alt="' + title_this + 'をYahoo!ブックマークに登録" border="0" align="bottom" /><img src="http://num.bookmarks.yahoo.co.jp/image/small/' + url_this + '" border="0" alt="' + title_this + 'のYahoo!ブックマーク登録数" align="bottom" /></a>');
	// Google Bookmarks
	document.write('<a href="http://www.google.com/bookmarks/mark?op=edit&bkmk=' + encodeURIComponent(url_this) + '&title=' + encodeURIComponent(title_this) + '" target="_blank"><img src="http://www.google.co.jp/favicon.ico" alt="' + title_this + 'を Google Bookmarksに追加" width="16" height="16" border="0" align="bottom" /></a>');
	// はてブ
	document.write('<a href="http://b.hatena.ne.jp/append?' + url_this + '"><img src="http://b.hatena.ne.jp/images/append.gif" width="16" height="12" border="0" alt="' + title_this + 'をはてなブックマーク に追加" align="bottom" /><img src="http://b.hatena.ne.jp/entry/image/' + url_this + '" border="0" alt="' + title_this + 'のはてブ数" align="bottom" /></a>');
	// livedoorクリップ
	document.write('<a href="http://clip.livedoor.com/clip/add?link=' + encodeURIComponent(url_this) + '&title=' + encodeURIComponent(title_this) + '"><img src="http://parts.blog.livedoor.jp/img/cmn/clip_16_12_b.gif" width="16" height="12" alt="' + title_this + 'を livedoorクリップに追加" border="0" align="bottom" /><img src="http://image.clip.livedoor.com/counter/' + url_this + '" alt="' + title_this + 'をlivedoorクリップに追加" border="0" align="bottom" /></a>');
	// del.icio.us
	document.write('<a href="http://del.icio.us/post?url=' + encodeURIComponent(url_this) + '&title=' + encodeURIComponent(title_this) + '"><img src="http://images.del.icio.us/static/img/delicious.gif" width="12" height="12" border="0" alt="' + title_this + ' を del.icio.us に追加" align="bottom" /></a>');
	// Pookmark
	document.write('<a href="http://pookmark.jp/post?url=' + encodeURIComponent(url_this) + '&title=' + encodeURIComponent(title_this) + '"><img src="http://pookmark.jp/images/add/add.gif" alt="' + title_this + 'を Pookmark に追加" border="0" align="bottom" /></a>');
	// FC2
	document.write('<a href="http://bookmark.fc2.com/user/post?url=' + encodeURIComponent(url_this) + '&title=' + encodeURIComponent(title_this) + '" target="_blank"><img src="http://bookmark.fc2.com/img/add-16.gif" alt="' + title_this + ' をFC2 Bookmarkに追加" width="12" height="12" border="0" align="bottom" /></a>');
	// buzzurl
	document.write('<a href="http://buzzurl.jp/config/add/confirm?url=' + encodeURIComponent(url_this) + '" target="_blank"><img src="http://buzzurl.jp/static/image/api/icon/add_icon_mini_08.gif" alt="' + title_this + 'をBuzzurlに追加" width="12" height="12" border="0" align="bottom" /><img src="http://api.buzzurl.jp/api/counter/' + url_this + '" border="0" alt="' + title_this + 'のBuzzurl登録数" align="bottom" /></a>');
	// Twitter
	var twitter_str = title_this + ' #yenspa ' + url_this;
	document.write('<a href="http://twitter.com/home?status=' + encodeURIComponent(twitter_str) + '" target="_blank"><img src="http://yenspa.jp/themes/yenspa/images/ic_twitter.gif" alt="' + title_this + 'をつぶやく" width="12" height="14" border="0" align="bottom" /></a>');
	// MailTo
	document.write('<a href="mailto:?body=' + encodeURIComponent(twitter_str) + '"><span style="font-size:82%;">メールする</span></a>');
};

yenspa.webtools = function(){
	var url = '/uploads/wp-yenspa/bitly.php';
	var loc = location.href;
	var twlink = 'http://twitter.com/home?status=';
	var title = document.title;
	var r = '<em class="ttl">ウェブツール</em>';
	data = {'long_url':loc};
	jQuery.ajax({
		url: url,
		data: data,
		type: 'post',
		dataType: 'json',
		success: function(d, dtype){
			if(d.statusCode == 'OK') {
				var query = title + ' #yenspa ' + d.shortUrl;
				twlink += encodeURIComponent(query);
				
			}
		},
		error: function(){}
	});
};
yenspa.scrollTo = function(t){
	if(t != '') {
		t = '#' + t;
		jQuery.scrollTo(t, 300, {easing:'swing'});
	}
};