function isArray (obj) 
{
  return (obj==null) ? false : ((obj.constructor == Array) ? true : false);
}

var cindex_chapter_caption = 0;
var cindex_chapter_a_name = 1;
var cindex_chapter_subarray = 2;
var cindex_chapter_style = 3;


var cindex_pndisplay = 0
var cindex_thr_pn = 1;
var cindex_thr_listtype = 2;
var cindex_thr_pntype = 3;

var c_az_id = '32361180';

function get_thr_href_A(az_id, pn)
{
  //var c_thr_href_partA='http://www.thomasregister.com/smartcat.cgi?az=';
  //var c_thr_href_partB='&template=http://www.idesco.com/dtcstmp.html&type=details_order&tablewidth=95%25&font=Arial,Helvetica,sans-serif&fontsize=-1&ptno=';
  //return c_thr_href_partA+az_id+c_thr_href_partB+pn
  return get_thr_href(az_id, pn, 'details_order', 'ptno');
}

function get_thr_href_B(az_id, pn)
{
  return get_thr_href(az_id, pn, 'list_order', 'rn');
}


function get_thr_href(az_id, pn, typestr, pnstr)
{
  var c_thr_href_partA='http://www.thomasregister.com/smartcat.cgi?az=';
  var tmpl = '';
  if (siteIndex==2)
    tmpl='http://www.idesco.com/idbtmpl.html';
  else
    tmpl='http://www.idesco.com/sptmpl.html';
  //var c_thr_href_partB='&template=http://www.idesco.com/dtcstmp.html&type='
  var c_thr_href_partB='&template='+tmpl+'&type='
  //var c_thr_href_partB='&template=http://www.idesco.com/ttmpl.html&type='
  var c_thr_href_partC='&tablewidth=100%25&font=Arial,Helvetica,sans-serif&fontsize=-1&'
  return c_thr_href_partA+az_id+c_thr_href_partB+typestr+c_thr_href_partC+pnstr+'='+pn;
}

//


function writeprodlist_type_B(aritems, sub_ind, az_id, colnum)
{
  writeprodlist_type_A(aritems, sub_ind, az_id, colnum, '', '', colnum, 0, 'details_order')
/*  var href_ind=0;
  var ibegin=0;
  var iend=aritems.length;
  if (sub_ind!=null)
  {
    ibegin=sub_ind;
    iend=sub_ind+1;
  }
	for (var i=ibegin;i<iend;i++)
	{
		var a_txt = (aritems[i][cindex_chapter_a_name]==null) ? '' : '<a name="'+aritems[i][cindex_chapter_a_name]+'"></a>';
    if (aritems[i][cindex_chapter_caption]!=null && aritems[i][cindex_chapter_caption]!='')
  		document.write('<tr><td colspan='+colnum+' height="40">'+a_txt+'<b>'+aritems[i][cindex_chapter_caption]+'</b></td></tr>');
		if (aritems[i][cindex_chapter_subarray]!=null)
		{
      var subaritems=aritems[i][cindex_chapter_subarray];
			for (var j=0;j<subaritems.length;j++)
			{
        document.write('<tr>')
				for (var k=0;k<colnum;k++)
				{
					var txtout = (subaritems[j][k]==null || subaritems[j][k]=='' || subaritems[j][k]==' ') ? '&nbsp;' : subaritems[j][k];
          if (k==href_ind && txtout != '&nbsp;')
            txtout = '<a class="bodylinktext" style="text-decoration:underline" href="'+get_thr_href_A(az_id, subaritems[j][k])+'">'+txtout+'</a>';
          document.write('<td align="left" style="padding-left:5">'+txtout+'</td>')
				}
        document.write('</tr>')
  			if (j<subaritems.length-1)
	  			document.write('<tr><td colspan='+colnum+' height="10"></td></tr>');
      }
    }
	}*/
}

function writeprodlist_type_C(aritems, sub_ind, az_id, colnum)
{
  writeprodlist_type_A(aritems, sub_ind, az_id, colnum, '', '', 0, 0, 'details_order')
}

//not for Q-TAGS and real lifes
//thr_url_type: 
function writeprodlist_typeA(aritems, sub_ind, az_id, colnum, show_order_string, show_order_string_style, pn_ind, href_ind, thr_url_type)
{
  writeprodlist_typeD(aritems, sub_ind, sub_ind, az_id, colnum, show_order_string, show_order_string_style, pn_ind, href_ind, thr_url_type, null);
}

