jQuery.noConflict();
var j$ = jQuery;

/* TOOLTIP]:
================================================================================*/

/*
 * Tooltip script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 


this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	j$(".tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		j$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		j$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		j$("#tooltip").remove();
    });	
	j$(".tooltip").mousemove(function(e){
		j$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

/* SEASONS
================================================================================*/

this.seasons = function(){
	var	date	= new Date();
	var	month	= date.getMonth();
	var path  = "/imgs/common/";
	var	season_dat	= new Array(12);
	season_dat[0]  = path + "bg_footer_winter.gif";
	season_dat[1]  = path + "bg_footer_winter.gif";
	season_dat[2]  = path + "bg_footer_spring.gif";
	season_dat[3]  = path + "bg_footer_spring.gif";
	season_dat[4]  = path + "bg_footer_spring.gif";
	season_dat[5]  = path + "bg_footer_summer.gif";
	season_dat[6]  = path + "bg_footer_summer.gif";
	season_dat[7]  = path + "bg_footer_summer.gif";
	season_dat[8]  = path + "bg_footer_fall.gif";
	season_dat[9]  = path + "bg_footer_fall.gif";
	season_dat[10] = path + "bg_footer_fall.gif";
	season_dat[11] = path + "bg_footer_winter.gif";
	//alert(month);
	if (season_dat[month] != "") {
		j$('#footer').css('background', 'url(' + season_dat[month] + ') no-repeat bottom center #252424');
	}
}

/* INIT
================================================================================*/


/* 新着記事にNewマークを表示する。 */
jQuery(function() {
// passage time
var pass = 168;

// display content
var content = 'New!!&nbsp;';
var currentDate = new Date();
var spans = document.getElementsByTagName('span');
for (i = 0; i < spans.length; i++) {
    if(spans[i].getAttribute('class') == 'new' || spans[i].getAttribute('className') == 'new') {
        time = spans[i].childNodes[0].nodeValue.split(":");
        var entryDate = new Date(time[0], time[1]-1, time[2], time[3], time[4], time[5]);
        var now = (entryDate.getTime() - currentDate.getTime())/(60*60*1000);
        now = Math.ceil(now);
        if(-now <= pass){
            spans[i].innerHTML = content;
            spans[i].style.display = 'inline';
        }
    }
}

/* Rollover */
	j$(".rollover").each(function(){
		if(j$(this).hasClass('current')){
			j$(this).attr("src",j$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_o$2"));
		} else {
			j$(this).mouseover(function(){
					j$(this).attr("src",j$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_o$2"));
			}).mouseout(function(){
					j$(this).attr("src",j$(this).attr("src").replace(/^(.+)_o(\.[a-z]+)$/, "$1$2"));
			});
		}
	});

// ページ内スクロール
	j$("a[href^=#]").click(function(){
		var Hash = j$(this.hash);
		var HashOffset = j$(Hash).offset().top;
		j$("html,body").animate({
			scrollTop: HashOffset
		}, 500);
		return false;
	});
seasons();
});
