// scroll
$(function() {
	$('p.pageTop a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target
			|| $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top - 0;
				$('html,body')
				.animate({scrollTop: targetOffset}, 888);
				return false;
			}
		}
	});
});

// timechange
datetoday = new Date();
timenow=datetoday.getTime();
datetoday.setTime(timenow);
thehour = datetoday.getHours();
if (thehour >= 19) 
	display = "/common/css/night.css";
	else if (thehour >= 16) display = "/common/css/sunset.css";
	else if (thehour >= 6) display = "/common/css/evening.css";
	else if (thehour >= 0) display = "/common/css/night.css";
	else display = "/common/css/evening.css";
var css = '<';
css+='link rel="stylesheet" href=' + display + ' \/';
css+='>';
document.write(css);

// blank
$(document).ready(function() {
	$("a.blank").click(function() {
		window.open(this.href,'blank');
		return false;
	});
});

// popup
$(function() {
	$('.popup').click(function(){
		window.open(this.href, "fuyudrive","width=431,height=757,resizable=yes");
		return false;
	});
});

// rollOver
function initRollOverImages() {  
	var image_cache = new Object();  
	$(".hover").not("[@src*='hvr.']").each(function(i) {  
		var imgsrc = this.src;  
		var dot = this.src.lastIndexOf('.');  
		var imgsrchvr = this.src.substr(0, dot) + 'hvr' + this.src.substr(dot, 4);  
		image_cache[this.src] = new Image();  
		image_cache[this.src].src = imgsrchvr;  
		$(this).hover(  
			function() { this.src = imgsrchvr; },  
			function() { this.src = imgsrc; }  
		);  
	});  
}

$(document).ready(initRollOverImages);
