function Box(top_left_img,
		top_img,
		top_right_img,
		mid_left_img,
		mid_right_img,
		bot_left_img,
		bot_img,
		bot_right_img,
		corner_width,
		corner_height)
{
	this.top_left_img = top_left_img;
	this.top_img = top_img;
	this.top_right_img = top_right_img;
	this.mid_left_img = mid_left_img;
	this.mid_right_img = mid_right_img;
	this.bot_left_img = bot_left_img;
	this.bot_img = bot_img;
	this.bot_right_img = bot_right_img;
	this.corner_width = corner_width;
	this.corner_height = corner_height;
}

function MakeBox(box,
	special_imgs, img_list) // special_imgs = 0 - none; 1 - bottom l, r; 2 - top l, r; 3 - all 4 corners
{
	this.top_img = box.top_img;
	this.mid_left_img = box.mid_left_img;
	this.mid_right_img = box.mid_right_img;
	this.bot_img = box.bot_img;
	
	if(special_imgs == 2 || special_imgs == 3)
	{
		this.top_left_img = img_list[0];
		this.top_right_img = img_list[1];
	}
	else
	{
	this.top_left_img = box.top_left_img;
	this.top_right_img = box.top_right_img;
	}

	i = 0;

	if (special_imgs == 3)
		i = 2;

	if(special_imgs == 1 || special_imgs == 3)
	{
		this.bot_left_img = img_list[i];
		this.bot_right_img = img_list[i+1];
	}
	else
	{
		this.bot_left_img = box.bot_left_img;
		this.bot_right_img = box.bot_right_img;
	}

	this.corner_width = box.corner_width;
	this.corner_height = box.corner_height;
}

function Render_Output(obj, txt)
{
	return (obj != null) ? txt + obj : '';
}

function Render_Box_Top(boxstyle, bgcolor, contentclass, border)
{
	document.write('<table border='+((border == null) ? 0 : border) +' cellpadding=0 cellspacing=0 ');
	document.write(((bgcolor == null) ? '' : ('bordercolor='+ bgcolor + ' bgcolor='+bgcolor))+'><tr><td'+(boxstyle == null ? ' class="'+contentclass+'"': '')+'>');
	if(boxstyle != null)
	{
		document.write('<img src="'+boxstyle.top_left_img+'"'+Render_Output(boxstyle.corner_width,' width=')+Render_Output(boxstyle.corner_height,' height=')+'></td>');
		document.write('<td background="'+boxstyle.top_img+'"><img src="../images/empty.gif" width=1 height=1></td>');
		document.write('<td><img src="'+boxstyle.top_right_img+'"'+Render_Output(boxstyle.corner_width,' width=')+Render_Output(boxstyle.corner_height,' height=')+'></td></tr><tr>');
		document.write('<td background="'+boxstyle.mid_left_img+'"><img src="../images/empty.gif" width=1 height=1></td><td'+((bgcolor == null) ? '' : (' class="'+contentclass+'"'))+'>');
	}
}

function Render_Box_Bottom(boxstyle)
{
	if(boxstyle != null)
	{
		document.write('</td><td background="'+boxstyle.mid_right_img+'"><img src="../images/empty.gif" width=1 height=1></td></tr><tr>');
		document.write('<td><img src="'+boxstyle.bot_left_img+'"'+Render_Output(boxstyle.corner_width,' width=')+Render_Output(boxstyle.corner_height,' height=')+'></td>');
		document.write('<td background="'+boxstyle.bot_img+'"><img src="../images/empty.gif" width=1 height=1></td>');
		document.write('<td><img src="'+boxstyle.bot_right_img+'"'+Render_Output(boxstyle.corner_width,' width=')+Render_Output(boxstyle.corner_height,' height=')+'>');
	}
	document.write('</td></tr></table>');
}

function Render_Box_Title(top, left,
	back_color, fade_color,
	fade_opacity, fade_finishopacity, fade_style,
	width, height, relative,
	boxstyle, special_imgs, img_list, // special_imgs = 0 - none; 1 - bottom l, r; 2 - top l, r; 3 - all 4 corners
	top_txt, left_txt,
	title, titlestyle_string,
	left_offset, left_offsetIE)
{
	document.write('<div style="position:absolute; top:'+top+'; left:'+abs_pos(left, left_offset, left_offsetIE)+'; z-index:5;">');
	document.write('<table border=0 cellpadding=0 cellspacing=0 bgcolor='+back_color+'><tr><td>');
	document.write('<table border=0 cellpadding=0 cellspacing=0 bgcolor='+fade_color+' style="filter:Alpha(Opacity='+fade_opacity+',FinishOpacity='+fade_finishopacity+',Style='+fade_style+')"><tr>');
	document.write('<td width='+width+' height='+height+'> </td></tr></table></td></tr></table></div>');

	boxstyle2 = new MakeBox(boxstyle, special_imgs, img_list);

	document.write('<div style="position:absolute; top:'+top+'; left:'+abs_pos(left, left_offset, left_offsetIE)+'; z-index:5;">');
	Render_Box_Top(boxstyle2);
	document.write('<img src="../images/empty.gif" width='+(width-10)+' height='+(height-12)+'>');
	Render_Box_Bottom(boxstyle2);
	document.write('</div>');

	document.write('<div style="position:'+(relative ? 'relative' : 'absolute')+'; top:'+top_txt+'; left:'+left_txt+'; z-index:5; '+titlestyle_string+'">'+title+'</div>');
}