var image_path = "../../../image/";

function v_set_image_path(path) {
	image_path = path;
}

var title_size = "6";
function v_set_title_size(size) {
	title_size = size;
}

// Page Body --------------------------

function v_body() {
	document.write('<body bgcolor="#d0d0d0" text="#000000">');
}

// Page Title -------------------------

function v_title() {
	document.write('<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><th>');
	document.write('<img src="',image_path,'line-r.gif" width="100%" height="3"><br>');
	document.write('<img src="',image_path,'tp1dot.gif" width="100%" height="5"><br>');
	if( document.title.indexOf(":") == -1 ) {
		document.write('<font size="',title_size,'" color="#000000"><b>',document.title,'</b><br></font>',"\n");
	} else {
		tt = document.title.split(":");
		document.write('<font size="',title_size,'" color="#000000"><b>',tt[1],'</b><br></font>',"\n");
	}
	document.write('<img src="',image_path,'tp1dot.gif" width="100%" height="5"><br>');
	document.write('<img src="',image_path,'line-r.gif" width="100%" height="3"><br>');
	document.write('</th></tr></table>');
}

// Section ----------------------------

function v_tag(tag) {
	document.write('<a name="',tag,'"></a>');
}

var section1_col = "#00a000";
var section2_col = "#00d070";
var section3_col = "#00d0f0";

function v_set_section_col(col) {
	section1_col = col;
}

function v_set_section2_col(col) {
	section2_col = col;
}

function v_set_section3_col(col) {
	section3_col = col;
}

function v_section(title) {
	document.write('<h3><font color="',section1_col,'">●</font>',title,'</h3>\n');
}

function v_section2(title) {
	document.write('<h4><font size="2" color="',section2_col,'">■</font>',title,'</h4>\n');
}

function v_section3(title) {
	document.write('<h4><font size="1" color="',section3_col,'">◆</font>',title,'</h4>\n');
}

// Document ---------------------------

function v_nl() {
	document.write('<br>\n');
}

function v_ca() {
	document.write('<br clear="all">\n');
}

function v_write(data) {
	document.write(data,'\n');
}

function v_write_nl(data) {
	document.write('<p>',data,'<p>\n');
}

function v_q(data) {
	document.write('<img src="../../image/q.gif" align="left"><b>',data,'</b><br clear="all">\n');
}

function v_a(data) {
	document.write('<img src="../../image/a.gif" align="left">',data,'<br clear="all">\n');
}

function v_font(size,col) {
	if( size == "" && col == "" ) {
		document.write('</font>');
	} else if( size == "" ) {
		document.write('<font color="',col,'">');
	} else if( col == "" ) {
		document.write('<font size="',size,'">');
	} else {
		document.write('<font size="',size,'" color="',col,'">');
	}
}

function v_sbq() {
	document.write('<blockquote>\n');
}

function v_ebq() {
	document.write('</blockquote>\n');
}

function v_sc() {
	document.write('<center>\n');
}

function v_ec() {
	document.write('</center>\n');
}

// Image ------------------------------

var vc = 0;
var v_gpd = 10;
var v_gbg = "#b0b0b0";
var v_galign = "center";

function v_set_group_attri(pad,bg) {
	v_gpd = pad;
	v_gbg = bg;
}

function v_set_group_align(align) {
	v_galign = align;
}

function v_sgr() {
	document.write('<table border="0" cellspacing="0" cellpadding="',v_gpd,'" align="',v_galign,'" bgcolor="',v_gbg,'">');
	document.write('<tr><td align="center">');
}

function v_egr() {
	document.write('</table>');
}

var v_image_title_col = "#000070";
var v_image_width = 300;
var v_image_title_size ="3";
var v_image_comment_size ="2";

function v_set_image_title_col(col) {
	v_image_title_col = col;
}

function v_set_image_width(width) {
	v_image_width = width;
}

function v_set_image_title_size(size) {
	v_image_title_size = size;
}

function v_set_image_comment_size(size) {
	v_image_comment_size = size;
}

function v_image(dir,filename,title,comment,copyright) {
	document.write('<table border="0" cellspacing="0" cellpadding="10" align="center">');
	document.write('<tr><td align="left" width="',v_image_width,'">');
	image_common(dir,filename,title,comment,copyright);
}

function v_image_l(dir,filename,title,comment,copyright) {
	document.write('<table border="0" cellspacing="0" cellpadding="10" align="left">');
	document.write('<tr><td align="left" width="',v_image_width,'">');
	image_common(dir,filename,title,comment,copyright);
}

function v_image_r(dir,filename,title,comment,copyright) {
	document.write('<table border="0" cellspacing="0" cellpadding="10" align="right">');
	document.write('<tr><td align="left" width="',v_image_width,'">');
	image_common(dir,filename,title,comment,copyright);
}