function writeprodlist_type_A(aritems, sub_ind, az_id, colnum, show_order_string, show_order_string_style, pn_ind, href_ind, thr_url_type)
{
  //writeprodlist_typeD(aritems, sub_ind, sub_ind, az_id, colnum, show_order_string, show_order_string_style, pn_ind, href_ind, thr_url_type, null);
  writeprodlist_typeK(aritems, sub_ind, sub_ind, az_id, colnum, show_order_string, show_order_string_style, pn_ind, href_ind, thr_url_type, null, null, null)
}

function writeprodlist_type_D(aritems, sub_ind_begin, sub_ind_end, az_id, colnum, show_order_string, show_order_string_style, pn_ind, href_ind, thr_url_type, chapter_break_h)
{
  writeprodlist_type_E(aritems, sub_ind_begin, sub_ind_end, az_id, colnum, show_order_string, show_order_string_style, pn_ind, href_ind, thr_url_type, chapter_break_h)
}

function writeprodlist_typeD(aritems, sub_ind_begin, sub_ind_end, az_id, colnum, show_order_string, show_order_string_style, pn_ind, href_ind, thr_url_type, chapter_break_h)
{
  var href_ind;

  var ibegin = (sub_ind_begin==null) ? 0 : sub_ind_begin;
  var iend = (sub_ind_end==null) ? aritems.length : sub_ind_end;
  if (sub_ind_begin==sub_ind_end && sub_ind_begin!=null)
    iend = sub_ind_begin+1;
  
	for (var i=ibegin;i<iend;i++)
	{
		var a_txt = (aritems[i][cindex_chapter_a_name]==null) ? '' : '<a name="'+aritems[i][cindex_chapter_a_name]+'"></a>';
    if (aritems[i][cindex_chapter_caption]!=null && aritems[i][cindex_chapter_caption]!='')
  		document.write('<tr><td colspan='+colnum+' height="40">'+a_txt+'<b>'+aritems[i][cindex_chapter_caption]+'</b></td></tr>');
    else
      if (chapter_break_h!=null && i!=ibegin && i!=iend )
        document.write('<tr><td colspan='+colnum+' height="'+chapter_break_h+'">'+a_txt+'</td></tr>');
		if (aritems[i][cindex_chapter_subarray]!=null)
		{
      var subaritems=aritems[i][cindex_chapter_subarray];
			for (var j=0;j<subaritems.length;j++)
			{
        document.write('<tr>')
        var hrefstr='';
        if (thr_url_type == 'details_order' && subaritems[j][pn_ind]!=null && subaritems[j][pn_ind]!='') 
          hrefstr=get_thr_href_A(az_id, subaritems[j][pn_ind]);
        else if (thr_url_type == 'list_order' && subaritems[j][pn_ind]!=null && subaritems[j][pn_ind]!='')
          hrefstr=get_thr_href_B(az_id, subaritems[j][pn_ind]);
				for (var k=0;k<colnum;k++)
				{
					var txtout;
          txtout = (subaritems[j][k]==null || subaritems[j][k]=='' || subaritems[j][k]==' ') ? '&nbsp;' : subaritems[j][k];
          if (k==href_ind && txtout != '&nbsp;' && hrefstr != '')
            txtout = '<a class="bodylinktext" style="text-decoration:underline" href="'+hrefstr+'">'+txtout+'</a>';
          document.write('<td align="left" valign="top" style="padding-left:3">'+txtout+'</td>')
				}
				if (show_order_string != null)
				{
				  var txtout = show_order_string;
					if (show_order_string_style == 'href' && hrefstr != '')
						txtout = '<a class="bodylinktext" style="text-decoration:underline" href="'+hrefstr+'">'+txtout+'</a>';
          else if (show_order_string_style == 'href' && hrefstr == '')
            txtout = "&nbsp;"
					document.write('<td align="left" valign="top" style="padding-left:3">'+txtout+'</td>')
				}
        document.write('</tr>')
  			if (j<subaritems.length-1)
	  			document.write('<tr><td colspan='+colnum+' height="10"></td></tr>');
      }
    }
	}
}

function writeprodlist_typeE(aritems, sub_ind_begin, sub_ind_end, az_id, colnum, show_order_string, show_order_string_style, pn_ind, href_ind, thr_url_type, chapter_break_h)
{
  if (sub_ind_begin!=null && sub_ind_begin!=sub_ind_end)
    sub_ind_end=sub_ind_end+1;
  writeprodlist_typeD(aritems, sub_ind_begin, sub_ind_end, az_id, colnum, show_order_string, show_order_string_style, pn_ind, href_ind, thr_url_type, chapter_break_h)
}

