/* CROSS-BROWSER EVENT HANDLER */
function addEvent(obj, evType, fn){
if (obj.addEventListener){
obj.addEventListener(evType, fn, true);
return true;
} else if (obj.attachEvent){
var r = obj.attachEvent("on"+evType, fn);
return r;
} else {
return false;
}
}
/* END EVENT HANDLER */
/* JPSPAN */
function doGetPage(i) {
// Call nav first, then page content so page will load last (thus call fixLinks() after everything has loaded).
var n = new pageholder(NavHolderHandler);
n.nav(i);
var p = new pageholder(PageHolderHandler);
p.ashtml(i);
setContent("

");
}
// Called by loadGravelContent() in loadFlash.js
function doGetNav(i) {
var p = new pageholder(NavHolderHandler);
p.nav(i);
}
var PageHolderHandler = {
ashtml: function(result) {
if( setContent(result) ) {
// Call up here so fixes links on right side as well as nav.
fix.fixLinks();
}
}
}
var NavHolderHandler = {
nav: function(result) {
if( setNav(result) ) {
if(!document.iframesfix) {
// Don't call fixLinks() twice -- load page last, so call there so fixLinks runs *after* all content has been loaded.
//fix.fixLinks();
}
}
}
}
/* END JPSPAN */
/* PAGELOCATOR */
function PageLocator(propertyToUse, dividingCharacter) {
this.propertyToUse = propertyToUse;
this.defaultQS = "main";
this.dividingCharacter = dividingCharacter;
}
PageLocator.prototype.getLocation = function() {
return eval(this.propertyToUse);
}
PageLocator.prototype.getHash = function() {
var url = this.getLocation();
if(url.indexOf(this.dividingCharacter)>-1) {
var url_elements = url.split(this.dividingCharacter);
return url_elements[url_elements.length-1];
} else {
return this.defaultQS;
}
}
PageLocator.prototype.getHref = function() {
var url = this.getLocation();
var url_elements = url.split(this.dividingCharacter)
return url_elements[0];
}
PageLocator.prototype.makeNewLocation = function(new_qs) {
return this.getHref() + this.dividingCharacter + new_qs;
}
/* END PAGELOCATOR */
/* AjaxIframesFixer */
function AjaxIframesFixer(iframeid) {
this.iframeid = iframeid;
if (document.getElementById('ajaxnav')) {
// fixLinks() now called in setNav() so it fires after nav is loaded.
//this.fixLinks();
this.locator = new PageLocator("document.frames['"+this.iframeid+"'].getLocation()", "?hash=");
this.windowlocator = new PageLocator("window.location.href", "#");
this.timer = new Timer(this);
this.delayInit(); // required or IE doesn't fire
}
}
AjaxIframesFixer.prototype.fixLinks = function (iframeid) {
var links = document.getElementsByTagName("A");
for(var i=0; i= 0 )
{
var hash = href.substr(href.indexOf("hash=")+5);
links[i].setAttribute("href","javascript:document.getElementById('"+this.iframeid+"').setAttribute('src', 'ieloader.php?hash="+hash+"');");
}
else
{
links[i].setAttribute("href","content.php?hash=" + this.locator.getHash() + hrefSplit[4]);
}
}
}
}
AjaxIframesFixer.prototype.delayInit = function(){
this.timer.setTimeout("checkBookmark", 200, "");
}
AjaxIframesFixer.prototype.checkBookmark = function(){
window.location = this.windowlocator.makeNewLocation(this.locator.getHash());
this.checkWhetherChanged(0);
}
AjaxIframesFixer.prototype.checkWhetherChanged = function(location){
if(this.locator.getHash() != location) {
if( window.location.href.indexOf("content.php") < 0 )
{
doGetPage( this.locator.getHash() );
//window.location = this.windowlocator.makeNewLocation(this.locator.getHash());
}
else
{
/*
document.getElementById("ajaxnav").style.display = "block";
var links = document.getElementsByTagName("A");
for(var i=0; i= 0) && (href.indexOf("#") < 0) )
{
var hash = href.substr(href.indexOf("hash=")+5);
links[i].setAttribute("href","javascript:document.getElementById('"+this.iframeid+"').setAttribute('src', 'ieloader.php?hash="+hash+"');");
//alert(hash);
}
else
{
//links[i].setAttribute("href","content.php?hash=" + this.locator.getHash() + hrefSplit[4]);
//alert("no hash-"+hrefSplit[4]);
}
}
}
//window.location = this.windowlocator.makeNewLocation(hash);
*/
}
window.location = this.windowlocator.makeNewLocation(this.locator.getHash());
}
this.timer.setTimeout("checkWhetherChanged", 200, this.locator.getHash());
}
/* END AjaxIframesFixer */
/* AjaxUrlFixer */
function AjaxUrlFixer() {
// fixLinks() now called in setNav() so it fires after nav is loaded.
//this.fixLinks();
this.locator = new PageLocator("window.location.href", "#");
this.timer = new Timer(this);
if( window.location.href.indexOf("content.php") < 0 )
{
// Only call doGetPage() if not in content.php.
this.checkWhetherChanged(0);
}
else
{
// We're in content.php, so do our own thing (don't use fixLinks).
var links = document.getElementsByTagName("A");
for(var i=0; i= 0 )
{
var hash = href.substr(href.indexOf("hash=")+5);
links[i].setAttribute("href","/v2/#"+hash);
}
else
{
//links[i].setAttribute("href","content.php?hash=" + this.locator.getHash() + href);
}
}
}
}
}
AjaxUrlFixer.prototype.fixLinks = function () {
var links = document.getElementsByTagName("A");
for(var i=0; i= 0 )
{
links[i].setAttribute("href","content.php?hash=" + this.locator.getHash() + href);
}
else
{
var hash = href.substr(href.indexOf("hash=")+5);
links[i].setAttribute("href","#"+hash);
}
}
}
}
AjaxUrlFixer.prototype.checkWhetherChanged = function(location){
if(this.locator.getHash() != location) {
doGetPage(this.locator.getHash());
}
this.timer.setTimeout("checkWhetherChanged", 200, this.locator.getHash());
}
/* END AjaxUrlFixer */
function setContent(new_content) {
if(!document.getElementById || !document.getElementsByTagName) return;
var container = document.getElementById("right");
container.innerHTML = new_content;
return true;
}
function setNav(new_nav) {
if(!document.getElementById || !document.getElementsByTagName) return;
var container = document.getElementById("nav");
container.innerHTML = new_nav;
// Call fixLinks() here so fires *AFTER* nav has loaded (otherwise, no links will be on the page to 'fix')...
// Fix object will use correct function -- for IE or other.
//fix.fixLinks();
return true;
}
function FixBackAndBookmarking() {
if(!document.getElementById || !document.getElementsByTagName) return;
if(document.iframesfix) {
fix = new AjaxIframesFixer('ajaxnav');
} else {
fix = new AjaxUrlFixer();
}
}