////////////////////////////////////////////////
//
// util.js[ver1.4 101027]
//
////////////////////////////////////////////////

var pageScrollTimer;
var util = {
	preloader: {
		loadedImages: [],
		load: function (url){
			var img = this.loadedImages;
			var l = img.length;
			img[l] = new Image();
			img[l].src = url;
		}
	}
};

$(function(){	   


$("table").each(function(){

var tBorder = $(this).attr("border");
//alert(tBorder);
if(tBorder !=0){
	bw = tBorder + "px";
	$(this).css({
				"borderWidth":bw,
				"borderColor":"#ccc",
				"borderStyle":"solid"
				});
	$(this).find("th").css({
				"borderWidth":bw,
				"borderColor":"#ccc",
				"borderStyle":"solid"
				});
	$(this).find("td").css({
				"borderWidth":bw,
				"borderColor":"#ccc",
				"borderStyle":"solid"
				});
}
		   
											});
		   

$(".gallery .sectionH3 table a img").hover(function(){
	//												alert("hoge");
													},function(){
													});

$('.hover').each(function(){					  
	this.originalSrc = $(this).attr('src');
		if ((/\d\.(jpg|gif|png)/).test(this.originalSrc)){
			this.rolloverSrc = this.originalSrc.replace(/(\.)(jpg|gif|png)/,"hover.$2");	
		}else{
			this.rolloverSrc = this.originalSrc.replace(/(\.)(jpg|gif|png)/,"Hover.$2");
		}	
	util.preloader.load(this.rolloverSrc);
});

$(".hover").hover(function(){
	$(this).attr('src',this.rolloverSrc);
},function(){
	$(this).attr('src',this.originalSrc);
});

$(".fade").hover(function(){
	$(this).fadeTo(100, 0.7);
},
function(){
	$(this).fadeTo(100, 1.0);
});

//$("div.wrap").wrapInner('<div class="inner"></div>');			   
//$("h1.wrap,h2.wrap,h3.wrap,h4.wrap,li.wrap,dt.wrap,dd.wrap").wrapInner('<span class="inner"></span>');

$('a.bl').click(function(){window.open(this.href, '_blank');return false;});

$('.pageTop a').click(function(){pageScroll(0,7);return false;});
$('.anchor').click(function(){
	var aim = $(this).attr('href');
	pageScroll(Math.floor($(aim).offset().top),7);
	return false;
});
});

function pageScroll(toY,frms,cuY){
	if (pageScrollTimer) clearTimeout(pageScrollTimer);
	if (!toY || toY < 0) toY = 0;
	if (!cuY) cuY = 0 + $(window).scrollTop();
	if (!frms) frms = 6;
	if ((toY > cuY) && (toY > getContentsHeight() - $(window).height())){ toY = getContentsHeight() - $(window).height() +1 };
	cuY += (toY - $(window).scrollTop()) / frms;
	if (cuY < 0) cuY = 0;
	var posY = Math.floor(cuY);

	window.scrollTo(0, posY);
	if (posY != toY) {pageScrollTimer = setTimeout("pageScroll("+toY+","+frms+","+cuY+")",16);}
}

function getContentsHeight(){return ($.support.boxModel) ? $('body').height() : document.body.scrollHeight ;}