function v_image_align(dir,filename,title,comment,copyright,align,width) {
	document.write('<table border="0" cellspacing="0" cellpadding="10" align="',align,'" width="',width,'">');
	document.write('<tr><td align="left" width="',width,'">');
	image_common(dir,filename,title,comment,copyright);
}

function image_common(dir,filename,title,comment,copyright) {
	if( filename == "" ) {
		document.write('<img src="../../../../../image/nowprinting.gif" alt="nowprinting.gif"><br>');
	} else {
		document.write('<img src="',dir,'/',filename,'" alt="',filename,'"><br>');
	}
	document.write('<img src="',image_path,'tp1dot.gif" height="2"><br>');
	document.write('<font size="',v_image_title_size,'">');
	document.write('画像',++vc,'：<font color="',v_image_title_col,'"><b>',title,'</b></font><br>');
	document.write('</font>');
	if( copyright == "" ) {
		document.write('<font size="',v_image_comment_size,'">',comment,'</font><br>');
	} else {
		document.write('<font size="',v_image_comment_size,'">',comment,'<font size="1" color="#707070">（',copyright,'）</font></font><br>');
	}
	document.write('</td></tr></table>\n');
}

function v_image2(dir,image1,image2,title1,title2,comment1,comment2,copyright,t_width) {
	document.write('<table border="0" cellspacing="0" cellpadding="10" align="center">');
	document.write('<tr><td width="',t_width,'" align="left">');
	document.write('<img src="image/',dir,'/',image1,'" alt="',image1,'"><br>');
	document.write('<img src="',image_path,'tp1dot.gif" height="2"><br>');
	if( title1 != "" ) {
		document.write('<font size="',v_image_title_size,'">');
		document.write('<b>画像',++vc,'</b>：<font color="#000070"><b>',title1,'</b></font><br>');
		document.write('</font>');
	}
	document.write('<font size="',v_image_comment_size,'">',comment1,'<font size="1" color="#707070">（',copyright,'）</font></font><br>');
	document.write('</td><td width="',t_width,'" align="left">');
	if( image2 != "" ) {
		document.write('<img src="image/',dir,'/',image2,'" alt="',image2,'"><br>');
		document.write('<img src="',image_path,'tp1dot.gif" height="2"><br>');
		if( title2 != "" ) {
			document.write('<font size="',v_image_title_size,'">');
			document.write('<b>画像',++vc,'</b>：<font color="#000070"><b>',title2,'</b></font><br>');
			document.write('</font>');
		}
		document.write('<font size="',v_image_comment_size,'">',comment2,'<font size="1" color="#707070">（',copyright,'）</font></font><br>');
	} else {
		document.write('<br>');
	}
	document.write('</td></tr></table>\n');
}

// Delimiter --------------------------

var delimitter = "grad-r.gif";

function v_set_delimitter(image) {
	delimitter = image;
}

function v_delimit(title) {
	document.write('<h2>',title,'<img src="',image_path,delimitter,'" height="2" width="100%"></h2>\n');
}

// List -------------------------------

var v_list_mark = "disc";

function v_set_list_mark(mark) {
	v_list_mark = mark;
}

function v_sol() {
	document.write("<ol>\n");
}

function v_eol() {
	document.write("</ol>\n");
}

function v_sul() {
	document.write("<ul>\n");
}

function v_eul() {
	document.write("</ul>\n");
}

function v_li(list) {
	document.write('<li type="',v_list_mark,'">',list,"\n");
}

function v_sdl() {
	document.write("<dl>");
}

function v_edl() {
	document.write("</dl>");
}

function v_dt(title) {
	document.write('<dt><b>',title,"</b></dt>\n");
}

function v_dd(list) {
	document.write('<dd>',list,"</dd>\n");
}

// Binominal Table --------------------

var v_table = new Array();
var v_table2 = new Array();
var v_table_num = 0;
var v_table2_num = 0;
var v_table_title_bg = "#b0b0b0";
var v_table_th_bg = "#d0d0d0";
var v_table_td_bg = "#f0f0f0";

function table(name,data) {
	this.name = name;
	this.data = data;
}

function v_table_reset() {
	v_table_num = 0;
	v_table2_num = 0;
}

function v_set_table_bg(titlec,thc,tdc) {
	v_table_title_bg = titlec;
	v_table_th_bg = thc;
	v_table_td_bg = tdc;
}

function v_set_table_title(title) {
	v_table[v_table_num++] = new table("title",title);
}

function v_set_table2_title(title) {
	v_table2[v_table2_num++] = new table("title",title);
}

function v_set_table_item(name,data) {
	v_table[v_table_num++] = new table(name,data);
}