function writeprodlist_type_E(aritems, sub_ind_begin, sub_ind_end, az_id, colnum, show_order_string, show_order_string_style, pn_ind, href_ind, thr_url_type, chapter_break_h)
{
  writeprodlist_typeK(aritems, sub_ind_begin, sub_ind_end, az_id, colnum, show_order_string, show_order_string_style, pn_ind, href_ind, thr_url_type, chapter_break_h, null, null)
}

function writeprodlist_typeK(aritems, sub_ind_begin, sub_ind_end, az_id, colnum, show_order_string, show_order_string_style, pn_ind, href_ind, thr_url_type, chapter_break_h, header_string, footer_string)
{
  //var href_ind;
  var ibegin = (sub_ind_begin==null) ? 0 : sub_ind_begin;
  var iend = (sub_ind_end==null) ? aritems.length : sub_ind_end+1;
  
	for (var i=ibegin;i<iend;i++)
	{
		var a_txt = (aritems[i][cindex_chapter_a_name]==null) ? '' : '<a name="'+aritems[i][cindex_chapter_a_name]+'"></a>';
    if (aritems[i][cindex_chapter_caption]!=null && aritems[i][cindex_chapter_caption]!='')
    {
      if (aritems[i].length>cindex_chapter_style && aritems[i][cindex_chapter_style]=='boldplain')
      {
    		document.write('<tr><td colspan='+colnum+' class="bodyplaintext" style="padding-left:3">'+a_txt+'<b>'+aritems[i][cindex_chapter_caption]+'</b></td></tr>');
        document.write('<tr><td colspan='+colnum+' class="bodyplaintext">&nbsp;</td></tr>');
      }
      else
      {
        document.write('<tr><td colspan='+colnum+' class="bodychapterheader">&nbsp;</td></tr>');
    		document.write('<tr><td colspan='+colnum+' class="bodychapterheader" style="padding-left:3">'+a_txt+'<b>'+aritems[i][cindex_chapter_caption]+'</b></td></tr>');
        document.write('<tr><td colspan='+colnum+' class="bodychapterheader">&nbsp;</td></tr>');
      }
    }
    else
      if (chapter_break_h!=null && i!=ibegin && i!=iend )
        document.write('<tr><td style="padding-left:3" colspan='+colnum+' height="'+chapter_break_h+'">'+a_txt+'</td></tr>');
    if (header_string!=null && header_string!='')
      document.write(header_string)
		if (aritems[i][cindex_chapter_subarray]!=null)
		{
      var subaritems=aritems[i][cindex_chapter_subarray];
			for (var j=0;j<subaritems.length;j++)
			{
        document.write('<tr>')
        var hrefstr='';
        if (thr_url_type == 'details_order' && subaritems[j][pn_ind]!=null && subaritems[j][pn_ind]!='') 
          hrefstr=get_thr_href_A(az_id, subaritems[j][pn_ind]);
        else if (thr_url_type == 'list_order' && subaritems[j][pn_ind]!=null && subaritems[j][pn_ind]!='')
          hrefstr=get_thr_href_B(az_id, subaritems[j][pn_ind]);
				for (var k=0;k<colnum;k++)
				{
          var txtout='';
          if (isArray(subaritems[j][k]))
          {
            txtout=(subaritems[j][k][cindex_pndisplay]==null || subaritems[j][k][cindex_pndisplay]=='' || subaritems[j][k]==' ') ? '&nbsp;' : subaritems[j][k][cindex_pndisplay];
            if (txtout != '&nbsp;')
            {
              var hrefstr_k = (subaritems[j][k][cindex_thr_pn]==null || subaritems[j][k][cindex_thr_pn]=='') ? hrefstr_k = subaritems[j][k][cindex_pndisplay] : subaritems[j][k][cindex_thr_pn];
              if (subaritems[j][k][cindex_thr_listtype] == 'list_order')
							{
								if (cindex_thr_pntype < subaritems[j][k].length)
	                hrefstr_k=get_thr_href(az_id, hrefstr_k, subaritems[j][k][cindex_thr_listtype], subaritems[j][k][cindex_thr_pntype]);
								else
									hrefstr_k=get_thr_href_B(az_id, hrefstr_k);
							}
              else //if (subaritems[j][k][cindex_thr_listtype] == 'details_order')  //default
                hrefstr_k=get_thr_href_A(az_id, hrefstr_k);
              txtout = '<a class="bodylinktext" style="text-decoration:underline" href="'+hrefstr_k+'">'+txtout+'</a>';
            }
          }
          else
          {
            txtout= (subaritems[j][k]==null || subaritems[j][k]=='' || subaritems[j][k]==' ') ? '&nbsp;' : subaritems[j][k];
            if (k==href_ind && txtout != '&nbsp;' && hrefstr != '')
              txtout = '<a class="bodylinktext" style="text-decoration:underline" href="'+hrefstr+'">'+txtout+'</a>';
          }
          document.write('<td align="left" valign="top" style="padding-left:3">'+txtout+'</td>')
				}
				if (show_order_string != null)
				{
				  var txtout = show_order_string;
					if (show_order_string_style == 'href' && hrefstr != '')
						txtout = '<a class="bodylinktext" style="text-decoration:underline" href="'+hrefstr+'">'+txtout+'</a>';
          else if (show_order_string_style == 'href' && hrefstr == '')
            txtout = "&nbsp;"
					document.write('<td align="left" valign="top" style="padding-left:3">'+txtout+'</td>')
				}
        document.write('</tr>')
  			if (j<subaritems.length-1)
	  			document.write('<tr><td colspan='+colnum+' height="10"></td></tr>');
      }
      if (footer_string!=null && footer_string!='')
        document.write(footer_string);
      document.write('<tr><td colspan='+colnum+' class="bodychapterheader">&nbsp;</td></tr>');        
    }
	}
}
function writeprodlist_type_L(aritems, sub_ind_begin, sub_ind_end, az_id, chapter_break_h, header_string, footer_string)
{
  var href_ind;
  var ibegin = (sub_ind_begin==null) ? 0 : sub_ind_begin;
  var iend = (sub_ind_end==null) ? aritems.length : sub_ind_end;
  if (sub_ind_begin==sub_ind_end && sub_ind_begin!=null)
    iend = sub_ind_begin+1;
  
	for (var i=ibegin;i<iend;i++)
	{
		var a_txt = (aritems[i][cindex_chapter_a_name]==null) ? '' : '<a name="'+aritems[i][cindex_chapter_a_name]+'"></a>';
    var colnum = (aritems[i][cindex_chapter_subarray]==null) ? 1 : aritems[i][cindex_chapter_subarray][0].length;
    if (aritems[i][cindex_chapter_caption]!=null && aritems[i][cindex_chapter_caption]!='')
      if (aritems[i].length>cindex_chapter_style && aritems[i][cindex_chapter_style]=='boldplain')
      {
    		document.write('<tr><td colspan='+colnum+' class="bodyplaintext" style="padding-left:3">'+a_txt+'<b>'+aritems[i][cindex_chapter_caption]+'</b></td></tr>');
        document.write('<tr><td colspan='+colnum+' class="bodyplaintext">&nbsp;</td></tr>');
      }
      else
      {
        document.write('<tr><td colspan='+colnum+' class="bodychapterheader">&nbsp;</td></tr>');
    		document.write('<tr><td colspan='+colnum+' class="bodychapterheader" style="padding-left:3">'+a_txt+'<b>'+aritems[i][cindex_chapter_caption]+'</b></td></tr>');
        document.write('<tr><td colspan='+colnum+' class="bodychapterheader">&nbsp;</td></tr>');
      }
  		//document.write('<tr><td colspan='+colnum+' height="40">'+a_txt+'<b>'+aritems[i][cindex_chapter_caption]+'</b></td></tr>');
    else
      if (chapter_break_h!=null && i!=ibegin && i!=iend )
        document.write('<tr><td colspan='+colnum+' height="'+chapter_break_h+'">'+a_txt+'</td></tr>');
    if (header_string!=null && header_string!='')
      document.write(header_string)

		if (aritems[i][cindex_chapter_subarray]!=null)
		{
      var subaritems=aritems[i][cindex_chapter_subarray];
			for (var j=0;j<subaritems.length;j++)
			{
        document.write('<tr>')
        var hrefstr='';
				for (var k=0;k<colnum;k++)
				{
          var txtout='';
          if (isArray(subaritems[j][k]))
          {
            txtout=(subaritems[j][k][cindex_pndisplay]==null || subaritems[j][k][cindex_pndisplay]=='' || subaritems[j][k]==' ') ? '&nbsp;' : subaritems[j][k][cindex_pndisplay];
            if (txtout != '&nbsp;')
            {
              var hrefstr_k = (subaritems[j][k][cindex_thr_pn]==null) ? hrefstr_k = subaritems[j][k][cindex_pndisplay] : subaritems[j][k][cindex_thr_pn];
              if (subaritems[j][k][cindex_thr_listtype] == 'list_order')
							{
								if (cindex_thr_pntype < subaritems[j][k].length)
	                hrefstr_k=get_thr_href(az_id, hrefstr_k, subaritems[j][k][cindex_thr_listtype], subaritems[j][k][cindex_thr_pntype]);
								else
									hrefstr_k=get_thr_href_B(az_id, hrefstr_k);
							}
              else //if (subaritems[j][k][cindex_thr_listtype] == 'details_order')  //default
                hrefstr_k=get_thr_href_A(az_id, hrefstr_k);
              txtout = '<a class="bodylinktext" style="text-decoration:underline" href="'+hrefstr_k+'">'+txtout+'</a>';
            }
          }
          else
          {
            txtout= (subaritems[j][k]==null || subaritems[j][k]=='' || subaritems[j][k]==' ') ? '&nbsp;' : subaritems[j][k];
            if (k==href_ind && txtout != '&nbsp;' && hrefstr != '')
              txtout = '<a class="bodylinktext" style="text-decoration:underline" href="'+hrefstr+'">'+txtout+'</a>';
          }
          document.write('<td align="left" valign="top" style="padding-left:3">'+txtout+'</td>')
				}
        document.write('</tr>')
  			if (j<subaritems.length-1)
	  			document.write('<tr><td colspan='+colnum+' height="10"></td></tr>');
      }
      if (footer_string!=null && footer_string!='')
        document.write(footer_string)
    }
	}
/*
  var href_ind;
  var ibegin = (sub_ind_begin==null) ? 0 : sub_ind_begin;
  var iend = (sub_ind_end==null) ? aritems.length : sub_ind_end;
  if (sub_ind_begin==sub_ind_end && sub_ind_begin!=null)
    iend = sub_ind_begin+1;
  
	for (var i=ibegin;i<iend;i++)
	{
		var a_txt = (aritems[i][cindex_chapter_a_name]==null) ? '' : '<a name="'+aritems[i][cindex_chapter_a_name]+'"></a>';
    var colnum = (aritems[i][cindex_chapter_subarray]==null) ? 1 : aritems[i][cindex_chapter_subarray].length;
    if (aritems[i][cindex_chapter_caption]!=null && aritems[i][cindex_chapter_caption]!='')
  		document.write('<tr><td colspan='+colnum+' height="40">'+a_txt+'<b>'+aritems[i][cindex_chapter_caption]+'</b></td></tr>');
    else
      if (chapter_break_h!=null && i!=ibegin && i!=iend )
        document.write('<tr><td colspan='+colnum+' height="'+chapter_break_h+'">'+a_txt+'</td></tr>');
    if (header_string!=null && header_string!='')
      document.write(header_string)

		if (aritems[i][cindex_chapter_subarray]!=null)
		{
      var subaritems=aritems[i][cindex_chapter_subarray];
			for (var j=0;j<subaritems.length;j++)
			{
        document.write('<tr>')
        var hrefstr='';
        if (thr_url_type == 'details_order' && subaritems[j][pn_ind]!=null && subaritems[j][pn_ind]!='') 
          hrefstr=get_thr_href_A(az_id, subaritems[j][pn_ind]);
        else if (thr_url_type == 'list_order' && subaritems[j][pn_ind]!=null && subaritems[j][pn_ind]!='')
          hrefstr=get_thr_href_B(az_id, subaritems[j][pn_ind]);
				for (var k=0;k<colnum;k++)
				{
          var txtout='';
          if (isArray(subaritems[j][k]))
          {
            txtout=(subaritems[j][k][cindex_pndisplay]==null || subaritems[j][k][cindex_pndisplay]=='' || subaritems[j][k]==' ') ? '&nbsp;' : subaritems[j][k][cindex_pndisplay];
            if (txtout != '&nbsp;')
            {
              var hrefstr_k = (subaritems[j][k][cindex_thr_pn]==null) ? hrefstr_k = subaritems[j][k][cindex_pndisplay] : subaritems[j][k][cindex_thr_pn];
              if (subaritems[j][k][cindex_thr_listtype] == 'list_order')
							{
								if (cindex_thr_pntype < subaritems[j][k].length)
	                hrefstr_k=get_thr_href(az_id, hrefstr_k, subaritems[j][k][cindex_thr_listtype], subaritems[j][k][cindex_thr_pntype]);
								else
									hrefstr_k=get_thr_href_B(az_id, hrefstr_k);
							}
              else //if (subaritems[j][k][cindex_thr_listtype] == 'details_order')  //default
                hrefstr_k=get_thr_href_A(az_id, hrefstr_k);
              txtout = '<a class="bodylinktext" style="text-decoration:underline" href="'+hrefstr_k+'">'+txtout+'</a>';
            }
          }
          else
          {
            txtout= (subaritems[j][k]==null || subaritems[j][k]=='' || subaritems[j][k]==' ') ? '&nbsp;' : subaritems[j][k];
            if (k==href_ind && txtout != '&nbsp;' && hrefstr != '')
              txtout = '<a class="bodylinktext" style="text-decoration:underline" href="'+hrefstr+'">'+txtout+'</a>';
          }
          document.write('<td align="left" valign="top" style="padding-left:3">'+txtout+'</td>')
				}
				if (show_order_string != null)
				{
				  var txtout = show_order_string;
					if (show_order_string_style == 'href' && hrefstr != '')
						txtout = '<a class="bodylinktext" style="text-decoration:underline" href="'+hrefstr+'">'+txtout+'</a>';
          else if (show_order_string_style == 'href' && hrefstr == '')
            txtout = "&nbsp;"
					document.write('<td align="left" valign="top" style="padding-left:3">'+txtout+'</td>')
				}
        document.write('</tr>')
  			if (j<subaritems.length-1)
	  			document.write('<tr><td colspan='+colnum+' height="10"></td></tr>');
      }
      if (footer_string!=null && footer_string!='')
        document.write(footer_string)
    }
	}
*/
}

