/* page top */

var pagetopTimer = false;
function pagetop() {
	if(document.all){
		var currentY = document.documentElement.scrollTop;
	}else{
		var currentY = window.pageYOffset;
	}
	if (currentY > 0.5) {
		var newY = parseInt(currentY - currentY / 5);
		window.scrollTo(0, newY);
		pagetopTimer = setTimeout('pagetop()', 1);
	}
	else {
		window.scrollTo(0, 0);
		clearTimeout(pagetopTimer);
		pagetopTimer = false;
	}
}

$(function () {
	$('.pagetop').click(function () {
		pagetop();
		return false;
	});
});


/* rollover */

$(function () {
	var preLoad = new Object();
	$('img.ro,input.ro').not("[src*='_ro.']").each(function(){
		var imgSrc = this.src;
		var fType = imgSrc.substring(imgSrc.lastIndexOf('.'));
		var imgName = imgSrc.substr(0, imgSrc.lastIndexOf('.'));
		var imgOver = imgName + '_ro' + fType;
		preLoad[this.src] = new Image();
		preLoad[this.src].src = imgOver;
		$(this).hover(
			function (){
				this.src = imgOver;
			},
			function (){
				this.src = imgSrc;
			}
		);
	});
});


/* annotation for basic */

$(window).load(function () {
	$('#basic .annotation').not('.nonenum').each(function () {
		var em_w = 0;
		var width = $(this).attr('offsetWidth');
		
		$(this).children('li').each(function () {
				var text = '<em class="num">※</em>' + '<span class="txt">' + $(this).html() + '</span>';
				$(this).html(text);
				
				em_w = $(this).children('.num').attr('offsetWidth');
		});
		
		$(this).children('li').not('.nonenum').children('.num').each(function (i) {
				var text = $(this).html() + (i+1);
				$(this).html(text);
				
				if (i == 0) {
					em_w = $(this).attr('offsetWidth');
				}
				else {
					if (em_w < $(this).attr('offsetWidth')) {
						em_w = $(this).attr('offsetWidth');
					}
				}
		});
		
		$(this).children('li').each(function () {
			$(this).children('.num').width(em_w + 5);
			$(this).children('.txt').width(width - (em_w + 5));
		});
	});
	
	$('#basic .annotation.nonenum').each(function () {
		var em_w = 0;
		var width = $(this).attr('offsetWidth');
		
		$(this).children('li').each(function () {
				var text = '<em class="num">※</em>' + '<span class="txt">' + $(this).html() + '</span>';
				$(this).html(text);
				
				em_w = $(this).children('.num').attr('offsetWidth');
		});
		
		$(this).children('li').each(function () {
			$(this).children('.num').width(em_w + 5);
			$(this).children('.txt').width(width - (em_w + 5));
		});
	});
});
