// constants/configuration
	var intGetId = 0; // the Id of the document, guessed or set
	var arrGetId = new Array(); // the Id of the document, traced to it's root in the navigation tree
	var fltIdReliability = 1.0; // the reliability of guessed Id's
	if(typeof booCheckForFrameset == 'undefined') var booCheckForFrameset = true;


// primary functions - functionality
	// get the global id identifying the current document
	function getId(intRecursion,fltIdReliability){
		if(typeof intRecursion != 'undefined') intRecursion = -1;
		if(intRecursion>-1){
			// get the Id at the requested recursion level
			return arrGetId[intRecursion];
		}else{
			// get the Id at the current level
			return intGetId;
		}
	}

	// set the global id identifying the current document
	function setId(intId,fltIdTrust){
		// validate input
		if(typeof fltIdTrust == 'undefined') fltIdTrust = 1;
		// update the document's Id
		intGetId = intId;
		arrGetId = TraceBranch(intId);
		fltIdReliability = fltIdTrust;
	}
	
	// return the reliability of the (guessed) Id
	function getIdReliability(){
		return fltIdReliability;
	}


// secondary function - construction
	function checkFrameset(){
		if (parent==self && booCheckForFrameset){ // checks if the page is in it's proper frameset
			// get the current URL and have it's domain stripped off
			docURL = URLstrip(-1);
			// pass it to the frameset page
			window.location.href='/?surl='+URLencode(docURL);
			// highly illogical
			return false;
		}else{
			// give the ok
			return true;
		}
	}


// ternary function - operation 
	function findId(){
		// check for predefined constants
		if(typeof intSetId == 'undefined') intSetId = -1;
		if(typeof strSetId == 'undefined') strSetId = '';
		
		// accept the predefined Id or look for one
		if(intSetId<0){
			// check for a predefined identifying string 'strSetId'
			if(strSetId==''){
				// make a unique Id from the url
				strSetId = document.location.href;
				intSearchField = 3;
			}else{
				// keep the unique Id and set the FindContent's search to compare full lines (-1)
				intSearchField = -1;
			}
			// lookup the most comparable string to find an Id
			arrSetId = FindContent(intSearchField,strSetId,0);
			intSetId = arrSetId[0][0];
			// calculate the difference in scores in the top 3 candidates into a measure of significance
			if(arrSetId.length>2) fltIdReliability = arrSetId[0][1] - arrSetId[1][1] + arrSetId[0][1] - arrSetId[2][1];
		}

		// accept only valid Id's (keeping the old one is better than getting a broken one)
		if(intSetId>=0) setId(intSetId,fltIdReliability);
	}
	

// executed inline
	if(checkFrameset()) findId();