function writeprodlist_type_M(aritems, sub_ind_begin, sub_ind_end, az_id, splitcol, lastcolvalign, pn_ind, thr_url_type, chapter_break_h)
{
  writeprodlist_type_N(aritems, sub_ind_begin, sub_ind_end, az_id, splitcol, lastcolvalign, pn_ind, thr_url_type, chapter_break_h, null)
}

function writeprodlist_type_N(aritems, sub_ind_begin, sub_ind_end, az_id, splitcol, lastcolvalign, pn_ind, thr_url_type, chapter_break_h, boldcol)
{
	var colnumtable=2;
  var href_ind=pn_ind;
  var ibegin = (sub_ind_begin==null) ? 0 : sub_ind_begin;
  var iend = (sub_ind_end==null) ? aritems.length : sub_ind_end+1;
  if (boldcol == null)
    boldcol = -1;
	for (var i=ibegin;i<iend;i++)
	{
		var a_txt = (aritems[i][cindex_chapter_a_name]==null) ? '' : '<a name="'+aritems[i][cindex_chapter_a_name]+'"></a>';
    if (aritems[i][cindex_chapter_caption]!=null && aritems[i][cindex_chapter_caption]!='')
    {
      if (aritems[i].length>cindex_chapter_style && aritems[i][cindex_chapter_style]=='boldplain')
      {
    		document.write('<tr><td colspan='+colnumtable+' class="bodyplaintext">'+a_txt+'<b>'+aritems[i][cindex_chapter_caption]+'</b></td></tr>');
        document.write('<tr><td colspan='+colnumtable+' class="bodyplaintext">&nbsp;</td></tr>');
      }
      else
      {
        document.write('<tr><td colspan='+colnumtable+' class="bodychapterheader">&nbsp;</td></tr>');
    		document.write('<tr><td colspan='+colnumtable+' class="bodychapterheader">'+a_txt+'<b>'+aritems[i][cindex_chapter_caption]+'</b></td></tr>');
        document.write('<tr><td colspan='+colnumtable+' class="bodychapterheader">&nbsp;</td></tr>');
      }
    }
    else
      if (chapter_break_h!=null && i!=ibegin && i!=iend )
        document.write('<tr><td colspan='+colnumtable+' height="'+chapter_break_h+'" class="bodychapterheader">'+a_txt+'</td></tr>');
    //if (header_string!=null && header_string!='')
    //  document.write(header_string)
		if (aritems[i][cindex_chapter_subarray]!=null)
		{
      var subaritems=aritems[i][cindex_chapter_subarray];
			for (var j=0;j<subaritems.length;j++)
			{
        document.write('<tr>')
        var hrefstr='';
        if (thr_url_type == 'details_order' && subaritems[j][pn_ind]!=null && subaritems[j][pn_ind]!='') 
          hrefstr=get_thr_href_A(az_id, subaritems[j][pn_ind]);
        else if (thr_url_type == 'list_order' && subaritems[j][pn_ind]!=null && subaritems[j][pn_ind]!='')
          hrefstr=get_thr_href_B(az_id, subaritems[j][pn_ind]);
        var txtouttd='';
				for (var k=0;(k<splitcol && k<subaritems[j].length);k++)
				{
          if (subaritems[j][k]==null)
            continue;
          if (isArray(subaritems[j][k]))
          {
            var txtout=(subaritems[j][k][cindex_pndisplay]=='' || subaritems[j][k]==' ') ? '&nbsp;' : subaritems[j][k][cindex_pndisplay];
            if (txtout != '&nbsp;')
            {
              var hrefstr_k = (subaritems[j][k][cindex_thr_pn]==null) ? hrefstr_k = subaritems[j][k][cindex_pndisplay] : subaritems[j][k][cindex_thr_pn];
              if (subaritems[j][k][cindex_thr_listtype] == 'list_order')
							{
								if (cindex_thr_pntype < subaritems[j][k].length)
	                hrefstr_k=get_thr_href(az_id, hrefstr_k, subaritems[j][k][cindex_thr_listtype], subaritems[j][k][cindex_thr_pntype]);
								else
									hrefstr_k=get_thr_href_B(az_id, hrefstr_k);
							}
              else //if (subaritems[j][k][cindex_thr_listtype] == 'details_order')  //default
                hrefstr_k=get_thr_href_A(az_id, hrefstr_k);
              txtout = '<a class="bodylinktext" style="text-decoration:underline" href="'+hrefstr_k+'">'+txtout+'</a>';
            }
          }
          else
          {
            txtout= (subaritems[j][k]==null || subaritems[j][k]=='' || subaritems[j][k]==' ') ? '&nbsp;' : subaritems[j][k];
            if (k==href_ind && txtout != '&nbsp;' && hrefstr != '')
              txtout = '<a class="bodylinktext" style="text-decoration:underline" href="'+hrefstr+'">'+txtout+'</a>';
          }
          if (k<=boldcol && txtout!=null && txtout!='')
            txtout='<b>'+txtout+'</b>';
          txtouttd += (txtouttd == '' ) ? txtout : ('<br>'+txtout);
				}
        document.write('<td align="left" valign="top" style="padding-left:3">'+txtouttd+'</td>');
        //txtouttd='';
				for (var k=splitcol;k<subaritems[j].length;k++)
				{
          if (subaritems[j][k]==null)
            continue;
          var txtout='';
          if (isArray(subaritems[j][k]))
          {
            txtout=(subaritems[j][k][cindex_pndisplay]==null || subaritems[j][k][cindex_pndisplay]=='' || subaritems[j][k]==' ') ? '&nbsp;' : subaritems[j][k][cindex_pndisplay];
            if (txtout != '&nbsp;')
            {
              var hrefstr_k = (subaritems[j][k][cindex_thr_pn]==null) ? hrefstr_k = subaritems[j][k][cindex_pndisplay] : subaritems[j][k][cindex_thr_pn];
              if (subaritems[j][k][cindex_thr_listtype] == 'list_order')
							{
								if (cindex_thr_pntype < subaritems[j][k].length)
	                hrefstr_k=get_thr_href(az_id, hrefstr_k, subaritems[j][k][cindex_thr_listtype], subaritems[j][k][cindex_thr_pntype]);
								else
									hrefstr_k=get_thr_href_B(az_id, hrefstr_k);
							}
              else //if (subaritems[j][k][cindex_thr_listtype] == 'details_order')  //default
                hrefstr_k=get_thr_href_A(az_id, hrefstr_k);
              txtout = '<a class="bodylinktext" style="text-decoration:underline" href="'+hrefstr_k+'">'+txtout+'</a>';
            }
          }
          else
          {
            txtout= (subaritems[j][k]==null || subaritems[j][k]=='' || subaritems[j][k]==' ') ? '&nbsp;' : subaritems[j][k];
            if (k==href_ind && txtout != '&nbsp;' && hrefstr != '')
              txtout = '<a class="bodylinktext" style="text-decoration:underline" href="'+hrefstr+'">'+txtout+'</a>';
          }
          //txtouttd += (txtouttd == '' ) ? txtout : ('<br>'+txtout);
          document.write('<td align="left" valign="'+lastcolvalign+'" style="padding-left:3">'+txtout+'</td>')
				}
        //document.write('<td align="left" valign="'+lastcolvalign+'" style="padding-left:3">'+txtouttd+'</td>');
        /*
				if (show_order_string != null)
				{
				  var txtout = show_order_string;
					if (show_order_string_style == 'href' && hrefstr != '')
						txtout = '<a class="bodylinktext" style="text-decoration:underline" href="'+hrefstr+'">'+txtout+'</a>';
          else if (show_order_string_style == 'href' && hrefstr == '')
            txtout = "&nbsp;"
					document.write('<td align="left" valign="top" style="padding-left:3">'+txtout+'</td>')
				}
        */
        document.write('</tr>')
  			if (j<subaritems.length-1)
	  			document.write('<tr><td colspan='+colnumtable+'>&nbsp;</td></tr>');
      }
      document.write('<tr><td colspan='+colnumtable+' class="bodychapterheader">&nbsp;</td></tr>');
      //if (footer_string!=null && footer_string!='')
      //  document.write(footer_string)
    }
	}
}

