function historyClass(obj_name, history_data, current_route_id, home_url, root_url, str1, str2, str3, str4, str5, str6, str7, str8, str9, str10, str11, str12) {

    this.current_route_number = 0;

    this.on_submit = function(form) {
        if(form && form.history) {
            var serialized = '';
            for(var i=0; i<history_data.length; i++)
                serialized += history_data[i].join("\t") + "\n";
            form.history.value = serialized;
        }

        return true;
    }

    this.render = function(version,auto_reroute,auto_alt_stop) {
        var i, j, route_number, data, route_id, vehicles, vehicles_html, bgcolor, walking, total, style, border, mode, calories;
        var html = '';

        for(i=0; i<history_data.length; i++) {
            route_id = history_data[i][0];
            route_number = history_data[i][1];
            walking = history_data[i][2];
            total = history_data[i][3];

            vehicles = history_data[i][4].split(',');
            vehicles_html = '';
            for(j=0; j<vehicles.length; j++) {
                vehicles_html += '<img src="' + root_url + '/i2/' + vehicles[j] + '.gif" border="0" style="vertical-align:middle;"> ';
            }

			if(version >= 2) {
				mode = history_data[i][5];
				calories = history_data[i][6];
			}

            bgcolor = '#ffffff';
            if(route_id == current_route_id) {
                this.current_route_number = route_number;
                bgcolor = '#F0F3FD';
            }

			style = 'cursor:pointer;" onClick="var url=\'' + home_url + '?action=route&route_id=' + route_id + '\'; if(post_request(url)) {window.location = url;}';
            border = i < history_data.length - 1 ? ' border-bottom:1px solid #E4E4E6;' : '';

            html += '<div id="' + route_id + '_r" style="background:#ffffff; background-color:#ffffff; bgcolor:#ffffff;' + border + ' margin:0; padding:2px 0 2px 0;">';
            html += '<div style="font-size:12px; background:' + bgcolor + '; background-color:' + bgcolor + '; bgcolor:' + bgcolor + '; margin:0; padding:2px;">';
            html += '<table width="608" cellpadding="0" cellspacing="0" border="0"><tr>';
            html += '<td align="left" valign="middle" width="96" style="font:bold 13px Arial, Verdana; color:#4960AC; ' + style + '">' + str6 + ' ' + route_number + '</td>';
            html += '<td align="left" valign="middle" width="101" style="' + style + '">' + (vehicles_html != '' ? vehicles_html : '&nbsp;') + '</td>';
	    html += '<td align="left" valign="middle" width="141" style="' + style + '">' + (calories > 0 ? calories : '&nbsp;') + '</td>';
            html += '<td align="left" valign="middle" width="105" style="' + style + '">' + (walking > 0 ? '<table cellpadding="0" cellspacing="0" border="0"><tr><td><img src="' + root_url + '/i2/walk.gif" border="0"></td><td>&nbsp;</td><td>' + this.verb_time(walking) + '</td></tr></table>' : (version >= 2 && mode == 'z' ? 'N/A' : '&nbsp;')) + '</td>';
            html += '<td align="left" valign="middle" width="105" style="' + style + '">' + (total > 0 ? this.verb_time(total) : '&nbsp;') + '</td>';
            html += '<td align="center" valign="middle" width="60"><a href="#" onClick="' + obj_name + '.remove(\'' + route_id + '\'); return false;"><img src="' + root_url + '/img/i14.gif" width="13" height="10" border="0" alt="' + str7 + ' ' + route_number + '"></a></td>';
            html += '</tr></table>';
            html += '</div>';
            html += '</div>' + "\n";
        }

        if(html != '') {
        	if (version==undefined) {
	        	var caption = '';
	            caption += '<div id="' + obj_name + '_caption">';
	            caption += '<div class="c1">' + str1 + '</div>';
	            caption += '<div class="b1" style="padding:9px 8px 5px 8px;">';
	            caption += '<div style="font-size:12px; background:#ffffff; background-color:#ffffff; bgcolor:#ffffff; margin:0 0 0 0; padding:0px 2px 2px 2px;">';
	            caption += '<table width="608" cellpadding="0" cellspacing="0" border="0"><tr>';
	            caption += '<td align="left" valign="top" width="96">&nbsp;</td>';
	            caption += '<td align="left" valign="top" width="222" style="font-size:11px; color:#383838; border-bottom:1px solid #E4E4E6;">' + str2 + '</td>';
	            caption += '<td align="left" valign="top" width="105" style="font-size:11px; color:#383838; border-bottom:1px solid #E4E4E6;">' + str3 + '</td>';
	            caption += '<td align="left" valign="top" width="125" style="font-size:11px; color:#383838; border-bottom:1px solid #E4E4E6;">' + str4 + '</td>';
	            caption += '<td align="center" valign="top" width="60" style="font-size:11px; color:#383838; border-bottom:1px solid #E4E4E6;">' + str5 + '</td>';
	            caption += '</tr></table>';
	            caption += '</div>' + "\n";
	            document.write(caption + html + '</div></div>');
	        } else if (version==1) {
	        	var caption = '';
	            caption += '<div id="' + obj_name + '_caption">';
	            caption += '<div style="padding:0px 0px 4px 3px; font-size: 15px; color:#737373;"><b>' + str1 + '</b><span style="font-size: 12px;">&nbsp;&nbsp;-&nbsp;&nbsp;Alternate&nbsp;route?&nbsp;Try';
	            if (auto_reroute != '') {
	            	caption += '&nbsp;<a href="' + home_url + '?action=route&route_id=' + current_route_id + '&excluded_vehicles=' + auto_reroute + '" onclick="return post_request(this.href);">reroute</a>&nbsp;|';
	            }
	            if (auto_alt_stop != '') {
	            	caption += '&nbsp;<a href="' + home_url + '?action=route&route_id=' + current_route_id + '&excluded_stops=' + auto_alt_stop + '" onclick="return post_request(this.href);">use another stop</a>&nbsp;|';
	            }
	            caption += '&nbsp;<a style="cursor:pointer;" onclick="gotoAnchor(\'Options\');">search with other options</a></span></div>';
	            caption += '<div style="padding:0px 8px 8px;">';
	            caption += '<div style="font-size:12px; background:#ffffff; background-color:#ffffff; bgcolor:#ffffff; margin:0 0 0 0; padding:0px 2px 2px 2px;">';
	            caption += '<table width="608" cellpadding="0" cellspacing="0" border="0"><tr>';
	            caption += '<td align="left" valign="top" width="96">&nbsp;</td>';
	            caption += '<td align="left" valign="top" width="222" style="font-size:11px; color:#383838; border-bottom:1px solid #E4E4E6;">' + str2 + '</td>';
	            caption += '<td align="left" valign="top" width="105" style="font-size:11px; color:#383838; border-bottom:1px solid #E4E4E6;">' + str3 + '</td>';
	            caption += '<td align="left" valign="top" width="125" style="font-size:11px; color:#383838; border-bottom:1px solid #E4E4E6;">' + str4 + '</td>';
	            caption += '<td align="center" valign="top" width="60" style="font-size:11px; color:#383838; border-bottom:1px solid #E4E4E6;">' + str5 + '</td>';
	            caption += '</tr></table>';
	            caption += '</div>' + "\n";
	            document.write(caption + html + '</div></div>');	        
	        } else {
	        	var caption = '';
	            caption += '<div id="' + obj_name + '_caption">';
	            caption += '<div style="padding:0px 0px 4px 3px; font-size: 15px; color:#737373;"><b>' + str1 + '</b></div>';
	            caption += '<div style="padding:0px 8px 8px;">';
	            caption += '<div style="font-size:12px; background:#ffffff; background-color:#ffffff; bgcolor:#ffffff; margin:0 0 0 0; padding:0px 2px 2px 2px;">';
	            caption += '<table width="608" cellpadding="0" cellspacing="0" border="0"><tr>';
	            caption += '<td align="left" valign="top" width="96">&nbsp;</td>';
	            caption += '<td align="left" valign="top" width="101" style="font-size:11px; color:#383838; border-bottom:1px solid #E4E4E6;">' + str2 + '</td>';
		    caption += '<td align="left" valign="top" width="141" style="font-size:11px; color:#383838; border-bottom:1px solid #E4E4E6;">' + str12 + ' <a href="#" id="hXjhTB8Z" onclick="return false;" onmouseout="hide_help_message();" onmouseover="' + "show_help_message(this.id, 'help_message', 'Calories Burned', 'This number is based on the amount of walking or biking your route involves. Calories burned are estimated and for informational purposes only. Actual calories burned may vary for different individuals.');" + '"><small>new!</small></a></td>';
	            caption += '<td align="left" valign="top" width="105" style="font-size:11px; color:#383838; border-bottom:1px solid #E4E4E6;">' + str3 + '</td>';
	            caption += '<td align="left" valign="top" width="105" style="font-size:11px; color:#383838; border-bottom:1px solid #E4E4E6;">' + str4 + '</td>';
	            caption += '<td align="center" valign="top" width="60" style="font-size:11px; color:#383838; border-bottom:1px solid #E4E4E6;">' + str5 + '</td>';
	            caption += '</tr></table>';	            	            
	            caption += '</div>' + "\n";
	            document.write(caption + html + '</div></div>');
	        }
        }
    }

    this.remove = function(route_id) {
        var div;
        if(div = document.getElementById(route_id + '_r'))
            div.style.display = 'none';

        for(var i=0; i<history_data.length; i++)
            if(history_data[i][0] == route_id)
                history_data.splice(i--, 1);

        if(history_data.length == 0)
            if(div = document.getElementById(obj_name + '_caption'))
                div.style.display = 'none';
    }

    this.verb_time = function(time) {

        var hours = Math.floor(time / 3600);
        time -= hours * 3600;
        var mins = Math.floor(time / 60);
        time -= mins * 60;
        if(time >= 30)
            mins++;

        if(mins == 60) {
            hours++;
            mins = 0;
        }

        time = '';
        if(hours > 0)
            time += hours == 1 ? hours + ' ' + str8 + ' ' : hours + ' ' + str9 + ' ';
        time += mins + (mins == 1 ? ' ' + str10 : ' ' + str11);
        return time;
    }
}

