var arc_Size = 0;
startIndex = 0;
endIndex = 0;

for(var sm=0;sm<sub_menu_items.length;sm++) {
    endIndex = startIndex + sub_menu_items[sm].length - 1;
    if(ns) {
        document.writeln('<layer id=sub_menu_' + (sm) + ' Z-INDEX=1 LEFT=' + sub_menu_left[sm] + ' TOP=' + sub_menu_top[sm] + ' VISIBILITY=hide  >');
    }

    if(ie) {
        document.writeln('<DIV id=sub_menu_' + (sm) + ' style="Z-INDEX: 1; LEFT: ' + sub_menu_left[sm] + 'px; TOP: ' + sub_menu_top[sm] + 'px; VISIBILITY: hidden; POSITION: absolute; " >');
    }

    document.writeln('<table width=' + sub_menu_table_width[sm] + ' background="images/'+page_background+'"  border=0 cellpadding=0 cellspacing=0> ');
    document.writeln('    <tr> ');
    document.writeln('        <td align=right> ');

    for(var i=0;i<sub_menu_items[sm].length;i++) {
        arc_Size = sub_menu_items_table_width[sm][i];
        document.writeln('<table width=' + sub_menu_items_table_width[sm][i] + ' height=23 background="images/b_arc_' + arc_Size + '.gif"  border=0 cellpadding=0 cellspacing=0> ');
        document.writeln('    <tr> ');
        document.writeln('        <td align=right > ');
        document.writeln('            <a href="" OnMouseOver="hide_HighlightItems(' + startIndex + ',' + endIndex + ');show_HighlightItem(' + (highlight_item_index) + ');return false;"> ');
        document.writeln('                <font color=' + sub_menu_mi_fc[sm] + '  size=2><b><i>' + sub_menu_items[sm][i] + ' &nbsp;');
        document.writeln('                </i></b></font>');
        document.writeln('            </a> ');
        document.writeln('        </td> ');
        document.writeln('    </tr> ');
        document.writeln('</table> ');

        highlight_item_index = highlight_item_index + 1;
    }

    document.writeln('        </td> ');
    document.writeln('    </tr> ');
    document.writeln('</table> ');

    if(ns) {
        document.writeln('</layer>');
    }

    if(ie) {
        document.writeln('</DIV>');
    }

    startIndex = endIndex + 1;
} // end of sub menu

var mystr;
hi_index = 0;
var arc_Size = 0;

for(var k=0;k<sub_menu_items.length;k++) {

    i_left = sub_menu_left[k];
    i_top = sub_menu_top[k];

    for(var i=0;i<sub_menu_items[k].length;i++) {
        arc_Size = sub_menu_items_table_width[k][i];
        if(ns) {
            document.writeln('<layer id=highlight_item_' + (hi_index) + ' LEFT=' + i_left + '  TOP=' + i_top + ' Z-INDEX=2 VISIBILITY=hide> ');
        }
        if(ie) {
            document.writeln('<DIV id=highlight_item_' + (hi_index) + ' style="Z-INDEX: 2; LEFT: ' + i_left + 'px; TOP: ' + i_top + 'px; VISIBILITY: hidden; POSITION: absolute;"> ');
        }

        document.writeln('    <table width=' + sub_menu_table_width[k] + '  border=0 cellpadding=0 cellspacing=0> ');
        document.writeln('        <tr> ');
        document.writeln('            <td align=right> ');
        document.writeln('                  <table width=' + sub_menu_items_table_width[k][i] + ' height=23 background="images/b_arc_' + arc_Size + '.gif"  border=0 cellpadding=0 cellspacing=0> ');
        document.writeln('                    <tr> ');
        document.writeln('                        <td  align=right> ');
        document.writeln('                            <a href="' + sub_menu_items_href[k][i] + '"  OnMouseOut="hide_HighlightItem(' + (hi_index) + ');return false;"> ');
        document.writeln('                              <font color=' + sub_menu_hi_fc[k] + '  size=2><b><i>' + sub_menu_items[k][i] + ' &nbsp;');
        document.writeln('                              </i></b></font>');
        document.writeln('                            </a> ');
        document.writeln('                        </td> ');
        document.writeln('                    </tr> ');
        document.writeln('                </table> ');
        document.writeln('            </td> ');
        document.writeln('        </tr> ');
        document.writeln('    </table> ');

        if(ns) {
            document.writeln('</layer> ');
        }
        if(ie) {
            document.writeln('</DIV> ');
        }

        i_top = i_top + 23;
        hi_index = hi_index + 1;

    } // end of for i

} // end of for k

var layer_name;
var index = 0;
var count = 0;

if(ns) {
    for(var i=0;i<document.layers.length;i++) {
        layer_name = document.layers[i].name;
        //alert("layer name  " + document.layers[i].name);
        if( layer_name.indexOf("sub_menu_") != -1 ) {
            sub_menu[index] = document.layers[i];
            index = index + 1;
            count = count + 1;
        }
    }
} // end of if ns

if(ie) {

    if(ns6 || ns7) {
        for(var i=0;i<6;i++) {
            sub_menu[i] = document.getElementById("sub_menu_" + (i))
        }
    }
    else {
        // pure IE
        for(var i=0;i<6;i++) {
            sub_menu[i] = eval('document.all.sub_menu_' + (i) )
        }
    }
} // end of if ie

var index = 0;
var layer_name;

if(ns) {
    for(var i=0;i<document.layers.length;i++) {
        layer_name = document.layers[i].name;
        if( layer_name.indexOf("highlight_item_") != -1 ) {
            highlight_item[index] = document.layers[i];
            index = index + 1;
            count = count + 1;
        }

    }
} // end of if ns

if(ie) {
    if(ns6 || ns7) {
        for(var i=0;i<30;i++) {
            highlight_item[i] = document.getElementById("highlight_item_" + (i))
        }
    }
    else {
        for(var i=0;i<30;i++) {
            highlight_item[i] = eval('document.all.highlight_item_' + (i) )
        }
    }
} // end of if ie