function writeTable(aritems)
{
	for (var i=0;i<aritems.length;i++)
	{
		var a_txt = (aritems[i][cindex_chapter_a_name]==null) ? '' : '<a name="'+aritems[i][cindex_chapter_a_name]+'"></a>';
		document.write('<tr><td colspan=2 height="40">'+a_txt+'<b>'+aritems[i][cindex_chapter_caption]+'</b></td></tr>');
		if (aritems[i][cindex_chapter_subarray]!=null)
		{
			subaritems=aritems[i][cindex_chapter_subarray]
			rowspancnt = 0;
			for (var j=0;j<subaritems.length;j++)
			{
				var txtout='';
				for (var k=0;k<cindex_item_price;k++)
				{
					if (subaritems[j][k]==null)
						continue;
					var satxt = (k<cindex_item_models) ? '<b>'+subaritems[j][k]+'</b>' : subaritems[j][k];
					txtout = (txtout=='') ? satxt	: (txtout+'<br>'+satxt);
				}
				document.write('	<td align="left" width="414">'+txtout.toString()+'</td>');
				document.write('	<td align="left" width="100" valign="bottom" style="padding-left:5">'+subaritems[j][cindex_item_price]+'</td>');
				document.write('</tr>');
				if (j<subaritems.length-1)
				{
					document.write('<tr><td colspan=2 height="22"></td></tr>');
				}
			}
		}
	}
}


