(function($, window){
	/*
	 * RSS Data取得
	 */
	window.jQIKRssData = [];
	var jQIKRss = window.jQIKRss = $.jQIKRss = function(vars){
		return jQIKRss.prototype.init(vars);
	}
	jQIKRss.prototype = {
		vars :{},//ikimono/labs
		pathURL : "/scripts/php/rss.php",
		selector : {
			jQBlogTab : "#includeblogtab",// タブ
			jQBlog : "#includeblog"
		},
		init : function(vars){
			if(typeof vars == "undefined") vars = {};
			this.vars = vars;
			// console.log(this.selector);
			this.selector.jQBlogDL = this.selector.jQBlog + " dl";
			this.selector.jQBlogP = ".moreInfo";
			// $(this.selector.jQBlog).append('');
			var a = this.selector.jQBlogTab + " a",$this=this;
			$(a).click(function(){
				window.jQIKData.rss = true;
				$($this.selector.jQBlog).html($this.element.jQBlog);
				for(var i=0;i<$(this).parent().parent().children().length;i++){
					var all = $($(this).parent().parent().children()[i]).children()[0],
					img = $(all).children()[0];
					
					$(img).attr({"src":$(img).attr("src").replace("_r", "_n")});
					$(img).bind("mouseover", function(){
						$(this).attr({"src":$(this).attr("src").replace("_n", "_r")});
					});
					$(img).bind("mouseout", function(){
						$(this).attr({"src":$(this).attr("src").replace("_r", "_n")});
						// console.log($(this).attr("src"));
					});
				}	
				var imgt = $(this).children()[0];
				$(imgt).attr({"src":$(imgt).attr("src").replace("_n", "_r")});
				$(imgt).bind("mouseover mouseout", function(){
					$(this).attr({"src":$(this).attr("src").replace("_n", "_r")});
				});
				$.ajax({url : $this.pathURL, data:{area:this.rel}, dataType : "json", success : function(json){
					$this.getRss(json, $this);
				}});
			});
			return this;
		},
		getRss:function(data, $this){
			var entry = data.item;
			$($this.selector.jQBlogP).html('<a href="'+data.channel.link+'">もっと見る</a>');
			$($this.selector.jQBlogDL).html('');
			for(var i=0;i<entry.length;i++){
				// if(i>2) return;
				// alert(entry[i].dc_date_format.split(" "));
				var date = entry[i].dc_date_format.split(" "),
				dateTmp = date[0].split("-");
				yyyy = dateTmp[0],
				mm = dateTmp[1],
				dd = dateTmp[2],
				dates = yyyy + "." + mm + "." + dd + "";
				$($this.selector.jQBlogDL).append('<dt>'+dates+"<br>"+entry[i].dc_creator+'</dt>');
				$($this.selector.jQBlogDL).append('<dd><a href="'+entry[i].link+'">'+entry[i].title+'</a><br>'+entry[i].description.substring(0,100)+'…</dd>');
			}
		},
		element :{
			jQBlog : '<p class="moreInfo"></p><dl></dl><p class="moreInfo">'
		}
	};
})(jQuery, window);
/* XML / JSONによる */
$(
	function(){
		/*var vars = {
			
		},rss = new $.jQIKRss(vars);*/
		var rss = new $.jQIKRss();
	}
);
/* 通信終了 */
$(document).ajaxStop(
	function(){

	}
);
/* 通信終了 */


