// determine if to use ancors or not in the application

function AnchorObject(swfId) {
	this.swfId = swfId;
	this.swfFunctionName = null;
	this.intv = null;
	this.oldLoc = document.location.href;
	this.usingAnchors = -1;
	
	this.startAnchorChecking = function (swfFunctionName) {
		this.swfFunctionName = swfFunctionName;
		this.intv = setInterval("Anchors.checkAncorChange(document.location.href)",100);
	}
	
	this.stopAnchorChecking = function () {
		if(this.intv) {
			clearInterval(this.intv);
		}
	}
	
	this.useAnchors = function() {
		if(this.usingAnchors<0) {
			var use = false;
			var browser = {'ns4':ns4, 'moz':moz, 'mac':mac, 'win':win, 'old':old, 'lin':lin, 'ie5mac':ie5mac, 'ie5win':ie5xwin, 'konq':konq, 'saf':saf, 'op':op, 'op4':op4, 'op5':op5, 'op6':op6, 'op7':op7};
			for(var i in browser) {
				if(browser[i] == undefined) {
					browser[i] = false;
				}
			}
			if((browser.moz || browser.ie5win) && !browser.ns4 && !browser.konq && !browser.ie5mac && !browser.saf && !browser.op && !browser.op4 && !browser.op5 && !browser.op6 && !browser.op7) {
				use = true;
			}
			//alert(traceAry(browser));
			//alert(useAnchors);
			this.usingAnchors = use?1:0;
		}
		return this.usingAnchors;
	}
	
	this.checkAncorChange = function (newLoc) {
		if(newLoc != this.oldLoc && this.usingAnchors>0) {
			this.oldLoc = newLoc;
			var anchorId = this.oldLoc.split('#')[1];
			var swf = document.getElementById(this.swfId);
			if(swf) {
				swf[this.swfFunctionName](anchorId);
			}
		}
	}
}
