= tmp_stack.split(',');
}
var tmp_current = parseInt(this.getCookie('CHCurrent'));
if (tmp_current >= -1) {
this.current = tmp_current;
}
};
/**
* Save a name/value pair as a browser cookie, to expire at
* end of session.
*/
HistoryStack.prototype.setCookie = function(name, value)
{
var cookie_str = name + "=" + escape(value);
document.cookie = cookie_str;
};
/**
* Retrieve a cookie value by the given name.
*/
HistoryStack.prototype.getCookie = function(name)
{
if (!name) return '';
var raw_cookies, tmp, i;
var cookies = new Array();
raw_cookies = document.cookie.split('; ');
for (i=0; i < raw_cookies.length; i++) {
tmp = raw_cookies[i].split('=');
cookies[tmp[0]] = unescape(tmp[1]);
}
if (cookies[name] != null) {
return cookies[name];
} else {
return '';
}
};
</script>
<script language="javascript">
<? sajax_show_javascript(); ?>
/**
* In Sajax, we create two functions: the initial event, and the response
* handler. In this case, the response handlers only take the output
* from the server and push it into the "window" element.
*
* Notice that two javascript functions call the same php function
*/
// Outputs directly to the "window" div
function to_window(output) {
document.getElementById("window").innerHTML = output;
display_history_buttons();
}
/**
* AJAX History
* Create a custom history object that will store events/clicks to
* session cookies. The do_* functions below are event handlers for
* history buttons - i.e. back, forward, reload.
*/
var myHistory = new HistoryStack();
myHistory.load();
/**
* Event handler for "back" button.
*/
function do_back()
{
myHistory.go(-1);
load_current();
}
/**
* Event handler for "forward" button.
*/
function do_forward()
{
myHistory.go(1);
load_current();
}
/**
* Event handler for "reload" button.
*/
function do_reload()
{
myHistory.go(0);
}
/**
* Re-Write
HTML for back, forward, and reload buttons
* into the "history" DIV.
*/
function display_history_buttons()
{
var str = '';
if (myHistory.hasPrev()) {
str += '<a href="#" onclick="do_back(); return false;"><img src="icons/back_on.gif" alt="后退" /></a>';
} else {
str += '<img src="icons/back_off.gif" alt="" />';
}
if (myHistory.hasNext()) {
str += '<a href="#" onclick="do_forward(); return false;"><img src="icons/forward_on.gif" alt="前进" /></a>';
} else {
str += '<img src="icons/forward_off.gif" alt="" />';
}
str += '<a href="#" onclick="do_reload(); return false;"><img src="icons/reload.gif" alt="刷新" /></a>';
document.getElementById("historybuttons").innerHTML = str;
}
function load_current()
{
// No existing history.
if (myHistory.stack.length == 0) {
x_get_table(to_window);
myHistory.addResource('table-0-5');
// Load from history.
} else {
var current = myHistory.getCurrent();
var params = current.split('-');
if (params[0] == 'table')