/*

	Examples
	
	author :Live!Ads oka
	lastupdate :091118
	
================================================== */

function init(){
	var window_height = $(window).height();
	var head = $("#header").innerHeight();
	var path = $("#topicPath").innerHeight();
	var menu = $(".menu").innerHeight();
	var copyright = $(".copyright").innerHeight() + 10;
	var height = window_height - head - path - menu - copyright;
	height = Math.max(548,height);
	iframe = Math.max(540,height-9);
	$(".scroll").css("height",height);
	$(".scroll dl").css("marginBottom",height-380);
	$("#contents_frame").css("height",iframe);

};


var page = {};
page.list = new Array();
page.current = 0;
page.end = 0;
page.init = function(){
	// A
	$(".scroll-wrap > div > dl > dd > ul > li > a").click(function(){
							
		$("#contents_frame").attr("src",this);
		$(".contentwrapper > dl > dd > ul > li > a[class='current']").attr("class","");
		$(this).attr("class","current");
		var num = this.href.split("/");
		num = num[num.length-1];
		num = num.split(".");
		page.current = Number(num[0]);
		$(".back > a").attr("style","visibility:visible");
		$(".next > a").attr("style","visibility:visible");
		page.total();
		return false;
		
	});	
	// back
	$(".back > a").click(function(){
		if(page.current <= 1) return false;

		page.current--;
		page.prevnext();
		
		return false;
		
	});	
	// next
	$(".next > a").click(function(){
		if(page.current >= page.end) return false;

		page.current++;
		page.prevnext();
		
		return false;
		
	});
	$("#contents_frame").attr("src","base.html");
	page.end = $(".scroll-wrap > div > dl > dd > ul > li > a").length;
	
	
	
	
	
	
};

page.prevnext = function(){
	$(".contentwrapper > dl > dd > ul > li > a[class='current']").attr("class","");
	$(".contentwrapper > dl > dd > ul > li > a[href='"+ page.current +".html']").attr("class","current");
	$("#contents_frame").attr("src",page.current + ".html");
	page.total();
};
page.total = function(){
	$("#PageNum").html(page.current + "/" + page.end);
};




$(window).resize(init);
$(document).ready(function(){
	init();
	page.init();
	var isMSIE = /*@cc_on!@*/0;
	if(isMSIE){
		font.check();
	}
});