function v_set_table2_item(name,data) {
	v_table2[v_table2_num++] = new table(name,data);
}

function v_disp_table(align) {
	document.write('<table border="0" cellspacing="1" cellpadding="5" bgcolor="#f0f0f0">');
	for(i=0;i<v_table_num;i++) {
		if(v_table[i].name == "title" ) {
			document.write('<tr><th bgcolor="',v_table_title_bg,'" colspan="2">',v_table[i].data,'</th>\n');
		} else {
			if(v_table[i].data == "" ) {
				document.write('<tr><th bgcolor="',v_table_th_bg,'" colspan="2">',v_table[i].name,'</th><td></td>');
			} else if(v_table[i].name == "" ) {
				document.write('<tr><td bgcolor="',v_table_td_bg,'" align="',align,'">',v_table[i].data,'</td>\n');
			} else {
				document.write('<tr><th nowrap bgcolor="',v_table_th_bg,'">',v_table[i].name,'</th>');
				document.write('<td bgcolor="',v_table_td_bg,'" align="',align,'">',v_table[i].data,'</td>\n');
			}
		}
	}
	document.write('</table>\n');
	v_table_reset();
}

function v_disp_table2(align) {
	document.write('<table border="0" cellspacing="0" cellpadding="5">');
	document.write('<tr><td valign="top">');

	document.write('<table border="0" cellspacing="1" cellpadding="5" bgcolor="#f0f0f0">');
	for(i=0;i<v_table_num;i++) {
		if(v_table[i].name == "title" ) {
			document.write('<tr><th bgcolor="',v_table_title_bg,'" colspan="2">',v_table[i].data,'</th>\n');
		} else {
			document.write('<tr><th nowrap bgcolor="',v_table_th_bg,'">',v_table[i].name,'</th>');
			document.write('<td bgcolor="',v_table_td_bg,'" align="',align,'">',v_table[i].data,'</td>\n');
		}
	}
	document.write('</table>\n');

	document.write('</td>');
	document.write('<td valign="top">');

	document.write('<table border="0" cellspacing="1" cellpadding="5" bgcolor="#f0f0f0">');
	for(i=0;i<v_table2_num;i++) {
		if(v_table2[i].name == "title" ) {
			document.write('<tr><th bgcolor="',v_table_title_bg,'" colspan="2">',v_table2[i].data,'</th>\n');
		} else {
			document.write('<tr><th nowrap bgcolor="',v_table_th_bg,'">',v_table2[i].name,'</th>');
			document.write('<td bgcolor="',v_table_td_bg,'" align="',align,'">',v_table2[i].data,'</td>\n');
		}
	}
	document.write('</table>\n');

	document.write('</td>');
	document.write('</table>\n');
	v_table_reset();
}

// Bibliography -----------------------

var v_bib = new Array();
var v_bib_num = 0;

function bib(author,title,page,publish,print) {
	this.author = author;
	this.title = title;
	this.page = page;
	this.publish = publish;
	this.print = print;
}

function v_bib_reset() {
	v_bib_num = 0;
}

function v_set_bib_item(author,title,page,publish,print) {
	v_bib[v_bib_num++] = new bib(author,title,page,publish,print);
}

function v_disp_bib() {
	document.write('<table border="0" cellspacing="1" cellpadding="3" bgcolor="#f0f0f0">');
	document.write('<tr bgcolor="#a0a0a0"><th><font size="2">著者</font></th><th><font size="2">題名</font></th><th><font size="2">ページ</font></th><th><font size="2">出版社</font></th><th><font size="2">発行</font></th>\n');
	for(i=0;i<v_bib_num;i++) {
		document.write('<tr><td bgcolor="#b7b7b7"><font size="2">',v_bib[i].author,'</font></th><td bgcolor="#c7c7c7"><font size="2">',v_bib[i].title,'</font></th><td bgcolor="#d7d7d7"><font size="2">',v_bib[i].page,'</font></th><td bgcolor="#e7e7e7"><font size="2">',v_bib[i].publish,'</font></th><td bgcolor="#f7f7f7"><font size="2">',v_bib[i].print,'</font></th>\n');
	}
	document.write('</table>\n');
	v_bib_reset();
}

// Reference --------------------------

function v_ref(file,title) {
	document.write('<a href="',file,'">');
	g = file.substr(0,1);
	document.write('<font size="3">');
	genre = v_get_genre(g);
	if( genre != "" ) {
		document.write('<font color="',genre.col,'">');
		if( top.vein_lang == "japanese" ) {
			document.write(genre.sym_j);
		} else {
			document.write(genre.sym_e);
		}
	} else {
			document.write('<font color="#000000">-');
	}
	document.write("</font></font>");
	document.write(title);
	document.write("</a><br>");
}