/*
function writeprodlist_typeA(aritems, sub_ind, az_id, colnum, show_order_string, show_order_string_style, pn_ind, href_ind, thr_url_type)
{
  var href_ind;
  var ibegin=0;
  var iend=aritems.length;
  if (sub_ind!=null)
  {
    ibegin=sub_ind;
    iend=sub_ind+1;
  }
	for (var i=ibegin;i<iend;i++)
	{
		var a_txt = (aritems[i][cindex_chapter_a_name]==null) ? '' : '<a name="'+aritems[i][cindex_chapter_a_name]+'"></a>';
    if (aritems[i][cindex_chapter_caption]!=null && aritems[i][cindex_chapter_caption]!='')
  		document.write('<tr><td colspan='+colnum+' height="40">'+a_txt+'<b>'+aritems[i][cindex_chapter_caption]+'</b></td></tr>');
		if (aritems[i][cindex_chapter_subarray]!=null)
		{
      var subaritems=aritems[i][cindex_chapter_subarray];
			for (var j=0;j<subaritems.length;j++)
			{
        document.write('<tr>')
        var hrefstr='';
        if (thr_url_type == 'details_order' && subaritems[j][pn_ind]!=null && subaritems[j][pn_ind]!='') 
          hrefstr=get_thr_href_A(az_id, subaritems[j][pn_ind]);
        else if (thr_url_type == 'list_order' && subaritems[j][pn_ind]!=null && subaritems[j][pn_ind]!='')
          hrefstr=get_thr_href_B(az_id, subaritems[j][pn_ind]);
				for (var k=0;k<colnum;k++)
				{
					var txtout = (subaritems[j][k]==null || subaritems[j][k]=='' || subaritems[j][k]==' ') ? '&nbsp;' : subaritems[j][k];
          if (k==href_ind && txtout != '&nbsp;' && hrefstr != '')
            txtout = '<a class="bodylinktext" style="text-decoration:underline" href="'+hrefstr+'">'+txtout+'</a>';
          document.write('<td align="left" valign="top" style="padding-left:5">'+txtout+'</td>')
				}
				if (show_order_string != null)
				{
				  var txtout = show_order_string;
					if (show_order_string_style == 'href' && hrefstr != '')
						txtout = '<a class="bodylinktext" style="text-decoration:underline" href="'+hrefstr+'">'+txtout+'</a>';
          else if (show_order_string_style == 'href' && hrefstr == '')
            txtout = "&nbsp;"
					document.write('<td align="left" valign="top" style="padding-left:5">'+txtout+'</td>')
				}
        document.write('</tr>')
  			if (j<subaritems.length-1)
	  			document.write('<tr><td colspan='+colnum+' height="10"></td></tr>');
      }
    }
	}
}
*/
